Class StorageStrategy

java.lang.Object
org.apache.drill.exec.store.StorageStrategy

public class StorageStrategy extends Object
Contains list of parameters that will be used to store path / files on file system.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final StorageStrategy
    For directories: drwxrwxr-x (owner and group have full access, others can read and execute).
    static final StorageStrategy
    Primary is used for temporary tables.
  • Constructor Summary

    Constructors
    Constructor
    Description
    StorageStrategy(String umask, boolean deleteOnExit)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    applyToFile(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path file)
    Applies storage strategy to file: sets permission and adds to file system delete on exit list if needed.
    org.apache.hadoop.fs.Path
    createFileAndApply(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path file)
    Creates passed file on appropriate file system.
    org.apache.hadoop.fs.Path
    createPathAndApply(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path)
    Creates passed path on appropriate file system.
    org.apache.hadoop.fs.permission.FsPermission
     
    org.apache.hadoop.fs.permission.FsPermission
     
     
    boolean
     
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • DEFAULT

      public static final StorageStrategy DEFAULT
      For directories: drwxrwxr-x (owner and group have full access, others can read and execute). For files: -rw-rw--r-- (owner and group can read and write, others can read). Folders and files are not deleted on file system close.
    • TEMPORARY

      public static final StorageStrategy TEMPORARY
      Primary is used for temporary tables. For directories: drwx------ (owner has full access, group and others have no access). For files: -rw------- (owner can read and write, group and others have no access). Folders and files are deleted on file system close.
  • Constructor Details

    • StorageStrategy

      public StorageStrategy(String umask, boolean deleteOnExit)
  • Method Details

    • getUmask

      public String getUmask()
    • isDeleteOnExit

      public boolean isDeleteOnExit()
    • getFolderPermission

      public org.apache.hadoop.fs.permission.FsPermission getFolderPermission()
      Returns:
      folder permission after applying umask
    • getFilePermission

      public org.apache.hadoop.fs.permission.FsPermission getFilePermission()
      Returns:
      file permission after applying umask
    • createPathAndApply

      public org.apache.hadoop.fs.Path createPathAndApply(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path) throws IOException
      Creates passed path on appropriate file system. Before creation checks which parent directories do not exists. Applies storage strategy rules to all newly created directories. Will return first created path or null already existed. Case 1: /a/b -> already exists, attempt to create /a/b/c/d Will create path and return /a/b/c. Case 2: /a/b/c -> already exists, attempt to create /a/b/c/d Will create path and return /a/b/c/d. Case 3: /a/b/c/d -> already exists, will return null.
      Parameters:
      fs - file system where file should be located
      path - location path
      Returns:
      first created parent path or file
      Throws:
      IOException - is thrown in case of problems while creating path, setting permission or adding path to delete on exit list
    • createFileAndApply

      public org.apache.hadoop.fs.Path createFileAndApply(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path file) throws IOException
      Creates passed file on appropriate file system. Before creation checks which parent directories do not exists. Applies storage strategy rules to all newly created directories and file. Will return first created parent path or file if no new parent paths created. Case 1: /a/b -> already exists, attempt to create /a/b/c/some_file.txt Will create file and return /a/b/c. Case 2: /a/b/c -> already exists, attempt to create /a/b/c/some_file.txt Will create file and return /a/b/c/some_file.txt. Case 3: /a/b/c/some_file.txt -> already exists, will fail.
      Parameters:
      fs - file system where file should be located
      file - file path
      Returns:
      first created parent path or file
      Throws:
      IOException - is thrown in case of problems while creating path, setting permission or adding path to delete on exit list
    • applyToFile

      public void applyToFile(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path file) throws IOException
      Applies storage strategy to file: sets permission and adds to file system delete on exit list if needed.
      Parameters:
      fs - file system
      file - path to file
      Throws:
      IOException - is thrown in case of problems while setting permission or adding file to delete on exit list
    • toString

      public String toString()
      Overrides:
      toString in class Object