ctubbsii commented on code in PR #5451:
URL: https://github.com/apache/accumulo/pull/5451#discussion_r2049519414
##########
core/src/main/java/org/apache/accumulo/core/util/tables/TableZooHelper.java:
##########
@@ -62,82 +55,81 @@ public TableZooHelper(ClientContext context) {
* getCause() of NamespaceNotFoundException
*/
public TableId getTableId(String tableName) throws TableNotFoundException {
- for (AccumuloTable systemTable : AccumuloTable.values()) {
- if (systemTable.tableName().equals(tableName)) {
- return systemTable.tableId();
- }
+ Pair<String,String> qualified = TableNameUtil.qualify(tableName);
+ NamespaceId nid =
context.getNamespaces().getNameToIdMap().get(qualified.getFirst());
+ if (nid == null) {
+ throw new TableNotFoundException(tableName, new
NamespaceNotFoundException(null,
+ qualified.getFirst(), "No mapping found for namespace"));
}
- try {
- return
_getTableIdDetectNamespaceNotFound(EXISTING_TABLE_NAME.validate(tableName));
- } catch (NamespaceNotFoundException e) {
- throw new TableNotFoundException(tableName, e);
+ TableId tid =
context.getTableMapping(nid).getNameToIdMap().get(qualified.getSecond());
Review Comment:
> When the namespace does not exists will this code still throw a
TableNotFoundException?
Specifically, it will throw a TableNotFoundException with a cause of
NamespaceNotFoundException, except in the case where the mapping node was
somehow deleted (or possibly, hasn't yet been created) after the namespace was
looked up. In that case, though, you'll get a simple TableNotFoundException
without the cause of NamespaceNotFoundException (because the namespace did
exist at the start of the operation, and this is a hard edge case to handle, so
you get the same error, but not as much info as to the cause).
--
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]