You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by iw...@apache.org on 2020/01/08 08:16:56 UTC

[hadoop] branch branch-3.1 updated: HDFS-15077. Fix intermittent failure of TestDFSClientRetries#testLeaseRenewSocketTimeout. (#1797)

This is an automated email from the ASF dual-hosted git repository.

iwasakims pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/branch-3.1 by this push:
     new c5580af  HDFS-15077. Fix intermittent failure of TestDFSClientRetries#testLeaseRenewSocketTimeout. (#1797)
c5580af is described below

commit c5580af1c4edf92ded879169449c2840c0c925cb
Author: Masatake Iwasaki <iw...@apache.org>
AuthorDate: Wed Jan 8 16:45:39 2020 +0900

    HDFS-15077. Fix intermittent failure of TestDFSClientRetries#testLeaseRenewSocketTimeout. (#1797)
    
    (cherry picked from commit aba3f6c3e1fbb150ea7ff0411c41ffd3a2796208)
---
 .../apache/hadoop/hdfs/client/impl/LeaseRenewer.java  |  3 ++-
 .../org/apache/hadoop/hdfs/TestDFSClientRetries.java  | 19 ++++++++-----------
 2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/client/impl/LeaseRenewer.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/client/impl/LeaseRenewer.java
index 957c0a9..1b594ea 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/client/impl/LeaseRenewer.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/client/impl/LeaseRenewer.java
@@ -270,8 +270,9 @@ public class LeaseRenewer {
         half: LEASE_RENEWER_SLEEP_DEFAULT;
   }
 
+  @VisibleForTesting
   /** Is the daemon running? */
-  synchronized boolean isRunning() {
+  public synchronized boolean isRunning() {
     return daemon != null && daemon.isAlive();
   }
 
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientRetries.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientRetries.java
index 880e3df..14a4732 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientRetries.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientRetries.java
@@ -394,13 +394,14 @@ public class TestDFSClientRetries {
           Mockito.anyString());
       DFSClient client = new DFSClient(null, spyNN, conf, null);
       // Get hold of the lease renewer instance used by the client
-      LeaseRenewer leaseRenewer = client.getLeaseRenewer();
-      leaseRenewer.setRenewalTime(100);
+      final LeaseRenewer leaseRenewer1 = client.getLeaseRenewer();
+      leaseRenewer1.setRenewalTime(100);
       OutputStream out1 = client.create(file1, false);
 
       Mockito.verify(spyNN, timeout(10000).times(1)).renewLease(
           Mockito.anyString());
-      verifyEmptyLease(leaseRenewer);
+      verifyEmptyLease(leaseRenewer1);
+      GenericTestUtils.waitFor(() -> !(leaseRenewer1.isRunning()), 100, 10000);
       try {
         out1.write(new byte[256]);
         fail("existing output stream should be aborted");
@@ -413,14 +414,14 @@ public class TestDFSClientRetries {
       // throws SocketTimeoutException.
       Mockito.doNothing().when(spyNN).renewLease(
           Mockito.anyString());
-      leaseRenewer = client.getLeaseRenewer();
-      leaseRenewer.setRenewalTime(100);
+      final LeaseRenewer leaseRenewer2 = client.getLeaseRenewer();
+      leaseRenewer2.setRenewalTime(100);
       OutputStream out2 = client.create(file2, false);
       Mockito.verify(spyNN, timeout(10000).times(2)).renewLease(
           Mockito.anyString());
       out2.write(new byte[256]);
       out2.close();
-      verifyEmptyLease(leaseRenewer);
+      verifyEmptyLease(leaseRenewer2);
     } finally {
       cluster.shutdown();
     }
@@ -765,11 +766,7 @@ public class TestDFSClientRetries {
   }
 
   private void verifyEmptyLease(LeaseRenewer leaseRenewer) throws Exception {
-    int sleepCount = 0;
-    while (!leaseRenewer.isEmpty() && sleepCount++ < 20) {
-      Thread.sleep(500);
-    }
-    assertTrue("Lease should be empty.", leaseRenewer.isEmpty());
+    GenericTestUtils.waitFor(() -> leaseRenewer.isEmpty(), 100, 10000);
   }
 
   class DFSClientReader implements Runnable {


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