You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-dev@hadoop.apache.org by GitBox <gi...@apache.org> on 2019/10/31 04:18:21 UTC

[GitHub] [hadoop-ozone] dineshchitlangia commented on a change in pull request #51: HDDS-2311. Fix logic of RetryPolicy in OzoneClientSideTranslatorPB.

dineshchitlangia commented on a change in pull request #51: HDDS-2311. Fix logic of RetryPolicy in OzoneClientSideTranslatorPB.
URL: https://github.com/apache/hadoop-ozone/pull/51#discussion_r340954497
 
 

 ##########
 File path: hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/ha/OMFailoverProxyProvider.java
 ##########
 @@ -243,14 +245,36 @@ public void performFailoverIfRequired(String newLeaderOMNodeId) {
     if (newLeaderOMNodeId == null) {
       LOG.debug("No suggested leader nodeId. Performing failover to next peer" +
           " node");
-      performFailover(null);
+      performFailoverToNextProxy();
     } else {
       if (updateLeaderOMNodeId(newLeaderOMNodeId)) {
         LOG.debug("Failing over OM proxy to nodeId: {}", newLeaderOMNodeId);
       }
     }
   }
 
+  /**
+   * Performs failover if the leaderOMNodeId returned through OMReponse does
+   * not match the current leaderOMNodeId cached by the proxy provider.
+   */
+  public void performFailoverToNextProxy() {
+    int newProxyIndex = incrementProxyIndex();
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("Incrementing OM proxy index to {}, nodeId: {}",
+          newProxyIndex, omNodeIDList.get(newProxyIndex));
+    }
+  }
+
+  /**
+   * Update the proxy index to the next proxy in the list.
+   * @return the new proxy index
+   */
+  private synchronized int incrementProxyIndex() {
+    currentProxyIndex = (currentProxyIndex + 1) % omProxies.size();
+    currentProxyOMNodeId = omNodeIDList.get(currentProxyIndex);
+    return currentProxyIndex;
+  }
+
   /**
 
 Review comment:
   Findbugs Issue:
   
   In class org.apache.hadoop.ozone.om.ha.OMFailoverProxyProvider
   Field org.apache.hadoop.ozone.om.ha.OMFailoverProxyProvider.currentProxyIndex
   Synchronized 71% of the time
   Unsynchronized access at OMFailoverProxyProvider.java:[line 235]
   Unsynchronized access at OMFailoverProxyProvider.java:[line 236]
   Synchronized access at OMFailoverProxyProvider.java:[line 273]
   Synchronized access at OMFailoverProxyProvider.java:[line 273]
   Synchronized access at OMFailoverProxyProvider.java:[line 274]
   Synchronized access at OMFailoverProxyProvider.java:[line 275]
   Synchronized access at OMFailoverProxyProvider.java:[line 287]
   Inconsistent synchronization of org.apache.hadoop.ozone.om.ha.OMFailoverProxyProvider.currentProxyIndex; locked 71% of time
   The fields of this class appear to be accessed inconsistently with respect to synchronization.  This bug report indicates that the bug pattern detector judged that
   
   The class contains a mix of locked and unlocked accesses,
   The class is not annotated as javax.annotation.concurrent.NotThreadSafe,
   At least one locked access was performed by one of the class's own methods, and
   The number of unsynchronized field accesses (reads and writes) was no more than one third of all accesses, with writes being weighed twice as high as reads
   A typical bug matching this bug pattern is forgetting to synchronize one of the methods in a class that is intended to be thread-safe.
   
   You can select the nodes labeled "Unsynchronized access" to show the code locations where the detector believed that a field was accessed without synchronization.
   
   Note that there are various sources of inaccuracy in this detector; for example, the detector cannot statically detect all situations in which a lock is held.  Also, even when the detector is accurate in distinguishing locked vs. unlocked accesses, the code in question may still be correct.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-dev-unsubscribe@hadoop.apache.org
For additional commands, e-mail: hdfs-dev-help@hadoop.apache.org