@Override public List<NodeToAttributes> getNodeToAttributes(Set<String> prefix) { try { readLock.lock(); List<NodeToAttributes> nodeToAttributes = new ArrayList<>(); nodeCollections.forEach((k, v) -> { List<NodeAttribute> attrs; if (prefix == null || prefix.isEmpty()) { attrs = new ArrayList<>(v.getAttributes().keySet()); } else { attrs = new ArrayList<>(); for (Entry<NodeAttribute, AttributeValue> nodeAttr : v.attributes .entrySet()) { if (prefix.contains( nodeAttr.getKey().getAttributeKey().getAttributePrefix())) { attrs.add(nodeAttr.getKey()); } } } nodeToAttributes.add(NodeToAttributes.newInstance(k, attrs)); }); return nodeToAttributes; } finally { readLock.unlock(); } }
.put(node, NodeToAttributes.newInstance(node, attributesList));
protected void handleStoreEvent(NodeAttributesStoreEvent event) { List<NodeToAttributes> mappingList = new ArrayList<>(); Map<String, Map<NodeAttribute, AttributeValue>> nodeToAttr = event.getNodeAttributeMappingList(); nodeToAttr.forEach((k, v) -> mappingList .add(NodeToAttributes.newInstance(k, new ArrayList<>(v.keySet())))); try { switch (event.getOperation()) { case REPLACE: store.replaceNodeAttributes(mappingList); break; case ADD: store.addNodeAttributes(mappingList); break; case REMOVE: store.removeNodeAttributes(mappingList); break; default: LOG.warn("Unsupported operation"); } } catch (IOException e) { LOG.error("Failed to store attribute modification to storage"); throw new YarnRuntimeException(e); } }
NodesToAttributesMappingRequest .newInstance(AttributeMappingOperationType.ADD, ImmutableList.of(NodeToAttributes.newInstance("host1", ImmutableList.of(NodeAttribute.newInstance( NodeAttribute.PREFIX_CENTRALIZED, "x", NodesToAttributesMappingRequest .newInstance(AttributeMappingOperationType.REMOVE, ImmutableList.of(NodeToAttributes.newInstance("host4", ImmutableList.of(NodeAttribute.newInstance( NodeAttribute.PREFIX_CENTRALIZED, "x", NodesToAttributesMappingRequest .newInstance(AttributeMappingOperationType.ADD, ImmutableList.of(NodeToAttributes.newInstance("host5", ImmutableList.of(NodeAttribute.newInstance( NodeAttribute.PREFIX_CENTRALIZED, "x", NodesToAttributesMappingRequest .newInstance(AttributeMappingOperationType.ADD, ImmutableList.of( NodeToAttributes.newInstance("host4:8889", ImmutableList.of(NodeAttribute.newInstance( NodeAttribute.PREFIX_CENTRALIZED, "x", NodeAttributeType.STRING, "dfasdf"))), NodeToAttributes.newInstance("host2:8889", ImmutableList.of(NodeAttribute.newInstance( NodeAttribute.PREFIX_CENTRALIZED, "x", NodesToAttributesMappingRequest