use of alluxio.worker.block.meta.StorageDir in project alluxio by Alluxio.
the class BlockWorkerTest method createBlockRemote.
/**
* Tests the {@link BlockWorker#createBlockRemote(long, long, String, long)} method.
*/
@Test
public void createBlockRemote() throws Exception {
long blockId = mRandom.nextLong();
long initialBytes = mRandom.nextLong();
long sessionId = mRandom.nextLong();
String tierAlias = "MEM";
BlockStoreLocation location = BlockStoreLocation.anyDirInTier(tierAlias);
StorageDir storageDir = Mockito.mock(StorageDir.class);
TempBlockMeta meta = new TempBlockMeta(sessionId, blockId, initialBytes, storageDir);
when(mBlockStore.createBlock(sessionId, blockId, location, initialBytes)).thenReturn(meta);
when(storageDir.getDirPath()).thenReturn("/tmp");
assertEquals(PathUtils.concatPath("/tmp", ".tmp_blocks", sessionId % 1024, String.format("%x-%x", sessionId, blockId)), mBlockWorker.createBlock(sessionId, blockId, tierAlias, initialBytes));
}
use of alluxio.worker.block.meta.StorageDir in project alluxio by Alluxio.
the class BlockWorkerTest method readBlock.
/**
* Tests the {@link BlockWorker#readBlock(long, long, long)} method.
*/
@Test
public void readBlock() throws Exception {
long blockId = mRandom.nextLong();
long sessionId = mRandom.nextLong();
long lockId = mRandom.nextLong();
long blockSize = mRandom.nextLong();
StorageDir storageDir = Mockito.mock(StorageDir.class);
when(storageDir.getDirPath()).thenReturn("/tmp");
BlockMeta meta = new BlockMeta(blockId, blockSize, storageDir);
when(mBlockStore.getBlockMeta(sessionId, blockId, lockId)).thenReturn(meta);
mBlockWorker.readBlock(sessionId, blockId, lockId);
verify(mBlockStore).getBlockMeta(sessionId, blockId, lockId);
assertEquals(PathUtils.concatPath("/tmp", blockId), mBlockWorker.readBlock(sessionId, blockId, lockId));
}
use of alluxio.worker.block.meta.StorageDir in project alluxio by Alluxio.
the class BlockWorkerTest method createBlock.
/**
* Tests the {@link BlockWorker#createBlock(long, long, String, long)} method.
*/
@Test
public void createBlock() throws Exception {
long blockId = mRandom.nextLong();
long initialBytes = mRandom.nextLong();
long sessionId = mRandom.nextLong();
String tierAlias = "MEM";
BlockStoreLocation location = BlockStoreLocation.anyDirInTier(tierAlias);
StorageDir storageDir = Mockito.mock(StorageDir.class);
TempBlockMeta meta = new TempBlockMeta(sessionId, blockId, initialBytes, storageDir);
when(mBlockStore.createBlock(sessionId, blockId, location, initialBytes)).thenReturn(meta);
when(storageDir.getDirPath()).thenReturn("/tmp");
assertEquals(PathUtils.concatPath("/tmp", ".tmp_blocks", sessionId % 1024, String.format("%x-%x", sessionId, blockId)), mBlockWorker.createBlock(sessionId, blockId, tierAlias, initialBytes));
}
use of alluxio.worker.block.meta.StorageDir in project alluxio by Alluxio.
the class EvictorContractTest method noNeedToEvictTest3.
/**
* Tests that no eviction plan is created when all directories are filled except for one
* directory.
*/
@Test
public void noNeedToEvictTest3() throws Exception {
// fill in all dirs except for one directory, then request the capacity of
// the directory with anyDirInTier
StorageDir dirLeft = mTestDir;
// start from BLOCK_ID
long blockId = BLOCK_ID;
for (StorageTier tier : mMetaManager.getTiers()) {
for (StorageDir dir : tier.getStorageDirs()) {
if (dir != dirLeft) {
TieredBlockStoreTestUtils.cache(SESSION_ID, blockId, dir.getCapacityBytes(), dir, mMetaManager, mEvictor);
blockId++;
}
}
}
Assert.assertTrue(mEvictor.freeSpaceWithView(dirLeft.getCapacityBytes(), BlockStoreLocation.anyDirInTier(dirLeft.getParentTier().getTierAlias()), mManagerView).isEmpty());
}
use of alluxio.worker.block.meta.StorageDir in project alluxio by Alluxio.
the class EvictorContractTest method requestSpaceLargerThanCapacity.
/**
* Tests that no eviction plan is available when requesting more space than capacity available.
*/
@Test
public void requestSpaceLargerThanCapacity() throws Exception {
// cache data in a dir
long totalCapacity = mMetaManager.getAvailableBytes(BlockStoreLocation.anyTier());
StorageDir dir = mTestDir;
BlockStoreLocation dirLocation = dir.toBlockStoreLocation();
long dirCapacity = mMetaManager.getAvailableBytes(dirLocation);
TieredBlockStoreTestUtils.cache(SESSION_ID, BLOCK_ID, dirCapacity, dir, mMetaManager, mEvictor);
// request space larger than total capacity, no eviction plan should be available
Assert.assertNull(mEvictor.freeSpaceWithView(totalCapacity + 1, BlockStoreLocation.anyTier(), mManagerView));
// request space larger than capacity for the random directory, no eviction plan should be
// available
Assert.assertNull(mEvictor.freeSpaceWithView(dirCapacity + 1, dirLocation, mManagerView));
}
Aggregations