Search in sources :

Example 1 with TokenProto

use of org.apache.hadoop.security.proto.SecurityProtos.TokenProto in project hadoop by apache.

the class ShuffleHandler method recordJobShuffleInfo.

private void recordJobShuffleInfo(JobID jobId, String user, Token<JobTokenIdentifier> jobToken) throws IOException {
    if (stateDb != null) {
        TokenProto tokenProto = TokenProto.newBuilder().setIdentifier(ByteString.copyFrom(jobToken.getIdentifier())).setPassword(ByteString.copyFrom(jobToken.getPassword())).setKind(jobToken.getKind().toString()).setService(jobToken.getService().toString()).build();
        JobShuffleInfoProto proto = JobShuffleInfoProto.newBuilder().setUser(user).setJobToken(tokenProto).build();
        try {
            stateDb.put(bytes(jobId.toString()), proto.toByteArray());
        } catch (DBException e) {
            throw new IOException("Error storing " + jobId, e);
        }
    }
    addJobToken(jobId, user, jobToken);
}
Also used : DBException(org.iq80.leveldb.DBException) JobShuffleInfoProto(org.apache.hadoop.mapred.proto.ShuffleHandlerRecoveryProtos.JobShuffleInfoProto) TokenProto(org.apache.hadoop.security.proto.SecurityProtos.TokenProto) IOException(java.io.IOException)

Example 2 with TokenProto

use of org.apache.hadoop.security.proto.SecurityProtos.TokenProto in project hadoop by apache.

the class IncreaseContainersResourceRequestPBImpl method getContainersToIncrease.

@Override
public List<Token> getContainersToIncrease() {
    if (containersToIncrease != null) {
        return containersToIncrease;
    }
    IncreaseContainersResourceRequestProtoOrBuilder p = viaProto ? proto : builder;
    List<TokenProto> list = p.getIncreaseContainersList();
    containersToIncrease = new ArrayList<>();
    for (TokenProto c : list) {
        containersToIncrease.add(convertFromProtoFormat(c));
    }
    return containersToIncrease;
}
Also used : TokenProto(org.apache.hadoop.security.proto.SecurityProtos.TokenProto) IncreaseContainersResourceRequestProtoOrBuilder(org.apache.hadoop.yarn.proto.YarnServiceProtos.IncreaseContainersResourceRequestProtoOrBuilder)

Example 3 with TokenProto

use of org.apache.hadoop.security.proto.SecurityProtos.TokenProto in project hadoop by apache.

the class PBHelperClient method convertLocatedBlockProto.

public static LocatedBlock convertLocatedBlockProto(LocatedBlockProto proto) {
    if (proto == null)
        return null;
    List<DatanodeInfoProto> locs = proto.getLocsList();
    DatanodeInfo[] targets = new DatanodeInfo[locs.size()];
    for (int i = 0; i < locs.size(); i++) {
        targets[i] = convert(locs.get(i));
    }
    final StorageType[] storageTypes = convertStorageTypes(proto.getStorageTypesList(), locs.size());
    final int storageIDsCount = proto.getStorageIDsCount();
    final String[] storageIDs;
    if (storageIDsCount == 0) {
        storageIDs = null;
    } else {
        Preconditions.checkState(storageIDsCount == locs.size());
        storageIDs = proto.getStorageIDsList().toArray(new String[storageIDsCount]);
    }
    byte[] indices = null;
    if (proto.hasBlockIndices()) {
        indices = proto.getBlockIndices().toByteArray();
    }
    // Set values from the isCached list, re-using references from loc
    List<DatanodeInfo> cachedLocs = new ArrayList<>(locs.size());
    List<Boolean> isCachedList = proto.getIsCachedList();
    for (int i = 0; i < isCachedList.size(); i++) {
        if (isCachedList.get(i)) {
            cachedLocs.add(targets[i]);
        }
    }
    final LocatedBlock lb;
    if (indices == null) {
        lb = new LocatedBlock(PBHelperClient.convert(proto.getB()), targets, storageIDs, storageTypes, proto.getOffset(), proto.getCorrupt(), cachedLocs.toArray(new DatanodeInfo[cachedLocs.size()]));
    } else {
        lb = new LocatedStripedBlock(PBHelperClient.convert(proto.getB()), targets, storageIDs, storageTypes, indices, proto.getOffset(), proto.getCorrupt(), cachedLocs.toArray(new DatanodeInfo[cachedLocs.size()]));
        List<TokenProto> tokenProtos = proto.getBlockTokensList();
        Token<BlockTokenIdentifier>[] blockTokens = convertTokens(tokenProtos);
        ((LocatedStripedBlock) lb).setBlockTokens(blockTokens);
    }
    lb.setBlockToken(convert(proto.getBlockToken()));
    return lb;
}
Also used : DatanodeInfo(org.apache.hadoop.hdfs.protocol.DatanodeInfo) StorageType(org.apache.hadoop.fs.StorageType) TokenProto(org.apache.hadoop.security.proto.SecurityProtos.TokenProto) ArrayList(java.util.ArrayList) LocatedBlock(org.apache.hadoop.hdfs.protocol.LocatedBlock) Token(org.apache.hadoop.security.token.Token) ByteString(com.google.protobuf.ByteString) DatanodeInfoProto(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.DatanodeInfoProto) LocatedStripedBlock(org.apache.hadoop.hdfs.protocol.LocatedStripedBlock)

