keith-turner commented on code in PR #2792:
URL: https://github.com/apache/accumulo/pull/2792#discussion_r973779278


##########
server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java:
##########
@@ -462,4 +502,39 @@ public long getErrorsStat() {
   public long getCandidatesStat() {
     return candidates;
   }
+
+  /**
+   * Return a set of all TableIDs in the
+   * {@link org.apache.accumulo.core.metadata.schema.Ample.DataLevel} for 
which we are considering
+   * deletes. When operating on DataLevel.USER this will return all user table 
ids in an ONLINE or
+   * OFFLINE state. When operating on DataLevel.METADATA this will return the 
table id for the
+   * accumulo.metadata table. When operating on DataLevel.ROOT this will 
return the table id for the
+   * accumulo.root table.
+   *
+   * @return The table ids
+   * @throws InterruptedException
+   *           if interrupted when calling ZooKeeper
+   */
+  @Override
+  public Set<TableId> getCandidateTableIDs() throws InterruptedException {
+    if (level == DataLevel.ROOT) {
+      return Set.of(RootTable.ID);
+    } else if (level == DataLevel.METADATA) {
+      return Collections.singleton(MetadataTable.ID);
+    } else if (level == DataLevel.USER) {
+      Set<TableId> tableIds = new HashSet<>();
+      tableIds.remove(MetadataTable.ID);
+      tableIds.remove(RootTable.ID);
+      getTableIDs().forEach((k, v) -> {
+        if (v == TableState.ONLINE || v == TableState.OFFLINE) {
+          // Don't return tables that are NEW, DELETING, or in an
+          // UNKNOWN state.
+          tableIds.add(k);
+        }
+      });

Review Comment:
   ```suggestion
         getTableIDs().forEach((k, v) -> {
           if (v == TableState.ONLINE || v == TableState.OFFLINE) {
             // Don't return tables that are NEW, DELETING, or in an
             // UNKNOWN state.
             tableIds.add(k);
           }
         });
         tableIds.remove(MetadataTable.ID);
         tableIds.remove(RootTable.ID);
   
   ```



##########
server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java:
##########
@@ -171,8 +179,40 @@ public Stream<Reference> getReferences() {
   }
 
   @Override
-  public Set<TableId> getTableIDs() {
-    return context.getTableIdToNameMap().keySet();
+  public Map<TableId,TableState> getTableIDs() throws InterruptedException {
+    final String tablesPath = context.getZooKeeperRoot() + Constants.ZTABLES;
+    final ZooReader zr = context.getZooReader();
+    int retries = 1;
+    UncheckedIOException ioe = null;
+    while (retries <= 10) {
+      try {
+        zr.sync(tablesPath);
+        final Map<TableId,TableState> tids = new HashMap<>();
+        for (String table : zr.getChildren(tablesPath)) {
+          TableId tableId = TableId.of(table);
+          TableState tableState = null;
+          String statePath = context.getZooKeeperRoot() + Constants.ZTABLES + 
"/"
+              + tableId.canonical() + Constants.ZTABLE_STATE;
+          byte[] state = zr.getData(statePath, null, null);

Review Comment:
   Not completely sure what getData will do if the node does not exist.  If it 
returns null then ignore the following.  If it throws a NNE then could do the 
following.
   
   ```suggestion
             byte[] state = null;
             try {
                state = zr.getData(statePath, null, null);
              } catch (NoNodeException e) {
                  // table was probably deleted after getting list of 
children... so let it end up as an UNKNOWN state
              }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to