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


##########
server/manager/src/main/java/org/apache/accumulo/manager/tableOps/Utils.java:
##########
@@ -68,47 +62,29 @@ 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()
           .getChildren(context.getZooKeeperRoot() + Constants.ZTABLES)) {
 
         final String zTablePath = context.getZooKeeperRoot() + 
Constants.ZTABLES + "/" + tid;
         try {
           final byte[] tname = context.getZooReader().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);
-            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.equals(TableId.of(tid))) {

Review Comment:
   I don't think that will be a common case so there would not be much benefit 
to adding complexity to the code. 



-- 
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