Return-Path: X-Original-To: apmail-accumulo-commits-archive@www.apache.org Delivered-To: apmail-accumulo-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 1CA439EA6 for ; Fri, 18 May 2012 13:32:24 +0000 (UTC) Received: (qmail 25412 invoked by uid 500); 18 May 2012 13:32:24 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 25371 invoked by uid 500); 18 May 2012 13:32:23 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 25364 invoked by uid 99); 18 May 2012 13:32:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 May 2012 13:32:23 +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; Fri, 18 May 2012 13:32:21 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 4243E2388860 for ; Fri, 18 May 2012 13:32:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1340090 - /accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReader.java Date: Fri, 18 May 2012 13:32:00 -0000 To: commits@accumulo.apache.org From: billie@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120518133200.4243E2388860@eris.apache.org> Author: billie Date: Fri May 18 13:31:59 2012 New Revision: 1340090 URL: http://svn.apache.org/viewvc?rev=1340090&view=rev Log: ACCUMULO-587 added finalize for batch reader Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReader.java Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReader.java URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReader.java?rev=1340090&r1=1340089&r2=1340090&view=diff ============================================================================== --- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReader.java (original) +++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReader.java Fri May 18 13:31:59 2012 @@ -36,8 +36,10 @@ import org.apache.accumulo.core.data.Val import org.apache.accumulo.core.security.Authorizations; import org.apache.accumulo.core.security.thrift.AuthInfo; import org.apache.accumulo.core.util.ArgumentChecker; +import org.apache.log4j.Logger; public class TabletServerBatchReader extends ScannerOptions implements BatchScanner { + public static final Logger log = Logger.getLogger(TabletServerBatchReader.class); private String table; private int numThreads; @@ -55,12 +57,17 @@ public class TabletServerBatchReader ext return nextBatchReaderInstance++; } - private int batchReaderInstance = getNextBatchReaderInstance(); + private final int batchReaderInstance = getNextBatchReaderInstance(); - private class BatchReaderThreadFactory implements ThreadFactory { + private static class BatchReaderThreadFactory implements ThreadFactory { private ThreadFactory dtf = Executors.defaultThreadFactory(); private int threadNum = 1; + private final int batchReaderInstance; + + BatchReaderThreadFactory(int batchReaderInstance) { + this.batchReaderInstance = batchReaderInstance; + } public Thread newThread(Runnable r) { Thread thread = dtf.newThread(r); @@ -80,7 +87,7 @@ public class TabletServerBatchReader ext this.numThreads = numQueryThreads; queryThreadPool = new ThreadPoolExecutor(numQueryThreads, numQueryThreads, 60, TimeUnit.SECONDS, new LinkedBlockingQueue(), - new BatchReaderThreadFactory()); + new BatchReaderThreadFactory(batchReaderInstance)); ranges = null; } @@ -89,6 +96,17 @@ public class TabletServerBatchReader ext queryThreadPool.shutdownNow(); } + /** + * Warning: do not rely upon finalize to close this class. Finalize is not guaranteed to be called. + */ + @Override + protected void finalize() { + if (!queryThreadPool.isShutdown()) { + log.warn(TabletServerBatchReader.class.getSimpleName() + " not shutdown; did you forget to call close()?"); + close(); + } + } + @Override public void setRanges(Collection ranges) { if (ranges == null || ranges.size() == 0) {