ivandika3 commented on code in PR #7950:
URL: https://github.com/apache/ozone/pull/7950#discussion_r1966541840


##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/proxy/SCMBlockLocationFailoverProxyProvider.java:
##########
@@ -17,283 +17,34 @@
 
 package org.apache.hadoop.hdds.scm.proxy;
 
-import static org.apache.hadoop.ozone.OzoneConsts.SCM_DUMMY_SERVICE_ID;
-
-import com.google.common.annotations.VisibleForTesting;
-import java.io.Closeable;
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hdds.conf.ConfigurationException;
 import org.apache.hadoop.hdds.conf.ConfigurationSource;
-import org.apache.hadoop.hdds.ratis.ServerNotLeaderException;
-import org.apache.hadoop.hdds.scm.ha.SCMHAUtils;
 import org.apache.hadoop.hdds.scm.ha.SCMNodeInfo;
 import org.apache.hadoop.hdds.scm.protocolPB.ScmBlockLocationProtocolPB;
-import org.apache.hadoop.hdds.utils.LegacyHadoopConfigurationSource;
-import org.apache.hadoop.io.retry.FailoverProxyProvider;
-import org.apache.hadoop.io.retry.RetryPolicies;
-import org.apache.hadoop.io.retry.RetryPolicy;
-import org.apache.hadoop.ipc.ProtobufRpcEngine;
-import org.apache.hadoop.ipc.RPC;
-import org.apache.hadoop.net.NetUtils;
-import org.apache.hadoop.security.UserGroupInformation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * Failover proxy provider for SCM block location.
  */
-public class SCMBlockLocationFailoverProxyProvider implements
-    FailoverProxyProvider<ScmBlockLocationProtocolPB>, Closeable {
+public class SCMBlockLocationFailoverProxyProvider extends
+    SCMFailoverProxyProviderBase<ScmBlockLocationProtocolPB> {
   public static final Logger LOG =
       LoggerFactory.getLogger(SCMBlockLocationFailoverProxyProvider.class);
-  private final SCMClientConfig scmClientConfig;
-
-  private final Map<String, ProxyInfo<ScmBlockLocationProtocolPB>> scmProxies;
-  private final Map<String, SCMProxyInfo> scmProxyInfoMap;
-  private List<String> scmNodeIds;
-
-  // As SCM Client is shared across threads, performFailOver()
-  // updates the currentProxySCMNodeId based on the updateLeaderNodeId which is
-  // updated in shouldRetry(). When 2 or more threads run in parallel, the
-  // RetryInvocationHandler will check the expectedFailOverCount
-  // and not execute performFailOver() for one of them. So the other thread(s)
-  // shall not call performFailOver(), it will call getProxy() which uses
-  // currentProxySCMNodeId and returns the proxy.
-  private volatile String currentProxySCMNodeId;
-  private volatile int currentProxyIndex;
-
-  private final ConfigurationSource conf;
-  private final long scmVersion;
-
-  private String scmServiceId;
-
-  private final int maxRetryCount;
-  private final long retryInterval;
-
-  private final UserGroupInformation ugi;
-
-  private String updatedLeaderNodeID = null;
-
 
   public SCMBlockLocationFailoverProxyProvider(ConfigurationSource conf) {
-    this.conf = conf;
-    this.scmVersion = RPC.getProtocolVersion(ScmBlockLocationProtocolPB.class);
-
-    try {
-      this.ugi = UserGroupInformation.getCurrentUser();
-    } catch (IOException ex) {
-      LOG.error("Unable to fetch user credentials from UGI", ex);
-      throw new RuntimeException(ex);
-    }
-
-    // Set some constant for non-HA.
-    if (scmServiceId == null) {
-      scmServiceId = SCM_DUMMY_SERVICE_ID;
-    }
-    this.scmProxies = new HashMap<>();
-    this.scmProxyInfoMap = new HashMap<>();
-
-    loadConfigs();
-
-    this.currentProxyIndex = 0;
-    currentProxySCMNodeId = scmNodeIds.get(currentProxyIndex);
-
-    scmClientConfig = conf.getObject(SCMClientConfig.class);
-    this.maxRetryCount = scmClientConfig.getRetryCount();
-    this.retryInterval = scmClientConfig.getRetryInterval();
-
+    super(ScmBlockLocationProtocolPB.class, conf, null);
     LOG.info("Created block location fail-over proxy with {} nodes: {}",
-        scmNodeIds.size(), scmProxyInfoMap.values());

Review Comment:
   Well spotted. Updated.



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