Search in sources :

Example 1 with EnumCounters

use of org.apache.hadoop.hdfs.util.EnumCounters in project hadoop by apache.

the class FSDirectory method getStorageTypeDeltas.

public EnumCounters<StorageType> getStorageTypeDeltas(byte storagePolicyID, long dsDelta, short oldRep, short newRep) {
    EnumCounters<StorageType> typeSpaceDeltas = new EnumCounters<StorageType>(StorageType.class);
    // empty file
    if (dsDelta == 0) {
        return typeSpaceDeltas;
    }
    // Storage type and its quota are only available when storage policy is set
    if (storagePolicyID != HdfsConstants.BLOCK_STORAGE_POLICY_ID_UNSPECIFIED) {
        BlockStoragePolicy storagePolicy = getBlockManager().getStoragePolicy(storagePolicyID);
        if (oldRep != newRep) {
            List<StorageType> oldChosenStorageTypes = storagePolicy.chooseStorageTypes(oldRep);
            for (StorageType t : oldChosenStorageTypes) {
                if (!t.supportTypeQuota()) {
                    continue;
                }
                Preconditions.checkArgument(dsDelta > 0);
                typeSpaceDeltas.add(t, -dsDelta);
            }
        }
        List<StorageType> newChosenStorageTypes = storagePolicy.chooseStorageTypes(newRep);
        for (StorageType t : newChosenStorageTypes) {
            if (!t.supportTypeQuota()) {
                continue;
            }
            typeSpaceDeltas.add(t, dsDelta);
        }
    }
    return typeSpaceDeltas;
}
Also used : EnumCounters(org.apache.hadoop.hdfs.util.EnumCounters) StorageType(org.apache.hadoop.fs.StorageType) BlockStoragePolicy(org.apache.hadoop.hdfs.protocol.BlockStoragePolicy)

Aggregations

StorageType (org.apache.hadoop.fs.StorageType)1 BlockStoragePolicy (org.apache.hadoop.hdfs.protocol.BlockStoragePolicy)1 EnumCounters (org.apache.hadoop.hdfs.util.EnumCounters)1