accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject [1/2] git commit: ACCUMULO-2354 ensure that the TabletLocationState iterator is closed
Date Wed, 19 Feb 2014 18:29:00 GMT
Repository: accumulo
Updated Branches:
  refs/heads/1.6.0-SNAPSHOT 3a44bb05e -> 0da9a5677


ACCUMULO-2354 ensure that the TabletLocationState iterator is closed


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/0da9a567
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/0da9a567
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/0da9a567

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: 0da9a567762cb79b6fb506310d366193f4953766
Parents: aab22b2
Author: Eric Newton <eric.newton@gmail.com>
Authored: Wed Feb 19 13:27:50 2014 -0500
Committer: Eric Newton <eric.newton@gmail.com>
Committed: Wed Feb 19 13:28:33 2014 -0500

----------------------------------------------------------------------
 .../server/master/state/MetaDataStateStore.java      |  3 +--
 .../server/master/state/MetaDataTableScanner.java    |  2 +-
 .../server/master/state/RootTabletStateStore.java    |  4 +---
 .../server/master/state/TabletStateStore.java        |  3 +--
 .../server/master/state/ZooTabletStateStore.java     |  8 ++++++--
 .../apache/accumulo/master/TabletGroupWatcher.java   | 15 ++++++++++++++-
 6 files changed, 24 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/0da9a567/server/base/src/main/java/org/apache/accumulo/server/master/state/MetaDataStateStore.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/master/state/MetaDataStateStore.java
b/server/base/src/main/java/org/apache/accumulo/server/master/state/MetaDataStateStore.java
index 57d38eb..e4d1eeb 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/master/state/MetaDataStateStore.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/master/state/MetaDataStateStore.java
@@ -17,7 +17,6 @@
 package org.apache.accumulo.server.master.state;
 
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.accumulo.core.client.BatchWriter;
@@ -66,7 +65,7 @@ public class MetaDataStateStore extends TabletStateStore {
   }
   
   @Override
