org.apache.storm.daemon.supervisor

## Class AdvancedFSOps

- java.lang.Object
- - org.apache.storm.daemon.supervisor.AdvancedFSOps

- All Implemented Interfaces:
    IAdvancedFSOps

      public class AdvancedFSOps
      extends Object
      implements IAdvancedFSOps

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `symlinksDisabled`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AdvancedFSOps(Map<String,Object> conf)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### symlinksDisabled

          protected final boolean symlinksDisabled

  - ### Constructor Detail

    - #### AdvancedFSOps

          protected AdvancedFSOps(Map<String,Object> conf)

  - ### Method Detail

    - #### make

          public static AdvancedFSOps make(Map<String,Object> conf)

      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

          public 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.

      Specified by:
        `restrictDirectoryPermissions` in interface `IAdvancedFSOps`
      Parameters:
        `dir` - the directory to change permissions on
      Throws:
        `IOException` - on any error

    - #### moveDirectoryPreferAtomic

          public void moveDirectoryPreferAtomic(File fromDir,
                                                File toDir)
                                         throws IOException

      Move fromDir to toDir, and try to make it an atomic move if possible.

      Specified by:
        `moveDirectoryPreferAtomic` in interface `IAdvancedFSOps`
      Parameters:
        `fromDir` - what to move
        `toDir` - where to move it from
      Throws:
        `IOException` - on any error

    - #### moveFile

          public void moveFile(File fromFile,
                               File toFile)
                        throws IOException

      Moves a file to a given destination.

      Specified by:
        `moveFile` in interface `IAdvancedFSOps`
      Parameters:
        `fromFile` - file to move
        `toFile` - where to move it
      Throws:
        `IOException` - on any error

    - #### supportsAtomicDirectoryMove

          public boolean supportsAtomicDirectoryMove()

      Check whether supports atomic directory move.

      Specified by:
        `supportsAtomicDirectoryMove` in interface `IAdvancedFSOps`
      Returns:
        true if an atomic directory move works, else false

    - #### copyDirectory

          public void copyDirectory(File fromDir,
                                    File toDir)
                             throws IOException

      Copy a directory.

      Specified by:
        `copyDirectory` in interface `IAdvancedFSOps`
      Parameters:
        `fromDir` - from where
        `toDir` - to where
      Throws:
        `IOException` - on any error

    - #### setupBlobPermissions

          public void setupBlobPermissions(File path,
                                           String user)
                                    throws IOException

      Setup permissions properly for an internal blob store path.

      Specified by:
        `setupBlobPermissions` in interface `IAdvancedFSOps`
      Parameters:
        `path` - the path to set the permissions on
        `user` - the user to change the permissions for
      Throws:
        `IOException` - on any error

    - #### deleteIfExists

          public void deleteIfExists(File path,
                                     String user,
                                     String logPrefix)
                              throws IOException

      Delete a file or a directory and all of the children. If it exists.

      Specified by:
        `deleteIfExists` in interface `IAdvancedFSOps`
      Parameters:
        `path` - what to delete
        `user` - who to delete it as if doing it as someone else is supported
        `logPrefix` - 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

          public void deleteIfExists(File path)
                              throws IOException

      Delete a file or a directory and all of the children. If it exists.

      Specified by:
        `deleteIfExists` in interface `IAdvancedFSOps`
      Parameters:
        `path` - what to delete
      Throws:
        `IOException` - on any error.

    - #### setupStormCodeDir

          public void setupStormCodeDir(String user,
                                        File path)
                                 throws IOException

      Setup the permissions for the storm code dir.

      Specified by:
        `setupStormCodeDir` in interface `IAdvancedFSOps`
      Parameters:
        `user` - the user that owns the topology
        `path` - the directory to set the permissions on
      Throws:
        `IOException` - on any error

    - #### setupWorkerArtifactsDir

          public void setupWorkerArtifactsDir(String user,
                                              File path)
                                       throws IOException

      Setup the permissions for the worker artifacts dirs.

      Specified by:
        `setupWorkerArtifactsDir` in interface `IAdvancedFSOps`
      Parameters:
        `user` - the user that owns the topology
        `path` - the directory to set the permissions on
      Throws:
        `IOException` - on any error

    - #### doRequiredTopoFilesExist

          public boolean doRequiredTopoFilesExist(Map<String,Object> conf,
                                                  String topologyId)
                                           throws IOException

      Sanity check if everything the topology needs is there for it to run.

      Specified by:
        `doRequiredTopoFilesExist` in interface `IAdvancedFSOps`
      Parameters:
        `conf` - the config of the supervisor
        `topologyId` - the ID of the topology
      Returns:
        true if everything is there, else false
      Throws:
        `IOException` - on any error

    - #### forceMkdir

          public void forceMkdir(File path)
                          throws IOException

      Makes a directory, including any necessary but nonexistent parent directories.

      Specified by:
        `forceMkdir` in interface `IAdvancedFSOps`
      Parameters:
        `path` - the directory to create
      Throws:
        `IOException` - on any error

    - #### forceMkdir

          public void forceMkdir(Path path)
                          throws IOException

      Makes a directory, including any necessary but nonexistent parent directories.

      Specified by:
        `forceMkdir` in interface `IAdvancedFSOps`
      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 interface `IAdvancedFSOps`
      Parameters:
        `dir` - the driectory to list the contents of
        `filter` - a filter to decide if it should be included or not
      Returns:
        A stream of directory entries
      Throws:
        `IOException` - on any error

    - #### newDirectoryStream

          public DirectoryStream<Path> newDirectoryStream(Path dir)
                                                   throws IOException

      Description copied from interface: `IAdvancedFSOps`

      List the contents of a directory.

      Specified by:
        `newDirectoryStream` in interface `IAdvancedFSOps`
      Parameters:
        `dir` - the driectory to list the contents of
      Returns:
        A stream of directory entries
      Throws:
        `IOException` - on any error

    - #### fileExists

          public boolean fileExists(File path)
                             throws IOException

      Check if a file exists or not.

      Specified by:
        `fileExists` in interface `IAdvancedFSOps`
      Parameters:
        `path` - the path to check
      Returns:
        true if it exists else false
      Throws:
        `IOException` - on any error.

    - #### fileExists

          public boolean fileExists(Path path)
                             throws IOException

      Check if a file exists or not.

      Specified by:
        `fileExists` in interface `IAdvancedFSOps`
      Parameters:
        `path` - the path to check
      Returns:
        true if it exists else false
      Throws:
        `IOException` - on any error.

    - #### getWriter

          public Writer getWriter(File file)
                           throws IOException

      Get a writer for the given location.

      Specified by:
        `getWriter` in interface `IAdvancedFSOps`
      Parameters:
        `file` - the file to write to
      Returns:
        the Writer to use.
      Throws:
        `IOException` - on any error

    - #### getOutputStream

          public OutputStream getOutputStream(File file)
                                       throws IOException

      Get an output stream to write to a given file.

      Specified by:
        `getOutputStream` in interface `IAdvancedFSOps`
      Parameters:
        `file` - the file to write to
      Returns:
        an OutputStream for that file
      Throws:
        `IOException` - on any error

    - #### dump

          public void dump(File location,
                           String data)
                    throws IOException

      Dump a string to a file.

      Specified by:
        `dump` in interface `IAdvancedFSOps`
      Parameters:
        `location` - where to write to
        `data` - the data to write
      Throws:
        `IOException` - on any error

    - #### slurpString

          public String slurpString(File location)
                             throws IOException

      Read the contents of a file into a String.

      Specified by:
        `slurpString` in interface `IAdvancedFSOps`
      Parameters:
        `location` - the file to read
      Returns:
        the contents of the file
      Throws:
        `IOException` - on any error

    - #### slurp

          public byte[] slurp(File location)
                       throws IOException

      Read the contents of a file into a byte array.

      Specified by:
        `slurp` in interface `IAdvancedFSOps`
      Parameters:
        `location` - the file to read
      Returns:
        the contents of the file
      Throws:
        `IOException` - on any error

    - #### createSymlink

          public void createSymlink(File link,
                                    File target)
                             throws IOException

      Create a symbolic link pointing at target.

      Specified by:
        `createSymlink` in interface `IAdvancedFSOps`
      Parameters:
        `link` - the link to create
        `target` - where it should point to
      Throws:
        `IOException` - on any error.

Copyright © 2019 The Apache Software Foundation. All rights reserved.