private synchronized void initLocalUpdatedContainerList() { if (this.updatedContainers != null) { return; } AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; List<YarnServiceProtos.UpdatedContainerProto> list = p.getUpdatedContainersList(); updatedContainers = new ArrayList<>(); for (YarnServiceProtos.UpdatedContainerProto c : list) { updatedContainers.add(convertFromProtoFormat(c)); } }
@Override public synchronized List<ContainerStatus> getCompletedContainersStatuses() { initLocalFinishedContainerList(); return this.completedContainersStatuses; }
builder.clearAllocatedContainers(); Iterable<ContainerProto> iterable = getContainerProtoIterable(this.allocatedContainers); builder.addAllAllocatedContainers(iterable); Iterable<NMTokenProto> iterable = getTokenProtoIterable(nmTokens); builder.addAllNmTokens(iterable); builder.clearCompletedContainerStatuses(); Iterable<ContainerStatusProto> iterable = getContainerStatusProtoIterable(this.completedContainersStatuses); builder.addAllCompletedContainerStatuses(iterable); builder.clearUpdatedNodes(); Iterable<NodeReportProto> iterable = getNodeReportProtoIterable(this.updatedNodes); builder.addAllUpdatedNodes(iterable); builder.setLimit(convertToProtoFormat(this.limit)); builder.setPreempt(convertToProtoFormat(this.preempt)); getIncreaseProtoIterable(this.increasedContainers); builder.addAllIncreasedContainers(iterable); builder.clearDecreasedContainers(); Iterable<ContainerResourceDecreaseProto> iterable = getChangeProtoIterable(this.decreasedContainers); builder.addAllDecreasedContainers(iterable);
builder.clearAllocatedContainers(); Iterable<ContainerProto> iterable = getContainerProtoIterable(this.allocatedContainers); builder.addAllAllocatedContainers(iterable); Iterable<NMTokenProto> iterable = getTokenProtoIterable(nmTokens); builder.addAllNmTokens(iterable); builder.clearCompletedContainerStatuses(); Iterable<ContainerStatusProto> iterable = getContainerStatusProtoIterable(this.completedContainersStatuses); builder.addAllCompletedContainerStatuses(iterable); builder.clearRejectedSchedulingRequests(); Iterable<YarnProtos.RejectedSchedulingRequestProto> iterable = getRejectedSchedulingRequestsProtoIterable( this.rejectedRequests); builder.addAllRejectedSchedulingRequests(iterable); builder.clearUpdatedNodes(); Iterable<NodeReportProto> iterable = getNodeReportProtoIterable(this.updatedNodes); builder.addAllUpdatedNodes(iterable); builder.setLimit(convertToProtoFormat(this.limit)); builder.setPreempt(convertToProtoFormat(this.preempt)); getUpdatedContainerProtoIterable(this.updatedContainers);
@SuppressWarnings("deprecation") @Test public void testAllocateResponseWithoutIncDecContainers() { AllocateResponse r = AllocateResponse.newInstance(3, new ArrayList<ContainerStatus>(), new ArrayList<Container>(), new ArrayList<NodeReport>(), null, AMCommand.AM_RESYNC, 3, null, new ArrayList<NMToken>(), null, null); // serde AllocateResponseProto p = ((AllocateResponsePBImpl) r).getProto(); r = new AllocateResponsePBImpl(p); // check value Assert.assertEquals(0, r.getIncreasedContainers().size()); Assert.assertEquals(0, r.getDecreasedContainers().size()); } }
@Override public AllocateResponse allocate(AllocateRequest request) throws YarnException, IOException { AllocateRequestProto requestProto = ((AllocateRequestPBImpl) request).getProto(); try { return new AllocateResponsePBImpl(proxy.allocate(null, requestProto)); } catch (ServiceException e) { RPCUtil.unwrapAndThrowException(e); return null; } }
@Test public void testProtoAllocateResponse() { AllocateResponseProto proto = AllocateResponseProto.getDefaultInstance(); AllocateResponsePBImpl alloc = new AllocateResponsePBImpl(proto); List<NMToken> nmTokens = new ArrayList<NMToken>(); try { alloc.setNMTokens(nmTokens); } catch (Exception ex) { fail(); } } }
@Override public synchronized List<Container> getAllocatedContainers() { initLocalNewContainerList(); return this.allocatedContainers; }
builder.clearAllocatedContainers(); Iterable<ContainerProto> iterable = getContainerProtoIterable(this.allocatedContainers); builder.addAllAllocatedContainers(iterable); Iterable<NMTokenProto> iterable = getTokenProtoIterable(nmTokens); builder.addAllNmTokens(iterable); builder.clearCompletedContainerStatuses(); Iterable<ContainerStatusProto> iterable = getContainerStatusProtoIterable(this.completedContainersStatuses); builder.addAllCompletedContainerStatuses(iterable); builder.clearUpdatedNodes(); Iterable<NodeReportProto> iterable = getNodeReportProtoIterable(this.updatedNodes); builder.addAllUpdatedNodes(iterable); builder.setLimit(convertToProtoFormat(this.limit)); builder.setPreempt(convertToProtoFormat(this.preempt)); getIncreaseProtoIterable(this.increasedContainers); builder.addAllIncreasedContainers(iterable); builder.clearDecreasedContainers(); Iterable<ContainerResourceDecreaseProto> iterable = getChangeProtoIterable(this.decreasedContainers); builder.addAllDecreasedContainers(iterable);
AllocateResponseProto p = ((AllocateResponsePBImpl) r).getProto(); r = new AllocateResponsePBImpl(p);
@Override public AllocateResponse allocate(AllocateRequest request) throws YarnException, IOException { AllocateRequestProto requestProto = ((AllocateRequestPBImpl) request).getProto(); try { return new AllocateResponsePBImpl(proxy.allocate(null, requestProto)); } catch (ServiceException e) { RPCUtil.unwrapAndThrowException(e); return null; } }
@Override public synchronized List<Container> getAllocatedContainers() { initLocalNewContainerList(); return this.allocatedContainers; }
private synchronized void initContainersFromPreviousAttemptsList() { if (this.containersFromPreviousAttempts != null) { return; } AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; List<ContainerProto> list = p.getContainersFromPreviousAttemptsList(); containersFromPreviousAttempts = new ArrayList<>(); for (ContainerProto c : list) { containersFromPreviousAttempts.add(convertFromProtoFormat(c)); } }
@Override public AllocateResponse allocate(AllocateRequest request) throws YarnException, IOException { AllocateRequestProto requestProto = ((AllocateRequestPBImpl) request).getProto(); try { return new AllocateResponsePBImpl(proxy.allocate(null, requestProto)); } catch (ServiceException e) { RPCUtil.unwrapAndThrowException(e); return null; } }
@Override public synchronized List<Container> getAllocatedContainers() { initLocalNewContainerList(); return this.allocatedContainers; }
@Override public synchronized List<ContainerStatus> getCompletedContainersStatuses() { initLocalFinishedContainerList(); return this.completedContainersStatuses; }
private synchronized void initLocalNewNMTokenList() { if (nmTokens != null) { return; } AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; List<NMTokenProto> list = p.getNmTokensList(); nmTokens = new ArrayList<NMToken>(); for (NMTokenProto t : list) { nmTokens.add(convertFromProtoFormat(t)); } }