Search in sources :

Example 6 with IncreaseContainersResourceRequest

use of org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceRequest in project hadoop by apache.

the class TestContainerResourceIncreaseRPC method testRPCTimeout.

private void testRPCTimeout(String rpcClass) throws Exception {
    Configuration conf = new Configuration();
    // set timeout low for the test
    conf.setInt("yarn.rpc.nm-command-timeout", 3000);
    conf.set(YarnConfiguration.IPC_RPC_IMPL, rpcClass);
    YarnRPC rpc = YarnRPC.create(conf);
    String bindAddr = "localhost:0";
    InetSocketAddress addr = NetUtils.createSocketAddr(bindAddr);
    Server server = rpc.getServer(ContainerManagementProtocol.class, new DummyContainerManager(), addr, conf, null, 1);
    server.start();
    try {
        ContainerManagementProtocol proxy = (ContainerManagementProtocol) rpc.getProxy(ContainerManagementProtocol.class, server.getListenerAddress(), conf);
        ApplicationId applicationId = ApplicationId.newInstance(0, 0);
        ApplicationAttemptId applicationAttemptId = ApplicationAttemptId.newInstance(applicationId, 0);
        ContainerId containerId = ContainerId.newContainerId(applicationAttemptId, 100);
        NodeId nodeId = NodeId.newInstance("localhost", 1234);
        Resource resource = Resource.newInstance(1234, 2);
        ContainerTokenIdentifier containerTokenIdentifier = new ContainerTokenIdentifier(containerId, "localhost", "user", resource, System.currentTimeMillis() + 10000, 42, 42, Priority.newInstance(0), 0);
        Token containerToken = newContainerToken(nodeId, "password".getBytes(), containerTokenIdentifier);
        // Construct container resource increase request,
        List<Token> increaseTokens = new ArrayList<>();
        increaseTokens.add(containerToken);
        IncreaseContainersResourceRequest increaseRequest = IncreaseContainersResourceRequest.newInstance(increaseTokens);
        try {
            proxy.increaseContainersResource(increaseRequest);
        } catch (Exception e) {
            LOG.info(StringUtils.stringifyException(e));
            Assert.assertEquals("Error, exception is not: " + SocketTimeoutException.class.getName(), SocketTimeoutException.class.getName(), e.getClass().getName());
            return;
        }
    } finally {
        server.stop();
    }
    Assert.fail("timeout exception should have occurred!");
}
Also used : YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) Server(org.apache.hadoop.ipc.Server) InetSocketAddress(java.net.InetSocketAddress) Resource(org.apache.hadoop.yarn.api.records.Resource) ArrayList(java.util.ArrayList) IncreaseContainersResourceRequest(org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceRequest) Token(org.apache.hadoop.yarn.api.records.Token) YarnRPC(org.apache.hadoop.yarn.ipc.YarnRPC) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) SocketTimeoutException(java.net.SocketTimeoutException) IOException(java.io.IOException) ContainerTokenIdentifier(org.apache.hadoop.yarn.security.ContainerTokenIdentifier) ContainerManagementProtocol(org.apache.hadoop.yarn.api.ContainerManagementProtocol) SocketTimeoutException(java.net.SocketTimeoutException) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) NodeId(org.apache.hadoop.yarn.api.records.NodeId) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId)

Aggregations

ArrayList (java.util.ArrayList)6 IncreaseContainersResourceRequest (org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceRequest)6 Token (org.apache.hadoop.yarn.api.records.Token)6 IncreaseContainersResourceResponse (org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceResponse)5 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)4 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)4 HashMap (java.util.HashMap)3 StartContainerRequest (org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest)3 StartContainersRequest (org.apache.hadoop.yarn.api.protocolrecords.StartContainersRequest)3 ContainerLaunchContext (org.apache.hadoop.yarn.api.records.ContainerLaunchContext)3 Test (org.junit.Test)3 File (java.io.File)2 IOException (java.io.IOException)2 PrintWriter (java.io.PrintWriter)2 Map (java.util.Map)2 Path (org.apache.hadoop.fs.Path)2 LocalResource (org.apache.hadoop.yarn.api.records.LocalResource)2 Resource (org.apache.hadoop.yarn.api.records.Resource)2 SerializedException (org.apache.hadoop.yarn.api.records.SerializedException)2 URL (org.apache.hadoop.yarn.api.records.URL)2