use of alluxio.worker.block.meta.StorageDir in project alluxio by Alluxio.
the class BlockStoreMetaTest method before.
/**
* Sets up all dependencies before a test runs.
*/
@Before
public void before() throws Exception {
String alluxioHome = mTestFolder.newFolder().getAbsolutePath();
ServerConfiguration.set(PropertyKey.WORKER_MANAGEMENT_TIER_ALIGN_ENABLED, false);
ServerConfiguration.set(PropertyKey.WORKER_MANAGEMENT_TIER_PROMOTE_ENABLED, false);
mMetadataManager = TieredBlockStoreTestUtils.defaultMetadataManager(alluxioHome);
// Add and commit COMMITTED_BLOCKS_NUM temp blocks repeatedly
StorageDir dir = mMetadataManager.getTier(Constants.MEDIUM_MEM).getDir(0);
for (long blockId = 0L; blockId < COMMITTED_BLOCKS_NUM; blockId++) {
TieredBlockStoreTestUtils.cache(TEST_SESSION_ID, blockId, TEST_BLOCK_SIZE, dir, mMetadataManager, null);
}
mBlockStoreMeta = new DefaultBlockStoreMeta(mMetadataManager, false);
mBlockStoreMetaFull = new DefaultBlockStoreMeta(mMetadataManager, true);
}
use of alluxio.worker.block.meta.StorageDir in project alluxio by Alluxio.
the class BlockMetadataManagerTest method moveBlockMetaDeprecated.
/**
* Tests the {@link BlockMetadataManager#moveBlockMeta(BlockMeta, BlockStoreLocation)} method.
*/
@Test
public void moveBlockMetaDeprecated() throws Exception {
StorageDir dir = mMetaManager.getTier(Constants.MEDIUM_MEM).getDir(0);
TempBlockMeta tempBlockMeta = new DefaultTempBlockMeta(TEST_SESSION_ID, TEST_TEMP_BLOCK_ID, TEST_BLOCK_SIZE, dir);
mMetaManager.addTempBlockMeta(tempBlockMeta);
mMetaManager.commitTempBlockMeta(tempBlockMeta);
BlockMeta blockMeta = mMetaManager.getBlockMeta(TEST_TEMP_BLOCK_ID);
// Move to anywhere
mMetaManager.moveBlockMeta(blockMeta, BlockStoreLocation.anyTier());
// Move to tier HDD tier
blockMeta = mMetaManager.moveBlockMeta(blockMeta, BlockStoreLocation.anyDirInTier(Constants.MEDIUM_HDD));
assertEquals(Constants.MEDIUM_HDD, blockMeta.getBlockLocation().tierAlias());
// Move to tier MEM and dir 0
blockMeta = mMetaManager.moveBlockMeta(blockMeta, new BlockStoreLocation(Constants.MEDIUM_MEM, 0));
assertEquals(Constants.MEDIUM_MEM, blockMeta.getBlockLocation().tierAlias());
assertEquals(0, blockMeta.getBlockLocation().dir());
}
use of alluxio.worker.block.meta.StorageDir in project alluxio by Alluxio.
the class BlockMetadataManagerTest method moveBlockMetaOutOfSpaceException.
/**
* Tests that an exception is thrown in the
* {@link BlockMetadataManager#moveBlockMeta(BlockMeta, TempBlockMeta)} method when the worker is
* out of space.
*/
@Test
public void moveBlockMetaOutOfSpaceException() throws Exception {
// Create a committed block under dir2 with larger size than the capacity of dir1,
// so that WorkerOutOfSpaceException should be thrown when move this block to dir1.
StorageDir dir1 = mMetaManager.getTier(Constants.MEDIUM_HDD).getDir(0);
StorageDir dir2 = mMetaManager.getTier(Constants.MEDIUM_HDD).getDir(1);
long maxHddDir1Capacity = TIER_CAPACITY_BYTES[1][0];
long blockMetaSize = maxHddDir1Capacity + 1;
BlockMeta blockMeta = new DefaultBlockMeta(TEST_BLOCK_ID, blockMetaSize, dir2);
TempBlockMeta tempBlockMeta2 = new DefaultTempBlockMeta(TEST_SESSION_ID, TEST_TEMP_BLOCK_ID2, TEST_BLOCK_SIZE, dir1);
mMetaManager.addTempBlockMeta(tempBlockMeta2);
dir2.addBlockMeta(blockMeta);
mThrown.expect(WorkerOutOfSpaceException.class);
mThrown.expectMessage(ExceptionMessage.NO_SPACE_FOR_BLOCK_META.getMessage(TEST_BLOCK_ID, blockMetaSize, maxHddDir1Capacity, TIER_ALIAS[1]));
mMetaManager.moveBlockMeta(blockMeta, tempBlockMeta2);
}
use of alluxio.worker.block.meta.StorageDir in project alluxio by Alluxio.
the class BlockMetadataManagerTest method moveBlockMetaSameDir.
/**
* Dummy unit test, actually the case of move block meta to same dir should never happen.
*/
@Test
public void moveBlockMetaSameDir() throws Exception {
// create and add two temp block metas with same tier and dir to the meta manager
StorageDir dir = mMetaManager.getTier(Constants.MEDIUM_MEM).getDir(0);
TempBlockMeta tempBlockMeta1 = new DefaultTempBlockMeta(TEST_SESSION_ID, TEST_TEMP_BLOCK_ID, TEST_BLOCK_SIZE, dir);
TempBlockMeta tempBlockMeta2 = new DefaultTempBlockMeta(TEST_SESSION_ID, TEST_TEMP_BLOCK_ID2, TEST_BLOCK_SIZE, dir);
mMetaManager.addTempBlockMeta(tempBlockMeta1);
mMetaManager.addTempBlockMeta(tempBlockMeta2);
// commit the first temp block meta
mMetaManager.commitTempBlockMeta(tempBlockMeta1);
BlockMeta blockMeta = mMetaManager.getBlockMeta(TEST_TEMP_BLOCK_ID);
mMetaManager.moveBlockMeta(blockMeta, tempBlockMeta2);
// test to make sure that the dst tempBlockMeta has been removed from the dir
mThrown.expect(BlockDoesNotExistException.class);
mThrown.expectMessage(ExceptionMessage.TEMP_BLOCK_META_NOT_FOUND.getMessage(TEST_TEMP_BLOCK_ID2));
mMetaManager.getTempBlockMeta(TEST_TEMP_BLOCK_ID2);
}
use of alluxio.worker.block.meta.StorageDir in project alluxio by Alluxio.
the class BlockMetadataManagerTest method getDir.
/**
* Tests the {@link BlockMetadataManager#getDir(BlockStoreLocation)} method.
*/
@Test
public void getDir() {
BlockStoreLocation loc;
StorageDir dir;
loc = new BlockStoreLocation(Constants.MEDIUM_MEM, 0);
dir = mMetaManager.getDir(loc);
assertEquals(loc.tierAlias(), dir.getParentTier().getTierAlias());
assertEquals(loc.dir(), dir.getDirIndex());
loc = new BlockStoreLocation(Constants.MEDIUM_HDD, 1);
dir = mMetaManager.getDir(loc);
assertEquals(loc.tierAlias(), dir.getParentTier().getTierAlias());
assertEquals(loc.dir(), dir.getDirIndex());
}
Aggregations