本文整理汇总了Java中org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.CGroupsHandler类的典型用法代码示例。如果您正苦于以下问题:Java CGroupsHandler类的具体用法?Java CGroupsHandler怎么用?Java CGroupsHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CGroupsHandler类属于org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources包,在下文中一共展示了CGroupsHandler类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.CGroupsHandler; //导入依赖的package包/类
@Override
public void initialize(Configuration conf)
throws ContainerExecutionException {
PrivilegedOperationExecutor privilegedOperationExecutor =
PrivilegedOperationExecutor.getInstance(conf);
CGroupsHandler cGroupsHandler;
try {
cGroupsHandler = ResourceHandlerModule.getCGroupsHandler(conf);
} catch (ResourceHandlerException e) {
LOG.error("Unable to get cgroups handle.");
throw new ContainerExecutionException(e);
}
defaultLinuxContainerRuntime = new DefaultLinuxContainerRuntime(
privilegedOperationExecutor);
defaultLinuxContainerRuntime.initialize(conf);
dockerLinuxContainerRuntime = new DockerLinuxContainerRuntime(
privilegedOperationExecutor, cGroupsHandler);
dockerLinuxContainerRuntime.initialize(conf);
}
示例2: addCGroupParentIfRequired
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.CGroupsHandler; //导入依赖的package包/类
public void addCGroupParentIfRequired(String resourcesOptions,
String containerIdStr, DockerRunCommand runCommand)
throws ContainerExecutionException {
if (resourcesOptions.equals(
(PrivilegedOperation.CGROUP_ARG_PREFIX + PrivilegedOperation
.CGROUP_ARG_NO_TASKS))) {
if (LOG.isInfoEnabled()) {
LOG.info("no resource restrictions specified. not using docker's "
+ "cgroup options");
}
} else {
if (LOG.isInfoEnabled()) {
LOG.info("using docker's cgroups options");
}
try {
CGroupsHandler cGroupsHandler = ResourceHandlerModule
.getCGroupsHandler(conf);
String cGroupPath = "/" + cGroupsHandler.getRelativePathForCGroup(
containerIdStr);
if (LOG.isInfoEnabled()) {
LOG.info("using cgroup parent: " + cGroupPath);
}
runCommand.setCGroupParent(cGroupPath);
} catch (ResourceHandlerException e) {
LOG.warn("unable to use cgroups handler. Exception: ", e);
throw new ContainerExecutionException(e);
}
}
}
示例3: DockerLinuxContainerRuntime
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.CGroupsHandler; //导入依赖的package包/类
public DockerLinuxContainerRuntime(PrivilegedOperationExecutor
privilegedOperationExecutor, CGroupsHandler cGroupsHandler) {
this.privilegedOperationExecutor = privilegedOperationExecutor;
this.cGroupsHandler = cGroupsHandler;
}
示例4: setup
import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.CGroupsHandler; //导入依赖的package包/类
@Before
public void setup() {
String tmpPath = new StringBuffer(System.getProperty("test.build.data"))
.append('/').append("hadoop.tmp.dir").toString();
conf = new Configuration();
conf.set("hadoop.tmp.dir", tmpPath);
mockExecutor = Mockito
.mock(PrivilegedOperationExecutor.class);
mockCGroupsHandler = Mockito.mock(CGroupsHandler.class);
containerId = "container_id";
container = mock(Container.class);
cId = mock(ContainerId.class);
context = mock(ContainerLaunchContext.class);
env = new HashMap<String, String>();
image = "busybox:latest";
env.put(DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_IMAGE, image);
when(container.getContainerId()).thenReturn(cId);
when(cId.toString()).thenReturn(containerId);
when(container.getLaunchContext()).thenReturn(context);
when(context.getEnvironment()).thenReturn(env);
when(container.getUser()).thenReturn(submittingUser);
runAsUser = "run_as_user";
user = "user";
appId = "app_id";
containerIdStr = containerId;
containerWorkDir = new Path("/test_container_work_dir");
nmPrivateContainerScriptPath = new Path("/test_script_path");
nmPrivateTokensPath = new Path("/test_private_tokens_path");
pidFilePath = new Path("/test_pid_file_path");
localDirs = new ArrayList<>();
logDirs = new ArrayList<>();
filecacheDirs = new ArrayList<>();
resourcesOptions = "cgroups=none";
userLocalDirs = new ArrayList<>();
containerLocalDirs = new ArrayList<>();
containerLogDirs = new ArrayList<>();
localizedResources = new HashMap<>();
localDirs.add("/test_local_dir");
logDirs.add("/test_log_dir");
filecacheDirs.add("/test_filecache_dir");
userLocalDirs.add("/test_user_local_dir");
containerLocalDirs.add("/test_container_local_dir");
containerLogDirs.add("/test_container_log_dir");
localizedResources.put(new Path("/test_local_dir/test_resource_file"),
Collections.singletonList("test_dir/test_resource_file"));
testCapabilities = new String[] {"NET_BIND_SERVICE", "SYS_CHROOT"};
conf.setStrings(YarnConfiguration.NM_DOCKER_CONTAINER_CAPABILITIES,
testCapabilities);
builder = new ContainerRuntimeContext
.Builder(container);
builder.setExecutionAttribute(RUN_AS_USER, runAsUser)
.setExecutionAttribute(USER, user)
.setExecutionAttribute(APPID, appId)
.setExecutionAttribute(CONTAINER_ID_STR, containerIdStr)
.setExecutionAttribute(CONTAINER_WORK_DIR, containerWorkDir)
.setExecutionAttribute(NM_PRIVATE_CONTAINER_SCRIPT_PATH,
nmPrivateContainerScriptPath)
.setExecutionAttribute(NM_PRIVATE_TOKENS_PATH, nmPrivateTokensPath)
.setExecutionAttribute(PID_FILE_PATH, pidFilePath)
.setExecutionAttribute(LOCAL_DIRS, localDirs)
.setExecutionAttribute(LOG_DIRS, logDirs)
.setExecutionAttribute(FILECACHE_DIRS, filecacheDirs)
.setExecutionAttribute(USER_LOCAL_DIRS, userLocalDirs)
.setExecutionAttribute(CONTAINER_LOCAL_DIRS, containerLocalDirs)
.setExecutionAttribute(CONTAINER_LOG_DIRS, containerLogDirs)
.setExecutionAttribute(LOCALIZED_RESOURCES, localizedResources)
.setExecutionAttribute(RESOURCES_OPTIONS, resourcesOptions);
}