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);
}
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);
}
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());
}
}
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);
}
}
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();
}
Aggregations