List of usage examples for org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher ContainerLaunch FINAL_CONTAINER_TOKENS_FILE
String FINAL_CONTAINER_TOKENS_FILE
To view the source code for org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher ContainerLaunch FINAL_CONTAINER_TOKENS_FILE.
Click Source Link
From source file:oz.hadoop.yarn.test.cluster.InJvmContainerExecutor.java
License:Apache License
/** * * @param container//from w ww . j a va 2 s . c om * @param containerWorkDir * @return */ private UserGroupInformation buildUgiForContainerLaunching(Container container, final Path containerWorkDir) { UserGroupInformation ugi; try { ugi = UserGroupInformation.createRemoteUser(UserGroupInformation.getLoginUser().getUserName()); ugi.setAuthenticationMethod(AuthMethod.TOKEN); String filePath = new Path(containerWorkDir, ContainerLaunch.FINAL_CONTAINER_TOKENS_FILE).toString(); Credentials credentials = Credentials.readTokenStorageFile(new File(filePath), this.getConf()); Collection<Token<? extends TokenIdentifier>> tokens = credentials.getAllTokens(); for (Token<? extends TokenIdentifier> token : tokens) { ugi.addToken(token); } } catch (Exception e) { throw new IllegalArgumentException( "Failed to build UserGroupInformation to launch container " + container, e); } return ugi; }
From source file:oz.hadoop.yarn.test.cluster.InJvmContainerExecutor.java
License:Apache License
/** * Most of this code is copied from the super class's launchContainer method (unfortunately), since directory * and other preparation logic is tightly coupled with the actual container launch. * Would be nice if it was broken apart where launch method would be invoked when * everything is prepared//from www . java 2 s . c o m */ private void prepareContainerDirectories(Container container, Path nmPrivateContainerScriptPath, Path nmPrivateTokensPath, String userName, String appId, Path containerWorkDir, List<String> localDirs, List<String> logDirs) { FsPermission dirPerm = new FsPermission(APPDIR_PERM); ContainerId containerId = container.getContainerId(); String containerIdStr = ConverterUtils.toString(containerId); String appIdStr = ConverterUtils.toString(containerId.getApplicationAttemptId().getApplicationId()); try { for (String sLocalDir : localDirs) { Path usersdir = new Path(sLocalDir, ContainerLocalizer.USERCACHE); Path userdir = new Path(usersdir, userName); Path appCacheDir = new Path(userdir, ContainerLocalizer.APPCACHE); Path appDir = new Path(appCacheDir, appIdStr); Path containerDir = new Path(appDir, containerIdStr); createDir(containerDir, dirPerm, true); } // Create the container log-dirs on all disks this.createLogDirs(appIdStr, containerIdStr, logDirs); Path tmpDir = new Path(containerWorkDir, YarnConfiguration.DEFAULT_CONTAINER_TEMP_DIR); createDir(tmpDir, dirPerm, false); // copy launch script to work dir Path launchDst = new Path(containerWorkDir, ContainerLaunch.CONTAINER_SCRIPT); fc.util().copy(nmPrivateContainerScriptPath, launchDst); // copy container tokens to work dir Path tokenDst = new Path(containerWorkDir, ContainerLaunch.FINAL_CONTAINER_TOKENS_FILE); fc.util().copy(nmPrivateTokensPath, tokenDst); } catch (Exception e) { throw new IllegalStateException("Failed to prepare container directories for container " + container, e); } }