Interface IAdvancedFSOps

  • All Known Implementing Classes:
    AdvancedFSOps

    public interface IAdvancedFSOps
    • Method Detail

      • restrictDirectoryPermissions

        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.
        Parameters:
        dir - the directory to change permissions on
        Throws:
        IOException - on any error
      • moveDirectoryPreferAtomic

        void moveDirectoryPreferAtomic​(File fromDir,
                                       File toDir)
                                throws IOException
        Move fromDir to toDir, and try to make it an atomic move if possible.
        Parameters:
        fromDir - what to move
        toDir - where to move it from
        Throws:
        IOException - on any error
      • moveFile

        void moveFile​(File fromFile,
                      File toFile)
               throws IOException
        Moves a file to a given destination.
        Parameters:
        fromFile - file to move
        toFile - where to move it
        Throws:
        IOException - on any error
      • supportsAtomicDirectoryMove

        boolean supportsAtomicDirectoryMove()
        Check whether supports atomic directory move.
        Returns:
        true if an atomic directory move works, else false
      • copyDirectory

        void copyDirectory​(File fromDir,
                           File toDir)
                    throws IOException
        Copy a directory.
        Parameters:
        fromDir - from where
        toDir - to where
        Throws:
        IOException - on any error
      • setupBlobPermissions

        void setupBlobPermissions​(File path,
                                  String user)
                           throws IOException
        Setup permissions properly for an internal blob store path.
        Parameters:
        path - the path to set the permissions on
        user - the user to change the permissions for
        Throws:
        IOException - on any error
      • deleteIfExists

        void deleteIfExists​(File path,
                            String user,
                            String logPrefix)
                     throws IOException
        Delete a file or a directory and all of the children. If it exists.
        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

        void deleteIfExists​(File path)
                     throws IOException
        Delete a file or a directory and all of the children. If it exists.
        Parameters:
        path - what to delete
        Throws:
        IOException - on any error.
      • setupStormCodeDir

        void setupStormCodeDir​(String user,
                               File path)
                        throws IOException
        Setup the permissions for the storm code dir.
        Parameters:
        user - the owner of the topology
        path - the directory to set the permissions on
        Throws:
        IOException - on any error
      • setupWorkerArtifactsDir

        void setupWorkerArtifactsDir​(String user,
                                     File path)
                              throws IOException
        Setup the permissions for the worker artifacts dirs.
        Parameters:
        user - the owner of the topology
        path - the directory to set the permissions on
        Throws:
        IOException - on any error
      • doRequiredTopoFilesExist

        boolean doRequiredTopoFilesExist​(Map<String,​Object> conf,
                                         String topologyId)
                                  throws IOException
        Sanity check if everything the topology needs is there for it to run.
        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

        void forceMkdir​(File path)
                 throws IOException
        Makes a directory, including any necessary but nonexistent parent directories.
        Parameters:
        path - the directory to create
        Throws:
        IOException - on any error
      • forceMkdir

        void forceMkdir​(Path path)
                 throws IOException
        Makes a directory, including any necessary but nonexistent parent directories.
        Parameters:
        path - the directory to create
        Throws:
        IOException - on any error
      • newDirectoryStream

        DirectoryStream<Path> newDirectoryStream​(Path dir,
                                                 DirectoryStream.Filter<? super Path> filter)
                                          throws IOException
        List the contents of a directory.
        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

        DirectoryStream<Path> newDirectoryStream​(Path dir)
                                          throws IOException
        List the contents of a directory.
        Parameters:
        dir - the driectory to list the contents of
        Returns:
        A stream of directory entries
        Throws:
        IOException - on any error
      • fileExists

        boolean fileExists​(File path)
                    throws IOException
        Check if a file exists or not.
        Parameters:
        path - the path to check
        Returns:
        true if it exists else false
        Throws:
        IOException - on any error.
      • fileExists

        boolean fileExists​(Path path)
                    throws IOException
        Check if a file exists or not.
        Parameters:
        path - the path to check
        Returns:
        true if it exists else false
        Throws:
        IOException - on any error.
      • getWriter

        Writer getWriter​(File file)
                  throws IOException
        Get a writer for the given location.
        Parameters:
        file - the file to write to
        Returns:
        the Writer to use.
        Throws:
        IOException - on any error
      • getOutputStream

        OutputStream getOutputStream​(File file)
                              throws IOException
        Get an output stream to write to a given file.
        Parameters:
        file - the file to write to
        Returns:
        an OutputStream for that file
        Throws:
        IOException - on any error
      • dump

        void dump​(File location,
                  String data)
           throws IOException
        Dump a string to a file.
        Parameters:
        location - where to write to
        data - the data to write
        Throws:
        IOException - on any error
      • slurpString

        String slurpString​(File location)
                    throws IOException
        Read the contents of a file into a String.
        Parameters:
        location - the file to read
        Returns:
        the contents of the file
        Throws:
        IOException - on any error
      • slurp

        byte[] slurp​(File location)
              throws IOException
        Read the contents of a file into a byte array.
        Parameters:
        location - the file to read
        Returns:
        the contents of the file
        Throws:
        IOException - on any error
      • createSymlink

        void createSymlink​(File link,
                           File target)
                    throws IOException
        Create a symbolic link pointing at target.
        Parameters:
        link - the link to create
        target - where it should point to
        Throws:
        IOException - on any error.