YARN-5271. ATS client doesn't work with Jersey 2 on the classpath. Contributed by Weiwei Yang.
This commit is contained in:
parent
140b9939da
commit
09520cb439
@ -167,11 +167,24 @@ protected void serviceInit(Configuration conf) throws Exception {
|
|||||||
|
|
||||||
if (conf.getBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED,
|
if (conf.getBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED,
|
||||||
YarnConfiguration.DEFAULT_TIMELINE_SERVICE_ENABLED)) {
|
YarnConfiguration.DEFAULT_TIMELINE_SERVICE_ENABLED)) {
|
||||||
timelineServiceEnabled = true;
|
try {
|
||||||
timelineClient = createTimelineClient();
|
timelineServiceEnabled = true;
|
||||||
timelineClient.init(conf);
|
timelineClient = createTimelineClient();
|
||||||
timelineDTRenewer = getTimelineDelegationTokenRenewer(conf);
|
timelineClient.init(conf);
|
||||||
timelineService = TimelineUtils.buildTimelineTokenService(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
|
// The AHSClientService is enabled by default when we start the
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package org.apache.hadoop.yarn.client.api.impl;
|
package org.apache.hadoop.yarn.client.api.impl;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
@ -155,6 +156,26 @@ public void testClientStop() {
|
|||||||
rm.stop();
|
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")
|
@SuppressWarnings("deprecation")
|
||||||
@Test (timeout = 30000)
|
@Test (timeout = 30000)
|
||||||
public void testSubmitApplication() throws Exception {
|
public void testSubmitApplication() throws Exception {
|
||||||
|
Loading…
Reference in New Issue
Block a user