Search in sources :

Example 1 with RMAppState

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);
}
Also used : RMContext(org.apache.hadoop.yarn.server.resourcemanager.RMContext) Binder(com.google.inject.Binder) RMAppState(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState) Injector(com.google.inject.Injector) ResourceManager(org.apache.hadoop.yarn.server.resourcemanager.ResourceManager) IOException(java.io.IOException) Module(com.google.inject.Module) Test(org.junit.Test)

Example 2 with RMAppState

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);
}
Also used : RMContext(org.apache.hadoop.yarn.server.resourcemanager.RMContext) Binder(com.google.inject.Binder) RMAppState(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState) Injector(com.google.inject.Injector) ResourceManager(org.apache.hadoop.yarn.server.resourcemanager.ResourceManager) IOException(java.io.IOException) Module(com.google.inject.Module) IOException(java.io.IOException) Test(org.junit.Test)

Example 3 with RMAppState

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);
}
Also used : RMAppState(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState) JSONObject(org.codehaus.jettison.json.JSONObject)

Example 4 with RMAppState

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);
}
Also used : RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) RMAppState(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState) RMAppAttempt(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt) FairScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) MockRM(org.apache.hadoop.yarn.server.resourcemanager.MockRM) RMAppAttemptState(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptState) RMContainer(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer) CapacityScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler)

Example 5 with RMAppState

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);
}
Also used : InputSource(org.xml.sax.InputSource) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) RMAppState(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState) DocumentBuilder(javax.xml.parsers.DocumentBuilder) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) StringReader(java.io.StringReader) Document(org.w3c.dom.Document)

Aggregations

RMAppState (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState)7 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)3 Binder (com.google.inject.Binder)2 Injector (com.google.inject.Injector)2 Module (com.google.inject.Module)2 IOException (java.io.IOException)2 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)2 RMContext (org.apache.hadoop.yarn.server.resourcemanager.RMContext)2 ResourceManager (org.apache.hadoop.yarn.server.resourcemanager.ResourceManager)2 RMAppAttempt (org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt)2 Test (org.junit.Test)2 StringReader (java.io.StringReader)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)1 UpdateApplicationTimeoutsResponse (org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationTimeoutsResponse)1 ApplicationTimeoutType (org.apache.hadoop.yarn.api.records.ApplicationTimeoutType)1 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)1 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)1 MockRM (org.apache.hadoop.yarn.server.resourcemanager.MockRM)1