Search in sources :

Example 1 with NodeStatusUpdater

use of org.apache.hadoop.yarn.server.nodemanager.NodeStatusUpdater in project hadoop by apache.

the class TestDistributedScheduler method setup.

private RequestInterceptor setup(Configuration conf, DistributedScheduler distributedScheduler) {
    NodeStatusUpdater nodeStatusUpdater = Mockito.mock(NodeStatusUpdater.class);
    Mockito.when(nodeStatusUpdater.getRMIdentifier()).thenReturn(12345l);
    NMContainerTokenSecretManager nmContainerTokenSecretManager = new NMContainerTokenSecretManager(conf);
    MasterKey mKey = new MasterKey() {

        @Override
        public int getKeyId() {
            return 1;
        }

        @Override
        public void setKeyId(int keyId) {
        }

        @Override
        public ByteBuffer getBytes() {
            return ByteBuffer.allocate(8);
        }

        @Override
        public void setBytes(ByteBuffer bytes) {
        }
    };
    nmContainerTokenSecretManager.setMasterKey(mKey);
    OpportunisticContainerAllocator containerAllocator = new OpportunisticContainerAllocator(nmContainerTokenSecretManager);
    NMTokenSecretManagerInNM nmTokenSecretManagerInNM = new NMTokenSecretManagerInNM();
    nmTokenSecretManagerInNM.setMasterKey(mKey);
    distributedScheduler.initLocal(1234, ApplicationAttemptId.newInstance(ApplicationId.newInstance(1, 1), 1), containerAllocator, nmTokenSecretManagerInNM, "test");
    RequestInterceptor finalReqIntcptr = Mockito.mock(RequestInterceptor.class);
    distributedScheduler.setNextInterceptor(finalReqIntcptr);
    return finalReqIntcptr;
}
Also used : NMContainerTokenSecretManager(org.apache.hadoop.yarn.server.nodemanager.security.NMContainerTokenSecretManager) MasterKey(org.apache.hadoop.yarn.server.api.records.MasterKey) NodeStatusUpdater(org.apache.hadoop.yarn.server.nodemanager.NodeStatusUpdater) NMTokenSecretManagerInNM(org.apache.hadoop.yarn.server.nodemanager.security.NMTokenSecretManagerInNM) RequestInterceptor(org.apache.hadoop.yarn.server.nodemanager.amrmproxy.RequestInterceptor) ByteBuffer(java.nio.ByteBuffer) OpportunisticContainerAllocator(org.apache.hadoop.yarn.server.scheduler.OpportunisticContainerAllocator)

Example 2 with NodeStatusUpdater

use of org.apache.hadoop.yarn.server.nodemanager.NodeStatusUpdater in project hadoop by apache.

the class TestMiniYarnClusterNodeUtilization method testMockNodeStatusHeartbeat.

/**
   * Trigger the NM to send a heartbeat using the simulated NodeStatus fixture.
   * Verify both the RMNode and SchedulerNode have been updated with the new
   * utilization.
   */
@Test(timeout = 60000)
public void testMockNodeStatusHeartbeat() throws InterruptedException, YarnException {
    assertTrue("NMs fail to connect to the RM", cluster.waitForNodeManagersToConnect(10000));
    NodeStatusUpdater updater = nm.getNodeStatusUpdater();
    updater.sendOutofBandHeartBeat();
    // Give the heartbeat time to propagate to the RM
    verifySimulatedUtilization();
    // Alter utilization
    int responseId = 20;
    nodeStatus = createNodeStatus(nm.getNMContext().getNodeId(), responseId, CONTAINER_PMEM_2, CONTAINER_VMEM_2, CONTAINER_CPU_2, NODE_PMEM_2, NODE_VMEM_2, NODE_CPU_2);
    nm.setNodeStatus(nodeStatus);
    updater.sendOutofBandHeartBeat();
    verifySimulatedUtilization();
}
Also used : NodeStatusUpdater(org.apache.hadoop.yarn.server.nodemanager.NodeStatusUpdater) Test(org.junit.Test)

Aggregations

NodeStatusUpdater (org.apache.hadoop.yarn.server.nodemanager.NodeStatusUpdater)2 ByteBuffer (java.nio.ByteBuffer)1 MasterKey (org.apache.hadoop.yarn.server.api.records.MasterKey)1 RequestInterceptor (org.apache.hadoop.yarn.server.nodemanager.amrmproxy.RequestInterceptor)1 NMContainerTokenSecretManager (org.apache.hadoop.yarn.server.nodemanager.security.NMContainerTokenSecretManager)1 NMTokenSecretManagerInNM (org.apache.hadoop.yarn.server.nodemanager.security.NMTokenSecretManagerInNM)1 OpportunisticContainerAllocator (org.apache.hadoop.yarn.server.scheduler.OpportunisticContainerAllocator)1 Test (org.junit.Test)1