org.apache.hadoop.security.proto.SecurityProtos.TokenProto Java Examples
The following examples show how to use
org.apache.hadoop.security.proto.SecurityProtos.TokenProto.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShuffleHandler.java From tez with Apache License 2.0 | 6 votes |
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); }
Example #2
Source File: ShuffleHandler.java From hadoop with Apache License 2.0 | 6 votes |
private void recoverJobShuffleInfo(String jobIdStr, byte[] data) throws IOException { JobID jobId; try { jobId = JobID.forName(jobIdStr); } catch (IllegalArgumentException e) { throw new IOException("Bad job ID " + jobIdStr + " in state store", e); } JobShuffleInfoProto proto = JobShuffleInfoProto.parseFrom(data); String user = proto.getUser(); TokenProto tokenProto = proto.getJobToken(); Token<JobTokenIdentifier> jobToken = new Token<JobTokenIdentifier>( tokenProto.getIdentifier().toByteArray(), tokenProto.getPassword().toByteArray(), new Text(tokenProto.getKind()), new Text(tokenProto.getService())); addJobToken(jobId, user, jobToken); }
Example #3
Source File: ShuffleHandler.java From hadoop with Apache License 2.0 | 6 votes |
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); }
Example #4
Source File: ShuffleHandler.java From big-c with Apache License 2.0 | 6 votes |
private void recoverJobShuffleInfo(String jobIdStr, byte[] data) throws IOException { JobID jobId; try { jobId = JobID.forName(jobIdStr); } catch (IllegalArgumentException e) { throw new IOException("Bad job ID " + jobIdStr + " in state store", e); } JobShuffleInfoProto proto = JobShuffleInfoProto.parseFrom(data); String user = proto.getUser(); TokenProto tokenProto = proto.getJobToken(); Token<JobTokenIdentifier> jobToken = new Token<JobTokenIdentifier>( tokenProto.getIdentifier().toByteArray(), tokenProto.getPassword().toByteArray(), new Text(tokenProto.getKind()), new Text(tokenProto.getService())); addJobToken(jobId, user, jobToken); }
Example #5
Source File: ShuffleHandler.java From big-c with Apache License 2.0 | 6 votes |
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); }
Example #6
Source File: ShuffleHandler.java From tez with Apache License 2.0 | 6 votes |
private void recoverJobShuffleInfo(String jobIdStr, byte[] data) throws IOException { JobID jobId; try { jobId = JobID.forName(jobIdStr); } catch (IllegalArgumentException e) { throw new IOException("Bad job ID " + jobIdStr + " in state store", e); } JobShuffleInfoProto proto = JobShuffleInfoProto.parseFrom(data); String user = proto.getUser(); TokenProto tokenProto = proto.getJobToken(); Token<JobTokenIdentifier> jobToken = new Token<JobTokenIdentifier>( tokenProto.getIdentifier().toByteArray(), tokenProto.getPassword().toByteArray(), new Text(tokenProto.getKind()), new Text(tokenProto.getService())); addJobToken(jobId, user, jobToken); }
Example #7
Source File: ClientDatanodeProtocolTranslatorPB.java From big-c with Apache License 2.0 | 5 votes |
@Override public HdfsBlocksMetadata getHdfsBlocksMetadata(String blockPoolId, long[] blockIds, List<Token<BlockTokenIdentifier>> tokens) throws IOException { List<TokenProto> tokensProtos = new ArrayList<TokenProto>(tokens.size()); for (Token<BlockTokenIdentifier> t : tokens) { tokensProtos.add(PBHelper.convert(t)); } // Build the request GetHdfsBlockLocationsRequestProto request = GetHdfsBlockLocationsRequestProto.newBuilder() .setBlockPoolId(blockPoolId) .addAllBlockIds(Longs.asList(blockIds)) .addAllTokens(tokensProtos) .build(); // Send the RPC GetHdfsBlockLocationsResponseProto response; try { response = rpcProxy.getHdfsBlockLocations(NULL_CONTROLLER, request); } catch (ServiceException e) { throw ProtobufHelper.getRemoteException(e); } // List of volumes in the response List<ByteString> volumeIdsByteStrings = response.getVolumeIdsList(); List<byte[]> volumeIds = new ArrayList<byte[]>(volumeIdsByteStrings.size()); for (ByteString bs : volumeIdsByteStrings) { volumeIds.add(bs.toByteArray()); } // Array of indexes into the list of volumes, one per block List<Integer> volumeIndexes = response.getVolumeIndexesList(); // Parsed HdfsVolumeId values, one per block return new HdfsBlocksMetadata(blockPoolId, blockIds, volumeIds, volumeIndexes); }
Example #8
Source File: OMPBHelper.java From hadoop-ozone with Apache License 2.0 | 5 votes |
/** * Converts Ozone delegation token to @{@link TokenProto}. * @return tokenProto */ public static TokenProto convertToTokenProto(Token<?> tok) { if(tok == null){ throw new IllegalArgumentException("Invalid argument: token is null"); } return TokenProto.newBuilder(). setIdentifier(getByteString(tok.getIdentifier())). setPassword(getByteString(tok.getPassword())). setKind(tok.getKind().toString()). setService(tok.getService().toString()).build(); }
Example #9
Source File: OMPBHelper.java From hadoop-ozone with Apache License 2.0 | 5 votes |
/** * Converts @{@link TokenProto} to Ozone delegation token. * * @return Ozone */ public static Token<OzoneTokenIdentifier> convertToDelegationToken( TokenProto tokenProto) { return new Token<>(tokenProto.getIdentifier() .toByteArray(), tokenProto.getPassword().toByteArray(), new Text( tokenProto.getKind()), new Text(tokenProto.getService())); }
Example #10
Source File: PBHelper.java From hadoop with Apache License 2.0 | 5 votes |
public static TokenProto convert(Token<?> tok) { return TokenProto.newBuilder(). setIdentifier(ByteString.copyFrom(tok.getIdentifier())). setPassword(ByteString.copyFrom(tok.getPassword())). setKind(tok.getKind().toString()). setService(tok.getService().toString()).build(); }
Example #11
Source File: ClientDatanodeProtocolTranslatorPB.java From hadoop with Apache License 2.0 | 5 votes |
@Override public HdfsBlocksMetadata getHdfsBlocksMetadata(String blockPoolId, long[] blockIds, List<Token<BlockTokenIdentifier>> tokens) throws IOException { List<TokenProto> tokensProtos = new ArrayList<TokenProto>(tokens.size()); for (Token<BlockTokenIdentifier> t : tokens) { tokensProtos.add(PBHelper.convert(t)); } // Build the request GetHdfsBlockLocationsRequestProto request = GetHdfsBlockLocationsRequestProto.newBuilder() .setBlockPoolId(blockPoolId) .addAllBlockIds(Longs.asList(blockIds)) .addAllTokens(tokensProtos) .build(); // Send the RPC GetHdfsBlockLocationsResponseProto response; try { response = rpcProxy.getHdfsBlockLocations(NULL_CONTROLLER, request); } catch (ServiceException e) { throw ProtobufHelper.getRemoteException(e); } // List of volumes in the response List<ByteString> volumeIdsByteStrings = response.getVolumeIdsList(); List<byte[]> volumeIds = new ArrayList<byte[]>(volumeIdsByteStrings.size()); for (ByteString bs : volumeIdsByteStrings) { volumeIds.add(bs.toByteArray()); } // Array of indexes into the list of volumes, one per block List<Integer> volumeIndexes = response.getVolumeIndexesList(); // Parsed HdfsVolumeId values, one per block return new HdfsBlocksMetadata(blockPoolId, blockIds, volumeIds, volumeIndexes); }
Example #12
Source File: TestPBHelper.java From hadoop with Apache License 2.0 | 5 votes |
@Test public void testConvertBlockToken() { Token<BlockTokenIdentifier> token = new Token<BlockTokenIdentifier>( "identifier".getBytes(), "password".getBytes(), new Text("kind"), new Text("service")); TokenProto tokenProto = PBHelper.convert(token); Token<BlockTokenIdentifier> token2 = PBHelper.convert(tokenProto); compare(token, token2); }
Example #13
Source File: TestPBHelper.java From big-c with Apache License 2.0 | 5 votes |
@Test public void testConvertBlockToken() { Token<BlockTokenIdentifier> token = new Token<BlockTokenIdentifier>( "identifier".getBytes(), "password".getBytes(), new Text("kind"), new Text("service")); TokenProto tokenProto = PBHelper.convert(token); Token<BlockTokenIdentifier> token2 = PBHelper.convert(tokenProto); compare(token, token2); }
Example #14
Source File: PBHelper.java From big-c with Apache License 2.0 | 5 votes |
public static TokenProto convert(Token<?> tok) { return TokenProto.newBuilder(). setIdentifier(ByteString.copyFrom(tok.getIdentifier())). setPassword(ByteString.copyFrom(tok.getPassword())). setKind(tok.getKind().toString()). setService(tok.getService().toString()).build(); }
Example #15
Source File: GetDelegationTokenResponsePBImpl.java From hadoop with Apache License 2.0 | 4 votes |
private TokenProto convertToProtoFormat(Token t) { return ((TokenPBImpl)t).getProto(); }
Example #16
Source File: ContainerResourceIncreasePBImpl.java From big-c with Apache License 2.0 | 4 votes |
private Token convertFromProtoFormat(TokenProto p) { return new TokenPBImpl(p); }
Example #17
Source File: ApplicationReportPBImpl.java From big-c with Apache License 2.0 | 4 votes |
private TokenProto convertToProtoFormat(Token t) { return ((TokenPBImpl)t).getProto(); }
Example #18
Source File: ApplicationReportPBImpl.java From big-c with Apache License 2.0 | 4 votes |
private TokenPBImpl convertFromProtoFormat(TokenProto p) { return new TokenPBImpl(p); }
Example #19
Source File: NMTokenPBImpl.java From big-c with Apache License 2.0 | 4 votes |
private synchronized Token convertFromProtoFormat(TokenProto proto) { return new TokenPBImpl(proto); }
Example #20
Source File: NMTokenPBImpl.java From big-c with Apache License 2.0 | 4 votes |
private synchronized TokenProto convertToProtoFormat(Token token) { return ((TokenPBImpl)token).getProto(); }
Example #21
Source File: TokenPBImpl.java From big-c with Apache License 2.0 | 4 votes |
private synchronized void maybeInitBuilder() { if (viaProto || builder == null) { builder = TokenProto.newBuilder(proto); } viaProto = false; }
Example #22
Source File: TokenPBImpl.java From big-c with Apache License 2.0 | 4 votes |
public synchronized TokenProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; return proto; }
Example #23
Source File: TokenPBImpl.java From big-c with Apache License 2.0 | 4 votes |
public TokenPBImpl(TokenProto proto) { this.proto = proto; viaProto = true; }
Example #24
Source File: TokenPBImpl.java From big-c with Apache License 2.0 | 4 votes |
public TokenPBImpl() { builder = TokenProto.newBuilder(); }
Example #25
Source File: ContainerPBImpl.java From big-c with Apache License 2.0 | 4 votes |
private TokenProto convertToProtoFormat(Token t) { return ((TokenPBImpl)t).getProto(); }
Example #26
Source File: ContainerPBImpl.java From big-c with Apache License 2.0 | 4 votes |
private TokenPBImpl convertFromProtoFormat(TokenProto p) { return new TokenPBImpl(p); }
Example #27
Source File: AllocateResponsePBImpl.java From big-c with Apache License 2.0 | 4 votes |
private TokenProto convertToProtoFormat(Token t) { return ((TokenPBImpl)t).getProto(); }
Example #28
Source File: AllocateResponsePBImpl.java From big-c with Apache License 2.0 | 4 votes |
private TokenPBImpl convertFromProtoFormat(TokenProto p) { return new TokenPBImpl(p); }
Example #29
Source File: StartContainerRequestPBImpl.java From big-c with Apache License 2.0 | 4 votes |
private TokenPBImpl convertFromProtoFormat(TokenProto containerProto) { return new TokenPBImpl(containerProto); }
Example #30
Source File: StartContainerRequestPBImpl.java From big-c with Apache License 2.0 | 4 votes |
private TokenProto convertToProtoFormat(Token container) { return ((TokenPBImpl)container).getProto(); }