Class AdvancedFSOps
java.lang.Object
org.apache.storm.daemon.supervisor.AdvancedFSOps
- All Implemented Interfaces:
IAdvancedFSOps
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
copyDirectory
(File fromDir, File toDir) Copy a directory.void
createSymlink
(File link, File target) Create a symbolic link pointing at target.void
deleteIfExists
(File path) Delete a file or a directory and all of the children.void
deleteIfExists
(File path, String user, String logPrefix) Delete a file or a directory and all of the children.boolean
doRequiredTopoFilesExist
(Map<String, Object> conf, String topologyId) Sanity check if everything the topology needs is there for it to run.void
Dump a string to a file.boolean
fileExists
(File path) Check if a file exists or not.boolean
fileExists
(Path path) Check if a file exists or not.void
forceMkdir
(File path) Makes a directory, including any necessary but nonexistent parent directories.void
forceMkdir
(Path path) Makes a directory, including any necessary but nonexistent parent directories.getOutputStream
(File file) Get an output stream to write to a given file.Get a writer for the given location.static AdvancedFSOps
Factory to create a new AdvancedFSOps.void
moveDirectoryPreferAtomic
(File fromDir, File toDir) Move fromDir to toDir, and try to make it an atomic move if possible.void
Moves a file to a given destination.newDirectoryStream
(Path dir) List the contents of a directory.newDirectoryStream
(Path dir, DirectoryStream.Filter<? super Path> filter) List the contents of a directory.void
Set directory permissions to (OWNER)RWX (GROUP)R-X (OTHER)--- On some systems that do not support this, it may become a noop.void
setupBlobPermissions
(File path, String user) Setup permissions properly for an internal blob store path.void
setupStormCodeDir
(String user, File path) Setup the permissions for the storm code dir.void
setupWorkerArtifactsDir
(String user, File path) Setup the permissions for the worker artifacts dirs.byte[]
Read the contents of a file into a byte array.slurpString
(File location) Read the contents of a file into a String.boolean
Check whether supports atomic directory move.
-
Field Details
-
symlinksDisabled
protected final boolean symlinksDisabled
-
-
Constructor Details
-
AdvancedFSOps
-
-
Method Details
-
make
Factory to create a new AdvancedFSOps.- Parameters:
conf
- the configuration of the process- Returns:
- the appropriate instance of the class for this config and environment.
-
restrictDirectoryPermissions
Set directory permissions to (OWNER)RWX (GROUP)R-X (OTHER)--- On some systems that do not support this, it may become a noop.- Specified by:
restrictDirectoryPermissions
in interfaceIAdvancedFSOps
- Parameters:
dir
- the directory to change permissions on- Throws:
IOException
- on any error
-
moveDirectoryPreferAtomic
Move fromDir to toDir, and try to make it an atomic move if possible.- Specified by:
moveDirectoryPreferAtomic
in interfaceIAdvancedFSOps
- Parameters:
fromDir
- what to movetoDir
- where to move it from- Throws:
IOException
- on any error
-
moveFile
Moves a file to a given destination.- Specified by:
moveFile
in interfaceIAdvancedFSOps
- Parameters:
fromFile
- file to movetoFile
- where to move it- Throws:
IOException
- on any error
-
supportsAtomicDirectoryMove
public boolean supportsAtomicDirectoryMove()Check whether supports atomic directory move.- Specified by:
supportsAtomicDirectoryMove
in interfaceIAdvancedFSOps
- Returns:
- true if an atomic directory move works, else false
-
copyDirectory
Copy a directory.- Specified by:
copyDirectory
in interfaceIAdvancedFSOps
- Parameters:
fromDir
- from wheretoDir
- to where- Throws:
IOException
- on any error
-
setupBlobPermissions
Setup permissions properly for an internal blob store path.- Specified by:
setupBlobPermissions
in interfaceIAdvancedFSOps
- Parameters:
path
- the path to set the permissions onuser
- the user to change the permissions for- Throws:
IOException
- on any error
-
deleteIfExists
Delete a file or a directory and all of the children. If it exists.- Specified by:
deleteIfExists
in interfaceIAdvancedFSOps
- Parameters:
path
- what to deleteuser
- who to delete it as if doing it as someone else is supportedlogPrefix
- if an external process needs to be launched to delete the object what prefix to include in the logs- Throws:
IOException
- on any error.
-
deleteIfExists
Delete a file or a directory and all of the children. If it exists.- Specified by:
deleteIfExists
in interfaceIAdvancedFSOps
- Parameters:
path
- what to delete- Throws:
IOException
- on any error.
-
setupStormCodeDir
Setup the permissions for the storm code dir.- Specified by:
setupStormCodeDir
in interfaceIAdvancedFSOps
- Parameters:
user
- the user that owns the topologypath
- the directory to set the permissions on- Throws:
IOException
- on any error
-
setupWorkerArtifactsDir
Setup the permissions for the worker artifacts dirs.- Specified by:
setupWorkerArtifactsDir
in interfaceIAdvancedFSOps
- Parameters:
user
- the user that owns the topologypath
- the directory to set the permissions on- Throws:
IOException
- on any error
-
doRequiredTopoFilesExist
public boolean doRequiredTopoFilesExist(Map<String, Object> conf, String topologyId) throws IOExceptionSanity check if everything the topology needs is there for it to run.- Specified by:
doRequiredTopoFilesExist
in interfaceIAdvancedFSOps
- Parameters:
conf
- the config of the supervisortopologyId
- the ID of the topology- Returns:
- true if everything is there, else false
- Throws:
IOException
- on any error
-
forceMkdir
Makes a directory, including any necessary but nonexistent parent directories.- Specified by:
forceMkdir
in interfaceIAdvancedFSOps
- Parameters:
path
- the directory to create- Throws:
IOException
- on any error
-
forceMkdir
Makes a directory, including any necessary but nonexistent parent directories.- Specified by:
forceMkdir
in interfaceIAdvancedFSOps
- Parameters:
path
- the directory to create- Throws:
IOException
- on any error
-
newDirectoryStream
public DirectoryStream<Path> newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter) throws IOException Description copied from interface:IAdvancedFSOps
List the contents of a directory.- Specified by:
newDirectoryStream
in interfaceIAdvancedFSOps
- Parameters:
dir
- the driectory to list the contents offilter
- a filter to decide if it should be included or not- Returns:
- A stream of directory entries
- Throws:
IOException
- on any error
-
newDirectoryStream
Description copied from interface:IAdvancedFSOps
List the contents of a directory.- Specified by:
newDirectoryStream
in interfaceIAdvancedFSOps
- Parameters:
dir
- the driectory to list the contents of- Returns:
- A stream of directory entries
- Throws:
IOException
- on any error
-
fileExists
Check if a file exists or not.- Specified by:
fileExists
in interfaceIAdvancedFSOps
- Parameters:
path
- the path to check- Returns:
- true if it exists else false
- Throws:
IOException
- on any error.
-
fileExists
Check if a file exists or not.- Specified by:
fileExists
in interfaceIAdvancedFSOps
- Parameters:
path
- the path to check- Returns:
- true if it exists else false
- Throws:
IOException
- on any error.
-
getWriter
Get a writer for the given location.- Specified by:
getWriter
in interfaceIAdvancedFSOps
- Parameters:
file
- the file to write to- Returns:
- the Writer to use.
- Throws:
IOException
- on any error
-
getOutputStream
Get an output stream to write to a given file.- Specified by:
getOutputStream
in interfaceIAdvancedFSOps
- Parameters:
file
- the file to write to- Returns:
- an OutputStream for that file
- Throws:
IOException
- on any error
-
dump
Dump a string to a file.- Specified by:
dump
in interfaceIAdvancedFSOps
- Parameters:
location
- where to write todata
- the data to write- Throws:
IOException
- on any error
-
slurpString
Read the contents of a file into a String.- Specified by:
slurpString
in interfaceIAdvancedFSOps
- Parameters:
location
- the file to read- Returns:
- the contents of the file
- Throws:
IOException
- on any error
-
slurp
Read the contents of a file into a byte array.- Specified by:
slurp
in interfaceIAdvancedFSOps
- Parameters:
location
- the file to read- Returns:
- the contents of the file
- Throws:
IOException
- on any error
-
createSymlink
Create a symbolic link pointing at target.- Specified by:
createSymlink
in interfaceIAdvancedFSOps
- Parameters:
link
- the link to createtarget
- where it should point to- Throws:
IOException
- on any error.
-