Search in sources :

Example 41 with YarnRuntimeException

use of org.apache.hadoop.yarn.exceptions.YarnRuntimeException in project hadoop by apache.

the class TestContainerLocalizer method testContainerLocalizerClosesFilesystems.

@Test
// mocked generics
@SuppressWarnings("unchecked")
public void testContainerLocalizerClosesFilesystems() throws Exception {
    // verify filesystems are closed when localizer doesn't fail
    ContainerLocalizerWrapper wrapper = new ContainerLocalizerWrapper();
    ContainerLocalizer localizer = wrapper.setupContainerLocalizerForTest();
    mockOutDownloads(localizer);
    doNothing().when(localizer).localizeFiles(any(LocalizationProtocol.class), any(CompletionService.class), any(UserGroupInformation.class));
    verify(localizer, never()).closeFileSystems(any(UserGroupInformation.class));
    localizer.runLocalization(nmAddr);
    verify(localizer).closeFileSystems(any(UserGroupInformation.class));
    // verify filesystems are closed when localizer fails
    localizer = wrapper.setupContainerLocalizerForTest();
    doThrow(new YarnRuntimeException("Forced Failure")).when(localizer).localizeFiles(any(LocalizationProtocol.class), any(CompletionService.class), any(UserGroupInformation.class));
    verify(localizer, never()).closeFileSystems(any(UserGroupInformation.class));
    try {
        localizer.runLocalization(nmAddr);
        Assert.fail("Localization succeeded unexpectedly!");
    } catch (IOException e) {
        verify(localizer).closeFileSystems(any(UserGroupInformation.class));
    }
}
Also used : YarnRuntimeException(org.apache.hadoop.yarn.exceptions.YarnRuntimeException) LocalizationProtocol(org.apache.hadoop.yarn.server.nodemanager.api.LocalizationProtocol) CompletionService(java.util.concurrent.CompletionService) IOException(java.io.IOException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) Test(org.junit.Test)

Example 42 with YarnRuntimeException

use of org.apache.hadoop.yarn.exceptions.YarnRuntimeException in project hadoop by apache.

the class TestRPCFactories method testPbClientFactory.

private void testPbClientFactory() {
    InetSocketAddress addr = new InetSocketAddress(0);
    System.err.println(addr.getHostName() + addr.getPort());
    Configuration conf = new Configuration();
    MRClientProtocol instance = new MRClientProtocolTestImpl();
    Server server = null;
    try {
        server = RpcServerFactoryPBImpl.get().getServer(MRClientProtocol.class, instance, addr, conf, null, 1);
        server.start();
        System.err.println(server.getListenerAddress());
        System.err.println(NetUtils.getConnectAddress(server));
        MRClientProtocol client = null;
        try {
            client = (MRClientProtocol) RpcClientFactoryPBImpl.get().getClient(MRClientProtocol.class, 1, NetUtils.getConnectAddress(server), conf);
        } catch (YarnRuntimeException e) {
            e.printStackTrace();
            Assert.fail("Failed to crete client");
        }
    } catch (YarnRuntimeException e) {
        e.printStackTrace();
        Assert.fail("Failed to crete 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) MRClientProtocol(org.apache.hadoop.mapreduce.v2.api.MRClientProtocol)

Example 43 with YarnRuntimeException

use of org.apache.hadoop.yarn.exceptions.YarnRuntimeException in project hadoop by apache.

the class AMRMClientImpl method serviceStart.

@Override
protected void serviceStart() throws Exception {
    final YarnConfiguration conf = new YarnConfiguration(getConfig());
    try {
        if (rmClient == null) {
            rmClient = ClientRMProxy.createRMProxy(conf, ApplicationMasterProtocol.class);
        }
    } catch (IOException e) {
        throw new YarnRuntimeException(e);
    }
    super.serviceStart();
}
Also used : YarnRuntimeException(org.apache.hadoop.yarn.exceptions.YarnRuntimeException) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) ApplicationMasterProtocol(org.apache.hadoop.yarn.api.ApplicationMasterProtocol) IOException(java.io.IOException)

Example 44 with YarnRuntimeException

use of org.apache.hadoop.yarn.exceptions.YarnRuntimeException in project hadoop by apache.

the class RecordFactoryProvider method getFactoryClassInstance.

private static Object getFactoryClassInstance(String factoryClassName) {
    try {
        Class<?> clazz = Class.forName(factoryClassName);
        Method method = clazz.getMethod("get", null);
        method.setAccessible(true);
        return method.invoke(null, null);
    } catch (ClassNotFoundException e) {
        throw new YarnRuntimeException(e);
    } catch (NoSuchMethodException e) {
        throw new YarnRuntimeException(e);
    } catch (InvocationTargetException e) {
        throw new YarnRuntimeException(e);
    } catch (IllegalAccessException e) {
        throw new YarnRuntimeException(e);
    }
}
Also used : YarnRuntimeException(org.apache.hadoop.yarn.exceptions.YarnRuntimeException) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 45 with YarnRuntimeException

use of org.apache.hadoop.yarn.exceptions.YarnRuntimeException in project hadoop by apache.

the class SharedCacheChecksumFactory method getChecksum.

/**
   * Get a new <code>SharedCacheChecksum</code> object based on the configurable
   * algorithm implementation
   * (see <code>yarn.sharedcache.checksum.algo.impl</code>)
   *
   * @return <code>SharedCacheChecksum</code> object
   */
public static SharedCacheChecksum getChecksum(Configuration conf) {
    Class<? extends SharedCacheChecksum> clazz = conf.getClass(YarnConfiguration.SHARED_CACHE_CHECKSUM_ALGO_IMPL, defaultAlgorithm, SharedCacheChecksum.class);
    SharedCacheChecksum checksum = instances.get(clazz);
    if (checksum == null) {
        try {
            checksum = ReflectionUtils.newInstance(clazz, conf);
            SharedCacheChecksum old = instances.putIfAbsent(clazz, checksum);
            if (old != null) {
                checksum = old;
            }
        } catch (Exception e) {
            throw new YarnRuntimeException(e);
        }
    }
    return checksum;
}
Also used : YarnRuntimeException(org.apache.hadoop.yarn.exceptions.YarnRuntimeException) YarnRuntimeException(org.apache.hadoop.yarn.exceptions.YarnRuntimeException)

Aggregations

YarnRuntimeException (org.apache.hadoop.yarn.exceptions.YarnRuntimeException)147 IOException (java.io.IOException)56 Configuration (org.apache.hadoop.conf.Configuration)38 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)28 Test (org.junit.Test)28 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)17 InetSocketAddress (java.net.InetSocketAddress)12 Path (org.apache.hadoop.fs.Path)12 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)9 InvocationTargetException (java.lang.reflect.InvocationTargetException)8 Server (org.apache.hadoop.ipc.Server)8 FileSystem (org.apache.hadoop.fs.FileSystem)7 FsPermission (org.apache.hadoop.fs.permission.FsPermission)7 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)7 FileNotFoundException (java.io.FileNotFoundException)6 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 JobId (org.apache.hadoop.mapreduce.v2.api.records.JobId)6 Job (org.apache.hadoop.mapreduce.v2.app.job.Job)6 ConnectException (java.net.ConnectException)5