当前位置: 首页>>代码示例>>Java>>正文


Java AMCommand.AM_SHUTDOWN属性代码示例

本文整理汇总了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;
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:59,代码来源:MasterServer.java

示例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;
}
 
开发者ID:yahoo,项目名称:storm-yarn,代码行数:59,代码来源:MasterServer.java


注:本文中的org.apache.hadoop.yarn.api.records.AMCommand.AM_SHUTDOWN属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。