Search in sources :

Example 1 with BlockTokenSecretProto

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

the class BlockTokenIdentifier method writeProtobuf.

@VisibleForTesting
void writeProtobuf(DataOutput out) throws IOException {
    BlockTokenSecretProto secret = PBHelperClient.convert(this);
    out.write(secret.toByteArray());
}
Also used : BlockTokenSecretProto(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.BlockTokenSecretProto) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 2 with BlockTokenSecretProto

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

the class BlockTokenIdentifier method readFieldsProtobuf.

@VisibleForTesting
void readFieldsProtobuf(DataInput in) throws IOException {
    BlockTokenSecretProto blockTokenSecretProto = BlockTokenSecretProto.parseFrom((DataInputStream) in);
    expiryDate = blockTokenSecretProto.getExpiryDate();
    keyId = blockTokenSecretProto.getKeyId();
    if (blockTokenSecretProto.hasUserId()) {
        userId = blockTokenSecretProto.getUserId();
    } else {
        userId = null;
    }
    if (blockTokenSecretProto.hasBlockPoolId()) {
        blockPoolId = blockTokenSecretProto.getBlockPoolId();
    } else {
        blockPoolId = null;
    }
    blockId = blockTokenSecretProto.getBlockId();
    for (int i = 0; i < blockTokenSecretProto.getModesCount(); i++) {
        AccessModeProto accessModeProto = blockTokenSecretProto.getModes(i);
        modes.add(PBHelperClient.convert(accessModeProto));
    }
    useProto = true;
}
Also used : AccessModeProto(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.AccessModeProto) BlockTokenSecretProto(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.BlockTokenSecretProto) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 3 with BlockTokenSecretProto

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

the class PBHelperClient method convert.

public static BlockTokenSecretProto convert(BlockTokenIdentifier blockTokenSecret) {
    BlockTokenSecretProto.Builder builder = BlockTokenSecretProto.newBuilder();
    builder.setExpiryDate(blockTokenSecret.getExpiryDate());
    builder.setKeyId(blockTokenSecret.getKeyId());
    String userId = blockTokenSecret.getUserId();
    if (userId != null) {
        builder.setUserId(userId);
    }
    String blockPoolId = blockTokenSecret.getBlockPoolId();
    if (blockPoolId != null) {
        builder.setBlockPoolId(blockPoolId);
    }
    builder.setBlockId(blockTokenSecret.getBlockId());
    for (BlockTokenIdentifier.AccessMode aMode : blockTokenSecret.getAccessModes()) {
        builder.addModes(convert(aMode));
    }
    return builder.build();
}
Also used : BlockTokenIdentifier(org.apache.hadoop.hdfs.security.token.block.BlockTokenIdentifier) BlockTokenSecretProto(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.BlockTokenSecretProto) ByteString(com.google.protobuf.ByteString)

Aggregations

BlockTokenSecretProto (org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.BlockTokenSecretProto)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 ByteString (com.google.protobuf.ByteString)1 AccessModeProto (org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.AccessModeProto)1 BlockTokenIdentifier (org.apache.hadoop.hdfs.security.token.block.BlockTokenIdentifier)1