Search in sources :

Example 1 with StorageTypesProto

use of org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.StorageTypesProto 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 StorageTypesProto

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

the class PBHelper method convertBlockECReconstructionInfo.

public static BlockECReconstructionInfo convertBlockECReconstructionInfo(BlockECReconstructionInfoProto blockEcReconstructionInfoProto) {
    ExtendedBlockProto blockProto = blockEcReconstructionInfoProto.getBlock();
    ExtendedBlock block = PBHelperClient.convert(blockProto);
    DatanodeInfosProto sourceDnInfosProto = blockEcReconstructionInfoProto.getSourceDnInfos();
    DatanodeInfo[] sourceDnInfos = PBHelperClient.convert(sourceDnInfosProto);
    DatanodeInfosProto targetDnInfosProto = blockEcReconstructionInfoProto.getTargetDnInfos();
    DatanodeInfo[] targetDnInfos = PBHelperClient.convert(targetDnInfosProto);
    HdfsProtos.StorageUuidsProto targetStorageUuidsProto = blockEcReconstructionInfoProto.getTargetStorageUuids();
    String[] targetStorageUuids = convert(targetStorageUuidsProto);
    StorageTypesProto targetStorageTypesProto = blockEcReconstructionInfoProto.getTargetStorageTypes();
    StorageType[] convertStorageTypes = PBHelperClient.convertStorageTypes(targetStorageTypesProto.getStorageTypesList(), targetStorageTypesProto.getStorageTypesList().size());
    byte[] liveBlkIndices = blockEcReconstructionInfoProto.getLiveBlockIndices().toByteArray();
    ErasureCodingPolicy ecPolicy = PBHelperClient.convertErasureCodingPolicy(blockEcReconstructionInfoProto.getEcPolicy());
    return new BlockECReconstructionInfo(block, sourceDnInfos, targetDnInfos, targetStorageUuids, convertStorageTypes, liveBlkIndices, ecPolicy);
}
Also used : BlockECReconstructionInfo(org.apache.hadoop.hdfs.server.protocol.BlockECReconstructionCommand.BlockECReconstructionInfo) DatanodeInfo(org.apache.hadoop.hdfs.protocol.DatanodeInfo) StorageType(org.apache.hadoop.fs.StorageType) ErasureCodingPolicy(org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy) ExtendedBlock(org.apache.hadoop.hdfs.protocol.ExtendedBlock) ByteString(com.google.protobuf.ByteString) HdfsProtos(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos) StorageUuidsProto(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.StorageUuidsProto) StorageTypesProto(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.StorageTypesProto) ExtendedBlockProto(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.ExtendedBlockProto) DatanodeInfosProto(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.DatanodeInfosProto)

Aggregations

StorageTypesProto (org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.StorageTypesProto)2 ByteString (com.google.protobuf.ByteString)1 StorageType (org.apache.hadoop.fs.StorageType)1 DatanodeInfo (org.apache.hadoop.hdfs.protocol.DatanodeInfo)1 ErasureCodingPolicy (org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy)1 ExtendedBlock (org.apache.hadoop.hdfs.protocol.ExtendedBlock)1 HdfsProtos (org.apache.hadoop.hdfs.protocol.proto.HdfsProtos)1 BlockStoragePolicyProto (org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.BlockStoragePolicyProto)1 DatanodeInfosProto (org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.DatanodeInfosProto)1 ExtendedBlockProto (org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.ExtendedBlockProto)1 StorageUuidsProto (org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.StorageUuidsProto)1 BlockECReconstructionInfo (org.apache.hadoop.hdfs.server.protocol.BlockECReconstructionCommand.BlockECReconstructionInfo)1