本文整理汇总了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));
}
}
}
示例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));
}
}
}