accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bil...@apache.org
Subject svn commit: r1345365 - /accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/impl/MultiTableBatchWriterImpl.java
Date Fri, 01 Jun 2012 21:59:08 GMT
Author: billie
Date: Fri Jun  1 21:59:07 2012
New Revision: 1345365

URL: http://svn.apache.org/viewvc?rev=1345365&view=rev
Log:
ACCUMULO-587 added finalize to multi-table batch writer

Modified:
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/impl/MultiTableBatchWriterImpl.java

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/impl/MultiTableBatchWriterImpl.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/impl/MultiTableBatchWriterImpl.java?rev=1345365&r1=1345364&r2=1345365&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/impl/MultiTableBatchWriterImpl.java
(original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/impl/MultiTableBatchWriterImpl.java
Fri Jun  1 21:59:07 2012
@@ -30,8 +30,10 @@ import org.apache.accumulo.core.data.Mut
 import org.apache.accumulo.core.master.state.tables.TableState;
 import org.apache.accumulo.core.security.thrift.AuthInfo;
 import org.apache.accumulo.core.util.ArgumentChecker;
+import org.apache.log4j.Logger;
 
 public class MultiTableBatchWriterImpl implements MultiTableBatchWriter {
+  static final Logger log = Logger.getLogger(MultiTableBatchWriterImpl.class);
   private boolean closed;
   
   private class TableBatchWriter implements BatchWriter {
@@ -86,6 +88,22 @@ public class MultiTableBatchWriterImpl i
     this.closed = true;
   }
   
+  /**
+   * Warning: do not rely upon finalize to close this class. Finalize is not guaranteed to
be called.
+   */
+  @Override
+  protected void finalize() {
+    if (!closed) {
+      log.warn(MultiTableBatchWriterImpl.class.getSimpleName() + " not shutdown; did you
forget to call close()?");
+      try {
+        close();
+      } catch (MutationsRejectedException mre) {
+        log.error(MultiTableBatchWriterImpl.class.getSimpleName() + " internal error.", mre);
+        throw new RuntimeException("Exception when closing " + MultiTableBatchWriterImpl.class.getSimpleName(),
mre);
+      }
+    }
+  }
+  
   @Override
   public synchronized BatchWriter getBatchWriter(String tableName) throws AccumuloException,
AccumuloSecurityException, TableNotFoundException {
     ArgumentChecker.notNull(tableName);



Mime
View raw message