use of alluxio.client.block.UnderFileSystemBlockInStream in project alluxio by Alluxio.
the class FileInStreamTest method failToUnderFs.
/**
* Tests the capability to fall back to a ufs stream when getting an alluxio stream fails.
*/
@Test
public void failToUnderFs() throws AlluxioException, IOException {
mInfo.setPersisted(true).setUfsPath("testUfsPath");
mStatus = new URIStatus(mInfo);
mTestStream = new FileInStream(mStatus, InStreamOptions.defaults().setCachePartiallyReadBlock(false), mContext);
Mockito.when(mBlockStore.getInStream(Mockito.eq(1L), Mockito.any(InStreamOptions.class))).thenThrow(new IOException("test IOException"));
if (mDelegateUfsOps) {
UnderFileSystemBlockInStream inStream = PowerMockito.mock(UnderFileSystemBlockInStream.class);
PowerMockito.when(StreamFactory.createUfsBlockInStream(Mockito.any(FileSystemContext.class), Mockito.anyString(), Mockito.anyLong(), Mockito.anyLong(), Mockito.anyLong(), Mockito.any(WorkerNetAddress.class), Mockito.any(InStreamOptions.class))).thenReturn(inStream);
mTestStream.seek(BLOCK_LENGTH + (BLOCK_LENGTH / 2));
} else {
UnderFileSystem ufs = ClientMockUtils.mockUnderFileSystem(Mockito.eq("testUfsPath"));
InputStream stream = Mockito.mock(InputStream.class);
Mockito.when(ufs.open("testUfsPath")).thenReturn(stream);
Mockito.when(stream.skip(BLOCK_LENGTH)).thenReturn(BLOCK_LENGTH);
Mockito.when(stream.skip(BLOCK_LENGTH / 2)).thenReturn(BLOCK_LENGTH / 2);
mTestStream.seek(BLOCK_LENGTH + (BLOCK_LENGTH / 2));
Mockito.verify(ufs).open("testUfsPath");
Mockito.verify(stream).skip(100);
Mockito.verify(stream).skip(50);
}
}
Aggregations