-  public Iterator<TabletLocationState> iterator() {
+  public ClosableIterator<TabletLocationState> iterator() {
     return new MetaDataTableScanner(instance, credentials, MetadataSchema.TabletsSection.getRange(),
state);
   }
   

http://git-wip-us.apache.org/repos/asf/accumulo/blob/0da9a567/server/base/src/main/java/org/apache/accumulo/server/master/state/MetaDataTableScanner.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/master/state/MetaDataTableScanner.java
b/server/base/src/main/java/org/apache/accumulo/server/master/state/MetaDataTableScanner.java
index f0ac7bc..155a5d2 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/master/state/MetaDataTableScanner.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/master/state/MetaDataTableScanner.java
@@ -46,7 +46,7 @@ import org.apache.accumulo.server.master.state.TabletLocationState.BadLocationSt
 import org.apache.hadoop.io.Text;
 import org.apache.log4j.Logger;
 
-public class MetaDataTableScanner implements Iterator<TabletLocationState> {
+public class MetaDataTableScanner implements ClosableIterator<TabletLocationState>
{
   private static final Logger log = Logger.getLogger(MetaDataTableScanner.class);
   
   BatchScanner mdScanner = null;

http://git-wip-us.apache.org/repos/asf/accumulo/blob/0da9a567/server/base/src/main/java/org/apache/accumulo/server/master/state/RootTabletStateStore.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/master/state/RootTabletStateStore.java
b/server/base/src/main/java/org/apache/accumulo/server/master/state/RootTabletStateStore.java
index bdf5478..219fd49 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/master/state/RootTabletStateStore.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/master/state/RootTabletStateStore.java
@@ -16,8 +16,6 @@
  */
 package org.apache.accumulo.server.master.state;
 
-import java.util.Iterator;
-
 import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.metadata.RootTable;
 import org.apache.accumulo.core.metadata.schema.MetadataSchema;
@@ -34,7 +32,7 @@ public class RootTabletStateStore extends MetaDataStateStore {
   }
   
   @Override
-  public Iterator<TabletLocationState> iterator() {
+  public ClosableIterator<TabletLocationState> iterator() {
     return new MetaDataTableScanner(instance, credentials, MetadataSchema.TabletsSection.getRange(),
state, RootTable.NAME);
   }
   

http://git-wip-us.apache.org/repos/asf/accumulo/blob/0da9a567/server/base/src/main/java/org/apache/accumulo/server/master/state/TabletStateStore.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/master/state/TabletStateStore.java
b/server/base/src/main/java/org/apache/accumulo/server/master/state/TabletStateStore.java
index ed68b4e..e898109 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/master/state/TabletStateStore.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/master/state/TabletStateStore.java
@@ -18,7 +18,6 @@ package org.apache.accumulo.server.master.state;
 
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Iterator;
 
 /**
  * Interface for storing information about tablet assignments. There are three implementations:
@@ -38,7 +37,7 @@ public abstract class TabletStateStore implements Iterable<TabletLocationState>
    * Scan the information about the tablets covered by this store
    */
   @Override
-  abstract public Iterator<TabletLocationState> iterator();
+  abstract public ClosableIterator<TabletLocationState> iterator();
   
   /**
    * Store the assigned locations in the data store.

http://git-wip-us.apache.org/repos/asf/accumulo/blob/0da9a567/server/base/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java
b/server/base/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java
index bbd1257..0a0e1ee 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java
@@ -48,8 +48,8 @@ public class ZooTabletStateStore extends TabletStateStore {
   }
   
   @Override
-  public Iterator<TabletLocationState> iterator() {
-    return new Iterator<TabletLocationState>() {
+  public ClosableIterator<TabletLocationState> iterator() {
+    return new ClosableIterator<TabletLocationState>() {
       boolean finished = false;
       
       @Override
@@ -101,6 +101,10 @@ public class ZooTabletStateStore extends TabletStateStore {
       public void remove() {
         throw new NotImplementedException();
       }
+
+      @Override
+      public void close() {
+      }
     };
   }
   

http://git-wip-us.apache.org/repos/asf/accumulo/blob/0da9a567/server/master/src/main/java/org/apache/accumulo/master/TabletGroupWatcher.java
----------------------------------------------------------------------
diff --git a/server/master/src/main/java/org/apache/accumulo/master/TabletGroupWatcher.java
b/server/master/src/main/java/org/apache/accumulo/master/TabletGroupWatcher.java
index 1a201f5..1590348 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/TabletGroupWatcher.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/TabletGroupWatcher.java
@@ -18,6 +18,7 @@ package org.apache.accumulo.master;
 
 import static java.lang.Math.min;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -66,6 +67,7 @@ import org.apache.accumulo.server.fs.FileRef;
 import org.apache.accumulo.server.fs.VolumeManager.FileType;
 import org.apache.accumulo.server.master.LiveTServerSet.TServerConnection;
 import org.apache.accumulo.server.master.state.Assignment;
+import org.apache.accumulo.server.master.state.ClosableIterator;
 import org.apache.accumulo.server.master.state.DistributedStoreException;
 import org.apache.accumulo.server.master.state.MergeInfo;
 import org.apache.accumulo.server.master.state.MergeState;
@@ -118,6 +120,7 @@ class TabletGroupWatcher extends Daemon {
 
       int totalUnloaded = 0;
       int unloaded = 0;
+      ClosableIterator<TabletLocationState> iter = null;
       try {
         Map<Text,MergeStats> mergeStatsCache = new HashMap<Text,MergeStats>();
         
@@ -145,7 +148,9 @@ class TabletGroupWatcher extends Daemon {
         stats.begin();
         // Walk through the tablets in our store, and work tablets
         // towards their goal
-        for (TabletLocationState tls : store) {
+        iter = store.iterator();
+        while (iter.hasNext()) {
+          TabletLocationState tls = iter.next();
           if (tls == null) {
             continue;
           }
@@ -286,6 +291,14 @@ class TabletGroupWatcher extends Daemon {
         } else {
           UtilWaitThread.sleep(Master.WAIT_BETWEEN_ERRORS);
         }
+      } finally {
+        if (iter != null) {
+          try {
+            iter.close();
+          } catch (IOException ex) {
+            Master.log.warn("Error closing TabletLocationState iterator: " + ex, ex);
+          }
+        }
       }
     }
   }


Mime
View raw message