use of org.apache.hadoop.yarn.server.resourcemanager.ResourceManager in project hadoop by apache.
the class TestMiniYarnClusterNodeUtilization method verifySimulatedUtilization.
/**
* Verify both the RMNode and SchedulerNode have been updated with the test
* fixture utilization data.
*/
private void verifySimulatedUtilization() throws InterruptedException {
ResourceManager rm = cluster.getResourceManager(0);
RMContext rmContext = rm.getRMContext();
ResourceUtilization containersUtilization = nodeStatus.getContainersUtilization();
ResourceUtilization nodeUtilization = nodeStatus.getNodeUtilization();
// We check if the nodeUtilization is up to date
for (int i = 0; i < 100; i++) {
for (RMNode ni : rmContext.getRMNodes().values()) {
if (ni.getNodeUtilization() != null) {
if (ni.getNodeUtilization().equals(nodeUtilization)) {
break;
}
}
}
Thread.sleep(100);
}
// Verify the data is readable from the RM and scheduler nodes
for (RMNode ni : rmContext.getRMNodes().values()) {
ResourceUtilization cu = ni.getAggregatedContainersUtilization();
assertEquals("Containers Utillization not propagated to RMNode", containersUtilization, cu);
ResourceUtilization nu = ni.getNodeUtilization();
assertEquals("Node Utillization not propagated to RMNode", nodeUtilization, nu);
SchedulerNode scheduler = rmContext.getScheduler().getSchedulerNode(ni.getNodeID());
cu = scheduler.getAggregatedContainersUtilization();
assertEquals("Containers Utillization not propagated to SchedulerNode", containersUtilization, cu);
nu = scheduler.getNodeUtilization();
assertEquals("Node Utillization not propagated to SchedulerNode", nodeUtilization, nu);
}
}
use of org.apache.hadoop.yarn.server.resourcemanager.ResourceManager in project hadoop by apache.
the class TestAbstractYarnScheduler method getPrivateResourceTrackerService.
private ResourceTrackerService getPrivateResourceTrackerService(Dispatcher privateDispatcher, ResourceManager rm, SleepHandler sleepHandler) {
Configuration conf = getConf();
RMContext privateContext = new RMContextImpl(privateDispatcher, null, null, null, null, null, null, null, null, null);
privateContext.setNodeLabelManager(Mockito.mock(RMNodeLabelsManager.class));
privateDispatcher.register(SchedulerEventType.class, sleepHandler);
privateDispatcher.register(SchedulerEventType.class, rm.getResourceScheduler());
privateDispatcher.register(RMNodeEventType.class, new ResourceManager.NodeEventDispatcher(privateContext));
((Service) privateDispatcher).init(conf);
((Service) privateDispatcher).start();
NMLivelinessMonitor nmLivelinessMonitor = new NMLivelinessMonitor(privateDispatcher);
nmLivelinessMonitor.init(conf);
nmLivelinessMonitor.start();
NodesListManager nodesListManager = new NodesListManager(privateContext);
nodesListManager.init(conf);
RMContainerTokenSecretManager containerTokenSecretManager = new RMContainerTokenSecretManager(conf);
containerTokenSecretManager.start();
NMTokenSecretManagerInRM nmTokenSecretManager = new NMTokenSecretManagerInRM(conf);
nmTokenSecretManager.start();
ResourceTrackerService privateResourceTrackerService = new ResourceTrackerService(privateContext, nodesListManager, nmLivelinessMonitor, containerTokenSecretManager, nmTokenSecretManager);
privateResourceTrackerService.init(conf);
privateResourceTrackerService.start();
rm.getResourceScheduler().setRMContext(privateContext);
return privateResourceTrackerService;
}
use of org.apache.hadoop.yarn.server.resourcemanager.ResourceManager in project hadoop by apache.
the class TestRMWebAppFairScheduler method testFairSchedulerWebAppPage.
@Test
public void testFairSchedulerWebAppPage() {
List<RMAppState> appStates = Arrays.asList(RMAppState.NEW, RMAppState.NEW_SAVING, RMAppState.SUBMITTED);
final RMContext rmContext = mockRMContext(appStates);
Injector injector = WebAppTests.createMockInjector(RMContext.class, rmContext, new Module() {
@Override
public void configure(Binder binder) {
try {
ResourceManager mockRmWithFairScheduler = mockRm(rmContext);
binder.bind(ResourceManager.class).toInstance(mockRmWithFairScheduler);
binder.bind(ApplicationBaseProtocol.class).toInstance(mockRmWithFairScheduler.getClientRMService());
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
});
FairSchedulerPage fsViewInstance = injector.getInstance(FairSchedulerPage.class);
fsViewInstance.render();
WebAppTests.flushOutput(injector);
}
use of org.apache.hadoop.yarn.server.resourcemanager.ResourceManager in project hadoop by apache.
the class TestRMWebAppFairScheduler method mockRm.
private static ResourceManager mockRm(RMContext rmContext) throws IOException {
ResourceManager rm = mock(ResourceManager.class);
ResourceScheduler rs = mockFairScheduler();
ClientRMService clientRMService = mockClientRMService(rmContext);
when(rm.getResourceScheduler()).thenReturn(rs);
when(rm.getRMContext()).thenReturn(rmContext);
when(rm.getClientRMService()).thenReturn(clientRMService);
return rm;
}
use of org.apache.hadoop.yarn.server.resourcemanager.ResourceManager in project hadoop by apache.
the class TestRMWebAppFairScheduler method testFairSchedulerWebAppPageInInconsistentState.
/**
* Testing inconsistent state between AbstractYarnScheduler#applications and
* RMContext#applications
*/
@Test
public void testFairSchedulerWebAppPageInInconsistentState() {
List<RMAppState> appStates = Arrays.asList(RMAppState.NEW, RMAppState.NEW_SAVING, RMAppState.SUBMITTED, RMAppState.RUNNING, RMAppState.FINAL_SAVING, RMAppState.ACCEPTED, RMAppState.FINISHED);
final RMContext rmContext = mockRMContext(appStates);
Injector injector = WebAppTests.createMockInjector(RMContext.class, rmContext, new Module() {
@Override
public void configure(Binder binder) {
try {
ResourceManager mockRmWithFairScheduler = mockRmWithApps(rmContext);
binder.bind(ResourceManager.class).toInstance(mockRmWithFairScheduler);
binder.bind(ApplicationBaseProtocol.class).toInstance(mockRmWithFairScheduler.getClientRMService());
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
});
FairSchedulerPage fsViewInstance = injector.getInstance(FairSchedulerPage.class);
try {
fsViewInstance.render();
} catch (Exception e) {
Assert.fail("Failed to render FairSchedulerPage: " + StringUtils.stringifyException(e));
}
WebAppTests.flushOutput(injector);
}
Aggregations