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);
}
}
Aggregations