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();
}
Aggregations