@Override public void write(OutputStream os, NodeAttributesManager mgr) throws IOException { ((NodesToAttributesMappingRequestPBImpl) NodesToAttributesMappingRequest .newInstance(AttributeMappingOperationType.ADD, attributes, false)) .getProto().writeDelimitedTo(os); }
protected Map<String, Set<NodeAttribute>> getNodeToAttributesMap( NodesToAttributesMappingRequest request) { List<NodeToAttributes> attributes = request.getNodesToAttributes(); Map<String, Set<NodeAttribute>> nodeToAttrMap = new HashMap<>(); attributes.forEach((v) -> nodeToAttrMap .put(v.getNode(), new HashSet<>(v.getNodeAttributes()))); return nodeToAttrMap; } }
public static NodesToAttributesMappingRequest newInstance( AttributeMappingOperationType operation, List<NodeToAttributes> nodesToAttributes, boolean failOnUnknownNodes) { NodesToAttributesMappingRequest request = Records.newRecord(NodesToAttributesMappingRequest.class); request.setNodesToAttributes(nodesToAttributes); request.setFailOnUnknownNodes(failOnUnknownNodes); request.setOperation(operation); return request; }
(NodesToAttributesMappingRequest) obj; if (getNodesToAttributes() == null) { if (other.getNodesToAttributes() != null) { return false; .containsAll(other.getNodesToAttributes())) { return false; if (other.getOperation() != null) { return false; } else if (!getOperation().equals(other.getOperation())) { return false; return getFailOnUnknownNodes() == other.getFailOnUnknownNodes();
List<NodeToAttributes> nodesToAttributes = request.getNodesToAttributes(); boolean failOnUnknownNodes = request.getFailOnUnknownNodes(); Map<String, Set<NodeAttribute>> nodeAttributeMapping = validateAndFetch(nodesToAttributes, failOnUnknownNodes); switch (request.getOperation()) { case ADD: nodeAttributesManager.addNodeAttributes(nodeAttributeMapping); break; default: throw new IOException("Invalid operation " + request.getOperation() + " specified in the mapAttributesToNodes request ");
@Override public void write(OutputStream os, NodeAttributesManager mgr) throws IOException { ((NodesToAttributesMappingRequestPBImpl) NodesToAttributesMappingRequest .newInstance(AttributeMappingOperationType.REMOVE, attributes, false)) .getProto().writeDelimitedTo(os); }
@Override public void write(OutputStream os, NodeAttributesManager mgr) throws IOException { ((NodesToAttributesMappingRequestPBImpl) NodesToAttributesMappingRequest .newInstance(AttributeMappingOperationType.REPLACE, attributes, false)) .getProto().writeDelimitedTo(os); }
@Override public void write(OutputStream os, NodeAttributesManager mgr) throws IOException { ((NodesToAttributesMappingRequestPBImpl) NodesToAttributesMappingRequest .newInstance(AttributeMappingOperationType.REPLACE, mgr.getNodeToAttributes( ImmutableSet.of(NodeAttribute.PREFIX_CENTRALIZED)), false)) .getProto().writeDelimitedTo(os); }
public int handleCommand(CommandLine cliParser) throws IOException, YarnException { String operation = null; if (cliParser.hasOption(ADD)) { operation = ADD; } else if (cliParser.hasOption(REMOVE)) { operation = REMOVE; } else if (cliParser.hasOption(REPLACE)) { operation = REPLACE; } if (operation != null) { List<NodeToAttributes> buildNodeLabelsListFromStr = buildNodeLabelsListFromStr(cliParser.getOptionValue(operation), !operation.equals(REPLACE), operation); NodesToAttributesMappingRequest request = NodesToAttributesMappingRequest.newInstance( AttributeMappingOperationType.valueOf(operation.toUpperCase()), buildNodeLabelsListFromStr, cliParser.hasOption(FAILUNKNOWNNODES)); ResourceManagerAdministrationProtocol adminProtocol = createAdminProtocol(); adminProtocol.mapAttributesToNodes(request); } else { // Handle case for only failOnUnknownNodes passed throw new IllegalArgumentException( getOptions().getOption(FAILUNKNOWNNODES).getDescription()); } return 0; }
.newInstance(AttributeMappingOperationType.ADD, ImmutableList.of(NodeToAttributes.newInstance("host1", ImmutableList.of(NodeAttribute.newInstance( .newInstance(AttributeMappingOperationType.REMOVE, ImmutableList.of(NodeToAttributes.newInstance("host4", ImmutableList.of(NodeAttribute.newInstance( .newInstance(AttributeMappingOperationType.ADD, ImmutableList.of(NodeToAttributes.newInstance("host5", ImmutableList.of(NodeAttribute.newInstance( .newInstance(AttributeMappingOperationType.ADD, ImmutableList.of( NodeToAttributes.newInstance("host4:8889", ImmutableList.of(NodeAttribute.newInstance( .newInstance(AttributeMappingOperationType.REPLACE, ImmutableList.of(NodeToAttributes.newInstance("host5", ImmutableList.of(NodeAttribute.newInstance( .newInstance(AttributeMappingOperationType.ADD, ImmutableList.of(NodeToAttributes.newInstance("host5", ImmutableList.of(NodeAttribute.newInstance(