Class BlockStoragePolicy

java.lang.Object
org.apache.hadoop.hdfs.protocol.BlockStoragePolicy
All Implemented Interfaces:
org.apache.hadoop.fs.BlockStoragePolicySpi

@Private public class BlockStoragePolicy extends Object implements org.apache.hadoop.fs.BlockStoragePolicySpi
A block storage policy describes how to select the storage types for the replicas of a block.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.slf4j.Logger
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    BlockStoragePolicy(byte id, String name, org.apache.hadoop.fs.StorageType[] storageTypes, org.apache.hadoop.fs.StorageType[] creationFallbacks, org.apache.hadoop.fs.StorageType[] replicationFallbacks)
     
    BlockStoragePolicy(byte id, String name, org.apache.hadoop.fs.StorageType[] storageTypes, org.apache.hadoop.fs.StorageType[] creationFallbacks, org.apache.hadoop.fs.StorageType[] replicationFallbacks, boolean copyOnCreateFile)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    List<org.apache.hadoop.fs.StorageType>
    chooseExcess(short replication, Iterable<org.apache.hadoop.fs.StorageType> chosen)
    Choose excess storage types for deletion, given the replication number and the storage types of the chosen replicas.
    List<org.apache.hadoop.fs.StorageType>
    chooseStorageTypes(short replication)
     
    List<org.apache.hadoop.fs.StorageType>
    chooseStorageTypes(short replication, Iterable<org.apache.hadoop.fs.StorageType> chosen)
    Choose the storage types for storing the remaining replicas, given the replication number and the storage types of the chosen replicas.
    List<org.apache.hadoop.fs.StorageType>
    chooseStorageTypes(short replication, Iterable<org.apache.hadoop.fs.StorageType> chosen, EnumSet<org.apache.hadoop.fs.StorageType> unavailables, boolean isNewBlock)
    Choose the storage types for storing the remaining replicas, given the replication number, the storage types of the chosen replicas and the unavailable storage types.
    boolean
     
    org.apache.hadoop.fs.StorageType
    getCreationFallback(EnumSet<org.apache.hadoop.fs.StorageType> unavailables)
     
    org.apache.hadoop.fs.StorageType[]
     
    byte
     
     
    org.apache.hadoop.fs.StorageType
    getReplicationFallback(EnumSet<org.apache.hadoop.fs.StorageType> unavailables)
     
    org.apache.hadoop.fs.StorageType[]
     
    org.apache.hadoop.fs.StorageType[]
     
    int
     
    boolean
     
     

    Methods inherited from class java.lang.Object

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

    • LOG

      public static final org.slf4j.Logger LOG
  • Constructor Details

    • BlockStoragePolicy

      @VisibleForTesting public BlockStoragePolicy(byte id, String name, org.apache.hadoop.fs.StorageType[] storageTypes, org.apache.hadoop.fs.StorageType[] creationFallbacks, org.apache.hadoop.fs.StorageType[] replicationFallbacks)
    • BlockStoragePolicy

      @VisibleForTesting public BlockStoragePolicy(byte id, String name, org.apache.hadoop.fs.StorageType[] storageTypes, org.apache.hadoop.fs.StorageType[] creationFallbacks, org.apache.hadoop.fs.StorageType[] replicationFallbacks, boolean copyOnCreateFile)
  • Method Details

    • chooseStorageTypes

      public List<org.apache.hadoop.fs.StorageType> chooseStorageTypes(short replication)
      Returns:
      a list of StorageTypes for storing the replicas of a block.
    • chooseStorageTypes

      public List<org.apache.hadoop.fs.StorageType> chooseStorageTypes(short replication, Iterable<org.apache.hadoop.fs.StorageType> chosen)
      Choose the storage types for storing the remaining replicas, given the replication number and the storage types of the chosen replicas.
      Parameters:
      replication - the replication number.
      chosen - the storage types of the chosen replicas.
      Returns:
      a list of StorageTypes for storing the replicas of a block.
    • chooseStorageTypes

      public List<org.apache.hadoop.fs.StorageType> chooseStorageTypes(short replication, Iterable<org.apache.hadoop.fs.StorageType> chosen, EnumSet<org.apache.hadoop.fs.StorageType> unavailables, boolean isNewBlock)
      Choose the storage types for storing the remaining replicas, given the replication number, the storage types of the chosen replicas and the unavailable storage types. It uses fallback storage in case that the desired storage type is unavailable.
      Parameters:
      replication - the replication number.
      chosen - the storage types of the chosen replicas.
      unavailables - the unavailable storage types.
      isNewBlock - Is it for new block creation?
      Returns:
      a list of StorageTypes for storing the replicas of a block.
    • chooseExcess

      public List<org.apache.hadoop.fs.StorageType> chooseExcess(short replication, Iterable<org.apache.hadoop.fs.StorageType> chosen)
      Choose excess storage types for deletion, given the replication number and the storage types of the chosen replicas.
      Parameters:
      replication - the replication number.
      chosen - the storage types of the chosen replicas.
      Returns:
      a list of StorageTypes for deletion.
    • getCreationFallback

      public org.apache.hadoop.fs.StorageType getCreationFallback(EnumSet<org.apache.hadoop.fs.StorageType> unavailables)
      Returns:
      the fallback StorageType for creation.
    • getReplicationFallback

      public org.apache.hadoop.fs.StorageType getReplicationFallback(EnumSet<org.apache.hadoop.fs.StorageType> unavailables)
      Returns:
      the fallback StorageType for replication.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getId

      public byte getId()
    • getName

      public String getName()
      Specified by:
      getName in interface org.apache.hadoop.fs.BlockStoragePolicySpi
    • getStorageTypes

      public org.apache.hadoop.fs.StorageType[] getStorageTypes()
      Specified by:
      getStorageTypes in interface org.apache.hadoop.fs.BlockStoragePolicySpi
    • getCreationFallbacks

      public org.apache.hadoop.fs.StorageType[] getCreationFallbacks()
      Specified by:
      getCreationFallbacks in interface org.apache.hadoop.fs.BlockStoragePolicySpi
    • getReplicationFallbacks

      public org.apache.hadoop.fs.StorageType[] getReplicationFallbacks()
      Specified by:
      getReplicationFallbacks in interface org.apache.hadoop.fs.BlockStoragePolicySpi
    • isCopyOnCreateFile

      public boolean isCopyOnCreateFile()
      Specified by:
      isCopyOnCreateFile in interface org.apache.hadoop.fs.BlockStoragePolicySpi