Search in sources :

Example 1 with StorageTier

use of alluxio.worker.block.meta.StorageTier in project alluxio by Alluxio.

the class EvictorContractTest method needToEvictAnyTier.

/**
   * Tests that an eviction plan is created when all capacity is used in each directory in all tiers
   * and the request size is the minimum capacity of all directories.
   */
@Test
public void needToEvictAnyTier() throws Exception {
    // cache data with size of "(capacity - 1)" in each dir in all tiers, request size of minimum
    // "capacity" of all dirs from anyTier
    long minCapacity = Long.MAX_VALUE;
    long blockId = BLOCK_ID;
    for (StorageTier tier : mMetaManager.getTiers()) {
        for (StorageDir dir : tier.getStorageDirs()) {
            long capacity = dir.getCapacityBytes();
            minCapacity = Math.min(minCapacity, capacity);
            TieredBlockStoreTestUtils.cache(SESSION_ID, blockId, capacity - 1, dir, mMetaManager, mEvictor);
            blockId++;
        }
    }
    EvictionPlan plan = mEvictor.freeSpaceWithView(minCapacity, BlockStoreLocation.anyTier(), mManagerView);
    EvictorTestUtils.assertEvictionPlanValid(minCapacity, plan, mMetaManager);
}
Also used : StorageTier(alluxio.worker.block.meta.StorageTier) StorageDir(alluxio.worker.block.meta.StorageDir) Test(org.junit.Test)

Example 2 with StorageTier

use of alluxio.worker.block.meta.StorageTier 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 3 with StorageTier

use of alluxio.worker.block.meta.StorageTier in project alluxio by Alluxio.

the class BlockMetadataManagerViewTest method getTierViewsBelow.

/**
   * Tests the {@link BlockMetadataManagerView#getTierViewsBelow(String)} method.
   */
@Test
public void getTierViewsBelow() {
    for (StorageTier tier : mMetaManager.getTiers()) {
        String tierAlias = tier.getTierAlias();
        Assert.assertEquals(mMetaManager.getTiersBelow(tierAlias).size(), mMetaManagerView.getTierViewsBelow(tierAlias).size());
    }
}
Also used : StorageTier(alluxio.worker.block.meta.StorageTier) Test(org.junit.Test)

Example 4 with StorageTier

use of alluxio.worker.block.meta.StorageTier in project alluxio by Alluxio.

the class BlockMetadataAllocatorView method initializeView.

@Override
public void initializeView() {
    // iteratively create all StorageTierViews and StorageDirViews
    for (StorageTier tier : mMetadataManager.getTiers()) {
        StorageTierAllocatorView tierView = new StorageTierAllocatorView(tier, mUseReservedSpace);
        mTierViews.add(tierView);
        mAliasToTierViews.put(tier.getTierAlias(), tierView);
    }
}
Also used : StorageTierAllocatorView(alluxio.worker.block.meta.StorageTierAllocatorView) StorageTier(alluxio.worker.block.meta.StorageTier)

Example 5 with StorageTier

use of alluxio.worker.block.meta.StorageTier in project alluxio by Alluxio.

the class BlockMetadataManager method getAvailableBytes.

/**
 * Gets the amount of available space of given location in bytes. Master queries the total number
 * of bytes available on each tier of the worker, and Evictor/Allocator often cares about the
 * bytes at a {@link StorageDir}. Throws an {@link IllegalArgumentException} when the location
 * does not belong to the tiered storage.
 *
 * @param location location the check available bytes
 * @return available bytes
 */
public long getAvailableBytes(BlockStoreLocation location) {
    long spaceAvailable = 0;
    if (location.equals(BlockStoreLocation.anyTier())) {
        for (StorageTier tier : mTiers) {
            spaceAvailable += tier.getAvailableBytes();
        }
        return spaceAvailable;
    } else if (!location.mediumType().isEmpty() && location.equals(BlockStoreLocation.anyDirInAnyTierWithMedium(location.mediumType()))) {
        for (StorageTier tier : mTiers) {
            for (StorageDir dir : tier.getStorageDirs()) {
                if (dir.getDirMedium().equals(location.mediumType())) {
                    spaceAvailable += dir.getAvailableBytes();
                }
            }
        }
        return spaceAvailable;
    }
    String tierAlias = location.tierAlias();
    StorageTier tier = getTier(tierAlias);
    // TODO(calvin): This should probably be max of the capacity bytes in the dirs?
    if (location.equals(BlockStoreLocation.anyDirInTier(tierAlias))) {
        return tier.getAvailableBytes();
    }
    int dirIndex = location.dir();
    StorageDir dir = tier.getDir(dirIndex);
    return dir == null ? 0 : dir.getAvailableBytes();
}
Also used : DefaultStorageTier(alluxio.worker.block.meta.DefaultStorageTier) StorageTier(alluxio.worker.block.meta.StorageTier) StorageDir(alluxio.worker.block.meta.StorageDir)

Aggregations

StorageTier (alluxio.worker.block.meta.StorageTier)27 Test (org.junit.Test)17 StorageDir (alluxio.worker.block.meta.StorageDir)16 HashMap (java.util.HashMap)5 BlockMeta (alluxio.worker.block.meta.BlockMeta)4 StorageTierView (alluxio.worker.block.meta.StorageTierView)4 BlockDoesNotExistException (alluxio.exception.BlockDoesNotExistException)3 DefaultBlockMeta (alluxio.worker.block.meta.DefaultBlockMeta)3 Pair (alluxio.collections.Pair)2 BlockStoreLocation (alluxio.worker.block.BlockStoreLocation)2 DefaultStorageTier (alluxio.worker.block.meta.DefaultStorageTier)2 StorageTierEvictorView (alluxio.worker.block.meta.StorageTierEvictorView)2 TempBlockMeta (alluxio.worker.block.meta.TempBlockMeta)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 ExpectedException (org.junit.rules.ExpectedException)2 StorageTierAssoc (alluxio.StorageTierAssoc)1 WorkerStorageTierAssoc (alluxio.WorkerStorageTierAssoc)1 PropertyKey (alluxio.conf.PropertyKey)1