@Public @Stable public static AllocateResponse newInstance(int responseId, List<ContainerStatus> completedContainers, List<Container> allocatedContainers, List<NodeReport> updatedNodes, Resource availResources, AMCommand command, int numClusterNodes, PreemptionMessage preempt, List<NMToken> nmTokens, List<ContainerResourceIncrease> increasedContainers, List<ContainerResourceDecrease> decreasedContainers) { AllocateResponse response = newInstance(responseId, completedContainers, allocatedContainers, updatedNodes, availResources, command, numClusterNodes, preempt, nmTokens); response.setIncreasedContainers(increasedContainers); response.setDecreasedContainers(decreasedContainers); return response; }
@Private @Unstable public static AllocateResponse newInstance(int responseId, List<ContainerStatus> completedContainers, List<Container> allocatedContainers, List<NodeReport> updatedNodes, Resource availResources, AMCommand command, int numClusterNodes, PreemptionMessage preempt, List<NMToken> nmTokens, Token amRMToken, List<ContainerResourceIncrease> increasedContainers, List<ContainerResourceDecrease> decreasedContainers) { AllocateResponse response = newInstance(responseId, completedContainers, allocatedContainers, updatedNodes, availResources, command, numClusterNodes, preempt, nmTokens, increasedContainers, decreasedContainers); response.setAMRMToken(amRMToken); return response; }
@Override public AllocateResponse allocate(AllocateRequest request) throws YarnException, IOException { Assert.assertEquals("response ID mismatch", responseId, request.getResponseId()); ++responseId; org.apache.hadoop.yarn.api.records.Token yarnToken = null; if (amToken != null) { yarnToken = org.apache.hadoop.yarn.api.records.Token.newInstance( amToken.getIdentifier(), amToken.getKind().toString(), amToken.getPassword(), amToken.getService().toString()); } return AllocateResponse.newInstance(responseId, Collections.<ContainerStatus>emptyList(), Collections.<Container>emptyList(), Collections.<NodeReport>emptyList(), Resources.none(), null, 1, null, Collections.<NMToken>emptyList(), yarnToken, Collections.<ContainerResourceIncrease>emptyList(), Collections.<ContainerResourceDecrease>emptyList()); }
@Override public synchronized void setDecreasedContainers( List<ContainerResourceDecrease> decreasedContainers) { if (decreasedContainers == null) { return; } initLocalDecreasedContainerList(); this.decreasedContainers.addAll(decreasedContainers); }
private synchronized void initLocalDecreasedContainerList() { if (this.decreasedContainers != null) { return; } AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; List<ContainerResourceDecreaseProto> list = p.getDecreasedContainersList(); decreasedContainers = new ArrayList<ContainerResourceDecrease>(); for (ContainerResourceDecreaseProto c : list) { decreasedContainers.add(convertFromProtoFormat(c)); } }
private synchronized Iterable<ContainerResourceDecreaseProto> getChangeProtoIterable( final List<ContainerResourceDecrease> newContainersList) { maybeInitBuilder(); return new Iterable<ContainerResourceDecreaseProto>() { @Override public synchronized Iterator<ContainerResourceDecreaseProto> iterator() { return new Iterator<ContainerResourceDecreaseProto>() { Iterator<ContainerResourceDecrease> iter = newContainersList .iterator(); @Override public synchronized boolean hasNext() { return iter.hasNext(); } @Override public synchronized ContainerResourceDecreaseProto next() { return convertToProtoFormat(iter.next()); } @Override public synchronized void remove() { throw new UnsupportedOperationException(); } }; } }; }
@Override public synchronized List<ContainerResourceDecrease> getDecreasedContainers() { initLocalDecreasedContainerList(); return decreasedContainers; }
private synchronized ContainerResourceDecrease convertFromProtoFormat( ContainerResourceDecreaseProto p) { return new ContainerResourceDecreasePBImpl(p); }
private synchronized ContainerResourceDecreaseProto convertToProtoFormat( ContainerResourceDecrease t) { return ((ContainerResourceDecreasePBImpl) t).getProto(); }
/** * Get the list of newly decreased containers by <code>NodeManager</code> */ @Public @Stable public abstract List<ContainerResourceDecrease> getDecreasedContainers();
/** * Set the list of newly decreased containers by <code>NodeManager</code> */ @Private @Unstable public abstract void setDecreasedContainers( List<ContainerResourceDecrease> decreasedContainers);
@Override public List<ContainerResourceDecrease> getDecreasedContainers() { return null; }