DomGarguilo commented on code in PR #5421:
URL: https://github.com/apache/accumulo/pull/5421#discussion_r2006107294
##########
core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java:
##########
@@ -1088,9 +1091,32 @@ public NamespaceMapping getNamespaces() {
return namespaces;
}
- public HashMap<TableId,ClientTabletCache> tabletCaches() {
+ public ClientTabletCache getTabletLocationCache(TableId tableId) {
ensureOpen();
- return tabletCaches;
+ synchronized (tabletLocationCache) {
+ return tabletLocationCache.computeIfAbsent(tableId, (TableId key) -> {
+ var mlo = new MetadataCachedTabletObtainer();
+ var lockChecker = getTServerLockChecker();
+ if (AccumuloTable.ROOT.tableId().equals(tableId)) {
+ return new RootClientTabletCache(lockChecker);
+ } else if (AccumuloTable.METADATA.tableId().equals(tableId)) {
+ return new ClientTabletCacheImpl(AccumuloTable.METADATA.tableId(),
+ getTabletLocationCache(AccumuloTable.ROOT.tableId()), mlo,
lockChecker);
+ } else {
+ return new ClientTabletCacheImpl(tableId,
+ getTabletLocationCache(AccumuloTable.METADATA.tableId()), mlo,
lockChecker);
+ }
Review Comment:
`MetadataCachedTabletObtainer` doesn't look particularly expensive to create
but its creation could be delayed until its needed here. Maybe something
similar to this:
```suggestion
var lockChecker = getTServerLockChecker();
if (AccumuloTable.ROOT.tableId().equals(tableId)) {
return new RootClientTabletCache(lockChecker);
}
var mlo = new MetadataCachedTabletObtainer();
if (AccumuloTable.METADATA.tableId().equals(tableId)) {
return new ClientTabletCacheImpl(AccumuloTable.METADATA.tableId(),
getTabletLocationCache(AccumuloTable.ROOT.tableId()), mlo,
lockChecker);
} else {
return new ClientTabletCacheImpl(tableId,
getTabletLocationCache(AccumuloTable.METADATA.tableId()), mlo,
lockChecker);
}
```
--
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]