This is an automated email from the ASF dual-hosted git repository.

kturner pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/main by this push:
     new 8eaecd3cc9 get table splits via ample (#3338)
8eaecd3cc9 is described below

commit 8eaecd3cc9b78c6a0198aee15a3505f24f8cafd8
Author: Keith Turner <ktur...@apache.org>
AuthorDate: Tue Apr 25 14:21:49 2023 -0400

    get table splits via ample (#3338)
    
    fixes #3333
---
 .../core/clientImpl/TableOperationsImpl.java       | 35 +++++++---------------
 .../core/metadata/schema/TabletsMetadata.java      |  2 ++
 2 files changed, 12 insertions(+), 25 deletions(-)

diff --git 
a/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java
 
b/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java
index 1da446f496..93734a39b1 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java
@@ -119,9 +119,9 @@ import 
org.apache.accumulo.core.manager.state.tables.TableState;
 import org.apache.accumulo.core.manager.thrift.FateOperation;
 import org.apache.accumulo.core.manager.thrift.FateService;
 import org.apache.accumulo.core.manager.thrift.ManagerClientService;
-import org.apache.accumulo.core.metadata.MetadataServicer;
 import org.apache.accumulo.core.metadata.MetadataTable;
 import org.apache.accumulo.core.metadata.RootTable;
+import org.apache.accumulo.core.metadata.schema.TabletDeletedException;
 import org.apache.accumulo.core.metadata.schema.TabletMetadata;
 import org.apache.accumulo.core.metadata.schema.TabletMetadata.Location;
 import org.apache.accumulo.core.metadata.schema.TabletMetadata.LocationType;
@@ -664,37 +664,22 @@ public class TableOperationsImpl extends 
TableOperationsHelper {
 
   private List<Text> _listSplits(String tableName)
       throws TableNotFoundException, AccumuloSecurityException {
+
     TableId tableId = context.getTableId(tableName);
-    TreeMap<KeyExtent,String> tabletLocations = new TreeMap<>();
+
     while (true) {
       try {
-        tabletLocations.clear();
-        // the following method throws AccumuloException for some conditions 
that should be retried
-        MetadataServicer.forTableId(context, 
tableId).getTabletLocations(tabletLocations);
-        break;
-      } catch (AccumuloSecurityException ase) {
-        throw ase;
-      } catch (Exception e) {
+        return 
context.getAmple().readTablets().forTable(tableId).fetch(PREV_ROW).checkConsistency()
+            .build().stream().map(tm -> 
tm.getExtent().endRow()).filter(Objects::nonNull)
+            .collect(Collectors.toList());
+      } catch (TabletDeletedException tde) {
+        // see if the table was deleted
         context.requireTableExists(tableId, tableName);
-
-        if (e instanceof RuntimeException && e.getCause() instanceof 
AccumuloSecurityException) {
-          throw (AccumuloSecurityException) e.getCause();
-        }
-
-        log.info("{} ... retrying ...", e, e);
+        log.debug("A merge happened while trying to list splits for {} {}, 
retrying ", tableName,
+            tableId, tde);
         sleepUninterruptibly(3, SECONDS);
       }
     }
-
-    ArrayList<Text> endRows = new ArrayList<>(tabletLocations.size());
-    for (KeyExtent ke : tabletLocations.keySet()) {
-      if (ke.endRow() != null) {
-        endRows.add(ke.endRow());
-      }
-    }
-
-    return endRows;
-
   }
 
   /**
diff --git 
a/core/src/main/java/org/apache/accumulo/core/metadata/schema/TabletsMetadata.java
 
b/core/src/main/java/org/apache/accumulo/core/metadata/schema/TabletsMetadata.java
index f6042f184b..876e6ec584 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/metadata/schema/TabletsMetadata.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/metadata/schema/TabletsMetadata.java
@@ -399,6 +399,8 @@ public class TabletsMetadata implements 
Iterable<TabletMetadata>, AutoCloseable
 
     /**
      * Checks that the metadata table forms a linked list and automatically 
backs up until it does.
+     * May cause {@link TabletDeletedException} to be thrown while reading 
tablets metadata in the
+     * case where a table is deleted or merge runs concurrently with scan.
      */
     Options checkConsistency();
 

Reply via email to