use of org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState 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.rmapp.RMAppState 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);
}
use of org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState in project hadoop by apache.
the class TestRMWebServicesAppsModification method verifyAppStateJson.
protected static void verifyAppStateJson(ClientResponse response, RMAppState... states) throws JSONException {
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
JSONObject json = response.getEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
String responseState = json.getString("state");
boolean valid = false;
for (RMAppState state : states) {
if (state.toString().equals(responseState)) {
valid = true;
}
}
String msg = "app state incorrect, got " + responseState;
assertTrue(msg, valid);
}
use of org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState in project hadoop by apache.
the class TestRMApplicationHistoryWriter method testRMWritingMassiveHistory.
private void testRMWritingMassiveHistory(boolean isFS) throws Exception {
// 1. Show RM can run with writing history data
// 2. Test additional workload of processing history events
YarnConfiguration conf = new YarnConfiguration();
if (isFS) {
conf.setBoolean(FairSchedulerConfiguration.ASSIGN_MULTIPLE, true);
conf.set(YarnConfiguration.RM_SCHEDULER, FairScheduler.class.getName());
} else {
conf.set(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class.getName());
}
// don't process history events
MockRM rm = new MockRM(conf) {
@Override
protected RMApplicationHistoryWriter createRMApplicationHistoryWriter() {
return new RMApplicationHistoryWriter() {
@Override
public void applicationStarted(RMApp app) {
}
@Override
public void applicationFinished(RMApp app, RMAppState finalState) {
}
@Override
public void applicationAttemptStarted(RMAppAttempt appAttempt) {
}
@Override
public void applicationAttemptFinished(RMAppAttempt appAttempt, RMAppAttemptState finalState) {
}
@Override
public void containerStarted(RMContainer container) {
}
@Override
public void containerFinished(RMContainer container) {
}
};
}
};
long startTime1 = System.currentTimeMillis();
testRMWritingMassiveHistory(rm);
long finishTime1 = System.currentTimeMillis();
long elapsedTime1 = finishTime1 - startTime1;
rm = new MockRM(conf);
long startTime2 = System.currentTimeMillis();
testRMWritingMassiveHistory(rm);
long finishTime2 = System.currentTimeMillis();
long elapsedTime2 = finishTime2 - startTime2;
// No more than 10% additional workload
// Should be much less, but computation time is fluctuated
Assert.assertTrue(elapsedTime2 - elapsedTime1 < elapsedTime1 / 10);
}
use of org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState in project hadoop by apache.
the class TestRMWebServicesAppsModification method verifyAppStateXML.
protected static void verifyAppStateXML(ClientResponse response, RMAppState... appStates) throws ParserConfigurationException, IOException, SAXException {
assertEquals(MediaType.APPLICATION_XML_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
String xml = response.getEntity(String.class);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
InputSource is = new InputSource();
is.setCharacterStream(new StringReader(xml));
Document dom = db.parse(is);
NodeList nodes = dom.getElementsByTagName("appstate");
assertEquals("incorrect number of elements", 1, nodes.getLength());
Element element = (Element) nodes.item(0);
String state = WebServicesTestUtils.getXmlString(element, "state");
boolean valid = false;
for (RMAppState appState : appStates) {
if (appState.toString().equals(state)) {
valid = true;
}
}
String msg = "app state incorrect, got " + state;
assertTrue(msg, valid);
}
Aggregations