public void recordNextNodeUpdateActivities(String nodeId) { if (nodeId == null) { recordNextAvailableNode = true; } else { activeRecordedNodes.add(NodeId.fromString(nodeId)); } }
public ActivitiesInfo getActivitiesInfo(String nodeId) { List<NodeAllocation> allocations; if (nodeId == null) { allocations = lastAvailableNodeActivities; } else { allocations = completedNodeAllocations.get(NodeId.fromString(nodeId)); } return new ActivitiesInfo(allocations, nodeId); }
@Public @Deprecated public static NodeId toNodeId(String nodeIdStr) { return NodeId.fromString(nodeIdStr); }
@Private @InterfaceStability.Unstable public static NodeId toNodeIdWithDefaultPort(String nodeIdStr) { if (nodeIdStr.indexOf(":") < 0) { return NodeId.fromString(nodeIdStr + ":0"); } return NodeId.fromString(nodeIdStr); }
private int updateNodeResource(String nodeIdStr, Resource resource, int overCommitTimeout) throws YarnException, IOException { ResourceManagerAdministrationProtocol adminProtocol = createAdminProtocol(); UpdateNodeResourceRequest request = recordFactory.newRecordInstance(UpdateNodeResourceRequest.class); NodeId nodeId = NodeId.fromString(nodeIdStr); Map<NodeId, ResourceOption> resourceMap = new HashMap<NodeId, ResourceOption>(); resourceMap.put( nodeId, ResourceOption.newInstance(resource, overCommitTimeout)); request.setNodeResourceMap(resourceMap); adminProtocol.updateNodeResource(request); return 0; }
public Map<NodeId, ResourceOption> getNodeResourceMap() { String[] nodes = getNodes(); Map<NodeId, ResourceOption> resourceOptions = new HashMap<NodeId, ResourceOption> (); for (String node : nodes) { NodeId nid = NodeId.fromString(node); int vcores = getVcoresPerNode(node); int memory = getMemoryPerNode(node); int overCommitTimeout = getOverCommitTimeoutPerNode(node); Resource resource = Resources.createResource(memory, vcores); ResourceOption resourceOption = ResourceOption.newInstance(resource, overCommitTimeout); resourceOptions.put(nid, resourceOption); } return resourceOptions; } }
private int updateNodeResource(String nodeIdStr, int memSize, int cores, int overCommitTimeout) throws IOException, YarnException { // check resource value first if (invalidResourceValue(memSize, cores)) { throw new IllegalArgumentException("Invalid resource value: " + "(" + memSize + "," + cores + ") for updateNodeResource."); } // Refresh the nodes ResourceManagerAdministrationProtocol adminProtocol = createAdminProtocol(); UpdateNodeResourceRequest request = recordFactory.newRecordInstance(UpdateNodeResourceRequest.class); NodeId nodeId = NodeId.fromString(nodeIdStr); Resource resource = Resources.createResource(memSize, cores); Map<NodeId, ResourceOption> resourceMap = new HashMap<NodeId, ResourceOption>(); resourceMap.put( nodeId, ResourceOption.newInstance(resource, overCommitTimeout)); request.setNodeResourceMap(resourceMap); adminProtocol.updateNodeResource(request); return 0; }
NodeId nodeId = NodeId.fromString(nodeIdStr); List<NodeReport> nodesReport = client.getNodeReports();
@GET @Path(RMWSConsts.NODES_NODEID) @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) @Override public NodeInfo getNode(@PathParam(RMWSConsts.NODEID) String nodeId) { initForReadableEndpoints(); if (nodeId == null || nodeId.isEmpty()) { throw new NotFoundException("nodeId, " + nodeId + ", is empty or null"); } ResourceScheduler sched = this.rm.getResourceScheduler(); if (sched == null) { throw new NotFoundException("Null ResourceScheduler instance"); } NodeId nid = NodeId.fromString(nodeId); RMNode ni = this.rm.getRMContext().getRMNodes().get(nid); boolean isInactive = false; if (ni == null) { ni = this.rm.getRMContext().getInactiveRMNodes().get(nid); if (ni == null) { throw new NotFoundException("nodeId, " + nodeId + ", is not found"); } isInactive = true; } NodeInfo nodeInfo = new NodeInfo(ni, sched); if (isInactive) { nodeInfo.setNodeHTTPAddress(RMWSConsts.EMPTY); } return nodeInfo; }
/** * Verify and parse NodeId. * @param html the html * @param nodeIdStr the nodeId string * @return the {@link NodeId} */ public static NodeId verifyAndGetNodeId(Block html, String nodeIdStr) { if (nodeIdStr == null || nodeIdStr.isEmpty()) { html.h1().__("Cannot get container logs without a NodeId").__(); return null; } NodeId nodeId = null; try { nodeId = NodeId.fromString(nodeIdStr); } catch (IllegalArgumentException e) { html.h1().__("Cannot get container logs. Invalid nodeId: " + nodeIdStr) .__(); return null; } return nodeId; }
NodeId nodeId = NodeId.fromString(nodeIdStr); List<NodeReport> nodesReport = client.getNodeReports();
atm.addContainer(NodeId.fromString("host1:123"), TestUtils.getMockContainerId(1, 1), ImmutableSet.of("mapper", "reducer")); atm.addContainer(NodeId.fromString("host2:123"), TestUtils.getMockContainerId(1, 2), ImmutableSet.of("mapper", "reducer")); atm.addContainer(NodeId.fromString("host1:123"), TestUtils.getMockContainerId(1, 3), ImmutableSet.of("service")); atm.addContainer(NodeId.fromString("host2:123"), TestUtils.getMockContainerId(1, 4), ImmutableSet.of("reducer")); atm.addContainer(NodeId.fromString("host2:123"), TestUtils.getMockContainerId(2, 3), ImmutableSet.of("service")); atm.removeContainer(NodeId.fromString("host1:123"), TestUtils.getMockContainerId(1, 1), ImmutableSet.of("mapper", "reducer")); atm.removeContainer(NodeId.fromString("host2:123"), TestUtils.getMockContainerId(1, 2), ImmutableSet.of("mapper", "reducer")); atm.removeContainer(NodeId.fromString("host1:123"), TestUtils.getMockContainerId(1, 3), ImmutableSet.of("service")); atm.removeContainer(NodeId.fromString("host2:123"),
atm.addContainer(NodeId.fromString("host1:123"), TestUtils.getMockContainerId(1, 1), ImmutableSet.of("mapper", "reducer")); atm.addContainer(NodeId.fromString("host2:123"), TestUtils.getMockContainerId(1, 2), ImmutableSet.of("mapper", "reducer")); atm.addContainer(NodeId.fromString("host1:123"), TestUtils.getMockContainerId(1, 3), ImmutableSet.of("service")); atm.addContainer(NodeId.fromString("host2:123"), TestUtils.getMockContainerId(1, 4), ImmutableSet.of("reducer")); atm.addContainer(NodeId.fromString("host2:123"), TestUtils.getMockContainerId(2, 3), ImmutableSet.of("service")); atm.getNodeCardinalityByOp(NodeId.fromString("host2:123"), AllocationTags.createSingleAppAllocationTags( TestUtils.getMockApplicationId(2),
@Test public void testMultipleAddRemoveContainer() { AllocationTagsManager atm = new AllocationTagsManager(rmContext); NodeId nodeId = NodeId.fromString("host1:123"); ContainerId cid1 = TestUtils.getMockContainerId(1, 1); ContainerId cid2 = TestUtils.getMockContainerId(1, 2); ContainerId cid3 = TestUtils.getMockContainerId(1, 3); Set<String> tags1 = ImmutableSet.of("mapper", "reducer"); Set<String> tags2 = ImmutableSet.of("mapper"); Set<String> tags3 = ImmutableSet.of("zk"); // node - mapper : 2 // - reduce : 1 atm.addContainer(nodeId, cid1, tags1); atm.addContainer(nodeId, cid2, tags2); atm.addContainer(nodeId, cid3, tags3); Assert.assertEquals(2L, (long) atm.getAllocationTagsWithCount(nodeId).get("mapper")); Assert.assertEquals(1L, (long) atm.getAllocationTagsWithCount(nodeId).get("reducer")); // remove container1 atm.removeContainer(nodeId, cid1, tags1); Assert.assertEquals(1L, (long) atm.getAllocationTagsWithCount(nodeId).get("mapper")); Assert.assertNull(atm.getAllocationTagsWithCount(nodeId).get("reducer")); // remove the same container again, the reducer no longer exists, // make sure there is no NPE here atm.removeContainer(nodeId, cid1, tags1); Assert.assertNull(atm.getAllocationTagsWithCount(nodeId).get("mapper")); Assert.assertNull(atm.getAllocationTagsWithCount(nodeId).get("reducer")); }
atm.addContainer(NodeId.fromString("host1:123"), TestUtils.getMockContainerId(1, 1), ImmutableSet.of("mapper", "reducer")); atm.addContainer(NodeId.fromString("host2:123"), TestUtils.getMockContainerId(2, 2), ImmutableSet.of("mapper", "reducer")); atm.addContainer(NodeId.fromString("host1:123"), TestUtils.getMockContainerId(2, 4), ImmutableSet.of("reducer")); atm.addContainer(NodeId.fromString("host2:123"), TestUtils.getMockContainerId(1, 3), ImmutableSet.of("service")); atm.addContainer(NodeId.fromString("host2:123"), TestUtils.getMockContainerId(2, 3), ImmutableSet.of("service"));
TestUtils.getMockNode("host1", "/rack1", 123, 1024)); verify(spyAllocationTagsManager, Mockito.times(1)).getNodeCardinalityByOp( eq(NodeId.fromString("host1:123")), any(AllocationTags.class), any(LongBinaryOperator.class)); TestUtils.getMockNode("host1", "/rack1", 123, 1024)); verify(spyAllocationTagsManager, Mockito.atLeast(1)).getNodeCardinalityByOp( eq(NodeId.fromString("host1:123")), any(AllocationTags.class), any(LongBinaryOperator.class)); when(node1.getNodeID()).thenReturn(NodeId.fromString("host1:123")); when(node1.getNodeID()).thenReturn(NodeId.fromString("host2:123")); Assert.assertFalse(allocator .precheckNode(node2, SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY));
NodeId nid = NodeId.fromString("h1:1234"); RMNode ni = rm.getRMContext().getRMNodes().get(nid); Resource resource = ni.getTotalCapability();
NodeId nid = NodeId.fromString("h1:1234"); RMNode ni = rm.getRMContext().getRMNodes().get(nid); Resource resource = ni.getTotalCapability();
NodeId nid = NodeId.fromString("h1:1234"); RMNode ni = rm.getRMContext().getRMNodes().get(nid); Resource resource = ni.getTotalCapability();
NodeId nid = NodeId.fromString("h1:1234"); RMNode ni = rm.getRMContext().getRMNodes().get(nid); Resource resource = ni.getTotalCapability();