Search in sources :

Example 6 with KillApplicationResponse

use of org.apache.hadoop.yarn.api.protocolrecords.KillApplicationResponse 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

KillApplicationResponse (org.apache.hadoop.yarn.api.protocolrecords.KillApplicationResponse)6 KillApplicationRequest (org.apache.hadoop.yarn.api.protocolrecords.KillApplicationRequest)4 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)3 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)2 Test (org.junit.Test)2 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 AccessControlException (java.security.AccessControlException)1 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)1 ApplicationClientProtocol (org.apache.hadoop.yarn.api.ApplicationClientProtocol)1 GetApplicationsRequest (org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest)1 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)1 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)1 MemoryRMStateStore (org.apache.hadoop.yarn.server.resourcemanager.recovery.MemoryRMStateStore)1 AppState (org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppState)1 Matchers.anyString (org.mockito.Matchers.anyString)1