Search in sources :

Example 11 with StorageDir

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

the class BlockMetadataManager method resizeTempBlockMeta.

/**
 * Modifies the size of a temp block.
 *
 * @param tempBlockMeta the temp block to modify
 * @param newSize new size in bytes
 * @throws InvalidWorkerStateException when newSize is smaller than current size
 */
public void resizeTempBlockMeta(TempBlockMeta tempBlockMeta, long newSize) throws InvalidWorkerStateException {
    StorageDir dir = tempBlockMeta.getParentDir();
    dir.resizeTempBlockMeta(tempBlockMeta, newSize);
}
Also used : StorageDir(alluxio.worker.block.meta.StorageDir)

Example 12 with StorageDir

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

the class BlockMetadataManager method abortTempBlockMeta.

/**
 * Aborts a temp block.
 *
 * @param tempBlockMeta the metadata of the temp block to add
 * @throws BlockDoesNotExistException when block can not be found
 */
public void abortTempBlockMeta(TempBlockMeta tempBlockMeta) throws BlockDoesNotExistException {
    StorageDir dir = tempBlockMeta.getParentDir();
    dir.removeTempBlockMeta(tempBlockMeta);
}
Also used : StorageDir(alluxio.worker.block.meta.StorageDir)

Example 13 with StorageDir

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

the class BlockMetadataManager method moveBlockMeta.

/**
 * Moves an existing block to another location currently hold by a temp block.
 *
 * @param blockMeta the metadata of the block to move
 * @param tempBlockMeta a placeholder in the destination directory
 * @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
 */
public BlockMeta moveBlockMeta(BlockMeta blockMeta, TempBlockMeta tempBlockMeta) throws BlockDoesNotExistException, WorkerOutOfSpaceException, BlockAlreadyExistsException {
    StorageDir srcDir = blockMeta.getParentDir();
    StorageDir dstDir = tempBlockMeta.getParentDir();
    srcDir.removeBlockMeta(blockMeta);
    BlockMeta newBlockMeta = new DefaultBlockMeta(blockMeta.getBlockId(), blockMeta.getBlockSize(), dstDir);
    dstDir.removeTempBlockMeta(tempBlockMeta);
    dstDir.addBlockMeta(newBlockMeta);
    return newBlockMeta;
}
Also used : DefaultBlockMeta(alluxio.worker.block.meta.DefaultBlockMeta) StorageDir(alluxio.worker.block.meta.StorageDir) BlockMeta(alluxio.worker.block.meta.BlockMeta) DefaultBlockMeta(alluxio.worker.block.meta.DefaultBlockMeta) TempBlockMeta(alluxio.worker.block.meta.TempBlockMeta)

Example 14 with StorageDir

use of alluxio.worker.block.meta.StorageDir 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)

Example 15 with StorageDir

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

the class DefaultBlockIterator method initialize.

/**
 * Initializes with the existing blocks.
 */
private void initialize() {
    // Initialize sets per location.
    for (StorageTier tier : mMetaManager.getTiers()) {
        for (StorageDir dir : tier.getStorageDirs()) {
            mPerDirOrderedSets.put(dir.toBlockStoreLocation(), new SortedBlockSet());
            mUnorderedLocations.add(dir.toBlockStoreLocation());
        }
    }
    // Initialize with existing items.
    for (StorageTier tier : mMetaManager.getTiers()) {
        for (StorageDir dir : tier.getStorageDirs()) {
            BlockStoreLocation dirLocation = dir.toBlockStoreLocation();
            for (long blockId : dir.getBlockIds()) {
                blockUpdated(blockId, dirLocation);
            }
        }
    }
}
Also used : StorageTier(alluxio.worker.block.meta.StorageTier) StorageDir(alluxio.worker.block.meta.StorageDir) BlockStoreLocation(alluxio.worker.block.BlockStoreLocation)

Aggregations

StorageDir (alluxio.worker.block.meta.StorageDir)55 Test (org.junit.Test)38 BlockMeta (alluxio.worker.block.meta.BlockMeta)18 StorageTier (alluxio.worker.block.meta.StorageTier)16 TempBlockMeta (alluxio.worker.block.meta.TempBlockMeta)16 DefaultBlockMeta (alluxio.worker.block.meta.DefaultBlockMeta)15 DefaultTempBlockMeta (alluxio.worker.block.meta.DefaultTempBlockMeta)8 ArrayList (java.util.ArrayList)8 BlockStoreLocation (alluxio.worker.block.BlockStoreLocation)6 HashMap (java.util.HashMap)5 BlockDoesNotExistException (alluxio.exception.BlockDoesNotExistException)4 StorageTierView (alluxio.worker.block.meta.StorageTierView)4 List (java.util.List)4 Random (java.util.Random)4 ExpectedException (org.junit.rules.ExpectedException)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 Pair (alluxio.collections.Pair)3 Before (org.junit.Before)3 PropertyKey (alluxio.conf.PropertyKey)2 ServerConfiguration (alluxio.conf.ServerConfiguration)2