Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4255D1881A for ; Thu, 6 Aug 2015 09:19:48 +0000 (UTC) Received: (qmail 34480 invoked by uid 500); 6 Aug 2015 09:19:35 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 34430 invoked by uid 500); 6 Aug 2015 09:19:35 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 34418 invoked by uid 99); 6 Aug 2015 09:19:35 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Aug 2015 09:19:35 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5788DE03EC; Thu, 6 Aug 2015 09:19:35 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: zhangduo@apache.org To: commits@hbase.apache.org Date: Thu, 06 Aug 2015 09:19:35 -0000 Message-Id: <0493a450b4414e009a583c5cb13baf6f@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] hbase git commit: Revert "HBASE-14178 regionserver blocks because of waiting for offsetLock" Repository: hbase Updated Branches: refs/heads/branch-1.2 922c3ba55 -> 7a45596b4 Revert "HBASE-14178 regionserver blocks because of waiting for offsetLock" This reverts commit 922c3ba554eeb13c2390cdd1140b26006bb8a7e9. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/a4092444 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/a4092444 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/a4092444 Branch: refs/heads/branch-1.2 Commit: a4092444e6eba39e7523c118e80b3fb726485984 Parents: 922c3ba Author: zhangduo Authored: Thu Aug 6 17:11:53 2015 +0800 Committer: zhangduo Committed: Thu Aug 6 17:11:53 2015 +0800 ---------------------------------------------------------------------- .../hadoop/hbase/io/hfile/CacheConfig.java | 42 -------------------- .../hadoop/hbase/io/hfile/HFileReaderV2.java | 18 ++++----- 2 files changed, 9 insertions(+), 51 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/a4092444/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CacheConfig.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CacheConfig.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CacheConfig.java index 26eb1da..0ed3cbd 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CacheConfig.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CacheConfig.java @@ -431,48 +431,6 @@ public class CacheConfig { return isBlockCacheEnabled() && this.prefetchOnOpen; } - /** - * Return true if we may find this type of block in block cache. - *

- * TODO: today {@code family.isBlockCacheEnabled()} only means {@code cacheDataOnRead}, so here we - * consider lots of other configurations such as {@code cacheDataOnWrite}. We should fix this in - * the future, {@code cacheDataOnWrite} should honor the CF level {@code isBlockCacheEnabled} - * configuration. - */ - public boolean shouldReadBlockFromCache(BlockType blockType) { - if (!isBlockCacheEnabled()) { - return false; - } - if (cacheDataOnRead) { - return true; - } - if (prefetchOnOpen) { - return true; - } - if (cacheDataOnWrite) { - return true; - } - if (blockType == null) { - return true; - } - if (blockType.getCategory() == BlockCategory.BLOOM || - blockType.getCategory() == BlockCategory.INDEX) { - return true; - } - return false; - } - - /** - * If we make sure the block could not be cached, we will not acquire the lock - * otherwise we will acquire lock - */ - public boolean shouldLockOnCacheMiss(BlockType blockType) { - if (blockType == null) { - return true; - } - return shouldCacheBlockOnRead(blockType.getCategory()); - } - @Override public String toString() { if (!isBlockCacheEnabled()) { http://git-wip-us.apache.org/repos/asf/hbase/blob/a4092444/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java index 67aa922..4790ee9 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java @@ -393,11 +393,12 @@ public class HFileReaderV2 extends AbstractHFileReader { TraceScope traceScope = Trace.startSpan("HFileReaderV2.readBlock"); try { while (true) { + if (useLock) { + lockEntry = offsetLock.getLockEntry(dataBlockOffset); + } + // Check cache for block. If found return. if (cacheConf.isBlockCacheEnabled()) { - if (useLock) { - lockEntry = offsetLock.getLockEntry(dataBlockOffset); - } // Try and get the block from the block cache. If the useLock variable is true then this // is the second time through the loop and it should not be counted as a block cache miss. HFileBlock cachedBlock = getCachedBlock(cacheKey, cacheBlock, useLock, isCompaction, @@ -422,14 +423,13 @@ public class HFileReaderV2 extends AbstractHFileReader { // Cache-hit. Return! return cachedBlock; } - if (!useLock && cacheBlock && cacheConf.shouldLockOnCacheMiss(expectedBlockType)) { - // check cache again with lock - useLock = true; - continue; - } // Carry on, please load. } - + if (!useLock) { + // check cache again with lock + useLock = true; + continue; + } if (Trace.isTracing()) { traceScope.getSpan().addTimelineAnnotation("blockCacheMiss"); }