Class BaseCommand

    • Field Detail

      • console

        protected final org.slf4j.Logger console
    • Constructor Detail

      • BaseCommand

        public BaseCommand​(org.slf4j.Logger console)
    • Method Detail

      • defaultFS

        public org.apache.hadoop.fs.FileSystem defaultFS()
                                                  throws IOException
        Returns:
        FileSystem to use when no file system scheme is present in a path
        Throws:
        IOException - if there is an error loading the default fs
      • output

        public void output​(String content,
                           org.slf4j.Logger console,
                           String filename)
                    throws IOException
        Output content to the console or a file. This will not produce checksum files.
        Parameters:
        content - String content to write
        console - A Logger for writing to the console
        filename - The destination Path as a String
        Throws:
        IOException - if there is an error while writing
      • create

        public org.apache.hadoop.fs.FSDataOutputStream create​(String filename)
                                                       throws IOException
        Creates a file and returns an open FSDataOutputStream. If the file does not have a file system scheme, this uses the default FS. This will not produce checksum files and will overwrite a file that already exists.
        Parameters:
        filename - The filename to create
        Returns:
        An open FSDataOutputStream
        Throws:
        IOException - if there is an error creating the file
      • createWithChecksum

        public org.apache.hadoop.fs.FSDataOutputStream createWithChecksum​(String filename)
                                                                   throws IOException
        Creates a file and returns an open FSDataOutputStream. If the file does not have a file system scheme, this uses the default FS. This will produce checksum files and will overwrite a file that already exists.
        Parameters:
        filename - The filename to create
        Returns:
        An open FSDataOutputStream
        Throws:
        IOException - if there is an error creating the file
      • createWithNoOverwrite

        public org.apache.hadoop.fs.FSDataOutputStream createWithNoOverwrite​(String filename)
                                                                      throws IOException
        Creates a file and returns an open FSDataOutputStream. If the file does not have a file system scheme, this uses the default FS. This will neither produce checksum files nor overwrite a file that already exists.
        Parameters:
        filename - The filename to create
        Returns:
        An open FSDataOutputStream
        Throws:
        IOException - if there is an error creating the file
      • qualifiedPath

        public org.apache.hadoop.fs.Path qualifiedPath​(String filename)
                                                throws IOException
        Returns a qualified Path for the filename. If the file does not have a file system scheme, this uses the default FS.
        Parameters:
        filename - The filename to qualify
        Returns:
        A qualified Path for the filename
        Throws:
        IOException - if there is an error creating a qualified path
      • qualifiedURI

        public URI qualifiedURI​(String filename)
                         throws IOException
        Returns a URI for the filename that is a qualified Path or a resource URI. If the file does not have a file system scheme, this uses the default FS.
        Parameters:
        filename - The filename to qualify
        Returns:
        A qualified URI for the filename
        Throws:
        IOException - if there is an error creating a qualified URI
      • open

        public InputStream open​(String filename)
                         throws IOException
        Opens an existing file or resource. If the file does not have a file system scheme, this uses the default FS.
        Parameters:
        filename - The filename to open.
        Returns:
        An open InputStream with the file contents
        Throws:
        IOException - if there is an error opening the file
        IllegalArgumentException - If the file does not exist
      • setConf

        public void setConf​(org.apache.hadoop.conf.Configuration conf)
        Specified by:
        setConf in interface org.apache.hadoop.conf.Configurable
      • getConf

        public org.apache.hadoop.conf.Configuration getConf()
        Specified by:
        getConf in interface org.apache.hadoop.conf.Configurable