Search in sources :

Example 11 with BlockInStream

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());
}
Also used : BlockInStream(alluxio.client.block.stream.BlockInStream) FileInfo(alluxio.wire.FileInfo) WorkerNetAddress(alluxio.wire.WorkerNetAddress) BlockInfo(alluxio.wire.BlockInfo) FileBlockInfo(alluxio.wire.FileBlockInfo) TieredIdentityFactory(alluxio.network.TieredIdentityFactory) URIStatus(alluxio.client.file.URIStatus) FileBlockInfo(alluxio.wire.FileBlockInfo) OpenFilePOptions(alluxio.grpc.OpenFilePOptions) InStreamOptions(alluxio.client.file.options.InStreamOptions) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 12 with BlockInStream

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());
}
Also used : BlockInStream(alluxio.client.block.stream.BlockInStream) FileInfo(alluxio.wire.FileInfo) WorkerNetAddress(alluxio.wire.WorkerNetAddress) BlockInfo(alluxio.wire.BlockInfo) FileBlockInfo(alluxio.wire.FileBlockInfo) TieredIdentityFactory(alluxio.network.TieredIdentityFactory) URIStatus(alluxio.client.file.URIStatus) FileBlockInfo(alluxio.wire.FileBlockInfo) OpenFilePOptions(alluxio.grpc.OpenFilePOptions) InStreamOptions(alluxio.client.file.options.InStreamOptions) BlockWorker(alluxio.worker.block.BlockWorker) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

BlockInStream (alluxio.client.block.stream.BlockInStream)12 InStreamOptions (alluxio.client.file.options.InStreamOptions)11 BlockInfo (alluxio.wire.BlockInfo)11 Test (org.junit.Test)11 URIStatus (alluxio.client.file.URIStatus)10 WorkerNetAddress (alluxio.wire.WorkerNetAddress)10 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7 TieredIdentityFactory (alluxio.network.TieredIdentityFactory)6 FileBlockInfo (alluxio.wire.FileBlockInfo)6 FileInfo (alluxio.wire.FileInfo)5 BlockOutStream (alluxio.client.block.stream.BlockOutStream)4 OpenFilePOptions (alluxio.grpc.OpenFilePOptions)4 BlockLocation (alluxio.wire.BlockLocation)4 BlockWorker (alluxio.worker.block.BlockWorker)4 AlluxioURI (alluxio.AlluxioURI)3 WriteType (alluxio.client.WriteType)3 BlockLocationPolicy (alluxio.client.block.policy.BlockLocationPolicy)3 GetWorkerOptions (alluxio.client.block.policy.options.GetWorkerOptions)3 FileSystemContext (alluxio.client.file.FileSystemContext)3 OutStreamOptions (alluxio.client.file.options.OutStreamOptions)3