Search in sources :

Example 6 with StorageDir

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);
}
Also used : StorageTier(alluxio.worker.block.meta.StorageTier) StorageDir(alluxio.worker.block.meta.StorageDir) Test(org.junit.Test)

Example 7 with StorageDir

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

Example 8 with StorageDir

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));
}
Also used : StorageDir(alluxio.worker.block.meta.StorageDir) TempBlockMeta(alluxio.worker.block.meta.TempBlockMeta) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 9 with StorageDir

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);
}
Also used : StorageDir(alluxio.worker.block.meta.StorageDir)

Example 10 with StorageDir

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);
}
Also used : StorageDir(alluxio.worker.block.meta.StorageDir)

Aggregations

StorageDir (alluxio.worker.block.meta.StorageDir)55 Test (org.junit.Test)38 BlockMeta (alluxio.worker.block.meta.BlockMeta)18 StorageTier (alluxio.worker.block.meta.StorageTier)16 TempBlockMeta (alluxio.worker.block.meta.TempBlockMeta)16 DefaultBlockMeta (alluxio.worker.block.meta.DefaultBlockMeta)15 DefaultTempBlockMeta (alluxio.worker.block.meta.DefaultTempBlockMeta)8 ArrayList (java.util.ArrayList)8 BlockStoreLocation (alluxio.worker.block.BlockStoreLocation)6 HashMap (java.util.HashMap)5 BlockDoesNotExistException (alluxio.exception.BlockDoesNotExistException)4 StorageTierView (alluxio.worker.block.meta.StorageTierView)4 List (java.util.List)4 Random (java.util.Random)4 ExpectedException (org.junit.rules.ExpectedException)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 Pair (alluxio.collections.Pair)3 Before (org.junit.Before)3 PropertyKey (alluxio.conf.PropertyKey)2 ServerConfiguration (alluxio.conf.ServerConfiguration)2