Search in sources :

Example 1 with RemoteBlockReader

use of alluxio.client.RemoteBlockReader in project alluxio by Alluxio.

the class DataServerIntegrationTest method readThroughClient.

@Test
public void readThroughClient() throws Exception {
    final int length = 10;
    FileSystemTestUtils.createByteFile(mFileSystem, "/file", WriteType.MUST_CACHE, length);
    BlockInfo block = getFirstBlockInfo(new AlluxioURI("/file"));
    RemoteBlockReader client = RemoteBlockReader.Factory.create(FileSystemContext.INSTANCE);
    ByteBuffer result = readRemotely(client, block, length);
    Assert.assertEquals(BufferUtils.getIncreasingByteBuffer(length), result);
}
Also used : RemoteBlockReader(alluxio.client.RemoteBlockReader) BlockInfo(alluxio.wire.BlockInfo) ByteBuffer(java.nio.ByteBuffer) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 2 with RemoteBlockReader

use of alluxio.client.RemoteBlockReader in project alluxio by Alluxio.

the class DataServerIntegrationTest method readThroughClientNonExistent.

// TODO(calvin): Make this work with the new BlockReader.
// @Test
public void readThroughClientNonExistent() throws Exception {
    final int length = 10;
    FileSystemTestUtils.createByteFile(mFileSystem, "/file", WriteType.MUST_CACHE, length);
    BlockInfo block = getFirstBlockInfo(new AlluxioURI("/file"));
    // Get the maximum block id, for use in determining a non-existent block id.
    URIStatus status = mFileSystem.getStatus(new AlluxioURI("/file"));
    long maxBlockId = block.getBlockId();
    for (long blockId : status.getBlockIds()) {
        if (blockId > maxBlockId) {
            maxBlockId = blockId;
        }
    }
    RemoteBlockReader client = RemoteBlockReader.Factory.create(FileSystemContext.INSTANCE);
    block.setBlockId(maxBlockId + 1);
    ByteBuffer result = readRemotely(client, block, length);
    Assert.assertNull(result);
}
Also used : RemoteBlockReader(alluxio.client.RemoteBlockReader) BlockInfo(alluxio.wire.BlockInfo) URIStatus(alluxio.client.file.URIStatus) ByteBuffer(java.nio.ByteBuffer) AlluxioURI(alluxio.AlluxioURI)

Aggregations

AlluxioURI (alluxio.AlluxioURI)2 RemoteBlockReader (alluxio.client.RemoteBlockReader)2 BlockInfo (alluxio.wire.BlockInfo)2 ByteBuffer (java.nio.ByteBuffer)2 URIStatus (alluxio.client.file.URIStatus)1 Test (org.junit.Test)1