Search in sources :

Example 6 with DefaultTempBlockMeta

use of alluxio.worker.block.meta.DefaultTempBlockMeta 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());
}
Also used : StorageDir(alluxio.worker.block.meta.StorageDir) DefaultTempBlockMeta(alluxio.worker.block.meta.DefaultTempBlockMeta) TempBlockMeta(alluxio.worker.block.meta.TempBlockMeta) DefaultTempBlockMeta(alluxio.worker.block.meta.DefaultTempBlockMeta) BlockMeta(alluxio.worker.block.meta.BlockMeta) DefaultBlockMeta(alluxio.worker.block.meta.DefaultBlockMeta) TempBlockMeta(alluxio.worker.block.meta.TempBlockMeta) DefaultTempBlockMeta(alluxio.worker.block.meta.DefaultTempBlockMeta) Test(org.junit.Test)

Example 7 with DefaultTempBlockMeta

use of alluxio.worker.block.meta.DefaultTempBlockMeta 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);
}
Also used : DefaultBlockMeta(alluxio.worker.block.meta.DefaultBlockMeta) StorageDir(alluxio.worker.block.meta.StorageDir) DefaultTempBlockMeta(alluxio.worker.block.meta.DefaultTempBlockMeta) TempBlockMeta(alluxio.worker.block.meta.TempBlockMeta) DefaultTempBlockMeta(alluxio.worker.block.meta.DefaultTempBlockMeta) BlockMeta(alluxio.worker.block.meta.BlockMeta) DefaultBlockMeta(alluxio.worker.block.meta.DefaultBlockMeta) TempBlockMeta(alluxio.worker.block.meta.TempBlockMeta) DefaultTempBlockMeta(alluxio.worker.block.meta.DefaultTempBlockMeta) Test(org.junit.Test)

Example 8 with DefaultTempBlockMeta

use of alluxio.worker.block.meta.DefaultTempBlockMeta 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);
}
Also used : StorageDir(alluxio.worker.block.meta.StorageDir) DefaultTempBlockMeta(alluxio.worker.block.meta.DefaultTempBlockMeta) TempBlockMeta(alluxio.worker.block.meta.TempBlockMeta) DefaultTempBlockMeta(alluxio.worker.block.meta.DefaultTempBlockMeta) BlockMeta(alluxio.worker.block.meta.BlockMeta) DefaultBlockMeta(alluxio.worker.block.meta.DefaultBlockMeta) TempBlockMeta(alluxio.worker.block.meta.TempBlockMeta) DefaultTempBlockMeta(alluxio.worker.block.meta.DefaultTempBlockMeta) Test(org.junit.Test)

Aggregations

DefaultTempBlockMeta (alluxio.worker.block.meta.DefaultTempBlockMeta)8 TempBlockMeta (alluxio.worker.block.meta.TempBlockMeta)8 StorageDir (alluxio.worker.block.meta.StorageDir)7 Test (org.junit.Test)7 BlockMeta (alluxio.worker.block.meta.BlockMeta)6 DefaultBlockMeta (alluxio.worker.block.meta.DefaultBlockMeta)6 BlockWriter (alluxio.worker.block.io.BlockWriter)1 LocalFileBlockWriter (alluxio.worker.block.io.LocalFileBlockWriter)1 ArrayList (java.util.ArrayList)1