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

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

commit c5736768d8ff3cb8799b5e254d7df36f1850a648
Merge: 5c58b08 54b2c32
Author: Keith Turner <ktur...@apache.org>
AuthorDate: Wed Aug 14 16:55:06 2019 -0400

    Merge branch '1.9' into 2.0

 .../accumulo/gc/GarbageCollectWriteAheadLogs.java  |  5 +++--
 .../apache/accumulo/master/FateServiceHandler.java |  3 ++-
 .../accumulo/master/util/TableValidators.java      | 22 ++++++++++++++++++++++
 .../accumulo/test/functional/CloneTestIT.java      | 16 ++++++++++++++++
 4 files changed, 43 insertions(+), 3 deletions(-)

diff --cc 
server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectWriteAheadLogs.java
index 5bb8201,23c4932..289e69d
--- 
a/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectWriteAheadLogs.java
+++ 
b/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectWriteAheadLogs.java
@@@ -53,6 -60,8 +53,7 @@@ import org.apache.accumulo.server.maste
  import org.apache.accumulo.server.master.state.TServerInstance;
  import org.apache.accumulo.server.master.state.TabletLocationState;
  import org.apache.accumulo.server.master.state.TabletState;
+ import org.apache.accumulo.server.master.state.ZooTabletStateStore;
 -import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
  import org.apache.hadoop.fs.FileStatus;
  import org.apache.hadoop.fs.Path;
  import org.apache.hadoop.io.Text;
