private void mergeLocalToBuilder() { if (this.clusterNodeAttributes != null) { addNodeAttributesToProto(); } }
@Override public synchronized Set<NodeAttributeInfo> getNodeAttributes() { if (this.clusterNodeAttributes != null) { return this.clusterNodeAttributes; } initLocalNodeAttributes(); return this.clusterNodeAttributes; }
private void mergeLocalToProto() { if (viaProto) { maybeInitBuilder(); } mergeLocalToBuilder(); proto = builder.build(); viaProto = true; }
private void addNodeAttributesToProto() { maybeInitBuilder(); builder.clearNodeAttributes(); if (clusterNodeAttributes == null || clusterNodeAttributes.isEmpty()) { return; } builder.addAllNodeAttributes(clusterNodeAttributes.stream() .map(s -> convertToProtoFormat(s)).collect(Collectors.toSet())); }
public synchronized GetClusterNodeAttributesResponseProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; return proto; }
private void initLocalNodeAttributes() { YarnServiceProtos.GetClusterNodeAttributesResponseProtoOrBuilder p = viaProto ? proto : builder; List<NodeAttributeInfoProto> attributesProtoList = p.getNodeAttributesList(); this.clusterNodeAttributes = new HashSet<>(); clusterNodeAttributes.addAll(attributesProtoList.stream() .map(attr -> convertFromProtoFormat(attr)).collect(Collectors.toSet())); }
@Override public synchronized void setNodeAttributes( Set<NodeAttributeInfo> attributes) { maybeInitBuilder(); this.clusterNodeAttributes = new HashSet<>(); if (attributes == null) { builder.clearNodeAttributes(); return; } this.clusterNodeAttributes.addAll(attributes); }
@Override public GetClusterNodeAttributesResponse getClusterNodeAttributes( GetClusterNodeAttributesRequest request) throws YarnException, IOException { YarnServiceProtos.GetClusterNodeAttributesRequestProto requestProto = ((GetClusterNodeAttributesRequestPBImpl) request).getProto(); try { return new GetClusterNodeAttributesResponsePBImpl( proxy.getClusterNodeAttributes(null, requestProto)); } catch (ServiceException e) { RPCUtil.unwrapAndThrowException(e); return null; } }
@Override public String toString() { return getProto().toString(); } }
@Override public GetClusterNodeAttributesResponseProto getClusterNodeAttributes( RpcController controller, YarnServiceProtos.GetClusterNodeAttributesRequestProto proto) throws ServiceException { GetClusterNodeAttributesRequest req = new GetClusterNodeAttributesRequestPBImpl(proto); try { GetClusterNodeAttributesResponse resp = real.getClusterNodeAttributes(req); return ((GetClusterNodeAttributesResponsePBImpl) resp).getProto(); } catch (YarnException ye) { throw new ServiceException(ye); } catch (IOException ie) { throw new ServiceException(ie); } }