Class CoreFileSystem
java.lang.Object
org.apache.hadoop.yarn.service.utils.CoreFileSystem
- Direct Known Subclasses:
SliderFileSystem
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.apache.hadoop.conf.Configurationprotected final org.apache.hadoop.fs.FileSystem -
Constructor Summary
ConstructorsConstructorDescriptionCoreFileSystem(org.apache.hadoop.conf.Configuration configuration) CoreFileSystem(org.apache.hadoop.fs.FileSystem fileSystem, org.apache.hadoop.conf.Configuration configuration) -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.hadoop.fs.PathbuildClusterDirPath(String clustername) Build up the path string for a cluster instance -no attempt to create the directory is madeorg.apache.hadoop.fs.PathbuildClusterUpgradeDirPath(String clusterName, String version) Build up the upgrade path string for a cluster.org.apache.hadoop.fs.PathbuildKeytabInstallationDirPath(String keytabFolder) Build up the path string for keytab install location -no attempt to create the directory is madeorg.apache.hadoop.fs.PathbuildKeytabPath(String keytabDir, String keytabName, String clusterName) Build up the path string for keytab install location -no attempt to create the directory is madeorg.apache.hadoop.fs.PathbuildResourcePath(String resourceFolder) Build up the path string for resource install location -no attempt to create the directory is madeorg.apache.hadoop.fs.PathbuildResourcePath(String dirName, String fileName) Build up the path string for resource install location -no attempt to create the directory is madecat(org.apache.hadoop.fs.Path path) voidcopyHdfsFileToLocal(org.apache.hadoop.fs.Path hdfsPath, File destFile) voidcopyLocalFileToHdfs(File localPath, org.apache.hadoop.fs.Path destPath, org.apache.hadoop.fs.permission.FsPermission fp) org.apache.hadoop.yarn.api.records.LocalResourcecreateAmResource(org.apache.hadoop.fs.Path destPath, org.apache.hadoop.yarn.api.records.LocalResourceType resourceType, org.apache.hadoop.yarn.api.records.LocalResourceVisibility visibility) Create an AM resource from thevoidcreateWithPermissions(org.apache.hadoop.fs.Path dir, org.apache.hadoop.fs.permission.FsPermission clusterPerms) Create a directory with the given permissions.voiddeleteClusterUpgradeDir(String clusterName, String version) Delete the upgrade cluster directory.org.apache.hadoop.fs.PathGet the base pathorg.apache.hadoop.fs.PathGet service dependency absolute filepath in HDFS used for application submission.org.apache.hadoop.fs.FileSystemReturns the underlying FileSystem for this object.org.apache.hadoop.fs.Pathorg.apache.hadoop.fs.PathgetTempPathForCluster(String clustername) Get the temp path for this clusterbooleanisFile(org.apache.hadoop.fs.Path path) Given a path, check if it exists and is a filelistFSDir(org.apache.hadoop.fs.Path path) list entries in a filesystem directorysubmitDirectory(org.apache.hadoop.fs.Path srcDir, String destRelativeDir) Register all files under a fs path as a directory to push outorg.apache.hadoop.yarn.api.records.LocalResourcesubmitFile(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 filesystemorg.apache.hadoop.yarn.api.records.LocalResourcesubmitJarWithClass(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 invoidsubmitTarGzipAndUpdate(Map<String, org.apache.hadoop.yarn.api.records.LocalResource> providerResources) Submit the AM tar.gz resource referenced by the instance's cluster filesystem.toString()voidverifyClusterDirectoryNonexistent(String clustername, org.apache.hadoop.fs.Path clusterDirectory) Verify that the cluster directory is not presentvoidverifyDirectoryNonexistent(org.apache.hadoop.fs.Path clusterDirectory) Verify that the given directory is not presentvoidverifyDirectoryWriteAccess(org.apache.hadoop.fs.Path dirPath) Verify that a user has write access to a directory.voidverifyFileExists(org.apache.hadoop.fs.Path path) Verify that a path existsvoidverifyPathExists(org.apache.hadoop.fs.Path path) Verify that a path exists
-
Field Details
-
fileSystem
protected final org.apache.hadoop.fs.FileSystem fileSystem -
configuration
protected final org.apache.hadoop.conf.Configuration configuration
-
-
Constructor Details
-
CoreFileSystem
public CoreFileSystem(org.apache.hadoop.fs.FileSystem fileSystem, org.apache.hadoop.conf.Configuration configuration) -
CoreFileSystem
- Throws:
IOException
-
-
Method Details
-
getTempPathForCluster
Get the temp path for this cluster- Parameters:
clustername- name of the cluster- Returns:
- path for temp files (is not purged)
-
getFileSystem
public org.apache.hadoop.fs.FileSystem getFileSystem()Returns the underlying FileSystem for this object.- Returns:
- filesystem
-
toString
-
buildClusterDirPath
Build up the path string for a cluster instance -no attempt to create the directory is made- Parameters:
clustername- name of the cluster- Returns:
- the path for persistent data
-
buildClusterUpgradeDirPath
Build up the upgrade path string for a cluster. No attempt to create the directory is made.- Parameters:
clusterName- name of the clusterversion- version of the cluster- Returns:
- the upgrade path to the cluster
-
deleteClusterUpgradeDir
Delete the upgrade cluster directory.- Parameters:
clusterName- name of the clusterversion- version of the cluster- Throws:
IOException
-
buildKeytabInstallationDirPath
Build up the path string for keytab install location -no attempt to create the directory is made- Returns:
- the path for keytab
-
buildKeytabPath
public 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- Returns:
- the path for keytab installation location
-
buildResourcePath
Build up the path string for resource install location -no attempt to create the directory is made- Returns:
- the path for resource
-
buildResourcePath
Build up the path string for resource install location -no attempt to create the directory is made- Returns:
- the path for resource
-
createWithPermissions
public void createWithPermissions(org.apache.hadoop.fs.Path dir, org.apache.hadoop.fs.permission.FsPermission clusterPerms) throws IOException, BadClusterStateException Create a directory with the given permissions.- Parameters:
dir- directoryclusterPerms- cluster permissions- Throws:
IOException- IO problemBadClusterStateException- any cluster state problem
-
verifyClusterDirectoryNonexistent
public void verifyClusterDirectoryNonexistent(String clustername, org.apache.hadoop.fs.Path clusterDirectory) throws IOException, SliderException Verify that the cluster directory is not present- Parameters:
clustername- name of the clusterclusterDirectory- actual directory to look for- Throws:
IOException- trouble with FSSliderException- If the directory exists
-
verifyDirectoryNonexistent
public void verifyDirectoryNonexistent(org.apache.hadoop.fs.Path clusterDirectory) throws IOException, SliderException Verify that the given directory is not present- Parameters:
clusterDirectory- actual directory to look for- Throws:
IOException- trouble with FSSliderException- If the directory exists
-
verifyDirectoryWriteAccess
public void verifyDirectoryWriteAccess(org.apache.hadoop.fs.Path dirPath) throws IOException, SliderException Verify that a user has write access to a directory. It does this by creating then deleting a temp file- Parameters:
dirPath- actual directory to look for- Throws:
FileNotFoundException- file not foundIOException- trouble with FSBadClusterStateException- if the directory is not writeableSliderException
-
verifyPathExists
Verify that a path exists- Parameters:
path- path to check- Throws:
FileNotFoundException- file not foundIOException- trouble with FS
-
verifyFileExists
Verify that a path exists- Parameters:
path- path to check- Throws:
FileNotFoundException- file not found or is not a fileIOException- trouble with FS
-
isFile
public boolean isFile(org.apache.hadoop.fs.Path path) Given a path, check if it exists and is a file- Parameters:
path- absolute path to the file to check- Returns:
- true if and only if path exists and is a file, false for all other reasons including if file check throws IOException
-
getBaseApplicationPath
public org.apache.hadoop.fs.Path getBaseApplicationPath()Get the base path- Returns:
- the base path optionally configured by
YarnServiceConf.YARN_SERVICE_BASE_PATH
-
getDependencyTarGzip
public org.apache.hadoop.fs.Path getDependencyTarGzip()Get service dependency absolute filepath in HDFS used for application submission.- Returns:
- the absolute path to service dependency tarball in HDFS
-
getHomeDirectory
public org.apache.hadoop.fs.Path getHomeDirectory() -
createAmResource
public org.apache.hadoop.yarn.api.records.LocalResource createAmResource(org.apache.hadoop.fs.Path destPath, org.apache.hadoop.yarn.api.records.LocalResourceType resourceType, org.apache.hadoop.yarn.api.records.LocalResourceVisibility visibility) throws IOException Create an AM resource from the- Parameters:
destPath- dest path in filesystemresourceType- resource type- Returns:
- the local resource for AM
- Throws:
IOException
-
submitDirectory
public Map<String,org.apache.hadoop.yarn.api.records.LocalResource> submitDirectory(org.apache.hadoop.fs.Path srcDir, String destRelativeDir) throws IOException Register all files under a fs path as a directory to push out- Parameters:
srcDir- src dirdestRelativeDir- dest dir (no trailing /)- Returns:
- the map of entries
- Throws:
IOException
-
submitJarWithClass
public org.apache.hadoop.yarn.api.records.LocalResource submitJarWithClass(Class clazz, org.apache.hadoop.fs.Path tempPath, String subdir, String jarName) throws IOException, SliderException Submit a JAR containing a specific class, returning the resource to be mapped in- Parameters:
clazz- class to look forsubdir- subdirectory (expected to end in a "/")jarName- At the destination- Returns:
- the local resource ref
- Throws:
IOException- trouble copying to HDFSSliderException
-
submitFile
public org.apache.hadoop.yarn.api.records.LocalResource submitFile(File localFile, org.apache.hadoop.fs.Path tempPath, String subdir, String destFileName) throws IOException Submit a local file to the filesystem references by the instance's cluster filesystem- Parameters:
localFile- filenamesubdir- subdirectory (expected to end in a "/")destFileName- destination filename- Returns:
- the local resource ref
- Throws:
IOException- trouble copying to HDFS
-
submitTarGzipAndUpdate
public void submitTarGzipAndUpdate(Map<String, org.apache.hadoop.yarn.api.records.LocalResource> providerResources) throws IOException, BadClusterStateExceptionSubmit the AM tar.gz resource referenced by the instance's cluster filesystem. Also, update the providerResources object with the new resource.- Parameters:
providerResources- the provider resource map to be updated- Throws:
IOException- trouble copying to HDFSBadClusterStateException
-
copyLocalFileToHdfs
public void copyLocalFileToHdfs(File localPath, org.apache.hadoop.fs.Path destPath, org.apache.hadoop.fs.permission.FsPermission fp) throws IOException - Throws:
IOException
-
copyHdfsFileToLocal
public void copyHdfsFileToLocal(org.apache.hadoop.fs.Path hdfsPath, File destFile) throws IOException - Throws:
IOException
-
listFSDir
list entries in a filesystem directory- Parameters:
path- directory- Returns:
- a listing, one to a line
- Throws:
IOException
-
cat
- Throws:
IOException
-