YARN-9732. yarn.system-metrics-publisher.enabled=false is not honored by RM. Contributed by KWON BYUNGCHANG.
This commit is contained in:
parent
189dc10884
commit
a79564fed0
|
@ -575,11 +575,13 @@ public class ResourceManager extends CompositeService
|
|||
protected SystemMetricsPublisher createSystemMetricsPublisher() {
|
||||
List<SystemMetricsPublisher> publishers =
|
||||
new ArrayList<SystemMetricsPublisher>();
|
||||
if (YarnConfiguration.timelineServiceV1Enabled(conf)) {
|
||||
if (YarnConfiguration.timelineServiceV1Enabled(conf) &&
|
||||
YarnConfiguration.systemMetricsPublisherEnabled(conf)) {
|
||||
SystemMetricsPublisher publisherV1 = new TimelineServiceV1Publisher();
|
||||
publishers.add(publisherV1);
|
||||
}
|
||||
if (YarnConfiguration.timelineServiceV2Enabled(conf)) {
|
||||
if (YarnConfiguration.timelineServiceV2Enabled(conf) &&
|
||||
YarnConfiguration.systemMetricsPublisherEnabled(conf)) {
|
||||
// we're dealing with the v.2.x publisher
|
||||
LOG.info("system metrics publisher with the timeline service V2 is "
|
||||
+ "configured");
|
||||
|
|
|
@ -38,10 +38,14 @@ import org.junit.Test;
|
|||
public class TestRMTimelineService {
|
||||
private static MockRM rm;
|
||||
|
||||
private void setup(boolean v1Enabled, boolean v2Enabled) {
|
||||
private void setup(boolean v1Enabled, boolean v2Enabled,
|
||||
boolean systemMetricEnabled) {
|
||||
Configuration conf = new YarnConfiguration(new Configuration(false));
|
||||
Assert.assertFalse(YarnConfiguration.timelineServiceEnabled(conf));
|
||||
|
||||
conf.setBoolean(YarnConfiguration.SYSTEM_METRICS_PUBLISHER_ENABLED,
|
||||
systemMetricEnabled);
|
||||
|
||||
if (v1Enabled || v2Enabled) {
|
||||
conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
|
||||
}
|
||||
|
@ -69,7 +73,8 @@ public class TestRMTimelineService {
|
|||
}
|
||||
|
||||
// validate RM services exist or not as we specified
|
||||
private void validate(boolean v1Enabled, boolean v2Enabled) {
|
||||
private void validate(boolean v1Enabled, boolean v2Enabled,
|
||||
boolean systemMetricEnabled) {
|
||||
boolean v1PublisherServiceFound = false;
|
||||
boolean v2PublisherServiceFound = false;
|
||||
List<Service> services = rm.getServices();
|
||||
|
@ -81,8 +86,13 @@ public class TestRMTimelineService {
|
|||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(v1Enabled, v1PublisherServiceFound);
|
||||
Assert.assertEquals(v2Enabled, v2PublisherServiceFound);
|
||||
if(systemMetricEnabled) {
|
||||
Assert.assertEquals(v1Enabled, v1PublisherServiceFound);
|
||||
Assert.assertEquals(v2Enabled, v2PublisherServiceFound);
|
||||
} else {
|
||||
Assert.assertEquals(false, v1PublisherServiceFound);
|
||||
Assert.assertEquals(false, v2PublisherServiceFound);
|
||||
}
|
||||
}
|
||||
|
||||
private void cleanup() throws Exception {
|
||||
|
@ -92,31 +102,58 @@ public class TestRMTimelineService {
|
|||
|
||||
// runs test to validate RM creates a timeline service publisher if and
|
||||
// only if the service is enabled for v1 and v2 (independently).
|
||||
private void runTest(boolean v1Enabled, boolean v2Enabled) throws Exception {
|
||||
setup(v1Enabled, v2Enabled);
|
||||
validate(v1Enabled, v2Enabled);
|
||||
private void runTest(boolean v1Enabled, boolean v2Enabled,
|
||||
boolean systemMetricEnabled) throws Exception {
|
||||
setup(v1Enabled, v2Enabled, systemMetricEnabled);
|
||||
validate(v1Enabled, v2Enabled, systemMetricEnabled);
|
||||
cleanup();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTimelineServiceV1V2Enabled() throws Exception {
|
||||
runTest(true, true);
|
||||
runTest(true, true, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTimelineServiceV1Enabled() throws Exception {
|
||||
runTest(true, false);
|
||||
runTest(true, false, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTimelineServiceV2Enabled() throws Exception {
|
||||
runTest(false, true);
|
||||
runTest(false, true, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTimelineServiceDisabled() throws Exception {
|
||||
runTest(false, false);
|
||||
runTest(false, false, true);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testTimelineServiceV1V2EnabledSystemMetricDisable()
|
||||
throws Exception {
|
||||
runTest(true, true, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTimelineServiceV1EnabledSystemMetricDisable()
|
||||
throws Exception {
|
||||
runTest(true, false, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTimelineServiceV2EnabledSystemMetricDisable()
|
||||
throws Exception {
|
||||
runTest(false, true, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTimelineServiceDisabledSystemMetricDisable()
|
||||
throws Exception {
|
||||
runTest(false, false, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue