public class AdvancedFSOps extends Object implements IAdvancedFSOps
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
symlinksDisabled |
| Modifier | Constructor and Description |
|---|---|
protected |
AdvancedFSOps(Map<String,Object> conf) |
| Modifier and Type | Method and Description |
|---|---|
void |
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(File location,
String data)
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.
|
OutputStream |
getOutputStream(File file)
Get an output stream to write to a given file.
|
Writer |
getWriter(File file)
Get a writer for the given location.
|
static AdvancedFSOps |
make(Map<String,Object> conf)
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 |
moveFile(File fromFile,
File toFile)
Moves a file to a given destination.
|
DirectoryStream<Path> |
newDirectoryStream(Path dir)
List the contents of a directory.
|
DirectoryStream<Path> |
newDirectoryStream(Path dir,
DirectoryStream.Filter<? super Path> filter)
List the contents of a directory.
|
void |
restrictDirectoryPermissions(File dir)
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[] |
slurp(File location)
Read the contents of a file into a byte array.
|
String |
slurpString(File location)
Read the contents of a file into a String.
|
boolean |
supportsAtomicDirectoryMove()
Check whether supports atomic directory move.
|
public static AdvancedFSOps make(Map<String,Object> conf)
Factory to create a new AdvancedFSOps.
conf - the configuration of the processpublic void restrictDirectoryPermissions(File dir) throws IOException
Set directory permissions to (OWNER)RWX (GROUP)R-X (OTHER)— On some systems that do not support this, it may become a noop.
restrictDirectoryPermissions in interface IAdvancedFSOpsdir - the directory to change permissions onIOException - on any errorpublic void moveDirectoryPreferAtomic(File fromDir, File toDir) throws IOException
Move fromDir to toDir, and try to make it an atomic move if possible.
moveDirectoryPreferAtomic in interface IAdvancedFSOpsfromDir - what to movetoDir - where to move it fromIOException - on any errorpublic void moveFile(File fromFile, File toFile) throws IOException
Moves a file to a given destination.
moveFile in interface IAdvancedFSOpsfromFile - file to movetoFile - where to move itIOException - on any errorpublic boolean supportsAtomicDirectoryMove()
Check whether supports atomic directory move.
supportsAtomicDirectoryMove in interface IAdvancedFSOpspublic void copyDirectory(File fromDir, File toDir) throws IOException
Copy a directory.
copyDirectory in interface IAdvancedFSOpsfromDir - from wheretoDir - to whereIOException - on any errorpublic void setupBlobPermissions(File path, String user) throws IOException
Setup permissions properly for an internal blob store path.
setupBlobPermissions in interface IAdvancedFSOpspath - the path to set the permissions onuser - the user to change the permissions forIOException - on any errorpublic void deleteIfExists(File path, String user, String logPrefix) throws IOException
Delete a file or a directory and all of the children. If it exists.
deleteIfExists in interface IAdvancedFSOpspath - 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 logsIOException - on any error.public void deleteIfExists(File path) throws IOException
Delete a file or a directory and all of the children. If it exists.
deleteIfExists in interface IAdvancedFSOpspath - what to deleteIOException - on any error.public void setupStormCodeDir(String user, File path) throws IOException
Setup the permissions for the storm code dir.
setupStormCodeDir in interface IAdvancedFSOpsuser - the user that owns the topologypath - the directory to set the permissions onIOException - on any errorpublic void setupWorkerArtifactsDir(String user, File path) throws IOException
Setup the permissions for the worker artifacts dirs.
setupWorkerArtifactsDir in interface IAdvancedFSOpsuser - the user that owns the topologypath - the directory to set the permissions onIOException - on any errorpublic boolean doRequiredTopoFilesExist(Map<String,Object> conf, String topologyId) throws IOException
Sanity check if everything the topology needs is there for it to run.
doRequiredTopoFilesExist in interface IAdvancedFSOpsconf - the config of the supervisortopologyId - the ID of the topologyIOException - on any errorpublic void forceMkdir(File path) throws IOException
Makes a directory, including any necessary but nonexistent parent directories.
forceMkdir in interface IAdvancedFSOpspath - the directory to createIOException - on any errorpublic void forceMkdir(Path path) throws IOException
Makes a directory, including any necessary but nonexistent parent directories.
forceMkdir in interface IAdvancedFSOpspath - the directory to createIOException - on any errorpublic DirectoryStream<Path> newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter) throws IOException
IAdvancedFSOpsList the contents of a directory.
newDirectoryStream in interface IAdvancedFSOpsdir - the driectory to list the contents offilter - a filter to decide if it should be included or notIOException - on any errorpublic DirectoryStream<Path> newDirectoryStream(Path dir) throws IOException
IAdvancedFSOpsList the contents of a directory.
newDirectoryStream in interface IAdvancedFSOpsdir - the driectory to list the contents ofIOException - on any errorpublic boolean fileExists(File path) throws IOException
Check if a file exists or not.
fileExists in interface IAdvancedFSOpspath - the path to checkIOException - on any error.public boolean fileExists(Path path) throws IOException
Check if a file exists or not.
fileExists in interface IAdvancedFSOpspath - the path to checkIOException - on any error.public Writer getWriter(File file) throws IOException
Get a writer for the given location.
getWriter in interface IAdvancedFSOpsfile - the file to write toIOException - on any errorpublic OutputStream getOutputStream(File file) throws IOException
Get an output stream to write to a given file.
getOutputStream in interface IAdvancedFSOpsfile - the file to write toIOException - on any errorpublic void dump(File location, String data) throws IOException
Dump a string to a file.
dump in interface IAdvancedFSOpslocation - where to write todata - the data to writeIOException - on any errorpublic String slurpString(File location) throws IOException
Read the contents of a file into a String.
slurpString in interface IAdvancedFSOpslocation - the file to readIOException - on any errorpublic byte[] slurp(File location) throws IOException
Read the contents of a file into a byte array.
slurp in interface IAdvancedFSOpslocation - the file to readIOException - on any errorpublic void createSymlink(File link, File target) throws IOException
Create a symbolic link pointing at target.
createSymlink in interface IAdvancedFSOpslink - the link to createtarget - where it should point toIOException - on any error.Copyright © 2021 The Apache Software Foundation. All rights reserved.