use of alluxio.client.block.stream.BlockInStream in project alluxio by Alluxio.
the class AlluxioBlockStoreTest method getInStreamUfsLocalFirst.
@Test
public void getInStreamUfsLocalFirst() throws Exception {
WorkerNetAddress remote = new WorkerNetAddress().setHost("remote");
WorkerNetAddress local = new WorkerNetAddress().setHost(WORKER_HOSTNAME_LOCAL);
BlockInfo info = new BlockInfo().setBlockId(0);
URIStatus dummyStatus = new URIStatus(new FileInfo().setPersisted(true).setBlockIds(Collections.singletonList(0L)).setFileBlockInfos(Collections.singletonList(new FileBlockInfo().setBlockInfo(info))));
OpenFilePOptions readOptions = OpenFilePOptions.newBuilder().build();
InStreamOptions options = new InStreamOptions(dummyStatus, readOptions, sConf);
when(mMasterClient.getBlockInfo(BLOCK_ID)).thenReturn(new BlockInfo());
when(mContext.getCachedWorkers()).thenReturn(Lists.newArrayList(new BlockWorkerInfo(remote, 100, 0), new BlockWorkerInfo(local, 100, 0)));
BlockInStream stream = mBlockStore.getInStream(BLOCK_ID, options);
assertEquals(local, stream.getAddress());
assertEquals(GrpcDataReader.Factory.class.getName(), stream.getDataReaderFactory().getClass().getName());
}
use of alluxio.client.block.stream.BlockInStream in project alluxio by Alluxio.
the class AlluxioBlockStoreTest method getInStreamUfsProcessLocal.
@Test
public void getInStreamUfsProcessLocal() throws Exception {
WorkerNetAddress remote = new WorkerNetAddress().setHost("remote");
WorkerNetAddress local = new WorkerNetAddress().setHost(WORKER_HOSTNAME_LOCAL);
BlockInfo info = new BlockInfo().setBlockId(0);
URIStatus dummyStatus = new URIStatus(new FileInfo().setPersisted(true).setBlockIds(Collections.singletonList(0L)).setFileBlockInfos(Collections.singletonList(new FileBlockInfo().setBlockInfo(info))));
OpenFilePOptions readOptions = OpenFilePOptions.newBuilder().build();
InStreamOptions options = new InStreamOptions(dummyStatus, readOptions, sConf);
when(mMasterClient.getBlockInfo(BLOCK_ID)).thenReturn(new BlockInfo());
when(mContext.getCachedWorkers()).thenReturn(Lists.newArrayList(new BlockWorkerInfo(remote, 100, 0), new BlockWorkerInfo(local, 100, 0)));
when(mContext.getNodeLocalWorker()).thenReturn(local);
when(mContext.hasProcessLocalWorker()).thenReturn(true);
BlockWorker blockWorker = Mockito.mock(BlockWorker.class);
when(mContext.getProcessLocalWorker()).thenReturn(blockWorker);
BlockInStream stream = mBlockStore.getInStream(BLOCK_ID, options);
assertEquals(local, stream.getAddress());
assertEquals(BlockWorkerDataReader.Factory.class.getName(), stream.getDataReaderFactory().getClass().getName());
}
Aggregations