Search in sources :

Example 26 with TempBlockMeta

use of alluxio.worker.block.meta.TempBlockMeta 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, getManagerView());
    TempBlockMeta tempBlockMeta = dirView == null ? null : dirView.createTempBlockMeta(SESSION_ID, mTestBlockId, blockSize);
    if (!avail) {
        Assert.assertTrue(tempBlockMeta == null);
    } else {
        Assert.assertTrue(tempBlockMeta != null);
        StorageDir pDir = tempBlockMeta.getParentDir();
        StorageTier pTier = pDir.getParentTier();
        Assert.assertTrue(pDir.getDirIndex() == dirIndex);
        Assert.assertEquals(tierAlias, pTier.getTierAlias());
        //update the dir meta info
        pDir.addBlockMeta(new BlockMeta(mTestBlockId, blockSize, pDir));
    }
}
Also used : StorageTier(alluxio.worker.block.meta.StorageTier) StorageDir(alluxio.worker.block.meta.StorageDir) StorageDirView(alluxio.worker.block.meta.StorageDirView) TempBlockMeta(alluxio.worker.block.meta.TempBlockMeta) BlockMeta(alluxio.worker.block.meta.BlockMeta) TempBlockMeta(alluxio.worker.block.meta.TempBlockMeta)

Example 27 with TempBlockMeta

use of alluxio.worker.block.meta.TempBlockMeta 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, getManagerView());
    TempBlockMeta tempBlockMeta = dirView == null ? null : dirView.createTempBlockMeta(SESSION_ID, mTestBlockId, blockSize);
    if (!avail) {
        Assert.assertTrue(tempBlockMeta == null);
    } else {
        Assert.assertTrue(tempBlockMeta != null);
    }
}
Also used : StorageDirView(alluxio.worker.block.meta.StorageDirView) TempBlockMeta(alluxio.worker.block.meta.TempBlockMeta)

Aggregations

TempBlockMeta (alluxio.worker.block.meta.TempBlockMeta)27 StorageDir (alluxio.worker.block.meta.StorageDir)14 Test (org.junit.Test)12 BlockMeta (alluxio.worker.block.meta.BlockMeta)11 BlockAlreadyExistsException (alluxio.exception.BlockAlreadyExistsException)6 WorkerOutOfSpaceException (alluxio.exception.WorkerOutOfSpaceException)5 LockResource (alluxio.resource.LockResource)5 BlockDoesNotExistException (alluxio.exception.BlockDoesNotExistException)4 InvalidWorkerStateException (alluxio.exception.InvalidWorkerStateException)3 AbstractBlockMeta (alluxio.worker.block.meta.AbstractBlockMeta)3 StorageDirView (alluxio.worker.block.meta.StorageDirView)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 BlockWriter (alluxio.worker.block.io.BlockWriter)2 LocalFileBlockWriter (alluxio.worker.block.io.LocalFileBlockWriter)2 StorageTier (alluxio.worker.block.meta.StorageTier)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1