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