This is an automated email from the ASF dual-hosted git repository. kturner pushed a commit to branch 3.1 in repository https://gitbox.apache.org/repos/asf/accumulo.git
commit 3b5d9cf68cbd36244303d9b4ada5a96fb10d11c8 Merge: 187733f634 5657bc8cf2 Author: Keith Turner <ktur...@apache.org> AuthorDate: Wed Feb 12 00:37:22 2025 +0000 Merge branch '2.1' into 3.1 .../apache/accumulo/manager/tableOps/Utils.java | 45 +++---------- .../manager/tableOps/clone/CloneZookeeper.java | 2 +- .../manager/tableOps/create/PopulateZookeeper.java | 5 +- .../manager/tableOps/rename/RenameTable.java | 2 +- .../tableImport/ImportPopulateZookeeper.java | 4 +- .../apache/accumulo/test/TableOperationsIT.java | 75 ++++++++++++++++++++++ 6 files changed, 93 insertions(+), 40 deletions(-) diff --cc server/manager/src/main/java/org/apache/accumulo/manager/tableOps/Utils.java index ad9b75f1d9,2e0f33c2a8..4af608e75f --- a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/Utils.java +++ b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/Utils.java @@@ -32,10 -30,8 +30,7 @@@ import java.util.concurrent.locks.Reent import java.util.function.Function; import org.apache.accumulo.core.Constants; - import org.apache.accumulo.core.client.NamespaceNotFoundException; import org.apache.accumulo.core.clientImpl.AcceptableThriftTableOperationException; - import org.apache.accumulo.core.clientImpl.Namespace; --import org.apache.accumulo.core.clientImpl.Namespaces; import org.apache.accumulo.core.clientImpl.thrift.TableOperation; import org.apache.accumulo.core.clientImpl.thrift.TableOperationExceptionType; import org.apache.accumulo.core.data.AbstractId; @@@ -70,48 -62,29 +63,30 @@@ public class Utils * Checks that a table name is only used by the specified table id or not used at all. */ public static void checkTableNameDoesNotExist(ServerContext context, String tableName, - TableId tableId, TableOperation operation) throws AcceptableThriftTableOperationException { + NamespaceId destNamespaceId, TableId tableId, TableOperation operation) + throws AcceptableThriftTableOperationException { + + var newTableName = TableNameUtil.qualify(tableName).getSecond(); - final Map<NamespaceId,String> namespaces = new HashMap<>(); - final boolean namespaceInTableName = tableName.contains("."); try { - for (String tid : context.getZooReader() + for (String tid : context.getZooSession().asReader() .getChildren(context.getZooKeeperRoot() + Constants.ZTABLES)) { final String zTablePath = context.getZooKeeperRoot() + Constants.ZTABLES + "/" + tid; try { - final byte[] tname = context.getZooReader().getData(zTablePath + Constants.ZTABLE_NAME); + final byte[] tname = + context.getZooSession().asReader().getData(zTablePath + Constants.ZTABLE_NAME); - Preconditions.checkState(tname != null, "Malformed table entry in ZooKeeper at %s", - zTablePath); - String namespaceName = Namespace.DEFAULT.name(); - if (namespaceInTableName) { + if (newTableName.equals(new String(tname, UTF_8))) { + // only make RPCs to get the namespace when the table names are equal final byte[] nId = - context.getZooReader().getData(zTablePath + Constants.ZTABLE_NAMESPACE); + context.getZooSession().asReader().getData(zTablePath + Constants.ZTABLE_NAMESPACE); - if (nId != null) { - final NamespaceId namespaceId = NamespaceId.of(new String(nId, UTF_8)); - if (!namespaceId.equals(Namespace.DEFAULT.id())) { - namespaceName = namespaces.get(namespaceId); - if (namespaceName == null) { - try { - namespaceName = Namespaces.getNamespaceName(context, namespaceId); - namespaces.put(namespaceId, namespaceName); - } catch (NamespaceNotFoundException e) { - throw new AcceptableThriftTableOperationException(null, tableName, - TableOperation.CREATE, TableOperationExceptionType.OTHER, - "Table (" + tableId.canonical() + ") contains reference to namespace (" - + namespaceId + ") that doesn't exist"); - } - } - } + if (destNamespaceId.canonical().equals(new String(nId, UTF_8)) + && !tableId.canonical().equals(tid)) { + throw new AcceptableThriftTableOperationException(tid, tableName, operation, + TableOperationExceptionType.EXISTS, null); } - } - if (tableName.equals(TableNameUtil.qualified(new String(tname, UTF_8), namespaceName)) - && !tableId.equals(TableId.of(tid))) { - throw new AcceptableThriftTableOperationException(tid, tableName, operation, - TableOperationExceptionType.EXISTS, null); } } catch (NoNodeException nne) { log.trace("skipping tableId {}, either being created or has been deleted.", tid, nne); diff --cc test/src/main/java/org/apache/accumulo/test/TableOperationsIT.java index df8151bbda,8007b81996..8744297ab4 --- a/test/src/main/java/org/apache/accumulo/test/TableOperationsIT.java +++ b/test/src/main/java/org/apache/accumulo/test/TableOperationsIT.java @@@ -39,6 -39,8 +39,7 @@@ import java.util.Set import java.util.SortedSet; import java.util.TreeMap; import java.util.TreeSet; -import java.util.concurrent.TimeUnit; + import java.util.stream.Collectors; import org.apache.accumulo.core.client.Accumulo; import org.apache.accumulo.core.client.AccumuloClient;