YARN-6149. Allow port range to be specified while starting NM Timeline collector manager. Contributed by Abhishek Modi.
This commit is contained in:
parent
0a6f90d4fc
commit
5345508fa3
|
@ -3808,6 +3808,10 @@ public class YarnConfiguration extends Configuration {
|
||||||
public static final String TIMELINE_SERVICE_COLLECTOR_BIND_HOST =
|
public static final String TIMELINE_SERVICE_COLLECTOR_BIND_HOST =
|
||||||
TIMELINE_SERVICE_COLLECTOR_PREFIX + "bind-host";
|
TIMELINE_SERVICE_COLLECTOR_PREFIX + "bind-host";
|
||||||
|
|
||||||
|
@Private
|
||||||
|
public static final String TIMELINE_SERVICE_COLLECTOR_BIND_PORT_RANGES =
|
||||||
|
TIMELINE_SERVICE_COLLECTOR_PREFIX + "bind-port-ranges";
|
||||||
|
|
||||||
@Private
|
@Private
|
||||||
public static final String TIMELINE_SERVICE_COLLECTOR_WEBAPP_ADDRESS =
|
public static final String TIMELINE_SERVICE_COLLECTOR_WEBAPP_ADDRESS =
|
||||||
TIMELINE_SERVICE_COLLECTOR_PREFIX + "webapp.address";
|
TIMELINE_SERVICE_COLLECTOR_PREFIX + "webapp.address";
|
||||||
|
|
|
@ -58,6 +58,7 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class on the NodeManager side that manages adding and removing collectors and
|
* Class on the NodeManager side that manages adding and removing collectors and
|
||||||
* their lifecycle. Also instantiates the per-node collector webapp.
|
* their lifecycle. Also instantiates the per-node collector webapp.
|
||||||
|
@ -280,14 +281,21 @@ public class NodeTimelineCollectorManager extends TimelineCollectorManager {
|
||||||
String bindAddress = null;
|
String bindAddress = null;
|
||||||
String host =
|
String host =
|
||||||
conf.getTrimmed(YarnConfiguration.TIMELINE_SERVICE_COLLECTOR_BIND_HOST);
|
conf.getTrimmed(YarnConfiguration.TIMELINE_SERVICE_COLLECTOR_BIND_HOST);
|
||||||
|
Configuration.IntegerRanges portRanges = conf.getRange(
|
||||||
|
YarnConfiguration.TIMELINE_SERVICE_COLLECTOR_BIND_PORT_RANGES, "");
|
||||||
|
int startPort = 0;
|
||||||
|
if (portRanges != null && !portRanges.isEmpty()) {
|
||||||
|
startPort = portRanges.getRangeStart();
|
||||||
|
}
|
||||||
if (host == null || host.isEmpty()) {
|
if (host == null || host.isEmpty()) {
|
||||||
// if collector bind-host is not set, fall back to
|
// if collector bind-host is not set, fall back to
|
||||||
// timeline-service.bind-host to maintain compatibility
|
// timeline-service.bind-host to maintain compatibility
|
||||||
bindAddress =
|
bindAddress =
|
||||||
conf.get(YarnConfiguration.DEFAULT_TIMELINE_SERVICE_BIND_HOST,
|
conf.get(YarnConfiguration.DEFAULT_TIMELINE_SERVICE_BIND_HOST,
|
||||||
YarnConfiguration.DEFAULT_TIMELINE_SERVICE_BIND_HOST) + ":0";
|
YarnConfiguration.DEFAULT_TIMELINE_SERVICE_BIND_HOST)
|
||||||
|
+ ":" + startPort;
|
||||||
} else {
|
} else {
|
||||||
bindAddress = host + ":0";
|
bindAddress = host + ":" + startPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -297,6 +305,9 @@ public class NodeTimelineCollectorManager extends TimelineCollectorManager {
|
||||||
.addEndpoint(URI.create(
|
.addEndpoint(URI.create(
|
||||||
(YarnConfiguration.useHttps(conf) ? "https://" : "http://") +
|
(YarnConfiguration.useHttps(conf) ? "https://" : "http://") +
|
||||||
bindAddress));
|
bindAddress));
|
||||||
|
if (portRanges != null && !portRanges.isEmpty()) {
|
||||||
|
builder.setPortRanges(portRanges);
|
||||||
|
}
|
||||||
if (YarnConfiguration.useHttps(conf)) {
|
if (YarnConfiguration.useHttps(conf)) {
|
||||||
builder = WebAppUtils.loadSslConfiguration(builder, conf);
|
builder = WebAppUtils.loadSslConfiguration(builder, conf);
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,8 @@ public class TestNMTimelineCollectorManager {
|
||||||
Configuration conf = new YarnConfiguration();
|
Configuration conf = new YarnConfiguration();
|
||||||
conf.setClass(YarnConfiguration.TIMELINE_SERVICE_WRITER_CLASS,
|
conf.setClass(YarnConfiguration.TIMELINE_SERVICE_WRITER_CLASS,
|
||||||
FileSystemTimelineWriterImpl.class, TimelineWriter.class);
|
FileSystemTimelineWriterImpl.class, TimelineWriter.class);
|
||||||
|
conf.set(YarnConfiguration.TIMELINE_SERVICE_COLLECTOR_BIND_PORT_RANGES,
|
||||||
|
"30000-30100");
|
||||||
collectorManager.init(conf);
|
collectorManager.init(conf);
|
||||||
collectorManager.start();
|
collectorManager.start();
|
||||||
}
|
}
|
||||||
|
@ -83,7 +85,8 @@ public class TestNMTimelineCollectorManager {
|
||||||
String[] parts = address.split(":");
|
String[] parts = address.split(":");
|
||||||
assertEquals(2, parts.length);
|
assertEquals(2, parts.length);
|
||||||
assertNotNull(parts[0]);
|
assertNotNull(parts[0]);
|
||||||
assertTrue(Integer.valueOf(parts[1]) > 0);
|
assertTrue(Integer.valueOf(parts[1]) >= 30000 &&
|
||||||
|
Integer.valueOf(parts[1]) <= 30100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout=60000)
|
@Test(timeout=60000)
|
||||||
|
@ -153,7 +156,6 @@ public class TestNMTimelineCollectorManager {
|
||||||
private NodeTimelineCollectorManager createCollectorManager() {
|
private NodeTimelineCollectorManager createCollectorManager() {
|
||||||
final NodeTimelineCollectorManager cm =
|
final NodeTimelineCollectorManager cm =
|
||||||
spy(new NodeTimelineCollectorManager());
|
spy(new NodeTimelineCollectorManager());
|
||||||
doReturn(new Configuration()).when(cm).getConfig();
|
|
||||||
CollectorNodemanagerProtocol nmCollectorService =
|
CollectorNodemanagerProtocol nmCollectorService =
|
||||||
mock(CollectorNodemanagerProtocol.class);
|
mock(CollectorNodemanagerProtocol.class);
|
||||||
GetTimelineCollectorContextResponse response =
|
GetTimelineCollectorContextResponse response =
|
||||||
|
|
Loading…
Reference in New Issue