/** * Build up the path string for app def folder -no attempt to * create the directory is made * * @param clustername name of the cluster * @return the path for persistent data */ public Path buildAppDefDirPath(String clustername) { Path path = buildClusterDirPath(clustername); return new Path(path, SliderKeys.APP_DEF_DIR); }
/** * Submit the AM tar.gz resource referenced by the instance's cluster * filesystem. Also, update the providerResources object with the new * resource. * * @param providerResources * the provider resource map to be updated * @throws IOException * trouble copying to HDFS */ public void submitTarGzipAndUpdate( Map<String, LocalResource> providerResources) throws IOException, BadClusterStateException { Path dependencyLibTarGzip = getDependencyTarGzip(); log.info("Loading all dependencies from {}", dependencyLibTarGzip); LocalResource lc = createAmResource(dependencyLibTarGzip, LocalResourceType.ARCHIVE); providerResources.put(SliderKeys.SLIDER_DEPENDENCY_LOCALIZED_DIR_LINK, lc); }
/** * Create the Slider cluster path for a named cluster and all its subdirs * This is a directory; a mkdirs() operation is executed * to ensure that it is there. * * @param clustername name of the cluster * @return the path to the cluster directory * @throws java.io.IOException trouble * @throws SliderException slider-specific exceptions */ public Path createClusterDirectories(String clustername, Configuration conf) throws IOException, SliderException { Path clusterDirectory = buildClusterDirPath(clustername); InstancePaths instancePaths = new InstancePaths(clusterDirectory); createClusterDirectories(instancePaths); return clusterDirectory; }
/** * Locate an application conf json in the FS. This includes a check to verify * that the file is there. * * @param clustername name of the cluster * @return the path to the spec. * @throws IOException IO problems * @throws SliderException if the path isn't there */ public Path locateInstanceDefinition(String clustername) throws IOException, SliderException { Path clusterDirectory = buildClusterDirPath(clustername); Path appConfPath = new Path(clusterDirectory, Filenames.APPCONF); verifyClusterSpecExists(clustername, appConfPath); return appConfPath; }
/** * Create the Slider cluster path for a named cluster and all its subdirs * This is a directory; a mkdirs() operation is executed * to ensure that it is there. * * @param instancePaths instance paths * @throws IOException trouble * @throws SliderException slider-specific exceptions */ public void createClusterDirectories(InstancePaths instancePaths) throws IOException, SliderException { Path instanceDir = instancePaths.instanceDir; verifyDirectoryNonexistent(instanceDir); FsPermission clusterPerms = getInstanceDirectoryPermissions(); createWithPermissions(instanceDir, clusterPerms); createWithPermissions(instancePaths.snapshotConfPath, clusterPerms); createWithPermissions(instancePaths.generatedConfPath, clusterPerms); createWithPermissions(instancePaths.historyPath, clusterPerms); createWithPermissions(instancePaths.tmpPathAM, clusterPerms); // Data Directory String dataOpts = configuration.get(SliderXmlConfKeys.DATA_DIRECTORY_PERMISSIONS, SliderXmlConfKeys.DEFAULT_DATA_DIRECTORY_PERMISSIONS); log.debug("Setting data directory permissions to {}", dataOpts); createWithPermissions(instancePaths.dataPath, new FsPermission(dataOpts)); }
"component"); Path componentClusterDir = coreFS.buildClusterDirPath(component); try { coreFS.verifyPathExists(componentClusterDir); } catch (IOException e) { throw new BadConfigException("external component " + component + String externalAppDef = componentAppConf.get(AgentKeys.APP_DEF); if (SliderUtils.isSet(externalAppDef)) { Path newAppDef = new Path(coreFS.buildAppDefDirPath(clustername), component + "_" + SliderKeys.DEFAULT_APP_PKG); componentAppConf.set(AgentKeys.APP_DEF, newAppDef); existingPrefix); Path newAppDef = new Path(coreFS.buildAppDefDirPath(clustername), component + existingPrefix + "_" + SliderKeys.DEFAULT_APP_PKG); externalAppDefs.put(componentAppDef, newAppDef);
/** * Build up the path string for a cluster instance -no attempt to * create the directory is made * * @param clustername name of the cluster * @return the path for persistent data */ public Path buildClusterDirPath(String clustername) { Preconditions.checkNotNull(clustername); Path path = getBaseApplicationPath(); return new Path(path, SliderKeys.CLUSTER_DIRECTORY + "/" + clustername); }
/** * Build up the path string for keytab install location -no attempt to * create the directory is made * * @return the path for keytab installation location */ public Path buildKeytabPath(String keytabDir, String keytabName, String clusterName) { Path homePath = getHomeDirectory(); Path baseKeytabDir; if (keytabDir != null) { baseKeytabDir = new Path(homePath, keytabDir); } else { baseKeytabDir = new Path(buildClusterDirPath(clusterName), SliderKeys.KEYTAB_DIR); } return keytabName == null ? baseKeytabDir : new Path(baseKeytabDir, keytabName); }
FileSystem fs = getFileSystem(); Path path = new Path(getBaseApplicationPath(), SliderKeys.CLUSTER_DIRECTORY); log.debug("Looking for all persisted application at {}", path.toString()); if (!fs.exists(path)) {
IOException, LockAcquireFailedException { if (!coreFS.getFileSystem().exists(persistDir)) { boolean owner; try { coreFS.cat(readlock, false, new Date(now).toGMTString()); owner = true; } catch (IOException e) {
throws IOException, YarnException { CoreFileSystem sliderFileSystem = new CoreFileSystem(conf); Preconditions.checkArgument(!listOnlyInState || minAppState != null, "null minAppState when listOnlyInState set"); sliderFileSystem.listPersistentInstances(); Map<String, SliderInstanceDescription> descriptions = new HashMap<String, SliderInstanceDescription>(persistentInstances.size());
public boolean maybeAddImagePath(Map<String, LocalResource> localResources, Path imagePath) throws IOException { if (imagePath != null) { LocalResource resource = createAmResource(imagePath, LocalResourceType.ARCHIVE); localResources.put(SliderKeys.LOCAL_TARBALL_INSTALL_SUBDIR, resource); return true; } else { return false; } }
/** * Get slider.tar.gz absolute filepath in HDFS * * @return the absolute path to slider.tar.gz in HDFS */ public Path getDependencyTarGzip() { Path dependencyLibAmPath = getDependencyPath(); Path dependencyLibTarGzip = new Path( dependencyLibAmPath.toUri().toString(), SliderKeys.SLIDER_DEPENDENCY_TAR_GZ_FILE_NAME + SliderKeys.SLIDER_DEPENDENCY_TAR_GZ_FILE_EXT); return dependencyLibTarGzip; }
public static Path extractImagePath(CoreFileSystem fs, MapOperations internalOptions) throws SliderException, IOException { Path imagePath; String imagePathOption = internalOptions.get(InternalKeys.INTERNAL_APPLICATION_IMAGE_PATH); String appHomeOption = internalOptions.get(InternalKeys.INTERNAL_APPLICATION_HOME); if (!isUnset(imagePathOption)) { if (!isUnset(appHomeOption)) { throw new BadClusterStateException( ErrorStrings.E_BOTH_IMAGE_AND_HOME_DIR_SPECIFIED); } imagePath = fs.createPathThatMustExist(imagePathOption); } else { imagePath = null; if (isUnset(appHomeOption)) { throw new BadClusterStateException( ErrorStrings.E_NO_IMAGE_OR_HOME_DIR_SPECIFIED); } } return imagePath; }
/** * Persist this * @param appconfdir conf dir * @param overwrite if true, we don't need to create cluster dir * @throws IOException * @throws SliderException * @throws LockAcquireFailedException */ public void persist(Path appconfdir, boolean overwrite) throws IOException, SliderException, LockAcquireFailedException { if (!overwrite) { coreFS.createClusterDirectories(instancePaths); } ConfPersister persister = new ConfPersister(coreFS, getInstanceDir()); ConfDirSnapshotAction action = null; if (appconfdir != null) { action = new ConfDirSnapshotAction(appconfdir); } persister.save(instanceDescription, action); for (Entry<String, Path> appDef : externalAppDefs.entrySet()) { SliderUtils.copy(conf, new Path(appDef.getKey()), appDef.getValue()); } }
long now = System.currentTimeMillis(); try { coreFS.cat(writelock, false, new Date(now).toGMTString()); } catch (FileAlreadyExistsException e) {
/** * Create the Slider cluster path for a named cluster and all its subdirs * This is a directory; a mkdirs() operation is executed * to ensure that it is there. * * @param instancePaths instance paths * @throws IOException trouble * @throws SliderException slider-specific exceptions */ public void createClusterDirectories(InstancePaths instancePaths) throws IOException, SliderException { Path instanceDir = instancePaths.instanceDir; verifyDirectoryNonexistent(instanceDir); FsPermission clusterPerms = getInstanceDirectoryPermissions(); createWithPermissions(instanceDir, clusterPerms); createWithPermissions(instancePaths.snapshotConfPath, clusterPerms); createWithPermissions(instancePaths.generatedConfPath, clusterPerms); createWithPermissions(instancePaths.historyPath, clusterPerms); createWithPermissions(instancePaths.tmpPathAM, clusterPerms); // Data Directory String dataOpts = configuration.get(SliderXmlConfKeys.DATA_DIRECTORY_PERMISSIONS, SliderXmlConfKeys.DEFAULT_DATA_DIRECTORY_PERMISSIONS); log.debug("Setting data directory permissions to {}", dataOpts); createWithPermissions(instancePaths.dataPath, new FsPermission(dataOpts)); }
"component"); Path componentClusterDir = coreFS.buildClusterDirPath(component); try { coreFS.verifyPathExists(componentClusterDir); } catch (IOException e) { throw new BadConfigException("external component " + component + String externalAppDef = componentAppConf.get(AgentKeys.APP_DEF); if (SliderUtils.isSet(externalAppDef)) { Path newAppDef = new Path(coreFS.buildAppDefDirPath(clustername), component + "_" + SliderKeys.DEFAULT_APP_PKG); componentAppConf.set(AgentKeys.APP_DEF, newAppDef); existingPrefix); Path newAppDef = new Path(coreFS.buildAppDefDirPath(clustername), component + existingPrefix + "_" + SliderKeys.DEFAULT_APP_PKG); externalAppDefs.put(componentAppDef, newAppDef);
/** * Build up the path string for resource install location -no attempt to * create the directory is made * * @return the path for resource */ public Path buildResourcePath(String resourceFolder) { Preconditions.checkNotNull(resourceFolder); Path path = getBaseApplicationPath(); return new Path(path, SliderKeys.RESOURCE_DIR + "/" + resourceFolder); }
/** * Locate an application conf json in the FS. This includes a check to verify * that the file is there. * * @param clustername name of the cluster * @return the path to the spec. * @throws IOException IO problems * @throws SliderException if the path isn't there */ public Path locateInstanceDefinition(String clustername) throws IOException, SliderException { Path clusterDirectory = buildClusterDirPath(clustername); Path appConfPath = new Path(clusterDirectory, Filenames.APPCONF); verifyClusterSpecExists(clustername, appConfPath); return appConfPath; }