accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [2/7] git commit: ACCUMULO-3157 close scanners
Date Mon, 22 Sep 2014 22:33:22 GMT
ACCUMULO-3157 close scanners


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

Branch: refs/heads/master
Commit: 7983b2f2a0fbb543518ada541554793994215392
Parents: 6340cbc
Author: Eric Newton <Eric Newton>
Authored: Mon Sep 22 11:51:08 2014 -0400
Committer: Josh Elser <elserj@apache.org>
Committed: Mon Sep 22 16:33:54 2014 -0400

----------------------------------------------------------------------
 .../server/util/FindOfflineTablets.java         | 42 +++++++++++---------
 1 file changed, 23 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/7983b2f2/server/src/main/java/org/apache/accumulo/server/util/FindOfflineTablets.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/util/FindOfflineTablets.java
b/server/src/main/java/org/apache/accumulo/server/util/FindOfflineTablets.java
index 42ebbe2..020e4ce 100644
--- a/server/src/main/java/org/apache/accumulo/server/util/FindOfflineTablets.java
+++ b/server/src/main/java/org/apache/accumulo/server/util/FindOfflineTablets.java
@@ -46,26 +46,30 @@ public class FindOfflineTablets {
     Instance instance = opts.getInstance();
     MetaDataTableScanner rootScanner = new MetaDataTableScanner(instance, SecurityConstants.getSystemCredentials(),
Constants.METADATA_ROOT_TABLET_KEYSPACE);
     MetaDataTableScanner metaScanner = new MetaDataTableScanner(instance, SecurityConstants.getSystemCredentials(),
Constants.NON_ROOT_METADATA_KEYSPACE);
-    @SuppressWarnings("unchecked")
-    Iterator<TabletLocationState> scanner = (Iterator<TabletLocationState>)new
IteratorChain(rootScanner, metaScanner);
-    LiveTServerSet tservers = new LiveTServerSet(instance, DefaultConfiguration.getDefaultConfiguration(),
new Listener() {
-      @Override
-      public void update(LiveTServerSet current, Set<TServerInstance> deleted, Set<TServerInstance>
added) {
-        if (!deleted.isEmpty() && scanning.get())
-          log.warn("Tablet servers deleted while scanning: " + deleted);
-        if (!added.isEmpty() && scanning.get())
-          log.warn("Tablet servers added while scanning: " + added);
+    try {
+      @SuppressWarnings("unchecked")
+      Iterator<TabletLocationState> scanner = (Iterator<TabletLocationState>)new
IteratorChain(rootScanner, metaScanner);
+      LiveTServerSet tservers = new LiveTServerSet(instance, DefaultConfiguration.getDefaultConfiguration(),
new Listener() {
+        @Override
+        public void update(LiveTServerSet current, Set<TServerInstance> deleted, Set<TServerInstance>
added) {
+          if (!deleted.isEmpty() && scanning.get())
+            log.warn("Tablet servers deleted while scanning: " + deleted);
+          if (!added.isEmpty() && scanning.get())
+            log.warn("Tablet servers added while scanning: " + added);
+        }
+      });
+      tservers.startListeningForTabletServerChanges();
+      scanning.set(true);
+      while (scanner.hasNext()) {
+        TabletLocationState locationState = scanner.next();
+        TabletState state = locationState.getState(tservers.getCurrentServers());
+        if (state != null && state != TabletState.HOSTED && TableManager.getInstance().getTableState(locationState.extent.getTableId().toString())
!= TableState.OFFLINE)
+          if (!locationState.extent.equals(Constants.ROOT_TABLET_EXTENT))
+            System.out.println(locationState + " is " + state + "  #walogs:" + locationState.walogs.size());
       }
-    });
-    tservers.startListeningForTabletServerChanges();
-    scanning.set(true);
-    while (scanner.hasNext()) {
-      TabletLocationState locationState = scanner.next();
-      TabletState state = locationState.getState(tservers.getCurrentServers());
-      if (state != null && state != TabletState.HOSTED && TableManager.getInstance().getTableState(locationState.extent.getTableId().toString())
!= TableState.OFFLINE)
-        if (!locationState.extent.equals(Constants.ROOT_TABLET_EXTENT))
-          System.out.println(locationState + " is " + state + "  #walogs:" + locationState.walogs.size());
+    } finally {
+      rootScanner.close();
+      metaScanner.close();
     }
   }
-  
 }


Mime
View raw message