YARN-8215. ATS v2 returns invalid YARN_CONTAINER_ALLOCATED_HOST_HTTP_ADDRESS from NM. Contributed by Rohith Sharma K S.
This commit is contained in:
parent
1634de0fc1
commit
7fc09c4f72
|
@ -23,6 +23,8 @@ import java.security.PrivilegedExceptionAction;
|
||||||
import java.util.HashMap;
|
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.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -80,6 +82,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;
|
||||||
|
|
||||||
|
@ -101,6 +104,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,6 +119,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
|
||||||
|
@ -331,11 +341,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);
|
||||||
|
|
|
@ -53,7 +53,6 @@ public class TestNMTimelinePublisher {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final DummyTimelineClient timelineClient = new DummyTimelineClient(null);
|
final DummyTimelineClient timelineClient = new DummyTimelineClient(null);
|
||||||
when(context.getNodeId()).thenReturn(NodeId.newInstance("localhost", 0));
|
when(context.getNodeId()).thenReturn(NodeId.newInstance("localhost", 0));
|
||||||
when(context.getHttpPort()).thenReturn(0);
|
|
||||||
|
|
||||||
Configuration conf = new Configuration();
|
Configuration conf = new Configuration();
|
||||||
conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
|
conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
|
||||||
|
|
Loading…
Reference in New Issue