|
@@ -24,6 +24,8 @@ import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
|
|
+import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
|
|
|
|
+
|
|
import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.LogFactory;
|
|
import org.apache.commons.logging.LogFactory;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
@@ -79,6 +81,7 @@ public class NMTimelinePublisher extends CompositeService {
|
|
private NodeId nodeId;
|
|
private NodeId nodeId;
|
|
|
|
|
|
private String httpAddress;
|
|
private String httpAddress;
|
|
|
|
+ private String httpPort;
|
|
|
|
|
|
private UserGroupInformation nmLoginUGI;
|
|
private UserGroupInformation nmLoginUGI;
|
|
|
|
|
|
@@ -100,6 +103,12 @@ public class NMTimelinePublisher extends CompositeService {
|
|
UserGroupInformation.getLoginUser() :
|
|
UserGroupInformation.getLoginUser() :
|
|
UserGroupInformation.getCurrentUser();
|
|
UserGroupInformation.getCurrentUser();
|
|
LOG.info("Initialized NMTimelinePublisher UGI to " + nmLoginUGI);
|
|
LOG.info("Initialized NMTimelinePublisher UGI to " + nmLoginUGI);
|
|
|
|
+
|
|
|
|
+ String webAppURLWithoutScheme =
|
|
|
|
+ WebAppUtils.getNMWebAppURLWithoutScheme(conf);
|
|
|
|
+ if (webAppURLWithoutScheme.contains(":")) {
|
|
|
|
+ httpPort = webAppURLWithoutScheme.split(":")[1];
|
|
|
|
+ }
|
|
super.serviceInit(conf);
|
|
super.serviceInit(conf);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -109,6 +118,7 @@ public class NMTimelinePublisher extends CompositeService {
|
|
// context will be updated after containerManagerImpl is started
|
|
// context will be updated after containerManagerImpl is started
|
|
// hence NMMetricsPublisher is added subservice of containerManagerImpl
|
|
// hence NMMetricsPublisher is added subservice of containerManagerImpl
|
|
this.nodeId = context.getNodeId();
|
|
this.nodeId = context.getNodeId();
|
|
|
|
+ this.httpAddress = nodeId.getHost() + ":" + httpPort;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -330,11 +340,6 @@ public class NMTimelinePublisher extends CompositeService {
|
|
|
|
|
|
public void publishContainerEvent(ContainerEvent event) {
|
|
public void publishContainerEvent(ContainerEvent event) {
|
|
// publish only when the desired event is received
|
|
// publish only when the desired event is received
|
|
- if (this.httpAddress == null) {
|
|
|
|
- // update httpAddress for first time. When this service started,
|
|
|
|
- // web server will not be started.
|
|
|
|
- this.httpAddress = nodeId.getHost() + ":" + context.getHttpPort();
|
|
|
|
- }
|
|
|
|
switch (event.getType()) {
|
|
switch (event.getType()) {
|
|
case INIT_CONTAINER:
|
|
case INIT_CONTAINER:
|
|
publishContainerCreatedEvent(event);
|
|
publishContainerCreatedEvent(event);
|