charlesconnell commented on code in PR #7215:
URL: https://github.com/apache/hadoop/pull/7215#discussion_r1880703678


##########
hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/client/impl/LeaseRenewer.java:
##########
@@ -378,17 +372,42 @@ public synchronized void closeClient(final DFSClient 
dfsc) {
       }
     }
 
-    //update renewal time
-    if (renewal == dfsc.getConf().getHdfsTimeout()/2) {
-      long min = HdfsConstants.LEASE_SOFTLIMIT_PERIOD;
-      for(DFSClient c : dfsclients) {
-        final int timeout = c.getConf().getHdfsTimeout();
-        if (timeout > 0 && timeout < min) {
-          min = timeout;
+    renewal = getNewRenewalIntervalMs(dfsclients);
+  }
+
+  @VisibleForTesting
+  static long getNewRenewalIntervalMs(Collection<DFSClient> dfsClients) {
+    // Update renewal time to the first applicable of:
+    //   1. Requested renewal time amongst all DFSClients, if requested and 
smaller than the default
+    //      renewal interval
+    //   2. Half the HDFS timeout amongst all DFSClients, if requested and 
smaller than the default
+    //      renewal interval
+    //   3. Default renewal time of HdfsConstants.LEASE_SOFTLIMIT_PERIOD / 2
+    // #2 exists because users with small timeouts want to find out quickly 
when a NameNode dies,
+    // and a small lease renewal interval will help to inform them quickly. 
See HDFS-278.
+    long min = HdfsConstants.LEASE_SOFTLIMIT_PERIOD / 2;
+    boolean leaseOverrideSet = false;
+    for (DFSClient c : dfsClients) {
+      final int newLeaseRenewalInterval = 
c.getConf().getLeaseRenewalIntervalMs();
+      if (newLeaseRenewalInterval > 0 && newLeaseRenewalInterval <= min) {
+        min = newLeaseRenewalInterval;
+        leaseOverrideSet = true;
+      }
+    }
+    if (leaseOverrideSet) {
+      return min;
+    }
+
+    for (DFSClient c : dfsClients) {

Review Comment:
   Yes, but I think it would make the code more complicated. The logic I want 
is that the lowest valid value from `getLeaseRenewalIntervalMs()` takes 
precedence over any value from `getHdfsTimeout()`. So, doing that in one loop 
would require tracking two `min`s.



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