hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lium...@apache.org
Subject [27/50] [abbrv] hadoop git commit: YARN-5271. ATS client doesn't work with Jersey 2 on the classpath. Contributed by Weiwei Yang.
Date Tue, 22 Nov 2016 23:11:21 GMT
YARN-5271. ATS client doesn't work with Jersey 2 on the classpath.  Contributed by Weiwei Yang.


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

Branch: refs/heads/HADOOP-13345
Commit: 09520cb439f8b002e3f2f3d8f5080ffc34f4bd5c
Parents: 140b993
Author: Wei-Chiu Chuang <weichiu@apache.org>
Authored: Thu Nov 17 22:17:23 2016 -0600
Committer: Wei-Chiu Chuang <weichiu@apache.org>
Committed: Thu Nov 17 22:17:23 2016 -0600

----------------------------------------------------------------------
 .../yarn/client/api/impl/YarnClientImpl.java    | 23 +++++++++++++++-----
 .../yarn/client/api/impl/TestYarnClient.java    | 21 ++++++++++++++++++
 2 files changed, 39 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/09520cb4/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/YarnClientImpl.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/YarnClientImpl.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/YarnClientImpl.java
index 57f50c4..f0fce22 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/YarnClientImpl.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/YarnClientImpl.java
@@ -167,11 +167,24 @@ public class YarnClientImpl extends YarnClient {
 
     if (conf.getBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED,
         YarnConfiguration.DEFAULT_TIMELINE_SERVICE_ENABLED)) {
-      timelineServiceEnabled = true;
-      timelineClient = createTimelineClient();
-      timelineClient.init(conf);
-      timelineDTRenewer = getTimelineDelegationTokenRenewer(conf);
-      timelineService = TimelineUtils.buildTimelineTokenService(conf);
+      try {
+        timelineServiceEnabled = true;
+        timelineClient = createTimelineClient();
+        timelineClient.init(conf);
+        timelineDTRenewer = getTimelineDelegationTokenRenewer(conf);
+        timelineService = TimelineUtils.buildTimelineTokenService(conf);
+      } catch (NoClassDefFoundError error) {
+        // When attempt to initiate the timeline client with
+        // different set of dependencies, it may fail with
+        // NoClassDefFoundError. When some of them are not compatible
+        // with timeline server. This is not necessarily a fatal error
+        // to the client.
+        LOG.warn("Timeline client could not be initialized "
+            + "because dependency missing or incompatible,"
+            + " disabling timeline client.",
+            error);
+        timelineServiceEnabled = false;
+      }
     }
 
     // The AHSClientService is enabled by default when we start the

http://git-wip-us.apache.org/repos/asf/hadoop/blob/09520cb4/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java
index 19966ad..e218036 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java
@@ -18,6 +18,7 @@
 
 package org.apache.hadoop.yarn.client.api.impl;
 
+import static org.junit.Assert.assertFalse;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
@@ -155,6 +156,26 @@ public class TestYarnClient {
     rm.stop();
   }
 
+  @Test
+  public void testTimelineClientInitFailure() throws Exception{
+    Configuration conf = new Configuration();
+    conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
+    YarnClient client = YarnClient.createYarnClient();
+    if(client instanceof YarnClientImpl) {
+      YarnClientImpl impl = (YarnClientImpl) client;
+      YarnClientImpl spyClient = spy(impl);
+      when(spyClient.createTimelineClient()).thenThrow(
+          new NoClassDefFoundError(
+              "Mock a failure when init timeline instance"));
+      spyClient.init(conf);
+      spyClient.start();
+      assertFalse("Timeline client should be disabled when"
+          + "it is failed to init",
+          spyClient.timelineServiceEnabled);
+      spyClient.stop();
+    }
+  }
+
   @SuppressWarnings("deprecation")
   @Test (timeout = 30000)
   public void testSubmitApplication() throws Exception {


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