Search in sources :

Example 6 with LocalizationProtocol

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

the class TestPBLocalizerRPC method testLocalizerRPC.

@Test
public void testLocalizerRPC() throws Exception {
    InetSocketAddress locAddr = new InetSocketAddress("0.0.0.0", 8040);
    LocalizerService server = new LocalizerService(locAddr);
    try {
        server.start();
        Configuration conf = new Configuration();
        YarnRPC rpc = YarnRPC.create(conf);
        LocalizationProtocol client = (LocalizationProtocol) rpc.getProxy(LocalizationProtocol.class, locAddr, conf);
        LocalizerStatus status = recordFactory.newRecordInstance(LocalizerStatus.class);
        status.setLocalizerId("localizer0");
        LocalizerHeartbeatResponse response = client.heartbeat(status);
        assertEquals(dieHBResponse(), response);
    } finally {
        server.stop();
    }
    assertTrue(true);
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) LocalizationProtocol(org.apache.hadoop.yarn.server.nodemanager.api.LocalizationProtocol) InetSocketAddress(java.net.InetSocketAddress) LocalizerHeartbeatResponse(org.apache.hadoop.yarn.server.nodemanager.api.protocolrecords.LocalizerHeartbeatResponse) YarnRPC(org.apache.hadoop.yarn.ipc.YarnRPC) LocalizerStatus(org.apache.hadoop.yarn.server.nodemanager.api.protocolrecords.LocalizerStatus) Test(org.junit.Test)

Example 7 with LocalizationProtocol

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

the class TestContainerLocalizer method testMainFailure.

@Test(timeout = 15000)
public void testMainFailure() throws Exception {
    ContainerLocalizerWrapper wrapper = new ContainerLocalizerWrapper();
    ContainerLocalizer localizer = wrapper.setupContainerLocalizerForTest();
    LocalizationProtocol nmProxy = wrapper.nmProxy;
    mockOutDownloads(localizer);
    // Assume the NM heartbeat fails say because of absent tokens.
    when(nmProxy.heartbeat(isA(LocalizerStatus.class))).thenThrow(new YarnException("Sigh, no token!"));
    // run localization, it should fail
    try {
        localizer.runLocalization(nmAddr);
        Assert.fail("Localization succeeded unexpectedly!");
    } catch (IOException e) {
        Assert.assertTrue(e.getMessage().contains("Sigh, no token!"));
    }
}
Also used : LocalizationProtocol(org.apache.hadoop.yarn.server.nodemanager.api.LocalizationProtocol) LocalizerStatus(org.apache.hadoop.yarn.server.nodemanager.api.protocolrecords.LocalizerStatus) IOException(java.io.IOException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) Test(org.junit.Test)

Aggregations

LocalizationProtocol (org.apache.hadoop.yarn.server.nodemanager.api.LocalizationProtocol)7 Configuration (org.apache.hadoop.conf.Configuration)4 Test (org.junit.Test)4 IOException (java.io.IOException)3 InetSocketAddress (java.net.InetSocketAddress)3 Path (org.apache.hadoop.fs.Path)3 LocalizerStatus (org.apache.hadoop.yarn.server.nodemanager.api.protocolrecords.LocalizerStatus)3 ArrayList (java.util.ArrayList)2 Server (org.apache.hadoop.ipc.Server)2 Credentials (org.apache.hadoop.security.Credentials)2 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)2 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)2 YarnRuntimeException (org.apache.hadoop.yarn.exceptions.YarnRuntimeException)2 ResourceLocalizationSpec (org.apache.hadoop.yarn.server.nodemanager.api.ResourceLocalizationSpec)2 DataInputStream (java.io.DataInputStream)1 DataOutputStream (java.io.DataOutputStream)1 Random (java.util.Random)1 ExecutorService (java.util.concurrent.ExecutorService)1 AbstractFileSystem (org.apache.hadoop.fs.AbstractFileSystem)1 FSDataOutputStream (org.apache.hadoop.fs.FSDataOutputStream)1