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

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

commit d40e89d301ee27c7490e1b23ccddd55ca7f14421
Merge: c6e31e2cc2 cd27402d50
Author: Dave Marion <dlmar...@apache.org>
AuthorDate: Mon Jun 24 18:01:54 2024 +0000

    Merge branch '2.1'

 .../spi/balancer/HostRegexTableLoadBalancer.java   |  3 +-
 .../accumulo/core/util/tables/TableZooHelper.java  | 17 ++++++
 .../server/client/ClientServiceHandler.java        |  5 +-
 .../server/security/AuditedSecurityOperation.java  |  7 ++-
 .../server/security/SecurityOperation.java         |  5 +-
 .../apache/accumulo/manager/tableOps/Utils.java    | 32 ++++++++--
 .../manager/tableOps/clone/ClonePermissions.java   |  4 +-
 .../manager/tableOps/clone/CloneZookeeper.java     |  4 +-
 .../manager/tableOps/create/PopulateZookeeper.java |  2 +-
 .../manager/tableOps/create/SetupPermissions.java  |  3 +-
 .../manager/tableOps/rename/RenameTable.java       |  2 +-
 .../tableImport/ImportPopulateZookeeper.java       |  2 +-
 .../tableImport/ImportSetupPermissions.java        |  2 +-
 .../org/apache/accumulo/test/CreateTableIT.java    | 69 ++++++++++++++++++++++
 14 files changed, 133 insertions(+), 24 deletions(-)

diff --cc 
core/src/main/java/org/apache/accumulo/core/util/tables/TableZooHelper.java
index 6ea16a7499,de53d2bf1e..7d8cb852dc
--- 
a/core/src/main/java/org/apache/accumulo/core/util/tables/TableZooHelper.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/util/tables/TableZooHelper.java
@@@ -35,9 -37,11 +36,10 @@@ import org.apache.accumulo.core.data.Na
  import org.apache.accumulo.core.data.TableId;
  import org.apache.accumulo.core.fate.zookeeper.ZooCache;
  import org.apache.accumulo.core.manager.state.tables.TableState;
 -import org.apache.accumulo.core.metadata.MetadataTable;
 -import org.apache.accumulo.core.metadata.RootTable;
++import org.apache.accumulo.core.metadata.AccumuloTable;
  
 -import com.google.common.cache.Cache;
 -import com.google.common.cache.CacheBuilder;
 +import com.github.benmanes.caffeine.cache.Cache;
 +import com.github.benmanes.caffeine.cache.Caffeine;
  
  public class TableZooHelper implements AutoCloseable {
  
@@@ -58,6 -62,12 +60,11 @@@
     *         getCause() of NamespaceNotFoundException
     */
    public TableId getTableId(String tableName) throws TableNotFoundException {
 -    if (MetadataTable.NAME.equals(tableName)) {
 -      return MetadataTable.ID;
 -    }
 -    if (RootTable.NAME.equals(tableName)) {
 -      return RootTable.ID;
++    for (AccumuloTable systemTable : AccumuloTable.values()) {
++      if (systemTable.tableName().equals(tableName)) {
++        return systemTable.tableId();
++      }
+     }
      try {
        return 
_getTableIdDetectNamespaceNotFound(EXISTING_TABLE_NAME.validate(tableName));
      } catch (NamespaceNotFoundException e) {
@@@ -89,6 -99,12 +96,11 @@@
    }
  
    public String getTableName(TableId tableId) throws TableNotFoundException {
 -    if (MetadataTable.ID.equals(tableId)) {
 -      return MetadataTable.NAME;
 -    }
 -    if (RootTable.ID.equals(tableId)) {
 -      return RootTable.NAME;
++    for (AccumuloTable systemTable : AccumuloTable.values()) {
++      if (systemTable.tableId().equals(tableId)) {
++        return systemTable.tableName();
++      }
+     }
      String tableName = getTableMap().getIdtoNameMap().get(tableId);
      if (tableName == null) {
        throw new TableNotFoundException(tableId.canonical(), null, null);
@@@ -180,6 -200,11 +192,11 @@@
    public NamespaceId getNamespaceId(TableId tableId) throws 
TableNotFoundException {
      checkArgument(context != null, "instance is null");
      checkArgument(tableId != null, "tableId is null");
+ 
 -    if (MetadataTable.ID.equals(tableId) || RootTable.ID.equals(tableId)) {
++    if (AccumuloTable.allTableIds().contains(tableId)) {
+       return Namespace.ACCUMULO.id();
+     }
+ 
      ZooCache zc = context.getZooCache();
      byte[] n = zc.get(context.getZooKeeperRoot() + Constants.ZTABLES + "/" + 
tableId
          + Constants.ZTABLE_NAMESPACE);
diff --cc test/src/main/java/org/apache/accumulo/test/CreateTableIT.java
index 0000000000,b26271a3e4..b2166929a1
mode 000000,100644..100644
--- a/test/src/main/java/org/apache/accumulo/test/CreateTableIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/CreateTableIT.java
@@@ -1,0 -1,67 +1,69 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you under the Apache License, Version 2.0 (the
+  * "License"); you may not use this file except in compliance
+  * with the License.  You may obtain a copy of the License at
+  *
+  *   https://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing,
+  * software distributed under the License is distributed on an
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  * KIND, either express or implied.  See the License for the
+  * specific language governing permissions and limitations
+  * under the License.
+  */
+ package org.apache.accumulo.test;
+ 
+ import static org.junit.jupiter.api.Assertions.assertEquals;
+ 
+ import java.time.Duration;
+ 
+ import org.apache.accumulo.core.client.Accumulo;
+ import org.apache.accumulo.core.client.AccumuloClient;
++import org.apache.accumulo.core.metadata.AccumuloTable;
+ import org.apache.accumulo.harness.SharedMiniClusterBase;
+ import org.junit.jupiter.api.AfterAll;
+ import org.junit.jupiter.api.BeforeAll;
+ import org.junit.jupiter.api.Test;
+ 
+ public class CreateTableIT extends SharedMiniClusterBase {
+ 
+   @Override
+   protected Duration defaultTimeout() {
+     return Duration.ofMinutes(5);
+   }
+ 
+   @BeforeAll
+   public static void setup() throws Exception {
+     SharedMiniClusterBase.startMiniCluster();
+   }
+ 
+   @AfterAll
+   public static void teardown() {
+     SharedMiniClusterBase.stopMiniCluster();
+   }
+ 
+   @Test
+   public void testCreateLotsOfTables() throws Exception {
+     try (AccumuloClient client = 
Accumulo.newClient().from(getClientProps()).build()) {
+ 
+       String[] tableNames = getUniqueNames(1000);
+ 
+       for (int i = 0; i < tableNames.length; i++) {
+         // Create waits for the Fate operation to complete
+         long start = System.currentTimeMillis();
+         client.tableOperations().create(tableNames[i]);
+         System.out.println("Table creation took: " + 
(System.currentTimeMillis() - start) + "ms");
+       }
+       // Confirm all 1000 user tables exist in addition to Root, Metadata,
+       // and ScanRef tables
 -      assertEquals(1003, client.tableOperations().list().size());
++      assertEquals(1000 + AccumuloTable.allTableIds().size(),
++          client.tableOperations().list().size());
+     }
+   }
+ 
+ }

Reply via email to