|
@@ -56,6 +56,7 @@ import org.apache.hadoop.yarn.server.metrics.AppAttemptMetricsConstants;
|
|
|
import org.apache.hadoop.yarn.server.metrics.ApplicationMetricsConstants;
|
|
|
import org.apache.hadoop.yarn.server.metrics.ContainerMetricsConstants;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
|
|
|
+import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppImpl;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppMetrics;
|
|
@@ -101,11 +102,12 @@ public class TestSystemMetricsPublisherForV2 {
|
|
|
FileContext.getLocalFSFileContext().delete(
|
|
|
new Path(testRootDir.getAbsolutePath()), true);
|
|
|
}
|
|
|
-
|
|
|
+ ResourceManager rm = mock(ResourceManager.class);
|
|
|
RMContext rmContext = mock(RMContext.class);
|
|
|
rmAppsMapInContext = new ConcurrentHashMap<ApplicationId, RMApp>();
|
|
|
when(rmContext.getRMApps()).thenReturn(rmAppsMapInContext);
|
|
|
- rmTimelineCollectorManager = new RMTimelineCollectorManager(rmContext);
|
|
|
+ when(rm.getRMContext()).thenReturn(rmContext);
|
|
|
+ rmTimelineCollectorManager = new RMTimelineCollectorManager(rm);
|
|
|
when(rmContext.getRMTimelineCollectorManager()).thenReturn(
|
|
|
rmTimelineCollectorManager);
|
|
|
|
|
@@ -117,12 +119,12 @@ public class TestSystemMetricsPublisherForV2 {
|
|
|
|
|
|
dispatcher.init(conf);
|
|
|
dispatcher.start();
|
|
|
- metricsPublisher = new TimelineServiceV2Publisher(rmContext) {
|
|
|
- @Override
|
|
|
- protected Dispatcher getDispatcher() {
|
|
|
- return dispatcher;
|
|
|
- }
|
|
|
- };
|
|
|
+ metricsPublisher =
|
|
|
+ new TimelineServiceV2Publisher(rmTimelineCollectorManager) {
|
|
|
+ @Override protected Dispatcher getDispatcher() {
|
|
|
+ return dispatcher;
|
|
|
+ }
|
|
|
+ };
|
|
|
metricsPublisher.init(conf);
|
|
|
metricsPublisher.start();
|
|
|
}
|
|
@@ -166,7 +168,7 @@ public class TestSystemMetricsPublisherForV2 {
|
|
|
public void testSystemMetricPublisherInitialization() {
|
|
|
@SuppressWarnings("resource")
|
|
|
TimelineServiceV2Publisher publisher =
|
|
|
- new TimelineServiceV2Publisher(mock(RMContext.class));
|
|
|
+ new TimelineServiceV2Publisher(mock(RMTimelineCollectorManager.class));
|
|
|
try {
|
|
|
Configuration conf = getTimelineV2Conf();
|
|
|
conf.setBoolean(YarnConfiguration.RM_PUBLISH_CONTAINER_EVENTS_ENABLED,
|
|
@@ -178,7 +180,8 @@ public class TestSystemMetricsPublisherForV2 {
|
|
|
|
|
|
publisher.stop();
|
|
|
|
|
|
- publisher = new TimelineServiceV2Publisher(mock(RMContext.class));
|
|
|
+ publisher = new TimelineServiceV2Publisher(
|
|
|
+ mock(RMTimelineCollectorManager.class));
|
|
|
conf = getTimelineV2Conf();
|
|
|
publisher.init(conf);
|
|
|
assertTrue("Expected to have registered event handlers and set ready to "
|