List of usage examples for org.apache.hadoop.yarn.api.records NodeId newInstance
@Public @Stable public static NodeId newInstance(String host, int port)
From source file:tachyon.yarn.ApplicationMasterTest.java
License:Apache License
/** * Tests that the Tachyon worker containers are launched properly. */// w w w . ja v a2 s.c o m @Test public void launchTachyonWorkerContainersTest() throws Exception { Container mockContainer1 = Mockito.mock(Container.class); Container mockContainer2 = Mockito.mock(Container.class); // The containers must be from different hosts because we don't support multiple clients on the // same host. Mockito.when(mockContainer1.getNodeId()).thenReturn(NodeId.newInstance("host1", 0)); Mockito.when(mockContainer2.getNodeId()).thenReturn(NodeId.newInstance("host2", 0)); // Say that the master is allocated so that container offers are assumed to be worker offers mPrivateAccess.getMasterAllocated().countDown(); mPrivateAccess.setMasterContainerAddress("masterAddress"); mPrivateAccess.setOutstandingWorkerContainerRequestsLatch(new CountDownLatch(2)); List<Container> containers = Lists.newArrayList(mockContainer1, mockContainer2); mMaster.onContainersAllocated(containers); Mockito.verify(mNMClient).startContainer(Mockito.same(mockContainer1), Mockito.argThat(getContextMatcher(EXPECTED_WORKER_CONTEXT))); Mockito.verify(mNMClient).startContainer(Mockito.same(mockContainer2), Mockito.argThat(getContextMatcher(EXPECTED_WORKER_CONTEXT))); Assert.assertEquals(containers.size(), mPrivateAccess.getWorkerHosts().size()); }