Search in sources :

Example 1 with BlockKey

use of org.apache.hadoop.hdfs.security.token.block.BlockKey in project hadoop by apache.

the class PBHelper method convert.

public static ExportedBlockKeysProto convert(ExportedBlockKeys keys) {
    ExportedBlockKeysProto.Builder builder = ExportedBlockKeysProto.newBuilder();
    builder.setIsBlockTokenEnabled(keys.isBlockTokenEnabled()).setKeyUpdateInterval(keys.getKeyUpdateInterval()).setTokenLifeTime(keys.getTokenLifetime()).setCurrentKey(convert(keys.getCurrentKey()));
    for (BlockKey k : keys.getAllKeys()) {
        builder.addAllKeys(convert(k));
    }
    return builder.build();
}
Also used : ExportedBlockKeysProto(org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.ExportedBlockKeysProto) BlockKey(org.apache.hadoop.hdfs.security.token.block.BlockKey)

Example 2 with BlockKey

use of org.apache.hadoop.hdfs.security.token.block.BlockKey in project hadoop by apache.

the class TestPBHelper method testConvertDatanodeRegistration.

@Test
public void testConvertDatanodeRegistration() {
    DatanodeID dnId = DFSTestUtil.getLocalDatanodeID();
    BlockKey[] keys = new BlockKey[] { getBlockKey(2), getBlockKey(3) };
    ExportedBlockKeys expKeys = new ExportedBlockKeys(true, 9, 10, getBlockKey(1), keys);
    DatanodeRegistration reg = new DatanodeRegistration(dnId, new StorageInfo(NodeType.DATA_NODE), expKeys, "3.0.0");
    DatanodeRegistrationProto proto = PBHelper.convert(reg);
    DatanodeRegistration reg2 = PBHelper.convert(proto);
    compare(reg.getStorageInfo(), reg2.getStorageInfo());
    compare(reg.getExportedKeys(), reg2.getExportedKeys());
    compare(reg, reg2);
    assertEquals(reg.getSoftwareVersion(), reg2.getSoftwareVersion());
}
Also used : DatanodeID(org.apache.hadoop.hdfs.protocol.DatanodeID) DatanodeRegistration(org.apache.hadoop.hdfs.server.protocol.DatanodeRegistration) DatanodeRegistrationProto(org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.DatanodeRegistrationProto) StorageInfo(org.apache.hadoop.hdfs.server.common.StorageInfo) DatanodeStorageInfo(org.apache.hadoop.hdfs.server.blockmanagement.DatanodeStorageInfo) ExportedBlockKeys(org.apache.hadoop.hdfs.security.token.block.ExportedBlockKeys) BlockKey(org.apache.hadoop.hdfs.security.token.block.BlockKey) Test(org.junit.Test)

Example 3 with BlockKey

use of org.apache.hadoop.hdfs.security.token.block.BlockKey in project hadoop by apache.

the class TestPBHelper method testConvertBlockKey.

@Test
public void testConvertBlockKey() {
    BlockKey key = getBlockKey(1);
    BlockKeyProto keyProto = PBHelper.convert(key);
    BlockKey key1 = PBHelper.convert(keyProto);
    compare(key, key1);
}
Also used : BlockKeyProto(org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.BlockKeyProto) BlockKey(org.apache.hadoop.hdfs.security.token.block.BlockKey) Test(org.junit.Test)

Example 4 with BlockKey

use of org.apache.hadoop.hdfs.security.token.block.BlockKey in project hadoop by apache.

the class TestPBHelper method testConvertExportedBlockKeys.

@Test
public void testConvertExportedBlockKeys() {
    BlockKey[] keys = new BlockKey[] { getBlockKey(2), getBlockKey(3) };
    ExportedBlockKeys expKeys = new ExportedBlockKeys(true, 9, 10, getBlockKey(1), keys);
    ExportedBlockKeysProto expKeysProto = PBHelper.convert(expKeys);
    ExportedBlockKeys expKeys1 = PBHelper.convert(expKeysProto);
    compare(expKeys, expKeys1);
}
Also used : ExportedBlockKeysProto(org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.ExportedBlockKeysProto) ExportedBlockKeys(org.apache.hadoop.hdfs.security.token.block.ExportedBlockKeys) BlockKey(org.apache.hadoop.hdfs.security.token.block.BlockKey) Test(org.junit.Test)

Example 5 with BlockKey

use of org.apache.hadoop.hdfs.security.token.block.BlockKey in project hadoop by apache.

the class PBHelper method convertBlockKeys.

public static BlockKey[] convertBlockKeys(List<BlockKeyProto> list) {
    BlockKey[] ret = new BlockKey[list.size()];
    int i = 0;
    for (BlockKeyProto k : list) {
        ret[i++] = convert(k);
    }
    return ret;
}
Also used : BlockKeyProto(org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.BlockKeyProto) BlockKey(org.apache.hadoop.hdfs.security.token.block.BlockKey)

Aggregations

BlockKey (org.apache.hadoop.hdfs.security.token.block.BlockKey)5 Test (org.junit.Test)3 BlockKeyProto (org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.BlockKeyProto)2 ExportedBlockKeysProto (org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.ExportedBlockKeysProto)2 ExportedBlockKeys (org.apache.hadoop.hdfs.security.token.block.ExportedBlockKeys)2 DatanodeID (org.apache.hadoop.hdfs.protocol.DatanodeID)1 DatanodeRegistrationProto (org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.DatanodeRegistrationProto)1 DatanodeStorageInfo (org.apache.hadoop.hdfs.server.blockmanagement.DatanodeStorageInfo)1 StorageInfo (org.apache.hadoop.hdfs.server.common.StorageInfo)1 DatanodeRegistration (org.apache.hadoop.hdfs.server.protocol.DatanodeRegistration)1