|
@@ -136,7 +136,7 @@ public class YarnClientImpl extends YarnClient {
|
|
|
private long asyncApiPollTimeoutMillis;
|
|
|
protected AHSClient historyClient;
|
|
|
private boolean historyServiceEnabled;
|
|
|
- protected TimelineClient timelineClient;
|
|
|
+ protected volatile TimelineClient timelineClient;
|
|
|
@VisibleForTesting
|
|
|
Text timelineService;
|
|
|
@VisibleForTesting
|
|
@@ -169,24 +169,9 @@ public class YarnClientImpl extends YarnClient {
|
|
|
|
|
|
if (conf.getBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED,
|
|
|
YarnConfiguration.DEFAULT_TIMELINE_SERVICE_ENABLED)) {
|
|
|
- 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;
|
|
|
- }
|
|
|
+ timelineServiceEnabled = true;
|
|
|
+ timelineDTRenewer = getTimelineDelegationTokenRenewer(conf);
|
|
|
+ timelineService = TimelineUtils.buildTimelineTokenService(conf);
|
|
|
}
|
|
|
|
|
|
// The AHSClientService is enabled by default when we start the
|
|
@@ -219,9 +204,6 @@ public class YarnClientImpl extends YarnClient {
|
|
|
if (historyServiceEnabled) {
|
|
|
historyClient.start();
|
|
|
}
|
|
|
- if (timelineServiceEnabled) {
|
|
|
- timelineClient.start();
|
|
|
- }
|
|
|
} catch (IOException e) {
|
|
|
throw new YarnRuntimeException(e);
|
|
|
}
|
|
@@ -236,7 +218,7 @@ public class YarnClientImpl extends YarnClient {
|
|
|
if (historyServiceEnabled) {
|
|
|
historyClient.stop();
|
|
|
}
|
|
|
- if (timelineServiceEnabled) {
|
|
|
+ if (timelineClient != null) {
|
|
|
timelineClient.stop();
|
|
|
}
|
|
|
super.serviceStop();
|
|
@@ -375,16 +357,26 @@ public class YarnClientImpl extends YarnClient {
|
|
|
@VisibleForTesting
|
|
|
org.apache.hadoop.security.token.Token<TimelineDelegationTokenIdentifier>
|
|
|
getTimelineDelegationToken() throws IOException, YarnException {
|
|
|
- try {
|
|
|
- return timelineClient.getDelegationToken(timelineDTRenewer);
|
|
|
- } catch (Exception e ) {
|
|
|
- if (timelineServiceBestEffort) {
|
|
|
- LOG.warn("Failed to get delegation token from the timeline server: "
|
|
|
- + e.getMessage());
|
|
|
- return null;
|
|
|
+ try {
|
|
|
+ // Only reachable when both security and timeline service are enabled.
|
|
|
+ if (timelineClient == null) {
|
|
|
+ synchronized (this) {
|
|
|
+ if (timelineClient == null) {
|
|
|
+ timelineClient = createTimelineClient();
|
|
|
+ timelineClient.init(getConfig());
|
|
|
+ timelineClient.start();
|
|
|
}
|
|
|
- throw e;
|
|
|
}
|
|
|
+ }
|
|
|
+ return timelineClient.getDelegationToken(timelineDTRenewer);
|
|
|
+ } catch (Exception e) {
|
|
|
+ if (timelineServiceBestEffort) {
|
|
|
+ LOG.warn("Failed to get delegation token from the timeline server: "
|
|
|
+ + e.getMessage());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ throw e;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private static String getTimelineDelegationTokenRenewer(Configuration conf)
|