Search in sources :

Example 1 with ResourceTracker

use of org.apache.hadoop.yarn.server.api.ResourceTracker in project hadoop by apache.

the class TestResourceTrackerPBClientImpl method start.

@BeforeClass
public static void start() {
    InetSocketAddress address = new InetSocketAddress(0);
    Configuration configuration = new Configuration();
    ResourceTracker instance = new ResourceTrackerTestImpl();
    server = RpcServerFactoryPBImpl.get().getServer(ResourceTracker.class, instance, address, configuration, null, 1);
    server.start();
    client = (ResourceTracker) RpcClientFactoryPBImpl.get().getClient(ResourceTracker.class, 1, NetUtils.getConnectAddress(server), configuration);
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) InetSocketAddress(java.net.InetSocketAddress) ResourceTracker(org.apache.hadoop.yarn.server.api.ResourceTracker) BeforeClass(org.junit.BeforeClass)

Example 2 with ResourceTracker

use of org.apache.hadoop.yarn.server.api.ResourceTracker in project hadoop by apache.

the class TestYSCRPCFactories method testPbServerFactory.

private void testPbServerFactory() {
    InetSocketAddress addr = new InetSocketAddress(0);
    Configuration conf = new Configuration();
    ResourceTracker instance = new ResourceTrackerTestImpl();
    Server server = null;
    try {
        server = RpcServerFactoryPBImpl.get().getServer(ResourceTracker.class, instance, addr, conf, null, 1);
        server.start();
    } catch (YarnRuntimeException e) {
        e.printStackTrace();
        Assert.fail("Failed to create server");
    } finally {
        server.stop();
    }
}
Also used : YarnRuntimeException(org.apache.hadoop.yarn.exceptions.YarnRuntimeException) Configuration(org.apache.hadoop.conf.Configuration) Server(org.apache.hadoop.ipc.Server) InetSocketAddress(java.net.InetSocketAddress) ResourceTracker(org.apache.hadoop.yarn.server.api.ResourceTracker)

Example 3 with ResourceTracker

use of org.apache.hadoop.yarn.server.api.ResourceTracker in project hadoop by apache.

the class TestNodeStatusUpdaterForLabels method testInvalidNodeLabelsFromProvider.

@Test(timeout = 20000)
public void testInvalidNodeLabelsFromProvider() throws InterruptedException, IOException {
    final ResourceTrackerForLabels resourceTracker = new ResourceTrackerForLabels();
    nm = new NodeManager() {

        @Override
        protected NodeLabelsProvider createNodeLabelsProvider(Configuration conf) throws IOException {
            return dummyLabelsProviderRef;
        }

        @Override
        protected NodeStatusUpdater createNodeStatusUpdater(Context context, Dispatcher dispatcher, NodeHealthCheckerService healthChecker, NodeLabelsProvider labelsProvider) {
            return new NodeStatusUpdaterImpl(context, dispatcher, healthChecker, metrics, labelsProvider) {

                @Override
                protected ResourceTracker getRMClient() {
                    return resourceTracker;
                }

                @Override
                protected void stopRMProxy() {
                    return;
                }
            };
        }
    };
    dummyLabelsProviderRef.setNodeLabels(toNodeLabelSet("P"));
    YarnConfiguration conf = createNMConfigForDistributeNodeLabels();
    conf.set(YarnConfiguration.NM_LOCALIZER_ADDRESS, "0.0.0.0:" + ServerSocketUtil.getPort(8040, 10));
    nm.init(conf);
    resourceTracker.resetNMHeartbeatReceiveFlag();
    nm.start();
    // wait till the first heartbeat
    resourceTracker.waitTillHeartbeat();
    resourceTracker.resetNMHeartbeatReceiveFlag();
    // heartbeat with invalid labels
    dummyLabelsProviderRef.setNodeLabels(toNodeLabelSet("_.P"));
    sendOutofBandHeartBeat();
    resourceTracker.waitTillHeartbeat();
    assertNull("On Invalid Labels we need to retain earlier labels, HB " + "needs to send null", resourceTracker.labels);
    resourceTracker.resetNMHeartbeatReceiveFlag();
    // on next heartbeat same invalid labels will be given by the provider, but
    // again label validation check and reset RM with empty labels set should
    // not happen
    sendOutofBandHeartBeat();
    resourceTracker.waitTillHeartbeat();
    assertNull("NodeStatusUpdater need not send repeatedly empty labels on " + "invalid labels from provider ", resourceTracker.labels);
    resourceTracker.resetNMHeartbeatReceiveFlag();
}
Also used : YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) NodeLabelsProvider(org.apache.hadoop.yarn.server.nodemanager.nodelabels.NodeLabelsProvider) ResourceTracker(org.apache.hadoop.yarn.server.api.ResourceTracker) IOException(java.io.IOException) Dispatcher(org.apache.hadoop.yarn.event.Dispatcher) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Test(org.junit.Test)

