Search in sources :

Example 6 with RMAppState

use of org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState in project hadoop by apache.

the class TestRMWebAppFairScheduler method mockRMContext.

private static RMContext mockRMContext(List<RMAppState> states) {
    final ConcurrentMap<ApplicationId, RMApp> applicationsMaps = Maps.newConcurrentMap();
    int i = 0;
    for (RMAppState state : states) {
        MockRMApp app = new MockRMApp(i, i, state) {

            @Override
            public RMAppMetrics getRMAppMetrics() {
                return new RMAppMetrics(Resource.newInstance(0, 0), 0, 0, 0, 0, 0, 0);
            }

            @Override
            public YarnApplicationState createApplicationState() {
                return YarnApplicationState.ACCEPTED;
            }
        };
        RMAppAttempt attempt = mock(RMAppAttempt.class);
        app.setCurrentAppAttempt(attempt);
        applicationsMaps.put(app.getApplicationId(), app);
        i++;
    }
    RMContextImpl rmContext = new RMContextImpl(null, null, null, null, null, null, null, null, null, null) {

        @Override
        public ConcurrentMap<ApplicationId, RMApp> getRMApps() {
            return applicationsMaps;
        }

        @Override
        public ResourceScheduler getScheduler() {
            return mock(AbstractYarnScheduler.class);
        }
    };
    return rmContext;
}
Also used : RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) MockRMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.MockRMApp) MockRMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.MockRMApp) RMAppState(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState) RMAppAttempt(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt) RMAppMetrics(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppMetrics) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) RMContextImpl(org.apache.hadoop.yarn.server.resourcemanager.RMContextImpl)

Example 7 with RMAppState

use of org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState in project hadoop by apache.

the class ClientRMService method updateApplicationTimeouts.

@Override
public UpdateApplicationTimeoutsResponse updateApplicationTimeouts(UpdateApplicationTimeoutsRequest request) throws YarnException, IOException {
    ApplicationId applicationId = request.getApplicationId();
    Map<ApplicationTimeoutType, String> applicationTimeouts = request.getApplicationTimeouts();
    UserGroupInformation callerUGI = getCallerUgi(applicationId, AuditConstants.UPDATE_APP_TIMEOUTS);
    RMApp application = verifyUserAccessForRMApp(applicationId, callerUGI, AuditConstants.UPDATE_APP_TIMEOUTS);
    if (applicationTimeouts.isEmpty()) {
        String message = "At least one ApplicationTimeoutType should be configured" + " for updating timeouts.";
        RMAuditLogger.logFailure(callerUGI.getShortUserName(), AuditConstants.UPDATE_APP_TIMEOUTS, "UNKNOWN", "ClientRMService", message, applicationId);
        throw RPCUtil.getRemoteException(message);
    }
    UpdateApplicationTimeoutsResponse response = recordFactory.newRecordInstance(UpdateApplicationTimeoutsResponse.class);
    RMAppState state = application.getState();
    if (!EnumSet.of(RMAppState.SUBMITTED, RMAppState.ACCEPTED, RMAppState.RUNNING).contains(state)) {
        if (COMPLETED_APP_STATES.contains(state)) {
            // If Application is in any of the final states, update timeout
            // can be skipped rather throwing exception.
            RMAuditLogger.logSuccess(callerUGI.getShortUserName(), AuditConstants.UPDATE_APP_TIMEOUTS, "ClientRMService", applicationId);
            return response;
        }
        String msg = "Application is in " + state + " state can not update timeout.";
        RMAuditLogger.logFailure(callerUGI.getShortUserName(), AuditConstants.UPDATE_APP_TIMEOUTS, "UNKNOWN", "ClientRMService", msg);
        throw RPCUtil.getRemoteException(msg);
    }
    try {
        rmAppManager.updateApplicationTimeout(application, applicationTimeouts);
    } catch (YarnException ex) {
        RMAuditLogger.logFailure(callerUGI.getShortUserName(), AuditConstants.UPDATE_APP_TIMEOUTS, "UNKNOWN", "ClientRMService", ex.getMessage());
        throw ex;
    }
    RMAuditLogger.logSuccess(callerUGI.getShortUserName(), AuditConstants.UPDATE_APP_TIMEOUTS, "ClientRMService", applicationId);
    return response;
}
Also used : RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) RMAppState(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState) ApplicationTimeoutType(org.apache.hadoop.yarn.api.records.ApplicationTimeoutType) UpdateApplicationTimeoutsResponse(org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationTimeoutsResponse) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

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