bharatviswa504 commented on a change in pull request #2141:
URL: https://github.com/apache/ozone/pull/2141#discussion_r618322387
##########
File path:
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/proxy/SCMSecurityProtocolFailoverProxyProvider.java
##########
@@ -173,14 +174,49 @@ private SCMSecurityProtocolPB
createSCMProxy(InetSocketAddress scmAddress)
@Override
- public void performFailover(SCMSecurityProtocolPB currentProxy) {
+ public synchronized void performFailover(SCMSecurityProtocolPB currentProxy)
{
if (LOG.isDebugEnabled()) {
int currentIndex = getCurrentProxyIndex();
LOG.debug("Failing over SCM Security proxy to index: {}, nodeId: {}",
currentIndex, scmNodeIds.get(currentIndex));
}
}
+ public void performFailoverToAssignedLeader(String newLeader, Exception e) {
+ ServerNotLeaderException snle =
+ (ServerNotLeaderException) SCMHAUtils.getServerNotLeaderException(e);
+ if (snle != null && snle.getSuggestedLeader() != null) {
+ newLeader = scmProxyInfoMap.values().stream().filter(
+ proxyInfo -> NetUtils.getHostPortString(proxyInfo.getAddress())
+
.equals(snle.getSuggestedLeader())).findFirst().get().getNodeId();
+ LOG.debug("Performing failover to suggested leader {}, nodeId {}",
+ snle.getSuggestedLeader(), newLeader);
+ }
+ if (newLeader == null) {
+ // If newLeader is not assigned, it will fail over to next proxy.
+ performFailoverToNextProxy();
+ LOG.debug("Performing failover to next proxy node {}",
+ currentProxySCMNodeId);
+ } else {
+ if (!assignLeaderToNode(newLeader)) {
+ LOG.debug("Failing over SCM proxy to nodeId: {}", newLeader);
+ performFailoverToNextProxy();
+ }
+ }
+ }
+
+ private boolean assignLeaderToNode(String newLeaderNodeId) {
Review comment:
Should we synchronize this?
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]