本文整理汇总了Java中org.apache.hadoop.yarn.api.records.AMCommand.AM_SHUTDOWN属性的典型用法代码示例。如果您正苦于以下问题:Java AMCommand.AM_SHUTDOWN属性的具体用法?Java AMCommand.AM_SHUTDOWN怎么用?Java AMCommand.AM_SHUTDOWN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.hadoop.yarn.api.records.AMCommand
的用法示例。
在下文中一共展示了AMCommand.AM_SHUTDOWN属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initAndStartHeartbeat
private Thread initAndStartHeartbeat(final StormAMRMClient client,
final BlockingQueue<Container> launcherQueue,
final int heartBeatIntervalMs) {
Thread thread = new Thread() {
@Override
public void run() {
try {
while (client.getServiceState() == Service.STATE.STARTED &&
!Thread.currentThread().isInterrupted()) {
Thread.sleep(heartBeatIntervalMs);
// We always send 50% progress.
AllocateResponse allocResponse = client.allocate(0.5f);
AMCommand am_command = allocResponse.getAMCommand();
if (am_command!=null &&
(am_command == AMCommand.AM_SHUTDOWN || am_command==AMCommand.AM_RESYNC)) {
LOG.info("Got AM_SHUTDOWN or AM_RESYNC from the RM");
_handler.stop();
System.exit(0);
}
List<Container> allocatedContainers = allocResponse.getAllocatedContainers();
if (allocatedContainers.size() > 0) {
// Add newly allocated containers to the client.
LOG.info("HB: Received allocated containers (" + allocatedContainers.size() + ")");
client.addAllocatedContainers(allocatedContainers);
if (client.supervisorsAreToRun()) {
LOG.info("HB: Supervisors are to run, so queueing (" + allocatedContainers.size() + ") containers...");
launcherQueue.addAll(allocatedContainers);
} else {
LOG.info("HB: Supervisors are to stop, so releasing all containers...");
client.stopAllSupervisors();
}
}
List<ContainerStatus> completedContainers =
allocResponse.getCompletedContainersStatuses();
if (completedContainers.size() > 0 && client.supervisorsAreToRun()) {
LOG.debug("HB: Containers completed (" + completedContainers.size() + "), so releasing them.");
client.startAllSupervisors();
}
}
} catch (Throwable t) {
// Something happened we could not handle. Make sure the AM goes
// down so that we are not surprised later on that our heart
// stopped..
LOG.error("Unhandled error in AM: ", t);
_handler.stop();
System.exit(1);
}
}
};
thread.start();
return thread;
}
示例2: initAndStartHeartbeat
private Thread initAndStartHeartbeat(final StormAMRMClient client,
final BlockingQueue<Container> launcherQueue,
final int heartBeatIntervalMs) {
Thread thread = new Thread() {
@Override
public void run() {
try {
while (client.getServiceState() == Service.STATE.STARTED &&
!Thread.currentThread().isInterrupted()) {
Thread.sleep(heartBeatIntervalMs);
// We always send 50% progress.
AllocateResponse allocResponse = client.allocate(0.5f);
AMCommand am_command = allocResponse.getAMCommand();
if (am_command!=null &&
(am_command == AMCommand.AM_SHUTDOWN || am_command==AMCommand.AM_RESYNC)) {
LOG.info("Got AM_SHUTDOWN or AM_RESYNC from the RM");
_handler.stop();
System.exit(0);
}
List<Container> allocatedContainers = allocResponse.getAllocatedContainers();
if (allocatedContainers.size() > 0) {
// Add newly allocated containers to the client.
LOG.info("HB: Received allocated containers (" + allocatedContainers.size() + ")");
client.addAllocatedContainers(allocatedContainers);
if (client.supervisorsAreToRun()) {
LOG.info("HB: Supervisors are to run, so queueing (" + allocatedContainers.size() + ") containers...");
launcherQueue.addAll(allocatedContainers);
} else {
LOG.info("HB: Supervisors are to stop, so releasing all containers...");
client.stopAllSupervisors();
}
}
List<ContainerStatus> completedContainers =
allocResponse.getCompletedContainersStatuses();
if (completedContainers.size() > 0 && client.supervisorsAreToRun()) {
LOG.debug("HB: Containers completed (" + completedContainers.size() + "), so releasing them.");
client.addSupervisors(completedContainers.size());
}
}
} catch (Throwable t) {
// Something happened we could not handle. Make sure the AM goes
// down so that we are not surprised later on that our heart
// stopped..
LOG.error("Unhandled error in AM: ", t);
_handler.stop();
System.exit(1);
}
}
};
thread.start();
return thread;
}