use of alluxio.worker.block.meta.StorageTier in project alluxio by Alluxio.
the class BlockStoreMetaTest method getUsedBytesOnDirs.
/**
* Tests the {@link BlockStoreMeta#getUsedBytesOnDirs()} method.
*/
@Test
public void getUsedBytesOnDirs() {
Map<Pair<String, String>, Long> dirsToUsedBytes = new HashMap<>();
for (StorageTier tier : mMetadataManager.getTiers()) {
for (StorageDir dir : tier.getStorageDirs()) {
dirsToUsedBytes.put(new Pair<>(tier.getTierAlias(), dir.getDirPath()), dir.getCapacityBytes() - dir.getAvailableBytes());
}
}
Assert.assertEquals(dirsToUsedBytes, mBlockStoreMeta.getUsedBytesOnDirs());
}
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.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 BlockMeta(blockMeta.getBlockId(), blockSize, newDir);
newDir.addBlockMeta(newBlockMeta);
return newBlockMeta;
}
use of alluxio.worker.block.meta.StorageTier in project alluxio by Alluxio.
the class BlockMetadataManagerViewTest method getAvailableBytes.
/**
* Tests the {@link BlockMetadataManagerView#getAvailableBytes(BlockStoreLocation)} method.
*/
@Test
public void getAvailableBytes() {
BlockStoreLocation location;
// When location represents anyTier
location = BlockStoreLocation.anyTier();
Assert.assertEquals(mMetaManager.getAvailableBytes(location), mMetaManagerView.getAvailableBytes(location));
// When location represents one particular tier
for (StorageTier tier : mMetaManager.getTiers()) {
String tierAlias = tier.getTierAlias();
location = BlockStoreLocation.anyDirInTier(tierAlias);
Assert.assertEquals(mMetaManager.getAvailableBytes(location), mMetaManagerView.getAvailableBytes(location));
for (StorageDir dir : tier.getStorageDirs()) {
// When location represents one particular dir
location = dir.toBlockStoreLocation();
Assert.assertEquals(mMetaManager.getAvailableBytes(location), mMetaManagerView.getAvailableBytes(location));
}
}
}
use of alluxio.worker.block.meta.StorageTier in project alluxio by Alluxio.
the class BlockMetadataManagerViewTest method sameTierViewsBelow.
/**
* Tests that {@link BlockMetadataManagerView#getTierViewsBelow(String)} returns the same
* TierViews as constructing by {@link BlockMetadataManager#getTiersBelow(String)}.
*/
@Test
public void sameTierViewsBelow() {
String tierAlias = mMetaManager.getTiers().get(TEST_TIER_ORDINAL).getTierAlias();
List<StorageTierView> tierViews1 = mMetaManagerView.getTierViewsBelow(tierAlias);
// Do some operations on metadata
StorageDir dir = mMetaManager.getTiers().get(TEST_TIER_ORDINAL + 1).getDir(TEST_DIR);
BlockMeta blockMeta = new BlockMeta(TEST_BLOCK_ID, TEST_BLOCK_SIZE, dir);
try {
dir.addBlockMeta(blockMeta);
} catch (Exception e) {
e.printStackTrace();
}
List<StorageTier> tiers2 = mMetaManager.getTiersBelow(tierAlias);
Assert.assertEquals(tierViews1.size(), tiers2.size());
for (int i = 0; i < tierViews1.size(); i++) {
assertSameTierView(tierViews1.get(i), new StorageTierView(tiers2.get(i), mMetaManagerView));
}
}
use of alluxio.worker.block.meta.StorageTier in project alluxio by Alluxio.
the class BlockMetadataManagerViewTest method getTierView.
/**
* Tests the {@link BlockMetadataManagerView#getTierView(String)} method.
*/
@Test
public void getTierView() {
for (StorageTier tier : mMetaManager.getTiers()) {
String tierAlias = tier.getTierAlias();
StorageTierView tierView = mMetaManagerView.getTierView(tierAlias);
Assert.assertEquals(tier.getTierAlias(), tierView.getTierViewAlias());
Assert.assertEquals(tier.getTierOrdinal(), tierView.getTierViewOrdinal());
}
}
Aggregations