本文整理匯總了Java中org.apache.hadoop.yarn.api.protocolrecords.StopContainerRequest類的典型用法代碼示例。如果您正苦於以下問題:Java StopContainerRequest類的具體用法?Java StopContainerRequest怎麽用?Java StopContainerRequest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
StopContainerRequest類屬於org.apache.hadoop.yarn.api.protocolrecords包,在下文中一共展示了StopContainerRequest類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: cancel
import org.apache.hadoop.yarn.api.protocolrecords.StopContainerRequest; //導入依賴的package包/類
@Override
public void cancel() {
LOG.info("Request to stop container {}.", container.getId());
StopContainerRequest stopRequest = Records.newRecord(StopContainerRequest.class);
stopRequest.setContainerId(container.getId());
try {
manager.stopContainer(stopRequest);
while (true) {
GetContainerStatusRequest statusRequest = Records.newRecord(GetContainerStatusRequest.class);
statusRequest.setContainerId(container.getId());
GetContainerStatusResponse statusResponse = manager.getContainerStatus(statusRequest);
LOG.trace("Container status: {} {}", statusResponse.getStatus(), statusResponse.getStatus().getDiagnostics());
if (statusResponse.getStatus().getState() == ContainerState.COMPLETE) {
break;
}
Uninterruptibles.sleepUninterruptibly(200, TimeUnit.MILLISECONDS);
}
LOG.info("Container {} stopped.", container.getId());
} catch (YarnRemoteException e) {
LOG.error("Fail to stop container {}", container.getId(), e);
throw Throwables.propagate(e);
}
}
示例2: cancel
import org.apache.hadoop.yarn.api.protocolrecords.StopContainerRequest; //導入依賴的package包/類
@Override
public void cancel() {
LOG.info("Request to stop container {}.", container.getId());
StopContainerRequest stopRequest = Records.newRecord(StopContainerRequest.class);
stopRequest.setContainerId(container.getId());
try {
manager.stopContainer(stopRequest);
boolean completed = false;
while (!completed) {
GetContainerStatusRequest statusRequest = Records.newRecord(GetContainerStatusRequest.class);
statusRequest.setContainerId(container.getId());
GetContainerStatusResponse statusResponse = manager.getContainerStatus(statusRequest);
LOG.info("Container status: {} {}", statusResponse.getStatus(), statusResponse.getStatus().getDiagnostics());
completed = (statusResponse.getStatus().getState() == ContainerState.COMPLETE);
}
LOG.info("Container {} stopped.", container.getId());
} catch (YarnRemoteException e) {
LOG.error("Fail to stop container {}", container.getId(), e);
throw Throwables.propagate(e);
}
}
示例3: stopContainer
import org.apache.hadoop.yarn.api.protocolrecords.StopContainerRequest; //導入依賴的package包/類
@Override
public synchronized void stopContainer() {
if(isCompletelyDone()) {
return;
}
if(this.state == ContainerState.PREP) {
this.state = ContainerState.KILLED_BEFORE_LAUNCH;
} else {
LOG.info("KILLING " + containerID);
ContainerManager proxy = null;
try {
proxy = getCMProxy(this.containerID, this.containerMgrAddress,
this.containerToken);
// kill the remote container if already launched
StopContainerRequest stopRequest = Records
.newRecord(StopContainerRequest.class);
stopRequest.setContainerId(this.containerID);
proxy.stopContainer(stopRequest);
// If stopContainer returns without an error, assuming the stop made
// it over to the NodeManager.
// context.getEventHandler().handle(
// new AMContainerEvent(containerID, AMContainerEventType.C_NM_STOP_SENT));
context.getResourceAllocator().removeContainer(containerID);
} catch (Throwable t) {
// ignore the cleanup failure
String message = "cleanup failed for container "
+ this.containerID + " : "
+ StringUtils.stringifyException(t);
// context.getEventHandler().handle(
// new AMContainerEventStopFailed(containerID, message));
LOG.warn(message);
this.state = ContainerState.DONE;
return;
} finally {
if (proxy != null) {
yarnRPC.stopProxy(proxy, conf);
}
}
this.state = ContainerState.DONE;
}
}