DelegatingLinuxContainerRuntime implements LinuxContainerRuntime { @Override public void initialize(Configuration conf, Context nmContext) throws ContainerExecutionException { String[] configuredRuntimes = conf.getTrimmedStrings( YarnConfiguration.LINUX_CONTAINER_RUNTIME_ALLOWED_RUNTIMES, YarnConfiguration.DEFAULT_LINUX_CONTAINER_RUNTIME_ALLOWED_RUNTIMES); for (String configuredRuntime : configuredRuntimes) { String normRuntime = configuredRuntime.toUpperCase(); allowedRuntimes.add(normRuntime); if (isPluggableRuntime(normRuntime)) { LinuxContainerRuntime runtime = createPluggableRuntime(conf, configuredRuntime); runtime.initialize(conf, nmContext); pluggableRuntimes.add(runtime); } } if (isRuntimeAllowed( LinuxContainerRuntimeConstants.RuntimeType.JAVASANDBOX.name())) { javaSandboxLinuxContainerRuntime = new JavaSandboxLinuxContainerRuntime( PrivilegedOperationExecutor.getInstance(conf)); javaSandboxLinuxContainerRuntime.initialize(conf, nmContext); } if (isRuntimeAllowed( LinuxContainerRuntimeConstants.RuntimeType.DOCKER.name())) { dockerLinuxContainerRuntime = new DockerLinuxContainerRuntime( PrivilegedOperationExecutor.getInstance(conf)); dockerLinuxContainerRuntime.initialize(conf, nmContext); } if (isRuntimeAllowed( LinuxContainerRuntimeConstants.RuntimeType.DEFAULT.name())) { defaultLinuxContainerRuntime = new DefaultLinuxContainerRuntime( PrivilegedOperationExecutor.getInstance(conf)); defaultLinuxContainerRuntime.initialize(conf, nmContext); } }  @Override void initialize(Configuration conf, Context nmContext); @Override boolean isRuntimeRequested(Map<String, String> env); @Override void prepareContainer(ContainerRuntimeContext ctx); @Override void launchContainer(ContainerRuntimeContext ctx); @Override void relaunchContainer(ContainerRuntimeContext ctx); @Override void signalContainer(ContainerRuntimeContext ctx); @Override void reapContainer(ContainerRuntimeContext ctx); @Override String[] getIpAndHost(Container container);  }
@Test public void testInitializeMissingRuntimeClass() throws Exception { conf.set(YarnConfiguration.LINUX_CONTAINER_RUNTIME_ALLOWED_RUNTIMES, "mock"); try { delegatingLinuxContainerRuntime.initialize(conf, null); fail("initialize should fail"); } catch (ContainerExecutionException e) { assert(e.getMessage().contains("Invalid runtime set")); } }