szetszwo commented on code in PR #9661:
URL: https://github.com/apache/ozone/pull/9661#discussion_r2722321750


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/ha/OMProxyInfo.java:
##########
@@ -57,27 +74,109 @@ public OMProxyInfo(T proxy, String serviceID, String 
nodeID, String rpcAddress,
     }
   }
 
-  public OMProxyInfo(String serviceID, String nodeID, String rpcAddress) {
-    this(null, serviceID, nodeID, rpcAddress, "nodeId=" + nodeID + 
",nodeAddress=" + rpcAddress);
-  }
-
   public String getNodeId() {
     return nodeId;
   }
 
-  public String getRpcAddrStr() {
+  public String getAddressString() {
     return rpcAddrStr;
   }
 
-  public InetSocketAddress getRpcAddr() {
-    return rpcAddr;
-  }
-
   public InetSocketAddress getAddress() {
     return rpcAddr;
   }
 
   public Text getDelegationTokenService() {
     return dtService;
   }
+
+  public synchronized T getProxy() {
+    return proxy;
+  }
+
+  public synchronized void 
createProxyIfNeeded(CheckedFunction<InetSocketAddress, T, IOException> 
createProxy) {
+    if (proxy == null) {
+      try {
+        proxy = createProxy.apply(getAddress());
+      } catch (IOException ioe) {
+        throw new IllegalStateException("Failed to create OM proxy for " + 
this, ioe);
+      }
+    }
+  }
+
+  /**
+   * An {@link OMProxyInfo} map,
+   * where the underlying collections are unmodifiable.
+   */
+  public static class Map<P> {
+    /** A list of proxies in a particular order. */
+    private final List<OMProxyInfo<P>> proxies;
+    /**
+     * The ordering of the nodes.
+     * <p>
+     * Invariant 1: Given a nodeId, let Integer i = ordering.get(nodeId);
+     *              If i != null, then nodeId.equals(info.getNodeId()) == 
true, where info = proxies.get(i).
+     *              Otherwise, i == null, then nodeId.equals(info.getNodeId()) 
== false for any info in proxies.
+     * <p>
+     * Invariant 2: Given 0 <= i < proxies.size(), let nodeId = 
proxies.get(i).getNodeId().
+     *              Then, ordering.get(nodeId) == i.
+     */
+    private final SortedMap<String, Integer> ordering;

Review Comment:
   I originally use SortedMap for printing the ids in alphabetical order.  It 
actually is a bug since it should use the original ordering for getNodeIds().  
Will fix it.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to