ctubbsii commented on code in PR #5282:
URL: https://github.com/apache/accumulo/pull/5282#discussion_r2004466111


##########
core/src/main/java/org/apache/accumulo/core/clientImpl/TabletLocator.java:
##########
@@ -81,62 +76,17 @@ public abstract List<Range> binRanges(ClientContext 
context, List<Range> ranges,
    */
   public abstract void invalidateCache(ClientContext context, String server);
 
-  private static class LocatorKey {
-    InstanceId instanceId;
-    TableId tableId;
-
-    LocatorKey(InstanceId instanceId, TableId table) {
-      this.instanceId = instanceId;
-      this.tableId = table;
-    }
-
-    @Override
-    public int hashCode() {
-      return instanceId.hashCode() + tableId.hashCode();
-    }
-
-    @Override
-    public boolean equals(Object o) {
-      if (o instanceof LocatorKey) {
-        return equals((LocatorKey) o);
-      }
-      return false;
-    }
-
-    public boolean equals(LocatorKey lk) {
-      return instanceId.equals(lk.instanceId) && tableId.equals(lk.tableId);
-    }
-
-  }
-
-  private static final HashMap<LocatorKey,TabletLocator> locators = new 
HashMap<>();
-  private static boolean enabled = true;
-
-  public static synchronized void clearLocators() {
+  public static synchronized void clearLocators(ClientContext context) {
+    final var locators = context.tabletLocators();
     for (TabletLocator locator : locators.values()) {
       locator.isValid = false;
     }
     locators.clear();
   }
 
-  static synchronized boolean isEnabled() {
-    return enabled;
-  }
-
-  static synchronized void disable() {
-    clearLocators();
-    enabled = false;
-  }
-
-  static synchronized void enable() {
-    enabled = true;
-  }
-
   public static synchronized TabletLocator getLocator(ClientContext context, 
TableId tableId) {
-    Preconditions.checkState(enabled, "The Accumulo singleton that that tracks 
tablet locations is "
-        + "disabled. This is likely caused by all AccumuloClients being closed 
or garbage collected");
-    LocatorKey key = new LocatorKey(context.getInstanceID(), tableId);
-    TabletLocator tl = locators.get(key);
+    final var locators = context.tabletLocators();

Review Comment:
   I created #5421 based on this comment. I'm not sure if that's what you were 
thinking, but I think it might be "close but not quite". Please take a look and 
comment on that PR.



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