Example 4 with TokenProto

use of org.apache.hadoop.security.proto.SecurityProtos.TokenProto in project hadoop by apache.

the class TestPBHelper method testConvertBlockToken.

@Test
public void testConvertBlockToken() {
    Token<BlockTokenIdentifier> token = new Token<BlockTokenIdentifier>("identifier".getBytes(), "password".getBytes(), new Text("kind"), new Text("service"));
    TokenProto tokenProto = PBHelperClient.convert(token);
    Token<BlockTokenIdentifier> token2 = PBHelperClient.convert(tokenProto);
    compare(token, token2);
}
Also used : BlockTokenIdentifier(org.apache.hadoop.hdfs.security.token.block.BlockTokenIdentifier) TokenProto(org.apache.hadoop.security.proto.SecurityProtos.TokenProto) Token(org.apache.hadoop.security.token.Token) Text(org.apache.hadoop.io.Text) Test(org.junit.Test)

Example 5 with TokenProto

use of org.apache.hadoop.security.proto.SecurityProtos.TokenProto in project tez by apache.

the class ShuffleHandler method recordJobShuffleInfo.

private void recordJobShuffleInfo(JobID jobId, String user, Token<JobTokenIdentifier> jobToken) throws IOException {
    if (stateDb != null) {
        TokenProto tokenProto = TokenProto.newBuilder().setIdentifier(ByteString.copyFrom(jobToken.getIdentifier())).setPassword(ByteString.copyFrom(jobToken.getPassword())).setKind(jobToken.getKind().toString()).setService(jobToken.getService().toString()).build();
        JobShuffleInfoProto proto = JobShuffleInfoProto.newBuilder().setUser(user).setJobToken(tokenProto).build();
        try {
            stateDb.put(bytes(jobId.toString()), proto.toByteArray());
        } catch (DBException e) {
            throw new IOException("Error storing " + jobId, e);
        }
    }
    addJobToken(jobId, user, jobToken);
}
Also used : DBException(org.iq80.leveldb.DBException) JobShuffleInfoProto(org.apache.hadoop.mapred.proto.ShuffleHandlerRecoveryProtos.JobShuffleInfoProto) TokenProto(org.apache.hadoop.security.proto.SecurityProtos.TokenProto) IOException(java.io.IOException)

Aggregations

TokenProto (org.apache.hadoop.security.proto.SecurityProtos.TokenProto)8 Token (org.apache.hadoop.security.token.Token)5 IOException (java.io.IOException)4 JobShuffleInfoProto (org.apache.hadoop.mapred.proto.ShuffleHandlerRecoveryProtos.JobShuffleInfoProto)4 ByteString (com.google.protobuf.ByteString)3 Text (org.apache.hadoop.io.Text)3 JniDBFactory.asString (org.fusesource.leveldbjni.JniDBFactory.asString)2 DBException (org.iq80.leveldb.DBException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 StorageType (org.apache.hadoop.fs.StorageType)1 DatanodeInfo (org.apache.hadoop.hdfs.protocol.DatanodeInfo)1 ExtendedBlock (org.apache.hadoop.hdfs.protocol.ExtendedBlock)1 LocatedBlock (org.apache.hadoop.hdfs.protocol.LocatedBlock)1 LocatedStripedBlock (org.apache.hadoop.hdfs.protocol.LocatedStripedBlock)1 DatanodeInfoProto (org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.DatanodeInfoProto)1 ExtendedBlockProto (org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.ExtendedBlockProto)1 BlockTokenIdentifier (org.apache.hadoop.hdfs.security.token.block.BlockTokenIdentifier)1 JobID (org.apache.hadoop.mapreduce.JobID)1