newNodeToLabels.getNodeToLabels().entrySet()) { nodeIdToLabels.put(ConverterUtils.toNodeIdWithDefaultPort(nitle.getKey()), new HashSet<String>(nitle.getValue().getNodeLabels()));
response.getType().toString()); nlsifo = response.getEntity(NodeLabelsInfo.class); assertEquals(1, nlsifo.getNodeLabels().size()); for (NodeLabelInfo nl : nlsifo.getNodeLabelsInfo()) { assertEquals("a", nl.getName()); response.getType().toString()); nlsifo = response.getEntity(NodeLabelsInfo.class); assertEquals(2, nlsifo.getNodeLabels().size()); 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()); nlsifo = response.getEntity(NodeLabelsInfo.class); assertEquals(2, nlsifo.getNodeLabels().size()); response.getType().toString()); nlsifo = response.getEntity(NodeLabelsInfo.class); assertEquals(1, nlsifo.getNodeLabels().size()); for (NodeLabelInfo nl : nlsifo.getNodeLabelsInfo()) { assertEquals("a", nl.getName()); response.getType().toString()); nlsifo = response.getEntity(NodeLabelsInfo.class); assertEquals(0, nlsifo.getNodeLabels().size());
@POST @Path("/remove-node-labels") @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public Response removeFromCluserNodeLabels(final NodeLabelsInfo oldNodeLabels, @Context HttpServletRequest hsr) throws Exception { init(); UserGroupInformation callerUGI = getCallerUserGroupInformation(hsr, true); if (callerUGI == null) { String msg = "Unable to obtain user name, user not authenticated for" + " post to .../remove-node-labels"; throw new AuthorizationException(msg); } if (!rm.getRMContext().getNodeLabelManager().checkAccess(callerUGI)) { String msg = "User " + callerUGI.getShortUserName() + " not authorized" + " for post to .../remove-node-labels "; throw new AuthorizationException(msg); } rm.getRMContext().getNodeLabelManager() .removeFromClusterNodeLabels(new HashSet<String>( oldNodeLabels.getNodeLabels())); return Response.status(Status.OK).build(); }
Set<String>>(); newLabelsForNode.put(nid, new HashSet<String>(newNodeLabelsInfo.getNodeLabels()));
Set<String>>(); newLabelsForNode.put(nid, new HashSet<String>(newNodeLabelsInfo.getNodeLabels()));
newNodeToLabels.getNodeToLabels().entrySet()) { nodeIdToLabels.put(ConverterUtils.toNodeIdWithDefaultPort(nitle.getKey()), new HashSet<String>(nitle.getValue().getNodeLabels()));
@POST @Path("/add-node-labels") @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public Response addToClusterNodeLabels(final NodeLabelsInfo newNodeLabels, @Context HttpServletRequest hsr) throws Exception { init(); UserGroupInformation callerUGI = getCallerUserGroupInformation(hsr, true); if (callerUGI == null) { String msg = "Unable to obtain user name, user not authenticated for" + " post to .../add-node-labels"; throw new AuthorizationException(msg); } if (!rm.getRMContext().getNodeLabelManager().checkAccess(callerUGI)) { String msg = "User " + callerUGI.getShortUserName() + " not authorized" + " for post to .../add-node-labels "; throw new AuthorizationException(msg); } rm.getRMContext().getNodeLabelManager() .addToCluserNodeLabels(new HashSet<String>( newNodeLabels.getNodeLabels())); return Response.status(Status.OK).build(); }
@POST @Path("/remove-node-labels") @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public Response removeFromCluserNodeLabels(final NodeLabelsInfo oldNodeLabels, @Context HttpServletRequest hsr) throws Exception { init(); UserGroupInformation callerUGI = getCallerUserGroupInformation(hsr, true); if (callerUGI == null) { String msg = "Unable to obtain user name, user not authenticated for" + " post to .../remove-node-labels"; throw new AuthorizationException(msg); } if (!rm.getRMContext().getNodeLabelManager().checkAccess(callerUGI)) { String msg = "User " + callerUGI.getShortUserName() + " not authorized" + " for post to .../remove-node-labels "; throw new AuthorizationException(msg); } rm.getRMContext().getNodeLabelManager() .removeFromClusterNodeLabels(new HashSet<String>( oldNodeLabels.getNodeLabels())); return Response.status(Status.OK).build(); }
@POST @Path("/add-node-labels") @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public Response addToClusterNodeLabels(final NodeLabelsInfo newNodeLabels, @Context HttpServletRequest hsr) throws Exception { init(); UserGroupInformation callerUGI = getCallerUserGroupInformation(hsr, true); if (callerUGI == null) { String msg = "Unable to obtain user name, user not authenticated for" + " post to .../add-node-labels"; throw new AuthorizationException(msg); } if (!rm.getRMContext().getNodeLabelManager().checkAccess(callerUGI)) { String msg = "User " + callerUGI.getShortUserName() + " not authorized" + " for post to .../add-node-labels "; throw new AuthorizationException(msg); } rm.getRMContext().getNodeLabelManager() .addToCluserNodeLabels(new HashSet<String>( newNodeLabels.getNodeLabels())); return Response.status(Status.OK).build(); }
@POST @Path(RMWSConsts.ADD_NODE_LABELS) @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) @Override public Response addToClusterNodeLabels(final NodeLabelsInfo newNodeLabels, @Context HttpServletRequest hsr) throws Exception { UserGroupInformation callerUGI = getCallerUserGroupInformation(hsr, true); initForWritableEndpoints(callerUGI, false); if (!rm.getRMContext().getNodeLabelManager().checkAccess(callerUGI)) { String msg = "User " + callerUGI.getShortUserName() + " not authorized" + " for post to .../add-node-labels "; throw new AuthorizationException(msg); } try { rm.getRMContext().getNodeLabelManager() .addToCluserNodeLabels(newNodeLabels.getNodeLabels()); } catch (IOException e) { throw new BadRequestException(e); } return Response.status(Status.OK).build(); }
nli.getNodeLabels().add("a"); ntli.getNodeToLabels().put("nid:0", nli); response = ntli = response.getEntity(NodeToLabelsInfo.class); nli = ntli.getNodeToLabels().get("nid:0"); assertEquals(1, nli.getNodeLabels().size()); assertTrue(nli.getNodeLabels().contains("a"));