@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 setIncreasedContainers( List<ContainerResourceIncrease> increasedContainers) { if (increasedContainers == null) return; initLocalIncreasedContainerList(); this.increasedContainers.addAll(increasedContainers); }
private synchronized void initLocalIncreasedContainerList() { if (this.increasedContainers != null) { return; } AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; List<ContainerResourceIncreaseProto> list = p.getIncreasedContainersList(); increasedContainers = new ArrayList<ContainerResourceIncrease>(); for (ContainerResourceIncreaseProto c : list) { increasedContainers.add(convertFromProtoFormat(c)); } }
private synchronized Iterable<ContainerResourceIncreaseProto> getIncreaseProtoIterable( final List<ContainerResourceIncrease> newContainersList) { maybeInitBuilder(); return new Iterable<ContainerResourceIncreaseProto>() { @Override public synchronized Iterator<ContainerResourceIncreaseProto> iterator() { return new Iterator<ContainerResourceIncreaseProto>() { Iterator<ContainerResourceIncrease> iter = newContainersList .iterator(); @Override public synchronized boolean hasNext() { return iter.hasNext(); } @Override public synchronized ContainerResourceIncreaseProto next() { return convertToProtoFormat(iter.next()); } @Override public synchronized void remove() { throw new UnsupportedOperationException(); } }; } }; }
@Override public synchronized List<ContainerResourceIncrease> getIncreasedContainers() { initLocalIncreasedContainerList(); return increasedContainers; }
private synchronized ContainerResourceIncrease convertFromProtoFormat( ContainerResourceIncreaseProto p) { return new ContainerResourceIncreasePBImpl(p); }
private synchronized ContainerResourceIncreaseProto convertToProtoFormat( ContainerResourceIncrease t) { return ((ContainerResourceIncreasePBImpl) t).getProto(); }
/** * Get the list of newly increased containers by <code>ResourceManager</code> */ @Public @Stable public abstract List<ContainerResourceIncrease> getIncreasedContainers();
/** * Set the list of newly increased containers by <code>ResourceManager</code> */ @Private @Unstable public abstract void setIncreasedContainers( List<ContainerResourceIncrease> increasedContainers);
@Override public List<ContainerResourceIncrease> getIncreasedContainers() { return null; }