當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。