Search in sources :

Example 16 with BlockStoreLocation

use of alluxio.worker.block.BlockStoreLocation in project alluxio by Alluxio.

the class LRUEvictorTest method cascadingEvictionTest1.

/**
   * Tests the cascading eviction with the first tier filled and the second tier empty resulting in
   * no eviction.
   */
@Test
public void cascadingEvictionTest1() throws Exception {
    // Two tiers, each dir in the second tier has more space than any dir in the first tier. Fill in
    // the first tier, leave the second tier empty. Request space from the first tier, blocks should
    // be moved from the first to the second tier without eviction.
    int firstTierOrdinal = TieredBlockStoreTestUtils.TIER_ORDINAL[0];
    long[] firstTierDirCapacity = TieredBlockStoreTestUtils.TIER_CAPACITY_BYTES[0];
    int nDir = firstTierDirCapacity.length;
    for (int i = 0; i < nDir; i++) {
        cache(SESSION_ID, BLOCK_ID + i, firstTierDirCapacity[i], firstTierOrdinal, i);
    }
    BlockStoreLocation anyDirInFirstTier = BlockStoreLocation.anyDirInTier(TieredBlockStoreTestUtils.TIER_ALIAS[firstTierOrdinal]);
    long smallestCapacity = firstTierDirCapacity[0];
    for (int i = 0; i < nDir; i++) {
        EvictionPlan plan = mEvictor.freeSpaceWithView(smallestCapacity, anyDirInFirstTier, mManagerView);
        Assert.assertTrue(EvictorTestUtils.validCascadingPlan(smallestCapacity, plan, mMetaManager));
        Assert.assertEquals(0, plan.toEvict().size());
        Assert.assertEquals(1, plan.toMove().size());
        long blockId = plan.toMove().get(0).getBlockId();
        Assert.assertEquals(BLOCK_ID + i, blockId);
        access(blockId);
    }
}
Also used : BlockStoreLocation(alluxio.worker.block.BlockStoreLocation) Test(org.junit.Test)

Example 17 with BlockStoreLocation

use of alluxio.worker.block.BlockStoreLocation in project alluxio by Alluxio.

the class PartialLRUEvictorTest method cascadingEvictionTest2.

/**
   * Tests the cascading eviction with the first and second tier filled resulting in blocks in the
   * second tier are evicted.
   */
@Test
public void cascadingEvictionTest2() throws Exception {
    // Two tiers, the second tier has more dirs than the first tier and each dir in the second tier
    // has more space than any dir in the first tier. Fill in all dirs and request space from the
    // first tier, blocks should be moved from the first to the second tier, and some blocks in the
    // second tier should be evicted to hold blocks moved from the first tier.
    BlockStoreLocation anyDirInFirstTier = BlockStoreLocation.anyDirInTier(TieredBlockStoreTestUtils.TIER_ALIAS[0]);
    int nDirInFirstTier = TieredBlockStoreTestUtils.TIER_CAPACITY_BYTES[0].length;
    int nDirInSecondTier = TieredBlockStoreTestUtils.TIER_CAPACITY_BYTES[1].length;
    long smallestCapacity = TieredBlockStoreTestUtils.TIER_CAPACITY_BYTES[0][0];
    long delta = smallestCapacity / 10;
    long blockId = BLOCK_ID;
    for (int tierLevel : TieredBlockStoreTestUtils.TIER_ORDINAL) {
        long[] tierCapacity = TieredBlockStoreTestUtils.TIER_CAPACITY_BYTES[tierLevel];
        for (int dirIdx = 0; dirIdx < tierCapacity.length; dirIdx++) {
            cache(SESSION_ID, blockId, tierCapacity[dirIdx] - dirIdx * delta, tierLevel, dirIdx);
            blockId++;
        }
    }
    EvictionPlan plan = mEvictor.freeSpaceWithView(smallestCapacity, anyDirInFirstTier, mManagerView);
    Assert.assertTrue(EvictorTestUtils.validCascadingPlan(smallestCapacity, plan, mMetaManager));
    // block in StorageDir with max free space in the first tier needs to be moved to the second
    // tier
    Assert.assertEquals(1, plan.toMove().size());
    long blockIdMovedInFirstTier = plan.toMove().get(0).getBlockId();
    Assert.assertEquals(BLOCK_ID + nDirInFirstTier - 1, blockIdMovedInFirstTier);
    // block in StorageDir with max free space in the second tier will be evicted to hold blocks
    // moved from first tier
    Assert.assertEquals(1, plan.toEvict().size());
    long blockIdEvictedInSecondTier = plan.toEvict().get(0).getFirst();
    Assert.assertEquals(BLOCK_ID + nDirInFirstTier + nDirInSecondTier - 1, blockIdEvictedInSecondTier);
}
Also used : BlockStoreLocation(alluxio.worker.block.BlockStoreLocation) Test(org.junit.Test)

Aggregations

BlockStoreLocation (alluxio.worker.block.BlockStoreLocation)17 Test (org.junit.Test)13 HashMap (java.util.HashMap)5 ArrayList (java.util.ArrayList)4 StorageDir (alluxio.worker.block.meta.StorageDir)3 Entry (java.util.Map.Entry)3 Pair (alluxio.collections.Pair)2 BlockMeta (alluxio.worker.block.meta.BlockMeta)2 StorageDirView (alluxio.worker.block.meta.StorageDirView)1 StorageTierView (alluxio.worker.block.meta.StorageTierView)1