Search in sources :

Example 1 with OpenLocalBlockResponse

use of alluxio.grpc.OpenLocalBlockResponse in project alluxio by Alluxio.

the class AlluxioBlockStoreTest method getInStreamLocal.

@Test
public void getInStreamLocal() throws Exception {
    WorkerNetAddress remote = new WorkerNetAddress().setHost("remote");
    WorkerNetAddress local = new WorkerNetAddress().setHost(WORKER_HOSTNAME_LOCAL);
    // Mock away gRPC usage.
    OpenLocalBlockResponse response = OpenLocalBlockResponse.newBuilder().setPath("/tmp").build();
    when(mWorkerClient.openLocalBlock(any(StreamObserver.class))).thenAnswer(invocation -> {
        mResponseObserver = invocation.getArgument(0, StreamObserver.class);
        return mStreamObserver;
    });
    doAnswer(invocation -> {
        mResponseObserver.onNext(response);
        mResponseObserver.onCompleted();
        return null;
    }).when(mStreamObserver).onNext(any(OpenLocalBlockRequest.class));
    BlockInfo info = new BlockInfo().setBlockId(BLOCK_ID).setLocations(Arrays.asList(new BlockLocation().setWorkerAddress(remote), new BlockLocation().setWorkerAddress(local)));
    when(mMasterClient.getBlockInfo(BLOCK_ID)).thenReturn(info);
    assertEquals(local, mBlockStore.getInStream(BLOCK_ID, new InStreamOptions(new URIStatus(new FileInfo().setBlockIds(Lists.newArrayList(BLOCK_ID))), sConf)).getAddress());
}
Also used : StreamObserver(io.grpc.stub.StreamObserver) ClientCallStreamObserver(io.grpc.stub.ClientCallStreamObserver) FileInfo(alluxio.wire.FileInfo) OpenLocalBlockResponse(alluxio.grpc.OpenLocalBlockResponse) WorkerNetAddress(alluxio.wire.WorkerNetAddress) BlockInfo(alluxio.wire.BlockInfo) FileBlockInfo(alluxio.wire.FileBlockInfo) BlockLocation(alluxio.wire.BlockLocation) URIStatus(alluxio.client.file.URIStatus) OpenLocalBlockRequest(alluxio.grpc.OpenLocalBlockRequest) InStreamOptions(alluxio.client.file.options.InStreamOptions) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

URIStatus (alluxio.client.file.URIStatus)1 InStreamOptions (alluxio.client.file.options.InStreamOptions)1 OpenLocalBlockRequest (alluxio.grpc.OpenLocalBlockRequest)1 OpenLocalBlockResponse (alluxio.grpc.OpenLocalBlockResponse)1 BlockInfo (alluxio.wire.BlockInfo)1 BlockLocation (alluxio.wire.BlockLocation)1 FileBlockInfo (alluxio.wire.FileBlockInfo)1 FileInfo (alluxio.wire.FileInfo)1 WorkerNetAddress (alluxio.wire.WorkerNetAddress)1 ClientCallStreamObserver (io.grpc.stub.ClientCallStreamObserver)1 StreamObserver (io.grpc.stub.StreamObserver)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1