本文整理汇总了Java中org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse.getNumClusterNodes方法的典型用法代码示例。如果您正苦于以下问题:Java AllocateResponse.getNumClusterNodes方法的具体用法?Java AllocateResponse.getNumClusterNodes怎么用?Java AllocateResponse.getNumClusterNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse
的用法示例。
在下文中一共展示了AllocateResponse.getNumClusterNodes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeRemoteRequest
import org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse; //导入方法依赖的package包/类
protected AllocateResponse makeRemoteRequest() throws YarnException,
IOException {
applyRequestLimits();
ResourceBlacklistRequest blacklistRequest =
ResourceBlacklistRequest.newInstance(new ArrayList<String>(blacklistAdditions),
new ArrayList<String>(blacklistRemovals));
AllocateRequest allocateRequest =
AllocateRequest.newInstance(lastResponseID,
super.getApplicationProgress(), new ArrayList<ResourceRequest>(ask),
new ArrayList<ContainerId>(release), blacklistRequest);
AllocateResponse allocateResponse = scheduler.allocate(allocateRequest);
lastResponseID = allocateResponse.getResponseId();
availableResources = allocateResponse.getAvailableResources();
lastClusterNmCount = clusterNmCount;
clusterNmCount = allocateResponse.getNumClusterNodes();
int numCompletedContainers =
allocateResponse.getCompletedContainersStatuses().size();
if (ask.size() > 0 || release.size() > 0) {
LOG.info("getResources() for " + applicationId + ":" + " ask="
+ ask.size() + " release= " + release.size() + " newContainers="
+ allocateResponse.getAllocatedContainers().size()
+ " finishedContainers=" + numCompletedContainers
+ " resourcelimit=" + availableResources + " knownNMs="
+ clusterNmCount);
}
ask.clear();
release.clear();
if (numCompletedContainers > 0) {
// re-send limited requests when a container completes to trigger asking
// for more containers
requestLimitsToUpdate.addAll(requestLimits.keySet());
}
if (blacklistAdditions.size() > 0 || blacklistRemovals.size() > 0) {
LOG.info("Update the blacklist for " + applicationId +
": blacklistAdditions=" + blacklistAdditions.size() +
" blacklistRemovals=" + blacklistRemovals.size());
}
blacklistAdditions.clear();
blacklistRemovals.clear();
return allocateResponse;
}
示例2: allocate
import org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse; //导入方法依赖的package包/类
@Override
public AllocationResponse allocate(float progressIndicator)
throws YarnRemoteException {
AllocateResponse allocateResponse = null;
ArrayList<ResourceRequest> askList = null;
ArrayList<ContainerId> releaseList = null;
AllocateRequest allocateRequest = null;
try {
synchronized (this) {
askList = new ArrayList<ResourceRequest>(ask);
releaseList = new ArrayList<ContainerId>(release);
// optimistically clear this collection assuming no RPC failure
ask.clear();
release.clear();
allocateRequest = BuilderUtils
.newAllocateRequest(appAttemptId, lastResponseId, progressIndicator,
askList, releaseList);
}
allocateResponse = rmClient.allocate(allocateRequest);
AllocationResponse response = AllocationResponses.create(allocateResponse);
synchronized (this) {
// update these on successful RPC
clusterNodeCount = allocateResponse.getNumClusterNodes();
lastResponseId = response.getResponseId();
clusterAvailableResources = response.getAvailableResources();
}
return response;
} finally {
// TODO how to differentiate remote YARN exception vs error in RPC
if (allocateResponse == null) {
// We hit an exception in allocate()
// Preserve ask and release for next call to allocate()
synchronized (this) {
release.addAll(releaseList);
// Requests could have been added or deleted during call to allocate.
// If requests were added/removed then there is nothing to do since
// the ResourceRequest object in ask would have the actual new value.
// If ask does not have this ResourceRequest then it was unchanged and
// so we can add the value back safely.
// This assumes that there will no concurrent calls to allocate() and
// so we don't have to worry about ask being changed in the
// synchronized block at the beginning of this method.
for (ResourceRequest oldAsk : askList) {
if (!ask.contains(oldAsk)) {
ask.add(oldAsk);
}
}
}
}
}
}