hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rohithsharm...@apache.org
Subject hadoop git commit: YARN-5005. TestRMWebServices#testDumpingSchedulerLogs fails randomly. Contributed by Bibin A Chundatt.
Date Fri, 27 May 2016 05:19:29 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 59335b4d7 -> ef3e0c6fd


YARN-5005. TestRMWebServices#testDumpingSchedulerLogs fails randomly. Contributed by Bibin
A Chundatt.

(cherry picked from commit 0a544f8a3e52f3467003a731d77380f56343d322)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/ef3e0c6f
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/ef3e0c6f
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/ef3e0c6f

Branch: refs/heads/branch-2
Commit: ef3e0c6fd6b62cae01a2aee95b5c52ab472e739d
Parents: 59335b4
Author: Rohith Sharma K S <rohithsharmaks@apache.org>
Authored: Fri May 27 10:44:35 2016 +0530
Committer: Rohith Sharma K S <rohithsharmaks@apache.org>
Committed: Fri May 27 10:48:47 2016 +0530

----------------------------------------------------------------------
 .../apache/hadoop/yarn/util/AdHocLogDumper.java    |  9 ++++++++-
 .../resourcemanager/webapp/TestRMWebServices.java  | 17 +++++++++++++++--
 2 files changed, 23 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/ef3e0c6f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/AdHocLogDumper.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/AdHocLogDumper.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/AdHocLogDumper.java
index d2e4c74..f33ddcd 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/AdHocLogDumper.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/AdHocLogDumper.java
@@ -26,6 +26,8 @@ import org.apache.hadoop.classification.InterfaceStability;
 import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
 import org.apache.log4j.*;
 
+import com.google.common.annotations.VisibleForTesting;
+
 import java.io.File;
 import java.io.IOException;
 import java.util.*;
@@ -41,7 +43,7 @@ public class AdHocLogDumper {
   private Map<String, Priority> appenderLevels;
   private Level currentLogLevel;
   public static final String AD_HOC_DUMPER_APPENDER = "ad-hoc-dumper-appender";
-  private static boolean logFlag = false;
+  private static volatile boolean logFlag = false;
   private static final Object lock = new Object();
 
   public AdHocLogDumper(String name, String targetFilename) {
@@ -107,6 +109,11 @@ public class AdHocLogDumper {
     }
   }
 
+  @VisibleForTesting
+  public static boolean getState() {
+    return logFlag;
+  }
+
   class RestoreLogLevel extends TimerTask {
     @Override
     public void run() {

http://git-wip-us.apache.org/repos/asf/hadoop/blob/ef3e0c6f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServices.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServices.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServices.java
index c329629..50a4849 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServices.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServices.java
@@ -41,7 +41,9 @@ import javax.xml.parsers.DocumentBuilderFactory;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.io.TwoDArrayWritable;
 import org.apache.hadoop.service.Service.STATE;
+import org.apache.hadoop.test.GenericTestUtils.SleepAnswer;
 import org.apache.hadoop.util.VersionInfo;
 import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest;
 import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsResponse;
@@ -62,6 +64,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairSchedule
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppsInfo;
 import org.apache.hadoop.yarn.server.security.ApplicationACLsManager;
+import org.apache.hadoop.yarn.util.AdHocLogDumper;
 import org.apache.hadoop.yarn.util.YarnVersionInfo;
 import org.apache.hadoop.yarn.webapp.ForbiddenException;
 import org.apache.hadoop.yarn.webapp.GenericExceptionHandler;
@@ -671,7 +674,7 @@ public class TestRMWebServices extends JerseyTestBase {
 
     // nothing should happen
     webSvc.dumpSchedulerLogs("1", mockHsr);
-    Thread.sleep(1000);
+    waitforLogDump(50);
     checkSchedulerLogFileAndCleanup();
 
     conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
@@ -709,7 +712,7 @@ public class TestRMWebServices extends JerseyTestBase {
       }
     });
     webSvc.dumpSchedulerLogs("1", mockHsr);
-    Thread.sleep(1000);
+    waitforLogDump(50);
     checkSchedulerLogFileAndCleanup();
   }
 
@@ -727,4 +730,14 @@ public class TestRMWebServices extends JerseyTestBase {
     assertTrue("scheduler log file doesn't exist", logFile.exists());
     FileUtils.deleteQuietly(logFile);
   }
+
+  private void waitforLogDump(int tickcount) throws InterruptedException {
+    while (tickcount > 0) {
+      Thread.sleep(100);
+      if (!AdHocLogDumper.getState()) {
+        return;
+      }
+      tickcount--;
+    }
+  }
 }


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


Mime
View raw message