Search in sources :

Example 1 with BlockStoragePolicyProto

use of org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.BlockStoragePolicyProto in project hadoop by apache.

the class PBHelperClient method convert.

public static BlockStoragePolicyProto convert(BlockStoragePolicy policy) {
    BlockStoragePolicyProto.Builder builder = BlockStoragePolicyProto.newBuilder().setPolicyId(policy.getId()).setName(policy.getName());
    // creation storage types
    StorageTypesProto creationProto = convert(policy.getStorageTypes());
    Preconditions.checkArgument(creationProto != null);
    builder.setCreationPolicy(creationProto);
    // creation fallback
    StorageTypesProto creationFallbackProto = convert(policy.getCreationFallbacks());
    if (creationFallbackProto != null) {
        builder.setCreationFallbackPolicy(creationFallbackProto);
    }
    // replication fallback
    StorageTypesProto replicationFallbackProto = convert(policy.getReplicationFallbacks());
    if (replicationFallbackProto != null) {
        builder.setReplicationFallbackPolicy(replicationFallbackProto);
    }
    return builder.build();
}
Also used : BlockStoragePolicyProto(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.BlockStoragePolicyProto) StorageTypesProto(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.StorageTypesProto)

Example 2 with BlockStoragePolicyProto

use of org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.BlockStoragePolicyProto in project hadoop by apache.

the class PBHelperClient method convertStoragePolicies.

public static BlockStoragePolicy[] convertStoragePolicies(List<BlockStoragePolicyProto> policyProtos) {
    if (policyProtos == null || policyProtos.size() == 0) {
        return new BlockStoragePolicy[0];
    }
    BlockStoragePolicy[] policies = new BlockStoragePolicy[policyProtos.size()];
    int i = 0;
    for (BlockStoragePolicyProto proto : policyProtos) {
        policies[i++] = convert(proto);
    }
    return policies;
}
Also used : BlockStoragePolicyProto(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.BlockStoragePolicyProto) BlockStoragePolicy(org.apache.hadoop.hdfs.protocol.BlockStoragePolicy)

Aggregations

BlockStoragePolicyProto (org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.BlockStoragePolicyProto)2 BlockStoragePolicy (org.apache.hadoop.hdfs.protocol.BlockStoragePolicy)1 StorageTypesProto (org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.StorageTypesProto)1