Package org.apache.hadoop.hdfs.protocol
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 -
Constructor Summary
ConstructorsConstructorDescriptionBlockStoragePolicy(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 TypeMethodDescriptionList<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.booleanorg.apache.hadoop.fs.StorageTypegetCreationFallback(EnumSet<org.apache.hadoop.fs.StorageType> unavailables) org.apache.hadoop.fs.StorageType[]bytegetId()getName()org.apache.hadoop.fs.StorageTypegetReplicationFallback(EnumSet<org.apache.hadoop.fs.StorageType> unavailables) org.apache.hadoop.fs.StorageType[]org.apache.hadoop.fs.StorageType[]inthashCode()booleantoString()
-
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
- 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
StorageTypefor creation.
-
getReplicationFallback
public org.apache.hadoop.fs.StorageType getReplicationFallback(EnumSet<org.apache.hadoop.fs.StorageType> unavailables) - Returns:
- the fallback
StorageTypefor replication.
-
hashCode
public int hashCode() -
equals
-
toString
-
getId
public byte getId() -
getName
- Specified by:
getNamein interfaceorg.apache.hadoop.fs.BlockStoragePolicySpi
-
getStorageTypes
public org.apache.hadoop.fs.StorageType[] getStorageTypes()- Specified by:
getStorageTypesin interfaceorg.apache.hadoop.fs.BlockStoragePolicySpi
-
getCreationFallbacks
public org.apache.hadoop.fs.StorageType[] getCreationFallbacks()- Specified by:
getCreationFallbacksin interfaceorg.apache.hadoop.fs.BlockStoragePolicySpi
-
getReplicationFallbacks
public org.apache.hadoop.fs.StorageType[] getReplicationFallbacks()- Specified by:
getReplicationFallbacksin interfaceorg.apache.hadoop.fs.BlockStoragePolicySpi
-
isCopyOnCreateFile
public boolean isCopyOnCreateFile()- Specified by:
isCopyOnCreateFilein interfaceorg.apache.hadoop.fs.BlockStoragePolicySpi
-