Search in sources :

Example 1 with QueueInvalidException

use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueInvalidException in project hadoop by apache.

the class CapacityScheduler method addApplicationOnRecovery.

private void addApplicationOnRecovery(ApplicationId applicationId, String queueName, String user, Priority priority) {
    try {
        writeLock.lock();
        CSQueue queue = getQueue(queueName);
        if (queue == null) {
            //not presently supported
            if (!YarnConfiguration.shouldRMFailFast(getConfig())) {
                this.rmContext.getDispatcher().getEventHandler().handle(new RMAppEvent(applicationId, RMAppEventType.KILL, "Application killed on recovery as it was submitted to queue " + queueName + " which no longer exists after restart."));
                return;
            } else {
                String queueErrorMsg = "Queue named " + queueName + " missing during application recovery." + " Queue removal during recovery is not presently " + "supported by the capacity scheduler, please " + "restart with all queues configured" + " which were present before shutdown/restart.";
                LOG.fatal(queueErrorMsg);
                throw new QueueInvalidException(queueErrorMsg);
            }
        }
        if (!(queue instanceof LeafQueue)) {
            // queue, which is not supported for running apps.
            if (!YarnConfiguration.shouldRMFailFast(getConfig())) {
                this.rmContext.getDispatcher().getEventHandler().handle(new RMAppEvent(applicationId, RMAppEventType.KILL, "Application killed on recovery as it was submitted to queue " + queueName + " which is no longer a leaf queue after restart."));
                return;
            } else {
                String queueErrorMsg = "Queue named " + queueName + " is no longer a leaf queue during application recovery." + " Changing a leaf queue to a parent queue during recovery is" + " not presently supported by the capacity scheduler. Please" + " restart with leaf queues before shutdown/restart continuing" + " as leaf queues.";
                LOG.fatal(queueErrorMsg);
                throw new QueueInvalidException(queueErrorMsg);
            }
        }
        // Submit to the queue
        try {
            queue.submitApplication(applicationId, user, queueName);
        } catch (AccessControlException ace) {
        // Ignore the exception for recovered app as the app was previously
        // accepted.
        }
        queue.getMetrics().submitApp(user);
        SchedulerApplication<FiCaSchedulerApp> application = new SchedulerApplication<FiCaSchedulerApp>(queue, user, priority);
        applications.put(applicationId, application);
        LOG.info("Accepted application " + applicationId + " from user: " + user + ", in queue: " + queueName);
        if (LOG.isDebugEnabled()) {
            LOG.debug(applicationId + " is recovering. Skip notifying APP_ACCEPTED");
        }
    } finally {
        writeLock.unlock();
    }
}
Also used : RMAppEvent(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppEvent) SchedulerApplication(org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApplication) FiCaSchedulerApp(org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp) AccessControlException(org.apache.hadoop.security.AccessControlException) QueueInvalidException(org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueInvalidException)

Example 2 with QueueInvalidException

use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueInvalidException in project hadoop by apache.

the class TestWorkPreservingRMRestart method verifyAppRecoveryWithWrongQueueConfig.

private void verifyAppRecoveryWithWrongQueueConfig(CapacitySchedulerConfiguration csConf, RMApp app, String diagnostics, MemoryRMStateStore memStore, RMState state) throws Exception {
    // Restart RM with fail-fast as false. App should be killed.
    csConf.setBoolean(YarnConfiguration.RM_FAIL_FAST, false);
    rm2 = new MockRM(csConf, memStore);
    rm2.start();
    // Wait for app to be killed.
    rm2.waitForState(app.getApplicationId(), RMAppState.KILLED);
    ApplicationReport report = rm2.getApplicationReport(app.getApplicationId());
    assertEquals(report.getFinalApplicationStatus(), FinalApplicationStatus.KILLED);
    assertEquals(report.getYarnApplicationState(), YarnApplicationState.KILLED);
    assertEquals(report.getDiagnostics(), diagnostics);
    // This is to simulate app recovery with fail fast config as true.
    for (Map.Entry<ApplicationId, ApplicationStateData> entry : state.getApplicationState().entrySet()) {
        ApplicationStateData appState = mock(ApplicationStateData.class);
        ApplicationSubmissionContext ctxt = mock(ApplicationSubmissionContext.class);
        when(appState.getApplicationSubmissionContext()).thenReturn(ctxt);
        when(ctxt.getApplicationId()).thenReturn(entry.getKey());
        memStore.removeApplicationStateInternal(appState);
        memStore.storeApplicationStateInternal(entry.getKey(), entry.getValue());
    }
    // Now restart RM with fail-fast as true. QueueException should be thrown.
    csConf.setBoolean(YarnConfiguration.RM_FAIL_FAST, true);
    MockRM rm = new MockRM(csConf, memStore);
    try {
        rm.start();
        Assert.fail("QueueException must have been thrown");
    } catch (QueueInvalidException e) {
    } finally {
        rm.close();
    }
}
Also used : ApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationReport) ApplicationSubmissionContext(org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext) TestSecurityMockRM(org.apache.hadoop.yarn.server.resourcemanager.TestRMRestart.TestSecurityMockRM) ApplicationStateData(org.apache.hadoop.yarn.server.resourcemanager.recovery.records.ApplicationStateData) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) Map(java.util.Map) QueueInvalidException(org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueInvalidException)

Aggregations

QueueInvalidException (org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueInvalidException)2 Map (java.util.Map)1 AccessControlException (org.apache.hadoop.security.AccessControlException)1 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)1 ApplicationReport (org.apache.hadoop.yarn.api.records.ApplicationReport)1 ApplicationSubmissionContext (org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext)1 TestSecurityMockRM (org.apache.hadoop.yarn.server.resourcemanager.TestRMRestart.TestSecurityMockRM)1 ApplicationStateData (org.apache.hadoop.yarn.server.resourcemanager.recovery.records.ApplicationStateData)1 RMAppEvent (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppEvent)1 SchedulerApplication (org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApplication)1 FiCaSchedulerApp (org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp)1