ContainerExecutor的继承关系
ContainerExecutor的实例化
ContainerExecutor的实例化是在NM初始化方法serviceInit()中完成的,通过配置参数yarn.nodemanager.container-executor.class 来配置使用哪种ContainerExecutor,默认使用DefaultContainerExecutor。如下:
ContainerExecutor exec = ReflectionUtils.newInstance(
conf.getClass(YarnConfiguration.NM_CONTAINER_EXECUTOR,
DefaultContainerExecutor.class, ContainerExecutor.class), conf);
try {
exec.init();
} catch (IOException e) {
throw new YarnRuntimeException("Failed to initialize container executor", e);
}
ContainerExecutor的使用
在NM的serviceInit()方法中看到有两处在使用ContainerExecutor,如下:
DeletionService del = createDeletionService(exec);
addService(del);
containerManager =
createContainerManager(context, exec, del, nodeStatusUpdater,
this.aclsManager, dirsHandler);
addService(containerManager);
TODO:具体是如何使用的?
三种ContainerExecutor分析
(1)DefaultContainerExecutor
先看构造方法(上面的反射用)
public DefaultContainerExecutor() {
try {
//构造了一个本地文件系统上下文对象,即FS的URL为file:///,其他配置就是new Configuration()
this.lfs = FileContext.getLocalFSFileContext();
} catch (UnsupportedFileSystemException e) {
throw new RuntimeException(e);
}
}
再看init方法
@Override
public void init() throws IOException {
// nothing to do or verify here
}
TODO:具体实现?
(2)DockerContainerExecutor
(3)LinuxContainerExecutor