public class CoreFileSystem extends Object
| Modifier and Type | Field and Description |
|---|---|
protected org.apache.hadoop.conf.Configuration |
configuration |
protected org.apache.hadoop.fs.FileSystem |
fileSystem |
| Constructor and Description |
|---|
CoreFileSystem(org.apache.hadoop.conf.Configuration configuration) |
CoreFileSystem(org.apache.hadoop.fs.FileSystem fileSystem,
org.apache.hadoop.conf.Configuration configuration) |
| Modifier and Type | Method and Description |
|---|---|
org.apache.hadoop.fs.Path |
buildAddonDirPath(String clustername,
String addonId)
Build up the path string for addon folder -no attempt to
create the directory is made
|
org.apache.hadoop.fs.Path |
buildAppDefDirPath(String clustername)
Build up the path string for app def folder -no attempt to
create the directory is made
|
org.apache.hadoop.fs.Path |
buildClusterDirPath(String clustername)
Build up the path string for a cluster instance -no attempt to
create the directory is made
|
org.apache.hadoop.fs.Path |
buildClusterSecurityDirPath(String clusterName)
Build up the path string for package install location -no attempt to
create the directory is made
|
org.apache.hadoop.fs.Path |
buildKeytabInstallationDirPath(String keytabFolder)
Build up the path string for keytab install location -no attempt to
create the directory is made
|
org.apache.hadoop.fs.Path |
buildKeytabPath(String keytabDir,
String keytabName,
String clusterName)
Build up the path string for keytab install location -no attempt to
create the directory is made
|
org.apache.hadoop.fs.Path |
buildPackageDirPath(String packageName,
String packageVersion)
Build up the path string for package install location -no attempt to
create the directory is made
|
void |
cat(org.apache.hadoop.fs.Path path,
boolean overwrite,
String data) |
void |
copyLocalFilesToHdfs(File localPath,
FilenameFilter filenameFilter,
org.apache.hadoop.fs.Path destDir,
org.apache.hadoop.fs.permission.FsPermission fp)
Copy local file(s) to destination HDFS directory.
|
void |
copyLocalFileToHdfs(File localPath,
org.apache.hadoop.fs.Path destPath,
org.apache.hadoop.fs.permission.FsPermission fp) |
org.apache.hadoop.yarn.api.records.LocalResource |
createAmResource(org.apache.hadoop.fs.Path destPath,
org.apache.hadoop.yarn.api.records.LocalResourceType resourceType)
Create an AM resource from the
|
org.apache.hadoop.fs.Path |
createAppInstanceTempPath(String clustername,
String subdir)
Create the application-instance specific temporary directory
in the DFS
|
void |
createClusterDirectories(InstancePaths instancePaths)
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.
|
org.apache.hadoop.fs.Path |
createClusterDirectories(String clustername,
org.apache.hadoop.conf.Configuration conf)
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.
|
org.apache.hadoop.fs.Path |
createPathThatMustExist(String uri)
Create a path that must exist in the cluster fs
|
void |
createWithPermissions(org.apache.hadoop.fs.Path dir,
org.apache.hadoop.fs.permission.FsPermission clusterPerms)
Create a directory with the given permissions.
|
org.apache.hadoop.fs.Path |
getBaseApplicationPath()
Get the base path
|
org.apache.hadoop.fs.Path |
getDependencyPath()
Get slider dependency parent dir in HDFS
|
org.apache.hadoop.fs.Path |
getDependencyTarGzip()
Get slider.tar.gz absolute filepath in HDFS
|
org.apache.hadoop.fs.FileSystem |
getFileSystem()
Returns the underlying FileSystem for this object.
|
org.apache.hadoop.fs.Path |
getHomeDirectory() |
org.apache.hadoop.fs.permission.FsPermission |
getInstanceDirectoryPermissions() |
org.apache.hadoop.fs.permission.FsPermission |
getPathPermissions(org.apache.hadoop.fs.Path path)
Get the permissions of a path
|
org.apache.hadoop.fs.Path |
getTempPathForCluster(String clustername)
Get the temp path for this cluster
|
boolean |
isFile(org.apache.hadoop.fs.Path path)
Given a path, check if it exists and is a file
|
String |
listFSDir(org.apache.hadoop.fs.Path path)
list entries in a filesystem directory
|
Map<String,org.apache.hadoop.fs.Path> |
listPersistentInstances()
List all application instances persisted for this user, giving the
path.
|
org.apache.hadoop.fs.Path |
locateInstanceDefinition(String clustername)
Locate an application conf json in the FS.
|
boolean |
maybeAddImagePath(Map<String,org.apache.hadoop.yarn.api.records.LocalResource> localResources,
org.apache.hadoop.fs.Path imagePath) |
boolean |
maybeAddImagePath(Map<String,org.apache.hadoop.yarn.api.records.LocalResource> localResources,
String imagePath) |
org.apache.hadoop.fs.Path |
purgeAppInstanceTempFiles(String clustername)
Create the application-instance specific temporary directory
in the DFS
|
Map<String,org.apache.hadoop.yarn.api.records.LocalResource> |
submitDirectory(org.apache.hadoop.fs.Path srcDir,
String destRelativeDir)
Register all files under a fs path as a directory to push out
|
org.apache.hadoop.yarn.api.records.LocalResource |
submitFile(File localFile,
org.apache.hadoop.fs.Path tempPath,
String subdir,
String destFileName)
Submit a local file to the filesystem references by the instance's cluster
filesystem
|
org.apache.hadoop.yarn.api.records.LocalResource |
submitJarWithClass(Class clazz,
org.apache.hadoop.fs.Path tempPath,
String subdir,
String jarName)
Submit a JAR containing a specific class, returning
the resource to be mapped in
|
void |
submitTarGzipAndUpdate(Map<String,org.apache.hadoop.yarn.api.records.LocalResource> providerResources)
Submit the AM tar.gz resource referenced by the instance's cluster
filesystem.
|
String |
toString() |
void |
touch(org.apache.hadoop.fs.Path path,
boolean overwrite) |
void |
verifyClusterDirectoryNonexistent(String clustername,
org.apache.hadoop.fs.Path clusterDirectory)
Verify that the cluster directory is not present
|
void |
verifyClusterSpecExists(String clustername,
org.apache.hadoop.fs.Path clusterSpecPath)
Verify that a cluster specification exists
|
void |
verifyDirectoryNonexistent(org.apache.hadoop.fs.Path clusterDirectory)
Verify that the given directory is not present
|
void |
verifyDirectoryWriteAccess(org.apache.hadoop.fs.Path dirPath)
Verify that a user has write access to a directory.
|
void |
verifyFileExists(org.apache.hadoop.fs.Path path)
Verify that a path exists
|
void |
verifyFileExistsInZip(org.apache.hadoop.fs.Path path,
String file)
Verify that a file exists in the zip file given by path
|
void |
verifyPathExists(org.apache.hadoop.fs.Path path)
Verify that a path exists
|
protected final org.apache.hadoop.fs.FileSystem fileSystem
protected final org.apache.hadoop.conf.Configuration configuration
public CoreFileSystem(org.apache.hadoop.fs.FileSystem fileSystem,
org.apache.hadoop.conf.Configuration configuration)
public CoreFileSystem(org.apache.hadoop.conf.Configuration configuration)
throws IOException
IOExceptionpublic org.apache.hadoop.fs.Path getTempPathForCluster(String clustername)
clustername - name of the clusterpublic org.apache.hadoop.fs.FileSystem getFileSystem()
public org.apache.hadoop.fs.Path buildClusterDirPath(String clustername)
clustername - name of the clusterpublic org.apache.hadoop.fs.Path buildAppDefDirPath(String clustername)
clustername - name of the clusterpublic org.apache.hadoop.fs.Path buildAddonDirPath(String clustername, String addonId)
clustername - name of the clusterpublic org.apache.hadoop.fs.Path buildPackageDirPath(String packageName, String packageVersion)
public org.apache.hadoop.fs.Path buildClusterSecurityDirPath(String clusterName)
public org.apache.hadoop.fs.Path buildKeytabInstallationDirPath(String keytabFolder)
public org.apache.hadoop.fs.Path buildKeytabPath(String keytabDir, String keytabName, String clusterName)
public org.apache.hadoop.fs.Path createClusterDirectories(String clustername, org.apache.hadoop.conf.Configuration conf) throws IOException, SliderException
clustername - name of the clusterIOException - troubleSliderException - slider-specific exceptionspublic void createClusterDirectories(InstancePaths instancePaths) throws IOException, SliderException
instancePaths - instance pathsIOException - troubleSliderException - slider-specific exceptionspublic void createWithPermissions(org.apache.hadoop.fs.Path dir,
org.apache.hadoop.fs.permission.FsPermission clusterPerms)
throws IOException,
BadClusterStateException
dir - directoryclusterPerms - cluster permissionsIOException - IO problemBadClusterStateException - any cluster state problempublic org.apache.hadoop.fs.permission.FsPermission getPathPermissions(org.apache.hadoop.fs.Path path)
throws IOException
path - path to checkIOException - any IO problem (including file not found)public org.apache.hadoop.fs.permission.FsPermission getInstanceDirectoryPermissions()
public void verifyClusterDirectoryNonexistent(String clustername, org.apache.hadoop.fs.Path clusterDirectory) throws IOException, SliderException
clustername - name of the clusterclusterDirectory - actual directory to look forIOException - trouble with FSSliderException - If the directory existspublic void verifyDirectoryNonexistent(org.apache.hadoop.fs.Path clusterDirectory)
throws IOException,
SliderException
clusterDirectory - actual directory to look forIOException - trouble with FSSliderException - If the directory existspublic void verifyDirectoryWriteAccess(org.apache.hadoop.fs.Path dirPath)
throws IOException,
SliderException
dirPath - actual directory to look forFileNotFoundException - file not foundIOException - trouble with FSBadClusterStateException - if the directory is not writeableSliderExceptionpublic void verifyPathExists(org.apache.hadoop.fs.Path path)
throws IOException
path - path to checkFileNotFoundException - file not foundIOException - trouble with FSpublic void verifyFileExists(org.apache.hadoop.fs.Path path)
throws IOException
path - path to checkFileNotFoundException - file not found or is not a fileIOException - trouble with FSpublic boolean isFile(org.apache.hadoop.fs.Path path)
path - absolute path to the file to checkpublic void verifyFileExistsInZip(org.apache.hadoop.fs.Path path,
String file)
throws IOException
path - path to zip filefile - file expected to be in zipFileNotFoundException - file not found or is not a zip fileIOException - trouble with FSpublic org.apache.hadoop.fs.Path createAppInstanceTempPath(String clustername, String subdir) throws IOException
clustername - name of the clustersubdir - application IDIOExceptionpublic org.apache.hadoop.fs.Path purgeAppInstanceTempFiles(String clustername) throws IOException
clustername - name of the clusterIOExceptionpublic org.apache.hadoop.fs.Path getBaseApplicationPath()
SliderXmlConfKeys.KEY_SLIDER_BASE_PATHpublic org.apache.hadoop.fs.Path getDependencyPath()
public org.apache.hadoop.fs.Path getDependencyTarGzip()
public org.apache.hadoop.fs.Path getHomeDirectory()
public boolean maybeAddImagePath(Map<String,org.apache.hadoop.yarn.api.records.LocalResource> localResources, org.apache.hadoop.fs.Path imagePath) throws IOException
IOExceptionpublic boolean maybeAddImagePath(Map<String,org.apache.hadoop.yarn.api.records.LocalResource> localResources, String imagePath) throws IOException
IOExceptionpublic org.apache.hadoop.yarn.api.records.LocalResource createAmResource(org.apache.hadoop.fs.Path destPath,
org.apache.hadoop.yarn.api.records.LocalResourceType resourceType)
throws IOException
destPath - dest path in filesystemresourceType - resource typeIOExceptionpublic Map<String,org.apache.hadoop.yarn.api.records.LocalResource> submitDirectory(org.apache.hadoop.fs.Path srcDir, String destRelativeDir) throws IOException
srcDir - src dirdestRelativeDir - dest dir (no trailing /)IOExceptionpublic org.apache.hadoop.yarn.api.records.LocalResource submitJarWithClass(Class clazz, org.apache.hadoop.fs.Path tempPath, String subdir, String jarName) throws IOException, SliderException
clazz - class to look forsubdir - subdirectory (expected to end in a "/")jarName - At the destinationIOException - trouble copying to HDFSSliderExceptionpublic org.apache.hadoop.yarn.api.records.LocalResource submitFile(File localFile, org.apache.hadoop.fs.Path tempPath, String subdir, String destFileName) throws IOException
localFile - filenamesubdir - subdirectory (expected to end in a "/")destFileName - destination filenameIOException - trouble copying to HDFSpublic void submitTarGzipAndUpdate(Map<String,org.apache.hadoop.yarn.api.records.LocalResource> providerResources) throws IOException, BadClusterStateException
providerResources - the provider resource map to be updatedIOException - trouble copying to HDFSBadClusterStateExceptionpublic void copyLocalFilesToHdfs(File localPath, FilenameFilter filenameFilter, org.apache.hadoop.fs.Path destDir, org.apache.hadoop.fs.permission.FsPermission fp) throws IOException
localPath is a
local directory then all files matching the filenameFilter
(optional) are copied, otherwise filenameFilter is ignored.localPath - a local file or directory pathfilenameFilter - if localPath is a directory then filenameFilter is used as
a filter (if specified)destDir - the destination HDFS directory where the file(s) should be copiedfp - file permissions of all the directories and files that will be
created in this apiIOExceptionpublic void copyLocalFileToHdfs(File localPath, org.apache.hadoop.fs.Path destPath, org.apache.hadoop.fs.permission.FsPermission fp) throws IOException
IOExceptionpublic String listFSDir(org.apache.hadoop.fs.Path path) throws IOException
path - directoryIOExceptionpublic Map<String,org.apache.hadoop.fs.Path> listPersistentInstances() throws IOException
IOExceptionpublic void touch(org.apache.hadoop.fs.Path path,
boolean overwrite)
throws IOException
IOExceptionpublic void cat(org.apache.hadoop.fs.Path path,
boolean overwrite,
String data)
throws IOException
IOExceptionpublic org.apache.hadoop.fs.Path createPathThatMustExist(String uri) throws SliderException, IOException
uri - uri to createSliderException - if the path does not existIOExceptionpublic org.apache.hadoop.fs.Path locateInstanceDefinition(String clustername) throws IOException, SliderException
clustername - name of the clusterIOException - IO problemsSliderException - if the path isn't therepublic void verifyClusterSpecExists(String clustername, org.apache.hadoop.fs.Path clusterSpecPath) throws IOException, SliderException
clustername - name of the cluster (For errors only)clusterSpecPath - cluster specification pathIOException - IO problemsSliderException - if the cluster specification is not presentCopyright © 2014–2015 The Apache Software Foundation. All rights reserved.