@GET @Path("/get-node-to-labels") @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public NodeToLabelsInfo getNodeToLabels(@Context HttpServletRequest hsr) throws IOException { init(); NodeToLabelsInfo ntl = new NodeToLabelsInfo(); HashMap<String, NodeLabelsInfo> ntlMap = ntl.getNodeToLabels(); Map<NodeId, Set<String>> nodeIdToLabels = rm.getRMContext().getNodeLabelManager().getNodeLabels(); for (Map.Entry<NodeId, Set<String>> nitle : nodeIdToLabels.entrySet()) { ntlMap.put(nitle.getKey().toString(), new NodeLabelsInfo(nitle.getValue())); } return ntl; }
newNodeToLabels.getNodeToLabels().entrySet()) { nodeIdToLabels.put(ConverterUtils.toNodeIdWithDefaultPort(nitle.getKey()), new HashSet<String>(nitle.getValue().getNodeLabels()));
newNodeToLabels.getNodeToLabels().entrySet()) { nodeIdToLabels.put(ConverterUtils.toNodeIdWithDefaultPort(nitle.getKey()), new HashSet<String>(nitle.getValue().getNodeLabels()));
@GET @Path("/get-node-to-labels") @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public NodeToLabelsInfo getNodeToLabels(@Context HttpServletRequest hsr) throws IOException { init(); NodeToLabelsInfo ntl = new NodeToLabelsInfo(); HashMap<String, NodeLabelsInfo> ntlMap = ntl.getNodeToLabels(); Map<NodeId, Set<String>> nodeIdToLabels = rm.getRMContext().getNodeLabelManager().getNodeLabels(); for (Map.Entry<NodeId, Set<String>> nitle : nodeIdToLabels.entrySet()) { ntlMap.put(nitle.getKey().toString(), new NodeLabelsInfo(nitle.getValue())); } return ntl; }
response.getType().toString()); NodeToLabelsInfo ntlinfo = response.getEntity(NodeToLabelsInfo.class); NodeLabelsInfo nlinfo = ntlinfo.getNodeToLabels().get("nid:0"); assertEquals(1, nlinfo.getNodeLabels().size()); assertTrue(nlinfo.getNodeLabelsInfo().contains(new NodeLabelInfo("a"))); response.getType().toString()); ntlinfo = response.getEntity(NodeToLabelsInfo.class); nlinfo = ntlinfo.getNodeToLabels().get("nid:0"); assertEquals(1, nlinfo.getNodeLabels().size()); assertFalse(nlinfo.getNodeLabelsInfo().contains( response.getType().toString()); ntlinfo = response.getEntity(NodeToLabelsInfo.class); nlinfo = ntlinfo.getNodeToLabels().get("nid:0"); assertEquals(1, nlinfo.getNodeLabels().size()); assertFalse(nlinfo.getNodeLabelsInfo().contains(
@GET @Path(RMWSConsts.GET_NODE_TO_LABELS) @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) @Override public NodeToLabelsInfo getNodeToLabels(@Context HttpServletRequest hsr) throws IOException { initForReadableEndpoints(); NodeToLabelsInfo ntl = new NodeToLabelsInfo(); HashMap<String, NodeLabelsInfo> ntlMap = ntl.getNodeToLabels(); Map<NodeId, Set<NodeLabel>> nodeIdToLabels = rm.getRMContext().getNodeLabelManager().getNodeLabelsInfo(); for (Map.Entry<NodeId, Set<NodeLabel>> nitle : nodeIdToLabels.entrySet()) { List<NodeLabel> labels = new ArrayList<NodeLabel>(nitle.getValue()); ntlMap.put(nitle.getKey().toString(), new NodeLabelsInfo(labels)); } return ntl; }
NodeToLabelsInfo ntli = new NodeToLabelsInfo(); NodeLabelsInfo nli = new NodeLabelsInfo(); nli.getNodeLabels().add("a"); ntli.getNodeToLabels().put("nid:0", nli); response = r.path("ws").path("v1").path("cluster") assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); ntli = response.getEntity(NodeToLabelsInfo.class); nli = ntli.getNodeToLabels().get("nid:0"); assertEquals(1, nli.getNodeLabels().size()); assertTrue(nli.getNodeLabels().contains("a"));