@@@ -88,14 -97,28 +89,14 @@@ public class GarbageCollectWriteAheadLo
      this.context = context;
      this.fs = fs;
      this.useTrash = useTrash;
 -    this.liveServers = new LiveTServerSet(context, new Listener() {
 -      @Override
 -      public void update(LiveTServerSet current, Set<TServerInstance> deleted,
 -          Set<TServerInstance> added) {
 -        log.debug("New tablet servers noticed: " + added);
 -        log.debug("Tablet servers removed: " + deleted);
 -      }
 +    this.liveServers = new LiveTServerSet(context, (current, deleted, added) 
-> {
 +      log.debug("New tablet servers noticed: {}", added);
 +      log.debug("Tablet servers removed: {}", deleted);
      });
      liveServers.startListeningForTabletServerChanges();
 -    this.walMarker = new WalStateManager(context.getInstance(), 
ZooReaderWriter.getInstance());
 -    this.store = new Iterable<TabletLocationState>() {
 -      @Override
 -      public Iterator<TabletLocationState> iterator() {
 -        try {
 -          return Iterators.concat(new ZooTabletStateStore().iterator(),
 -              new RootTabletStateStore(context).iterator(),
 -              new MetaDataStateStore(context).iterator());
 -        } catch (DistributedStoreException e) {
 -          throw new RuntimeException(e);
 -        }
 -      }
 -    };
 +    this.walMarker = new WalStateManager(context);
-     this.store = () -> Iterators.concat(new 
RootTabletStateStore(context).iterator(),
-         new MetaDataStateStore(context).iterator());
++    this.store = () -> Iterators.concat(new 
ZooTabletStateStore(context).iterator(),
++        new RootTabletStateStore(context).iterator(), new 
MetaDataStateStore(context).iterator());
    }
  
    /**
diff --cc 
server/master/src/main/java/org/apache/accumulo/master/FateServiceHandler.java
index c19ee7b,7949ac2..0cf7c14
--- 
a/server/master/src/main/java/org/apache/accumulo/master/FateServiceHandler.java
+++ 
b/server/master/src/main/java/org/apache/accumulo/master/FateServiceHandler.java
@@@ -250,12 -225,12 +251,12 @@@ class FateServiceHandler implements Fat
        case TABLE_CLONE: {
          TableOperation tableOp = TableOperation.CLONE;
          validateArgumentCount(arguments, tableOp, 2);
-         TableId srcTableId = validateTableIdArgument(arguments.get(0), 
tableOp, NOT_ROOT_ID);
 -        String srcTableId = validateTableIdArgument(arguments.get(0), 
tableOp, CAN_CLONE);
++        TableId srcTableId = validateTableIdArgument(arguments.get(0), 
tableOp, CAN_CLONE);
          String tableName = validateTableNameArgument(arguments.get(1), 
tableOp, NOT_SYSTEM);
 -        String namespaceId;
 +        NamespaceId namespaceId;
          try {
            namespaceId =
 -              Namespaces.getNamespaceId(master.getInstance(), 
Tables.qualify(tableName).getFirst());
 +              Namespaces.getNamespaceId(master.getContext(), 
Tables.qualify(tableName).getFirst());
          } catch (NamespaceNotFoundException e) {
            // shouldn't happen, but possible once cloning between namespaces 
is supported
            throw new ThriftTableOperationException(null, tableName, tableOp,
diff --cc 
server/master/src/main/java/org/apache/accumulo/master/util/TableValidators.java
index ddbce98,a9d3edb..4d44765
--- 
a/server/master/src/main/java/org/apache/accumulo/master/util/TableValidators.java
+++ 
b/server/master/src/main/java/org/apache/accumulo/master/util/TableValidators.java
@@@ -80,6 -79,28 +80,28 @@@ public class TableValidators 
      }
    };
  
 -  public static final Validator<String> CAN_CLONE = new Validator<String>() {
++  public static final Validator<TableId> CAN_CLONE = new Validator<TableId>() 
{
+ 
 -    private List<String> metaIDs = Arrays.asList(RootTable.ID, 
MetadataTable.ID);
++    private List<TableId> metaIDs = Arrays.asList(RootTable.ID, 
MetadataTable.ID);
+ 
+     @Override
 -    public boolean apply(String tableId) {
++    public boolean test(TableId tableId) {
+       return !metaIDs.contains(tableId);
+     }
+ 
+     @Override
 -    public String invalidMessage(String tableId) {
++    public String invalidMessage(TableId tableId) {
+       String msg;
+       if (tableId.equals(MetadataTable.ID)) {
+         msg = " Cloning " + MetadataTable.NAME
+             + " is dangerous and no longer supported, see 
https://github.com/apache/accumulo/issues/1309.";;
+       } else {
+         msg = "Can not clone " + RootTable.NAME;
+       }
+       return msg;
+     }
+   };
+ 
    public static final Validator<String> NOT_SYSTEM = new Validator<String>() {
  
      @Override
diff --cc 
test/src/main/java/org/apache/accumulo/test/functional/CloneTestIT.java
index 0e414bd,d76a28a..7aed692
--- a/test/src/main/java/org/apache/accumulo/test/functional/CloneTestIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/CloneTestIT.java
@@@ -33,9 -33,11 +33,10 @@@ import java.util.Set
  import java.util.TreeSet;
  
  import org.apache.accumulo.cluster.AccumuloCluster;
 +import org.apache.accumulo.core.client.Accumulo;
 +import org.apache.accumulo.core.client.AccumuloClient;
+ import org.apache.accumulo.core.client.AccumuloException;
  import org.apache.accumulo.core.client.BatchWriter;
 -import org.apache.accumulo.core.client.BatchWriterConfig;
 -import org.apache.accumulo.core.client.Connector;
 -import org.apache.accumulo.core.client.MutationsRejectedException;
  import org.apache.accumulo.core.client.Scanner;
  import org.apache.accumulo.core.client.TableNotFoundException;
  import org.apache.accumulo.core.client.admin.DiskUsage;
@@@ -253,38 -269,49 +255,52 @@@ public class CloneTestIT extends Accumu
  
    @Test
    public void testCloneWithSplits() throws Exception {
 -    Connector conn = getConnector();
 -
 -    List<Mutation> mutations = new ArrayList<>();
 -    TreeSet<Text> splits = new TreeSet<>();
 -    for (int i = 0; i < 10; i++) {
 -      splits.add(new Text(Integer.toString(i)));
 -      Mutation m = new Mutation(Integer.toString(i));
 -      m.put("", "", "");
 -      mutations.add(m);
 -    }
 +    try (AccumuloClient client = 
Accumulo.newClient().from(getClientProps()).build()) {
 +
 +      List<Mutation> mutations = new ArrayList<>();
 +      TreeSet<Text> splits = new TreeSet<>();
 +      for (int i = 0; i < 10; i++) {
 +        splits.add(new Text(Integer.toString(i)));
 +        Mutation m = new Mutation(Integer.toString(i));
 +        m.put("", "", "");
 +        mutations.add(m);
 +      }
  
 -    String[] tables = getUniqueNames(2);
 +      String[] tables = getUniqueNames(2);
  
 -    conn.tableOperations().create(tables[0]);
 +      client.tableOperations().create(tables[0]);
  
 -    conn.tableOperations().addSplits(tables[0], splits);
 +      client.tableOperations().addSplits(tables[0], splits);
  
 -    BatchWriter bw = conn.createBatchWriter(tables[0], new 
BatchWriterConfig());
 -    bw.addMutations(mutations);
 -    bw.close();
 +      try (BatchWriter bw = client.createBatchWriter(tables[0])) {
 +        bw.addMutations(mutations);
 +      }
  
 -    conn.tableOperations().clone(tables[0], tables[1], true, null, null);
 +      client.tableOperations().clone(tables[0], tables[1], true, null, null);
  
 -    conn.tableOperations().deleteRows(tables[1], new Text("4"), new 
Text("8"));
 +      client.tableOperations().deleteRows(tables[1], new Text("4"), new 
Text("8"));
  
 -    List<String> rows = Arrays.asList("0", "1", "2", "3", "4", "9");
 -    List<String> actualRows = new ArrayList<>();
 -    for (Entry<Key,Value> entry : conn.createScanner(tables[1], 
Authorizations.EMPTY)) {
 -      actualRows.add(entry.getKey().getRow().toString());
 -    }
 +      List<String> rows = Arrays.asList("0", "1", "2", "3", "4", "9");
 +      List<String> actualRows = new ArrayList<>();
 +      for (Entry<Key,Value> entry : client.createScanner(tables[1], 
Authorizations.EMPTY)) {
 +        actualRows.add(entry.getKey().getRow().toString());
 +      }
  
 -    assertEquals(rows, actualRows);
 +      assertEquals(rows, actualRows);
 +    }
    }
+ 
+   @Test(expected = AccumuloException.class)
+   public void testCloneRootTable() throws Exception {
 -    Connector conn = getConnector();
 -    conn.tableOperations().clone(RootTable.NAME, "rc1", true, null, null);
++    try (AccumuloClient client = 
Accumulo.newClient().from(getClientProps()).build()) {
++      client.tableOperations().clone(RootTable.NAME, "rc1", true, null, null);
++    }
+   }
+ 
+   @Test(expected = AccumuloException.class)
+   public void testCloneMetadataTable() throws Exception {
 -    Connector conn = getConnector();
 -    conn.tableOperations().clone(MetadataTable.NAME, "mc1", true, null, null);
++    try (AccumuloClient client = 
Accumulo.newClient().from(getClientProps()).build()) {
++      client.tableOperations().clone(MetadataTable.NAME, "mc1", true, null, 
null);
++    }
+   }
  }

Reply via email to