Search in sources :

Example 11 with KillApplicationRequest

use of org.apache.hadoop.yarn.api.protocolrecords.KillApplicationRequest in project hadoop by apache.

the class TestApplicationACLs method verifyOwnerAccess.

private void verifyOwnerAccess() throws Exception {
    AccessControlList viewACL = new AccessControlList("");
    viewACL.addGroup(FRIENDLY_GROUP);
    AccessControlList modifyACL = new AccessControlList("");
    modifyACL.addUser(FRIEND);
    ApplicationId applicationId = submitAppAndGetAppId(viewACL, modifyACL);
    final GetApplicationReportRequest appReportRequest = recordFactory.newRecordInstance(GetApplicationReportRequest.class);
    appReportRequest.setApplicationId(applicationId);
    final KillApplicationRequest finishAppRequest = recordFactory.newRecordInstance(KillApplicationRequest.class);
    finishAppRequest.setApplicationId(applicationId);
    // View as owner
    rmClient.getApplicationReport(appReportRequest);
    // List apps as owner
    Assert.assertEquals("App view by owner should list the apps!!", 1, rmClient.getApplications(recordFactory.newRecordInstance(GetApplicationsRequest.class)).getApplicationList().size());
    // Kill app as owner
    rmClient.forceKillApplication(finishAppRequest);
    resourceManager.waitForState(applicationId, RMAppState.KILLED);
}
Also used : AccessControlList(org.apache.hadoop.security.authorize.AccessControlList) GetApplicationReportRequest(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest) KillApplicationRequest(org.apache.hadoop.yarn.api.protocolrecords.KillApplicationRequest) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId)

Example 12 with KillApplicationRequest

use of org.apache.hadoop.yarn.api.protocolrecords.KillApplicationRequest in project hadoop by apache.

the class TestApplicationACLs method verifyAdministerQueueUserAccess.

private void verifyAdministerQueueUserAccess() throws Exception {
    isQueueUser = true;
    AccessControlList viewACL = new AccessControlList("");
    viewACL.addGroup(FRIENDLY_GROUP);
    AccessControlList modifyACL = new AccessControlList("");
    modifyACL.addUser(FRIEND);
    ApplicationId applicationId = submitAppAndGetAppId(viewACL, modifyACL);
    final GetApplicationReportRequest appReportRequest = recordFactory.newRecordInstance(GetApplicationReportRequest.class);
    appReportRequest.setApplicationId(applicationId);
    final KillApplicationRequest finishAppRequest = recordFactory.newRecordInstance(KillApplicationRequest.class);
    finishAppRequest.setApplicationId(applicationId);
    ApplicationClientProtocol administerQueueUserRmClient = getRMClientForUser(QUEUE_ADMIN_USER);
    // View as the administerQueueUserRmClient
    administerQueueUserRmClient.getApplicationReport(appReportRequest);
    // List apps as administerQueueUserRmClient
    Assert.assertEquals("App view by queue-admin-user should list the apps!!", 5, administerQueueUserRmClient.getApplications(recordFactory.newRecordInstance(GetApplicationsRequest.class)).getApplicationList().size());
    // Kill app as the administerQueueUserRmClient
    administerQueueUserRmClient.forceKillApplication(finishAppRequest);
    resourceManager.waitForState(applicationId, RMAppState.KILLED);
}
Also used : AccessControlList(org.apache.hadoop.security.authorize.AccessControlList) GetApplicationReportRequest(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest) KillApplicationRequest(org.apache.hadoop.yarn.api.protocolrecords.KillApplicationRequest) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) ApplicationClientProtocol(org.apache.hadoop.yarn.api.ApplicationClientProtocol)

Example 13 with KillApplicationRequest

use of org.apache.hadoop.yarn.api.protocolrecords.KillApplicationRequest in project hadoop by apache.

the class YarnClientImpl method killApplication.

@Override
public void killApplication(ApplicationId applicationId, String diagnostics) throws YarnException, IOException {
    KillApplicationRequest request = Records.newRecord(KillApplicationRequest.class);
    request.setApplicationId(applicationId);
    if (diagnostics != null) {
        request.setDiagnostics(diagnostics);
    }
    try {
        int pollCount = 0;
        long startTime = System.currentTimeMillis();
        while (true) {
            KillApplicationResponse response = rmClient.forceKillApplication(request);
            if (response.getIsKillCompleted()) {
                LOG.info("Killed application " + applicationId);
                break;
            }
            long elapsedMillis = System.currentTimeMillis() - startTime;
            if (enforceAsyncAPITimeout() && elapsedMillis >= this.asyncApiPollTimeoutMillis) {
                throw new YarnException("Timed out while waiting for application " + applicationId + " to be killed.");
            }
            if (++pollCount % 10 == 0) {
                LOG.info("Waiting for application " + applicationId + " to be killed.");
            }
            Thread.sleep(asyncApiPollIntervalMillis);
        }
    } catch (InterruptedException e) {
        String msg = "Interrupted while waiting for application " + applicationId + " to be killed.";
        LOG.error(msg);
        throw new YarnException(msg, e);
    }
}
Also used : KillApplicationResponse(org.apache.hadoop.yarn.api.protocolrecords.KillApplicationResponse) KillApplicationRequest(org.apache.hadoop.yarn.api.protocolrecords.KillApplicationRequest) YarnException(org.apache.hadoop.yarn.exceptions.YarnException)

Aggregations

KillApplicationRequest (org.apache.hadoop.yarn.api.protocolrecords.KillApplicationRequest)13 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)9 ApplicationClientProtocol (org.apache.hadoop.yarn.api.ApplicationClientProtocol)7 AccessControlList (org.apache.hadoop.security.authorize.AccessControlList)5 GetApplicationReportRequest (org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest)5 KillApplicationResponse (org.apache.hadoop.yarn.api.protocolrecords.KillApplicationResponse)4 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)4 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)3 Test (org.junit.Test)3 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 AccessControlException (java.security.AccessControlException)1 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)1 GetApplicationsRequest (org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest)1 ApplicationReport (org.apache.hadoop.yarn.api.records.ApplicationReport)1 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)1 AbstractEvent (org.apache.hadoop.yarn.event.AbstractEvent)1 Dispatcher (org.apache.hadoop.yarn.event.Dispatcher)1 DrainDispatcher (org.apache.hadoop.yarn.event.DrainDispatcher)1 Event (org.apache.hadoop.yarn.event.Event)1 EventHandler (org.apache.hadoop.yarn.event.EventHandler)1