use of alluxio.worker.block.meta.StorageDir in project alluxio by Alluxio.
the class EvictorContractTest method needToEvictAnyDirInTier.
/**
* Tests that an eviction plan is created when all capacity is used in each directory in a tier
* and the request size is the capacity of the largest directory.
*/
@Test
public void needToEvictAnyDirInTier() throws Exception {
// cache data with size of "(capacity - 1)" in each dir in a tier, request size of "capacity" of
// the last dir(whose capacity is largest) in this tier from anyDirInTier(tier), all blocks
// cached in the last dir should be in the eviction plan.
StorageTier tier = mMetaManager.getTiers().get(0);
long blockId = BLOCK_ID;
List<StorageDir> dirs = tier.getStorageDirs();
for (StorageDir dir : dirs) {
TieredBlockStoreTestUtils.cache(SESSION_ID, blockId, dir.getCapacityBytes() - 1, dir, mMetaManager, mEvictor);
blockId++;
}
long requestBytes = dirs.get(dirs.size() - 1).getCapacityBytes();
EvictionPlan plan = mEvictor.freeSpaceWithView(requestBytes, BlockStoreLocation.anyDirInTier(tier.getTierAlias()), mManagerView);
EvictorTestUtils.assertEvictionPlanValid(requestBytes, plan, mMetaManager);
}
use of alluxio.worker.block.meta.StorageDir in project alluxio by Alluxio.
the class EvictorContractTest method noNeedToEvictTest2.
/**
* Tests that no eviction plan is created when there is enough space in a directory.
*/
@Test
public void noNeedToEvictTest2() throws Exception {
// cache some data in a dir, then request the remaining space from the dir, the eviction plan
// should be empty.
StorageDir dir = mTestDir;
long capacity = dir.getCapacityBytes();
long cachedBytes = capacity / 2 + 1;
TieredBlockStoreTestUtils.cache(SESSION_ID, BLOCK_ID, cachedBytes, dir, mMetaManager, mEvictor);
Assert.assertTrue(mEvictor.freeSpaceWithView(capacity - cachedBytes, dir.toBlockStoreLocation(), mManagerView).isEmpty());
}
use of alluxio.worker.block.meta.StorageDir in project alluxio by Alluxio.
the class BlockWorkerTest method createBlockLowerTier.
/**
* Tests the {@link BlockWorker#createBlock(long, long, String, long)} method with a tier
* other than MEM.
*/
@Test
public void createBlockLowerTier() throws Exception {
long blockId = mRandom.nextLong();
long initialBytes = mRandom.nextLong();
long sessionId = mRandom.nextLong();
String tierAlias = "HDD";
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 BlockMetadataManager method removeBlockMeta.
/**
* Removes the metadata of a specific block.
*
* @param block the metadata of the block to remove
* @throws BlockDoesNotExistException when block is not found
*/
public void removeBlockMeta(BlockMeta block) throws BlockDoesNotExistException {
StorageDir dir = block.getParentDir();
dir.removeBlockMeta(block);
}
use of alluxio.worker.block.meta.StorageDir in project alluxio by Alluxio.
the class BlockMetadataManager method addTempBlockMeta.
/**
* Adds a temp block.
*
* @param tempBlockMeta the metadata of the temp block to add
* @throws WorkerOutOfSpaceException when no more space left to hold the block
* @throws BlockAlreadyExistsException when the block already exists
*/
public void addTempBlockMeta(TempBlockMeta tempBlockMeta) throws WorkerOutOfSpaceException, BlockAlreadyExistsException {
StorageDir dir = tempBlockMeta.getParentDir();
dir.addTempBlockMeta(tempBlockMeta);
}
Aggregations