public Container createContainer(Resource capability, Priority priority, String hostname, int port, String nodeHttpAddress) { ContainerId containerId = ContainerId.newContainerId(customAppAttemptId, nextId.getAndIncrement()); NodeId nodeId = NodeId.newInstance(hostname, port); Container container = Container.newInstance(containerId, nodeId, nodeHttpAddress, capability, priority, null); return container; } }
private static NodeReport constructNodeReport(LlapServiceInstance serviceInstance, boolean healthy) { NodeReport nodeReport = NodeReport.newInstance(NodeId .newInstance(serviceInstance.getHost(), serviceInstance.getRpcPort()), healthy ? NodeState.RUNNING : NodeState.LOST, serviceInstance.getServicesAddress(), null, null, null, 0, "", 0l); return nodeReport; }
private static Container mockContainer(String host, int port, int containerId, Resource resource) { Container mockContainer = mock(Container.class); NodeId mockNodeId = NodeId.newInstance(host, port); ContainerId mockContainerId = ContainerId.newInstance( ApplicationAttemptId.newInstance( ApplicationId.newInstance(System.currentTimeMillis(), 1), 1 ), containerId ); when(mockContainer.getId()).thenReturn(mockContainerId); when(mockContainer.getNodeId()).thenReturn(mockNodeId); when(mockContainer.getResource()).thenReturn(resource); when(mockContainer.getPriority()).thenReturn(Priority.UNDEFINED); return mockContainer; }
1), i)); when(mockContainer.getNodeId()).thenReturn(NodeId.newInstance("container", 1234)); containerList.add(mockContainer);
private Map<String, Host> cloneNodeMap() { Set<NodeId> nodesToCopy = new HashSet<NodeId>(); for (String nodeName : nodeCollections.keySet()) { nodesToCopy.add(NodeId.newInstance(nodeName, WILDCARD_PORT)); } return cloneNodeMap(nodesToCopy); }
private NodeId buildNodeId(InetSocketAddress connectAddress, String hostOverride) { if (hostOverride != null) { connectAddress = NetUtils.getConnectAddress( new InetSocketAddress(hostOverride, connectAddress.getPort())); } return NodeId.newInstance( connectAddress.getAddress().getCanonicalHostName(), connectAddress.getPort()); }
private NodeId buildNodeId(InetSocketAddress connectAddress, String hostOverride) { if (hostOverride != null) { connectAddress = NetUtils.getConnectAddress( new InetSocketAddress(hostOverride, connectAddress.getPort())); } return NodeId.newInstance( connectAddress.getAddress().getCanonicalHostName(), connectAddress.getPort()); }
private Map<String, Host> cloneNodeMap() { Set<NodeId> nodesToCopy = new HashSet<NodeId>(); for (String nodeName : nodeCollections.keySet()) { nodesToCopy.add(NodeId.newInstance(nodeName, WILDCARD_PORT)); } return cloneNodeMap(nodesToCopy); }
private NodeId buildNodeId(InetSocketAddress connectAddress, String hostOverride) { if (hostOverride != null) { connectAddress = NetUtils.getConnectAddress( new InetSocketAddress(hostOverride, connectAddress.getPort())); } return NodeId.newInstance( connectAddress.getAddress().getCanonicalHostName(), connectAddress.getPort()); }
private Map<String, Host> cloneNodeMap() { Set<NodeId> nodesToCopy = new HashSet<NodeId>(); for (String nodeName : nodeCollections.keySet()) { nodesToCopy.add(NodeId.newInstance(nodeName, WILDCARD_PORT)); } return cloneNodeMap(nodesToCopy); }
public NodeId toNodeId(String str) { if (str.contains(":")) { int idx = str.indexOf(':'); NodeId id = NodeId.newInstance(str.substring(0, idx), Integer.parseInt(str.substring(idx + 1))); return id; } else { return NodeId.newInstance(str, CommonNodeLabelsManager.WILDCARD_PORT); } }
public NodeId toNodeId(String str) { if (str.contains(":")) { int idx = str.indexOf(':'); NodeId id = NodeId.newInstance(str.substring(0, idx), Integer.parseInt(str.substring(idx + 1))); return id; } else { return NodeId.newInstance(str, CommonNodeLabelsManager.WILDCARD_PORT); } }
private static Container createMockContainer() { Container container = mock(Container.class); NodeId nodeId = NodeId.newInstance("foo.bar.org", 1234); when(container.getNodeId()).thenReturn(nodeId); return container; }
private void complexNodeLabelMappingToManager() throws IOException { // set node -> label mgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("x", "y", "z")); mgr.addLabelsToNode(ImmutableMap.of(NodeId.newInstance("h1", 0), TestUtils.toSet("x"), NodeId.newInstance("h2", 0), TestUtils.toSet("y"), NodeId.newInstance("h3", 0), TestUtils.toSet("y"), NodeId.newInstance("h4", 0), TestUtils.toSet("z"), NodeId.newInstance("h5", 0), RMNodeLabelsManager.EMPTY_STRING_SET)); }
private static NodeReport constructNodeReport(LlapServiceInstance serviceInstance, boolean healthy) { NodeReport nodeReport = NodeReport.newInstance(NodeId .newInstance(serviceInstance.getHost(), serviceInstance.getRpcPort()), healthy ? NodeState.RUNNING : NodeState.LOST, serviceInstance.getServicesAddress(), null, null, null, 0, "", 0l); return nodeReport; }
private void simpleNodeLabelMappingToManager() throws IOException { // set node -> label mgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("x", "y")); mgr.addLabelsToNode(ImmutableMap.of(NodeId.newInstance("h1", 0), TestUtils.toSet("x"), NodeId.newInstance("h2", 0), TestUtils.toSet("y"))); }
public ContainerId assignContainer(String nodeName, boolean isReduce) { ContainerId containerId = ContainerId.newContainerId(attemptId, nextContainerId++); Priority priority = isReduce ? RMContainerAllocator.PRIORITY_REDUCE : RMContainerAllocator.PRIORITY_MAP; Container container = Container.newInstance(containerId, NodeId.newInstance(nodeName, 1234), nodeName + ":5678", Resource.newInstance(1024, 1), priority, null); containersToAllocate.add(container); return containerId; }
private Token createNewContainerToken(ContainerId contId, String containerManagerAddr) { long currentTime = System.currentTimeMillis(); return MRApp.newContainerToken(NodeId.newInstance("127.0.0.1", 1234), "password".getBytes(), new ContainerTokenIdentifier( contId, containerManagerAddr, "user", Resource.newInstance(1024, 1), currentTime + 10000L, 123, currentTime, Priority.newInstance(0), 0)); }
@Test public void testUnRegisterNodeManagerRequestPBImpl() throws Exception { UnRegisterNodeManagerRequestPBImpl request = new UnRegisterNodeManagerRequestPBImpl(); NodeId nodeId = NodeId.newInstance("host", 1234); request.setNodeId(nodeId); UnRegisterNodeManagerRequestPBImpl copy = new UnRegisterNodeManagerRequestPBImpl( request.getProto()); Assert.assertEquals(nodeId, copy.getNodeId()); }
@Test public void testRegisterNodeManagerRequestWithNullLabels() { RegisterNodeManagerRequest request = RegisterNodeManagerRequest.newInstance( NodeId.newInstance("host", 1234), 1234, Resource.newInstance(0, 0), "version", null, null); // serialze to proto, and get request from proto RegisterNodeManagerRequest request1 = new RegisterNodeManagerRequestPBImpl( ((RegisterNodeManagerRequestPBImpl) request).getProto()); // check labels are coming with no values Assert.assertNull(request1.getNodeLabels()); }