use of alluxio.wire.BlockInfo in project alluxio by Alluxio.
the class DefaultAsyncPersistHandlerTest method persistenceFileWithBlocksOnMultipleWorkers.
/**
* Tests the persistence of file with block on multiple workers.
*/
@Test
public void persistenceFileWithBlocksOnMultipleWorkers() throws Exception {
DefaultAsyncPersistHandler handler = new DefaultAsyncPersistHandler(new FileSystemMasterView(mFileSystemMaster));
AlluxioURI path = new AlluxioURI("/test");
List<FileBlockInfo> blockInfoList = new ArrayList<>();
BlockLocation location1 = new BlockLocation().setWorkerId(1);
blockInfoList.add(new FileBlockInfo().setBlockInfo(new BlockInfo().setLocations(Lists.newArrayList(location1))));
BlockLocation location2 = new BlockLocation().setWorkerId(2);
blockInfoList.add(new FileBlockInfo().setBlockInfo(new BlockInfo().setLocations(Lists.newArrayList(location2))));
long fileId = 2;
Mockito.when(mFileSystemMaster.getFileId(path)).thenReturn(fileId);
Mockito.when(mFileSystemMaster.getFileInfo(fileId)).thenReturn(new FileInfo().setLength(1).setCompleted(true));
Mockito.when(mFileSystemMaster.getFileBlockInfoList(path)).thenReturn(blockInfoList);
// no persist scheduled on any worker
Assert.assertEquals(0, handler.pollFilesToPersist(1).size());
Assert.assertEquals(0, handler.pollFilesToPersist(2).size());
}
use of alluxio.wire.BlockInfo in project alluxio by Alluxio.
the class DataServerIntegrationTest method negativeOffset.
@Test
public void negativeOffset() throws Exception {
final int length = 10;
FileSystemTestUtils.createByteFile(mFileSystem, "/file", WriteType.MUST_CACHE, length);
BlockInfo block = getFirstBlockInfo(new AlluxioURI("/file"));
DataServerMessage recvMsg = request(block, length * -2, 1);
assertError(recvMsg, block.getBlockId());
}
use of alluxio.wire.BlockInfo in project alluxio by Alluxio.
the class DataServerIntegrationTest method readTooLarge.
@Test
public void readTooLarge() throws Exception {
final int length = 20;
FileSystemTestUtils.createByteFile(mFileSystem, "/file", WriteType.MUST_CACHE, length);
BlockInfo block = getFirstBlockInfo(new AlluxioURI("/file"));
DataServerMessage recvMsg = request(block, 0, length * 2);
assertError(recvMsg, block.getBlockId());
}
use of alluxio.wire.BlockInfo in project alluxio by Alluxio.
the class DataServerIntegrationTest method readPartialTest1.
@Test
public void readPartialTest1() throws Exception {
FileSystemTestUtils.createByteFile(mFileSystem, "/file", WriteType.MUST_CACHE, 10);
BlockInfo block = getFirstBlockInfo(new AlluxioURI("/file"));
final int offset = 0;
final int length = 6;
DataServerMessage recvMsg = request(block, offset, length);
assertValid(recvMsg, length, block.getBlockId(), offset, length);
}
use of alluxio.wire.BlockInfo in project alluxio by Alluxio.
the class DataServerIntegrationTest method readPartialTest2.
@Test
public void readPartialTest2() throws Exception {
FileSystemTestUtils.createByteFile(mFileSystem, "/file", WriteType.MUST_CACHE, 10);
BlockInfo block = getFirstBlockInfo(new AlluxioURI("/file"));
final int offset = 2;
final int length = 6;
DataServerMessage recvMsg = request(block, offset, length);
assertValid(recvMsg, BufferUtils.getIncreasingByteBuffer(offset, length), block.getBlockId(), offset, length);
}
Aggregations