Search in sources :

Example 16 with StorageTier

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

Example 17 with StorageTier

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

Example 18 with StorageTier

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();
    }
}
Also used : LockResource(alluxio.resource.LockResource) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) StorageTier(alluxio.worker.block.meta.StorageTier) StorageDir(alluxio.worker.block.meta.StorageDir)

Example 19 with StorageTier

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

Example 20 with StorageTier

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;
}
Also used : DefaultBlockMeta(alluxio.worker.block.meta.DefaultBlockMeta) DefaultStorageTier(alluxio.worker.block.meta.DefaultStorageTier) StorageTier(alluxio.worker.block.meta.StorageTier) StorageDir(alluxio.worker.block.meta.StorageDir) WorkerOutOfSpaceException(alluxio.exception.WorkerOutOfSpaceException) BlockMeta(alluxio.worker.block.meta.BlockMeta) DefaultBlockMeta(alluxio.worker.block.meta.DefaultBlockMeta) TempBlockMeta(alluxio.worker.block.meta.TempBlockMeta)

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