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


Java RuntimeSpecification.getName方法代码示例

本文整理汇总了Java中org.apache.twill.api.RuntimeSpecification.getName方法的典型用法代码示例。如果您正苦于以下问题:Java RuntimeSpecification.getName方法的具体用法?Java RuntimeSpecification.getName怎么用?Java RuntimeSpecification.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.twill.api.RuntimeSpecification的用法示例。


在下文中一共展示了RuntimeSpecification.getName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addContainerRequests

import org.apache.twill.api.RuntimeSpecification; //导入方法依赖的package包/类
/**
 * Adds container requests with the given resource capability for each runtime.
 */
private void addContainerRequests(Resource capability,
                                  Collection<RuntimeSpecification> runtimeSpecs,
                                  Queue<ProvisionRequest> provisioning,
                                  AllocationSpecification.Type allocationType) {
  for (RuntimeSpecification runtimeSpec : runtimeSpecs) {
    String name = runtimeSpec.getName();
    int newContainers = expectedContainers.getExpected(name) - runningContainers.count(name);
    if (newContainers > 0) {
      if (allocationType.equals(AllocationSpecification.Type.ALLOCATE_ONE_INSTANCE_AT_A_TIME)) {
        //Spawning 1 instance at a time
        newContainers = 1;
      }

      // TODO: Allow user to set priority?
      LOG.info("Request {} containers with capability {} for runnable {}", newContainers, capability, name);
      YarnAMClient.ContainerRequestBuilder builder = amClient.addContainerRequest(capability, newContainers);
      builder.setPriority(0);

      TwillSpecification.PlacementPolicy placementPolicy = placementPolicyManager.getPlacementPolicy(name);
      if (placementPolicy != null) {
        builder.addHosts(placementPolicy.getHosts())
               .addRacks(placementPolicy.getRacks());
      }

      String requestId = builder.apply();
      provisioning.add(new ProvisionRequest(runtimeSpec, requestId, newContainers, allocationType));
    }
  }
}
 
开发者ID:apache,项目名称:twill,代码行数:33,代码来源:ApplicationMasterService.java

示例2: addContainerRequests

import org.apache.twill.api.RuntimeSpecification; //导入方法依赖的package包/类
/**
 * Adds container requests with the given resource capability for each runtime.
 */
private void addContainerRequests(Resource capability,
                                  Collection<RuntimeSpecification> runtimeSpecs,
                                  Queue<ProvisionRequest> provisioning,
                                  AllocationSpecification.Type allocationType) {
  for (RuntimeSpecification runtimeSpec : runtimeSpecs) {
    String name = runtimeSpec.getName();
    int newContainers = expectedContainers.getExpected(name) - runningContainers.count(name);
    if (newContainers > 0) {
      if (allocationType.equals(AllocationSpecification.Type.ALLOCATE_ONE_INSTANCE_AT_A_TIME)) {
        //Spawning 1 instance at a time
        newContainers = 1;
      }
      TwillSpecification.PlacementPolicy placementPolicy = placementPolicyManager.getPlacementPolicy(name);
      Set<String> hosts = Sets.newHashSet();
      Set<String> racks = Sets.newHashSet();
      if (placementPolicy != null) {
        hosts = placementPolicy.getHosts();
        racks = placementPolicy.getRacks();
      }
      // TODO: Allow user to set priority?
      LOG.info("Request {} container with capability {} for runnable {}", newContainers, capability, name);
      String requestId = amClient.addContainerRequest(capability, newContainers)
              .addHosts(hosts)
              .addRacks(racks)
              .setPriority(0).apply();
      provisioning.add(new ProvisionRequest(runtimeSpec, requestId, newContainers, allocationType));
    }
  }
}
 
开发者ID:chtyim,项目名称:incubator-twill,代码行数:33,代码来源:ApplicationMasterService.java


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