Search in sources :

Example 1 with BlockInfo

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());
}
Also used : FileSystemMasterView(alluxio.master.file.meta.FileSystemMasterView) FileInfo(alluxio.wire.FileInfo) BlockInfo(alluxio.wire.BlockInfo) FileBlockInfo(alluxio.wire.FileBlockInfo) ArrayList(java.util.ArrayList) FileBlockInfo(alluxio.wire.FileBlockInfo) BlockLocation(alluxio.wire.BlockLocation) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with BlockInfo

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());
}
Also used : BlockInfo(alluxio.wire.BlockInfo) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 3 with BlockInfo

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());
}
Also used : BlockInfo(alluxio.wire.BlockInfo) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 4 with BlockInfo

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);
}
Also used : BlockInfo(alluxio.wire.BlockInfo) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 5 with BlockInfo

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);
}
Also used : BlockInfo(alluxio.wire.BlockInfo) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Aggregations

BlockInfo (alluxio.wire.BlockInfo)28 Test (org.junit.Test)21 AlluxioURI (alluxio.AlluxioURI)18 BlockLocation (alluxio.wire.BlockLocation)5 FileBlockInfo (alluxio.wire.FileBlockInfo)5 WorkerNetAddress (alluxio.wire.WorkerNetAddress)5 RemoteBlockInStream (alluxio.client.block.RemoteBlockInStream)4 ArrayList (java.util.ArrayList)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 InodeFile (alluxio.master.file.meta.InodeFile)3 IOException (java.io.IOException)3 RemoteBlockReader (alluxio.client.RemoteBlockReader)2 URIStatus (alluxio.client.file.URIStatus)2 LockBlockResource (alluxio.client.resource.LockBlockResource)2 AlluxioException (alluxio.exception.AlluxioException)2 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)2 FileSystemMasterView (alluxio.master.file.meta.FileSystemMasterView)2 FileInfo (alluxio.wire.FileInfo)2 LockBlockResult (alluxio.wire.LockBlockResult)2 BlockWorker (alluxio.worker.block.BlockWorker)2