Example 4 with ResourceTracker

use of org.apache.hadoop.yarn.server.api.ResourceTracker in project hadoop by apache.

the class TestMiniYarnClusterNodeUtilization method testUpdateNodeUtilization.

/**
   * Simulates a NM heartbeat using the simulated NodeStatus fixture. Verify
   * both the RMNode and SchedulerNode have been updated with the new
   * utilization.
   */
@Test(timeout = 60000)
public void testUpdateNodeUtilization() throws InterruptedException, IOException, YarnException {
    assertTrue("NMs fail to connect to the RM", cluster.waitForNodeManagersToConnect(10000));
    // Simulate heartbeat using NodeStatus fixture
    NodeHeartbeatRequest request = NodeHeartbeatRequest.newInstance(nodeStatus, null, null, null);
    ResourceTracker tracker = ServerRMProxy.createRMProxy(conf, ResourceTracker.class);
    tracker.nodeHeartbeat(request);
    // Give the heartbeat time to propagate to the RM
    verifySimulatedUtilization();
    // Alter utilization
    int responseId = 10;
    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);
    tracker.nodeHeartbeat(request);
    // Give the heartbeat time to propagate to the RM
    verifySimulatedUtilization();
}
Also used : ResourceTracker(org.apache.hadoop.yarn.server.api.ResourceTracker) NodeHeartbeatRequest(org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatRequest) Test(org.junit.Test)

Example 5 with ResourceTracker

use of org.apache.hadoop.yarn.server.api.ResourceTracker in project hadoop by apache.

the class TestYSCRPCFactories method testPbClientFactory.

private void testPbClientFactory() {
    InetSocketAddress addr = new InetSocketAddress(0);
    System.err.println(addr.getHostName() + addr.getPort());
    Configuration conf = new Configuration();
    ResourceTracker instance = new ResourceTrackerTestImpl();
    Server server = null;
    try {
        server = RpcServerFactoryPBImpl.get().getServer(ResourceTracker.class, instance, addr, conf, null, 1);
        server.start();
        System.err.println(server.getListenerAddress());
        System.err.println(NetUtils.getConnectAddress(server));
        ResourceTracker client = null;
        try {
            client = (ResourceTracker) RpcClientFactoryPBImpl.get().getClient(ResourceTracker.class, 1, NetUtils.getConnectAddress(server), conf);
        } catch (YarnRuntimeException e) {
            e.printStackTrace();
            Assert.fail("Failed to create client");
        }
    } catch (YarnRuntimeException e) {
        e.printStackTrace();
        Assert.fail("Failed to create server");
    } finally {
        server.stop();
    }
}
Also used : YarnRuntimeException(org.apache.hadoop.yarn.exceptions.YarnRuntimeException) Configuration(org.apache.hadoop.conf.Configuration) Server(org.apache.hadoop.ipc.Server) InetSocketAddress(java.net.InetSocketAddress) ResourceTracker(org.apache.hadoop.yarn.server.api.ResourceTracker)

Aggregations

ResourceTracker (org.apache.hadoop.yarn.server.api.ResourceTracker)6 Configuration (org.apache.hadoop.conf.Configuration)5 InetSocketAddress (java.net.InetSocketAddress)3 Test (org.junit.Test)3 IOException (java.io.IOException)2 Server (org.apache.hadoop.ipc.Server)2 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)2 Dispatcher (org.apache.hadoop.yarn.event.Dispatcher)2 YarnRuntimeException (org.apache.hadoop.yarn.exceptions.YarnRuntimeException)2 NodeLabelsProvider (org.apache.hadoop.yarn.server.nodemanager.nodelabels.NodeLabelsProvider)2 NodeHeartbeatRequest (org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatRequest)1 BeforeClass (org.junit.BeforeClass)1