Skip to content

Commit 0047e02

Browse files
committed
Fix src and dest namespace handling in clone table operation
Closes apache#5324
1 parent 0f53ae0 commit 0047e02

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

server/manager/src/main/java/org/apache/accumulo/manager/FateServiceHandler.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -286,20 +286,26 @@ public void executeFateOperation(TInfo tinfo, TCredentials c, long opid, FateOpe
286286
keepOffline = Boolean.parseBoolean(ByteBufferUtil.toString(arguments.get(2)));
287287
}
288288

289+
NamespaceId srcNamespaceId;
289290
NamespaceId namespaceId;
290291
try {
292+
srcNamespaceId = manager.getContext().getNamespaceId(srcTableId);
291293
namespaceId = Namespaces.getNamespaceId(manager.getContext(),
292294
TableNameUtil.qualify(tableName).getFirst());
293295
} catch (NamespaceNotFoundException e) {
294296
// shouldn't happen, but possible once cloning between namespaces is supported
295297
throw new ThriftTableOperationException(null, tableName, tableOp,
296298
TableOperationExceptionType.NAMESPACE_NOTFOUND, "");
299+
} catch (TableNotFoundException e) {
300+
// shouldn't happen, but possible once cloning between namespaces is supported
301+
throw new ThriftTableOperationException(srcTableId.canonical(), null, tableOp,
302+
TableOperationExceptionType.NOTFOUND, "");
297303
}
298304

299305
final boolean canCloneTable;
300306
try {
301307
canCloneTable =
302-
manager.security.canCloneTable(c, srcTableId, tableName, namespaceId, namespaceId);
308+
manager.security.canCloneTable(c, srcTableId, tableName, namespaceId, srcNamespaceId);
303309
} catch (ThriftSecurityException e) {
304310
throwIfTableMissingSecurityException(e, srcTableId, null, TableOperation.CLONE);
305311
throw e;
@@ -336,9 +342,9 @@ public void executeFateOperation(TInfo tinfo, TCredentials c, long opid, FateOpe
336342
goalMessage += " and keep offline.";
337343
}
338344

339-
manager.fate().seedTransaction(
340-
op.toString(), opid, new TraceRepo<>(new CloneTable(c.getPrincipal(), namespaceId,
341-
srcTableId, tableName, propertiesToSet, propertiesToExclude, keepOffline)),
345+
manager.fate().seedTransaction(op.toString(), opid,
346+
new TraceRepo<>(new CloneTable(c.getPrincipal(), srcNamespaceId, srcTableId,
347+
namespaceId, tableName, propertiesToSet, propertiesToExclude, keepOffline)),
342348
autoCleanup, goalMessage);
343349

344350
break;

server/manager/src/main/java/org/apache/accumulo/manager/tableOps/clone/CloneTable.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,17 @@ public class CloneTable extends ManagerRepo {
3434
private static final long serialVersionUID = 1L;
3535
private final CloneInfo cloneInfo;
3636

37-
public CloneTable(String user, NamespaceId namespaceId, TableId srcTableId, String tableName,
38-
Map<String,String> propertiesToSet, Set<String> propertiesToExclude, boolean keepOffline) {
37+
public CloneTable(String user, NamespaceId srcNamespaceId, TableId srcTableId,
38+
NamespaceId namespaceId, String tableName, Map<String,String> propertiesToSet,
39+
Set<String> propertiesToExclude, boolean keepOffline) {
3940
cloneInfo = new CloneInfo();
4041
cloneInfo.user = user;
4142
cloneInfo.srcTableId = srcTableId;
4243
cloneInfo.tableName = tableName;
4344
cloneInfo.propertiesToExclude = propertiesToExclude;
4445
cloneInfo.propertiesToSet = propertiesToSet;
45-
cloneInfo.srcNamespaceId = namespaceId;
46+
cloneInfo.srcNamespaceId = srcNamespaceId;
47+
cloneInfo.namespaceId = namespaceId;
4648
cloneInfo.keepOffline = keepOffline;
4749
}
4850

0 commit comments

Comments
 (0)