use of alluxio.thrift.LockBlockTOptions in project alluxio by Alluxio.
the class UnderFileSystemBlockStoreTest method before.
@Before
public void before() throws Exception {
mAlluxioBlockStore = Mockito.mock(BlockStore.class);
LockBlockTOptions options = new LockBlockTOptions();
options.setMaxUfsReadConcurrency(5);
options.setBlockSize(TEST_BLOCK_SIZE);
options.setOffset(TEST_BLOCK_SIZE);
options.setUfsPath(mFolder.newFile().getAbsolutePath());
mOpenUfsBlockOptions = new OpenUfsBlockOptions(options);
}
use of alluxio.thrift.LockBlockTOptions in project alluxio by Alluxio.
the class BlockWorkerTest method closeUnderFileSystemBlock.
@Test
public void closeUnderFileSystemBlock() throws Exception {
long blockId = mRandom.nextLong();
LockBlockTOptions lockBlockTOptions = new LockBlockTOptions();
lockBlockTOptions.setMaxUfsReadConcurrency(10);
lockBlockTOptions.setUfsPath("/a");
OpenUfsBlockOptions openUfsBlockOptions = new OpenUfsBlockOptions(lockBlockTOptions);
long sessionId = 1;
for (; sessionId < 11; sessionId++) {
Assert.assertTrue(mBlockWorker.openUfsBlock(sessionId, blockId, openUfsBlockOptions));
mBlockWorker.closeUfsBlock(sessionId, blockId);
}
Assert.assertTrue(mBlockWorker.openUfsBlock(sessionId, blockId, openUfsBlockOptions));
}
use of alluxio.thrift.LockBlockTOptions in project alluxio by Alluxio.
the class BlockWorkerTest method openUnderFileSystemBlock.
@Test
public void openUnderFileSystemBlock() throws Exception {
long blockId = mRandom.nextLong();
LockBlockTOptions lockBlockTOptions = new LockBlockTOptions();
lockBlockTOptions.setMaxUfsReadConcurrency(10);
lockBlockTOptions.setUfsPath("/a");
OpenUfsBlockOptions openUfsBlockOptions = new OpenUfsBlockOptions(lockBlockTOptions);
long sessionId = 1;
for (; sessionId < 11; sessionId++) {
Assert.assertTrue(mBlockWorker.openUfsBlock(sessionId, blockId, openUfsBlockOptions));
}
Assert.assertFalse(mBlockWorker.openUfsBlock(sessionId, blockId, openUfsBlockOptions));
}
use of alluxio.thrift.LockBlockTOptions in project alluxio by Alluxio.
the class BlockServiceHandlerIntegrationTest method lockBlockFailure.
// Tests that lock block returns error on failure
@Test
public void lockBlockFailure() throws Exception {
mFileSystem.createFile(new AlluxioURI("/testFile")).close();
URIStatus file = mFileSystem.getStatus(new AlluxioURI("/testFile"));
final long blockId = BlockId.createBlockId(BlockId.getContainerId(file.getFileId()), 0);
Exception exception = null;
try {
mBlockWorkerServiceHandler.lockBlock(blockId, SESSION_ID, new LockBlockTOptions());
} catch (AlluxioTException e) {
exception = e;
}
// A file does not exist exception should have been thrown
Assert.assertNotNull(exception);
}
use of alluxio.thrift.LockBlockTOptions in project alluxio by Alluxio.
the class BlockServiceHandlerIntegrationTest method lockBlock.
// Tests that lock block returns the correct path
@Test
public void lockBlock() throws Exception {
final int blockSize = (int) WORKER_CAPACITY_BYTES / 2;
CreateFileOptions options = CreateFileOptions.defaults().setBlockSizeBytes(blockSize).setWriteType(WriteType.MUST_CACHE);
FileOutStream out = mFileSystem.createFile(new AlluxioURI("/testFile"), options);
URIStatus file = mFileSystem.getStatus(new AlluxioURI("/testFile"));
final long blockId = BlockId.createBlockId(BlockId.getContainerId(file.getFileId()), 0);
out.write(BufferUtils.getIncreasingByteArray(blockSize));
out.close();
String localPath = mBlockWorkerServiceHandler.lockBlock(blockId, SESSION_ID, new LockBlockTOptions()).getBlockPath();
// The local path should exist
Assert.assertNotNull(localPath);
UnderFileSystem ufs = UnderFileSystem.Factory.get(localPath);
byte[] data = new byte[blockSize];
InputStream in = ufs.open(localPath);
int bytesRead = in.read(data);
// The data in the local file should equal the data we wrote earlier
Assert.assertEquals(blockSize, bytesRead);
Assert.assertTrue(BufferUtils.equalIncreasingByteArray(bytesRead, data));
mBlockWorkerServiceHandler.unlockBlock(blockId, SESSION_ID);
}
Aggregations