Search in sources :

Example 1 with ClientDatanodeProtocolPB

use of org.apache.hadoop.hdfs.protocolPB.ClientDatanodeProtocolPB in project hadoop by apache.

the class TestBlockToken method createMockDatanode.

private static Server createMockDatanode(BlockTokenSecretManager sm, Token<BlockTokenIdentifier> token, Configuration conf) throws IOException, ServiceException {
    ClientDatanodeProtocolPB mockDN = mock(ClientDatanodeProtocolPB.class);
    BlockTokenIdentifier id = sm.createIdentifier();
    id.readFields(new DataInputStream(new ByteArrayInputStream(token.getIdentifier())));
    doAnswer(new GetLengthAnswer(sm, id)).when(mockDN).getReplicaVisibleLength(any(RpcController.class), any(GetReplicaVisibleLengthRequestProto.class));
    RPC.setProtocolEngine(conf, ClientDatanodeProtocolPB.class, ProtobufRpcEngine.class);
    BlockingService service = ClientDatanodeProtocolService.newReflectiveBlockingService(mockDN);
    return new RPC.Builder(conf).setProtocol(ClientDatanodeProtocolPB.class).setInstance(service).setBindAddress(ADDRESS).setPort(0).setNumHandlers(5).setVerbose(true).setSecretManager(sm).build();
}
Also used : RpcController(com.google.protobuf.RpcController) ByteArrayInputStream(java.io.ByteArrayInputStream) BlockingService(com.google.protobuf.BlockingService) ClientDatanodeProtocolPB(org.apache.hadoop.hdfs.protocolPB.ClientDatanodeProtocolPB) DataInputStream(java.io.DataInputStream) GetReplicaVisibleLengthRequestProto(org.apache.hadoop.hdfs.protocol.proto.ClientDatanodeProtocolProtos.GetReplicaVisibleLengthRequestProto)

Aggregations

BlockingService (com.google.protobuf.BlockingService)1 RpcController (com.google.protobuf.RpcController)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInputStream (java.io.DataInputStream)1 GetReplicaVisibleLengthRequestProto (org.apache.hadoop.hdfs.protocol.proto.ClientDatanodeProtocolProtos.GetReplicaVisibleLengthRequestProto)1 ClientDatanodeProtocolPB (org.apache.hadoop.hdfs.protocolPB.ClientDatanodeProtocolPB)1