Search in sources :

Example 31 with StorageDirView

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

the class AllocatorTestBase method assertTempBlockMeta.

/**
 * Given an allocator with the location and blockSize, 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
 */
protected void assertTempBlockMeta(Allocator allocator, BlockStoreLocation location, long blockSize, boolean avail) throws IOException {
    mTestBlockId++;
    StorageDirView dirView = allocator.allocateBlockWithView(SESSION_ID, blockSize, location, getMetadataEvictorView(), true);
    TempBlockMeta tempBlockMeta = dirView == null ? null : dirView.createTempBlockMeta(SESSION_ID, mTestBlockId, blockSize);
    if (!avail) {
        assertTrue(tempBlockMeta == null);
    } else {
        assertTrue(tempBlockMeta != null);
    }
}
Also used : StorageDirView(alluxio.worker.block.meta.StorageDirView) TempBlockMeta(alluxio.worker.block.meta.TempBlockMeta)

Example 32 with StorageDirView

use of alluxio.worker.block.meta.StorageDirView 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 33 with StorageDirView

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

the class AllocatorTestBase method assertAllocationInSpecificDir.

protected void assertAllocationInSpecificDir() throws Exception {
    for (int i = 0; i < TIER_ALIAS.length; i++) {
        String tier = TIER_ALIAS[i];
        for (int j = 0; j < TIER_PATH[i].length; j++) {
            BlockStoreLocation loc = new BlockStoreLocation(tier, j);
            StorageDirView dirView = mAllocator.allocateBlockWithView(AllocatorTestBase.SESSION_ID, 1, loc, getMetadataEvictorView(), true);
            assertNotNull(dirView);
            assertEquals(tier, dirView.getParentTierView().getTierViewAlias());
            assertEquals(j, dirView.getDirViewIndex());
        }
    }
}
Also used : StorageDirView(alluxio.worker.block.meta.StorageDirView) BlockStoreLocation(alluxio.worker.block.BlockStoreLocation)

Aggregations

StorageDirView (alluxio.worker.block.meta.StorageDirView)33 StorageTierView (alluxio.worker.block.meta.StorageTierView)15 BlockStoreLocation (alluxio.worker.block.BlockStoreLocation)6 BlockMeta (alluxio.worker.block.meta.BlockMeta)6 TempBlockMeta (alluxio.worker.block.meta.TempBlockMeta)6 BlockDoesNotExistException (alluxio.exception.BlockDoesNotExistException)5 Pair (alluxio.collections.Pair)4 WorkerOutOfSpaceException (alluxio.exception.WorkerOutOfSpaceException)4 LockResource (alluxio.resource.LockResource)3 StorageDirEvictorView (alluxio.worker.block.meta.StorageDirEvictorView)3 ArrayList (java.util.ArrayList)3 Nullable (javax.annotation.Nullable)3 BlockAlreadyExistsException (alluxio.exception.BlockAlreadyExistsException)2 BlockTransferInfo (alluxio.worker.block.evictor.BlockTransferInfo)2 LinkedList (java.util.LinkedList)2 StorageTierAssoc (alluxio.StorageTierAssoc)1 InvalidWorkerStateException (alluxio.exception.InvalidWorkerStateException)1 DefaultBlockMeta (alluxio.worker.block.meta.DefaultBlockMeta)1 StorageDir (alluxio.worker.block.meta.StorageDir)1 StorageTier (alluxio.worker.block.meta.StorageTier)1