use of alluxio.worker.block.meta.StorageDir in project alluxio by Alluxio.
the class EvictorTestUtils method blocksInTheSameDir.
/**
* Whether blocks in the {@link EvictionPlan} are in the same {@link StorageDir}.
*
* @param plan the eviction plan
* @param meta the metadata manager
* @return true if blocks are in the same dir otherwise false
* @throws BlockDoesNotExistException if fail to get metadata of a block
*/
public static boolean blocksInTheSameDir(EvictionPlan plan, BlockMetadataManager meta) throws BlockDoesNotExistException {
Preconditions.checkNotNull(plan);
StorageDir dir = null;
List<Long> blockIds = new ArrayList<>();
for (Pair<Long, BlockStoreLocation> evict : plan.toEvict()) {
blockIds.add(evict.getFirst());
}
for (BlockTransferInfo move : plan.toMove()) {
blockIds.add(move.getBlockId());
}
for (long blockId : blockIds) {
StorageDir blockDir = meta.getBlockMeta(blockId).getParentDir();
if (dir == null) {
dir = blockDir;
} else if (dir != blockDir) {
return false;
}
}
return true;
}
use of alluxio.worker.block.meta.StorageDir 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.StorageDir in project alluxio by Alluxio.
the class TieredBlockStoreTest method relaxLocationWrites.
@Test
public void relaxLocationWrites() throws Exception {
long totalCapacityBytes = 0;
for (StorageDir dir : new StorageDir[] { mTestDir1, mTestDir2, mTestDir3, mTestDir4 }) {
totalCapacityBytes += dir.getCapacityBytes();
}
long fileSizeBytes = 1000;
int maxFileCount = (int) (totalCapacityBytes / fileSizeBytes);
// Write to first dir, 2 times of the whole store's peak capacity.
for (int i = 0; i <= maxFileCount * 2; i++) {
TieredBlockStoreTestUtils.cache(i, i, fileSizeBytes, mBlockStore, mTestDir1.toBlockStoreLocation(), false);
}
}
use of alluxio.worker.block.meta.StorageDir in project alluxio by Alluxio.
the class AbstractBlockAnnotatorTest method testRemovedBlock.
// Common tests for {@link EvictionOrderProvider} implementations.
@Test
public void testRemovedBlock() throws Exception {
StorageDir dir = getDir(0, 0);
createBlock(0, dir);
List<Long> expectedList = new ArrayList<Long>() {
{
add(0L);
}
};
validateIterator(mBlockIterator.getIterator(BlockStoreLocation.anyTier(), BlockOrder.NATURAL), expectedList.iterator());
removeBlock(0);
expectedList.clear();
validateIterator(mBlockIterator.getIterator(BlockStoreLocation.anyTier(), BlockOrder.NATURAL), expectedList.iterator());
}
use of alluxio.worker.block.meta.StorageDir in project alluxio by Alluxio.
the class AbstractBlockAnnotatorTest method testMovedBlock.
@Test
public void testMovedBlock() throws Exception {
StorageDir srcDir = getDir(0, 0);
StorageDir dstDir = getDir(0, 1);
createBlock(0, srcDir);
List<Long> expectedList = new ArrayList<Long>() {
{
add(0L);
}
};
validateIterator(mBlockIterator.getIterator(BlockStoreLocation.anyTier(), BlockOrder.NATURAL), expectedList.iterator());
moveBlock(0, dstDir);
validateIterator(mBlockIterator.getIterator(BlockStoreLocation.anyTier(), BlockOrder.NATURAL), expectedList.iterator());
}
Aggregations