use of alluxio.worker.block.meta.StorageTier in project alluxio by Alluxio.
the class EvictorContractTest method noNeedToEvictTest3.
/**
* Tests that no eviction plan is created when all directories are filled except for one
* directory.
*/
@Test
public void noNeedToEvictTest3() throws Exception {
// fill in all dirs except for one directory, then request the capacity of
// the directory with anyDirInTier
StorageDir dirLeft = mTestDir;
// start from BLOCK_ID
long blockId = BLOCK_ID;
for (StorageTier tier : mMetaManager.getTiers()) {
for (StorageDir dir : tier.getStorageDirs()) {
if (dir != dirLeft) {
TieredBlockStoreTestUtils.cache(SESSION_ID, blockId, dir.getCapacityBytes(), dir, mMetaManager, mEvictor);
blockId++;
}
}
}
Assert.assertTrue(mEvictor.freeSpaceWithView(dirLeft.getCapacityBytes(), BlockStoreLocation.anyDirInTier(dirLeft.getParentTier().getTierAlias()), mManagerView).isEmpty());
}
use of alluxio.worker.block.meta.StorageTier in project alluxio by Alluxio.
the class AllocatorTestBase method assertTempBlockMeta.
/**
* Given an allocator with the location, blockSize, tierAlias and dirIndex,
* we assert whether the block can be allocated.
*
* @param allocator the allocation manager of Alluxio managed data
* @param location the location in block store
* @param blockSize the size of block in bytes
* @param avail the block should be successfully allocated or not
* @param tierAlias the block should be allocated at this tier
* @param dirIndex the block should be allocated at this dir
*/
protected void assertTempBlockMeta(Allocator allocator, BlockStoreLocation location, int blockSize, boolean avail, String tierAlias, int dirIndex) throws Exception {
mTestBlockId++;
StorageDirView dirView = allocator.allocateBlockWithView(SESSION_ID, blockSize, location, getMetadataEvictorView(), false);
TempBlockMeta tempBlockMeta = dirView == null ? null : dirView.createTempBlockMeta(SESSION_ID, mTestBlockId, blockSize);
if (!avail) {
assertTrue(tempBlockMeta == null);
} else {
assertTrue(tempBlockMeta != null);
StorageDir pDir = tempBlockMeta.getParentDir();
StorageTier pTier = pDir.getParentTier();
assertEquals(dirIndex, pDir.getDirIndex());
assertEquals(tierAlias, pTier.getTierAlias());
// update the dir meta info
pDir.addBlockMeta(new DefaultBlockMeta(mTestBlockId, blockSize, pDir));
}
}
use of alluxio.worker.block.meta.StorageTier in project alluxio by Alluxio.
the class TieredBlockStore method checkStorage.
@Override
public boolean checkStorage() {
try (LockResource r = new LockResource(mMetadataWriteLock)) {
List<StorageDir> dirsToRemove = new ArrayList<>();
for (StorageTier tier : mMetaManager.getTiers()) {
for (StorageDir dir : tier.getStorageDirs()) {
String path = dir.getDirPath();
if (!FileUtils.isStorageDirAccessible(path)) {
LOG.error("Storage check failed for path {}. The directory will be excluded.", path);
dirsToRemove.add(dir);
}
}
}
dirsToRemove.forEach(this::removeDir);
return !dirsToRemove.isEmpty();
}
}
use of alluxio.worker.block.meta.StorageTier in project alluxio by Alluxio.
the class BlockMetadataEvictorView method initializeView.
@Override
protected void initializeView() {
// iteratively create all StorageTierViews and StorageDirViews
for (StorageTier tier : mMetadataManager.getTiers()) {
StorageTierEvictorView tierView = new StorageTierEvictorView(tier, this);
mTierViews.add(tierView);
mAliasToTierViews.put(tier.getTierAlias(), tierView);
}
}
use of alluxio.worker.block.meta.StorageTier in project alluxio by Alluxio.
the class BlockMetadataManager method moveBlockMeta.
/**
* Moves the metadata of an existing block to another location or throws IOExceptions. Throws an
* {@link IllegalArgumentException} if the newLocation is not in the tiered storage.
*
* @param blockMeta the metadata of the block to move
* @param newLocation new location of the block
* @return the new block metadata if success, absent otherwise
* @throws BlockDoesNotExistException when the block to move is not found
* @throws BlockAlreadyExistsException when the block to move already exists in the destination
* @throws WorkerOutOfSpaceException when destination have no extra space to hold the block to
* move
* @deprecated As of version 0.8. Use {@link #moveBlockMeta(BlockMeta, TempBlockMeta)} instead.
*/
@Deprecated
public BlockMeta moveBlockMeta(BlockMeta blockMeta, BlockStoreLocation newLocation) throws BlockDoesNotExistException, BlockAlreadyExistsException, WorkerOutOfSpaceException {
// If existing location belongs to the target location, simply return the current block meta.
BlockStoreLocation oldLocation = blockMeta.getBlockLocation();
if (oldLocation.belongsTo(newLocation)) {
LOG.info("moveBlockMeta: moving {} to {} is a noop", oldLocation, newLocation);
return blockMeta;
}
long blockSize = blockMeta.getBlockSize();
String newTierAlias = newLocation.tierAlias();
StorageTier newTier = getTier(newTierAlias);
StorageDir newDir = null;
if (newLocation.equals(BlockStoreLocation.anyDirInTier(newTierAlias))) {
for (StorageDir dir : newTier.getStorageDirs()) {
if (dir.getAvailableBytes() >= blockSize) {
newDir = dir;
break;
}
}
} else {
StorageDir dir = newTier.getDir(newLocation.dir());
if (dir != null && dir.getAvailableBytes() >= blockSize) {
newDir = dir;
}
}
if (newDir == null) {
throw new WorkerOutOfSpaceException("Failed to move BlockMeta: newLocation " + newLocation + " does not have enough space for " + blockSize + " bytes");
}
StorageDir oldDir = blockMeta.getParentDir();
oldDir.removeBlockMeta(blockMeta);
BlockMeta newBlockMeta = new DefaultBlockMeta(blockMeta.getBlockId(), blockSize, newDir);
newDir.addBlockMeta(newBlockMeta);
return newBlockMeta;
}
Aggregations