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 F218B108A8 for ; Tue, 26 Nov 2013 21:07:19 +0000 (UTC) Received: (qmail 25636 invoked by uid 500); 26 Nov 2013 21:07:19 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 25555 invoked by uid 500); 26 Nov 2013 21:07:19 -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 25548 invoked by uid 99); 26 Nov 2013 21:07:19 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Nov 2013 21:07:19 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Nov 2013 21:07:16 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 78D562388ABC; Tue, 26 Nov 2013 21:06:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1545838 - /hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java Date: Tue, 26 Nov 2013 21:06:55 -0000 To: commits@hbase.apache.org From: larsh@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131126210655.78D562388ABC@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: larsh Date: Tue Nov 26 21:06:55 2013 New Revision: 1545838 URL: http://svn.apache.org/r1545838 Log: HBASE-10015 Replace intrinsic locking with explicit locks in StoreScanner Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java?rev=1545838&r1=1545837&r2=1545838&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java (original) +++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java Tue Nov 26 21:06:55 2013 @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.List; import java.util.NavigableSet; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.locks.ReentrantLock; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -96,6 +97,7 @@ public class StoreScanner extends NonLaz // A flag whether use pread for scan private boolean scanUsePread = false; + private ReentrantLock lock = new ReentrantLock(); private final long readPt; @@ -354,11 +356,16 @@ public class StoreScanner extends NonLaz } @Override - public synchronized KeyValue peek() { + public KeyValue peek() { + lock.lock(); + try { if (this.heap == null) { return this.lastTop; } return this.heap.peek(); + } finally { + lock.unlock(); + } } @Override @@ -368,7 +375,9 @@ public class StoreScanner extends NonLaz } @Override - public synchronized void close() { + public void close() { + lock.lock(); + try { if (this.closing) return; this.closing = true; // under test, we dont have a this.store @@ -378,13 +387,21 @@ public class StoreScanner extends NonLaz this.heap.close(); this.heap = null; // CLOSED! this.lastTop = null; // If both are null, we are closed. + } finally { + lock.unlock(); + } } @Override - public synchronized boolean seek(KeyValue key) throws IOException { + public boolean seek(KeyValue key) throws IOException { + lock.lock(); + try { // reset matcher state, in case that underlying store changed checkReseek(); return this.heap.seek(key); + } finally { + lock.unlock(); + } } /** @@ -394,7 +411,9 @@ public class StoreScanner extends NonLaz * @return true if there are more rows, false if scanner is done */ @Override - public synchronized boolean next(List outResult, int limit) throws IOException { + public boolean next(List outResult, int limit) throws IOException { + lock.lock(); + try { if (checkReseek()) { return true; } @@ -530,16 +549,21 @@ public class StoreScanner extends NonLaz // No more keys close(); return false; + } finally { + lock.unlock(); + } } @Override - public synchronized boolean next(List outResult) throws IOException { + public boolean next(List outResult) throws IOException { return next(outResult, -1); } // Implementation of ChangedReadersObserver @Override - public synchronized void updateReaders() throws IOException { + public void updateReaders() throws IOException { + lock.lock(); + try { if (this.closing) return; // All public synchronized API calls will call 'checkReseek' which will cause @@ -559,6 +583,9 @@ public class StoreScanner extends NonLaz this.heap = null; // the re-seeks could be slow (access HDFS) free up memory ASAP // Let the next() call handle re-creating and seeking + } finally { + lock.unlock(); + } } /** @@ -622,7 +649,9 @@ public class StoreScanner extends NonLaz } @Override - public synchronized boolean reseek(KeyValue kv) throws IOException { + public boolean reseek(KeyValue kv) throws IOException { + lock.lock(); + try { //Heap will not be null, if this is called from next() which. //If called from RegionScanner.reseek(...) make sure the scanner //stack is reset if needed. @@ -631,6 +660,9 @@ public class StoreScanner extends NonLaz return heap.requestSeek(kv, true, useRowColBloom); } return heap.reseek(kv); + } finally { + lock.unlock(); + } } @Override