Search in sources :

Example 11 with StorageTier

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

the class BlockStoreMetaTest method getBlockList.

/**
   * Tests the {@link BlockStoreMeta#getBlockList()} method.
   */
@Test
public void getBlockList() {
    Map<String, List<Long>> tierAliasToBlockIds = new HashMap<>();
    for (StorageTier tier : mMetadataManager.getTiers()) {
        List<Long> blockIdsOnTier = new ArrayList<>();
        for (StorageDir dir : tier.getStorageDirs()) {
            blockIdsOnTier.addAll(dir.getBlockIds());
        }
        tierAliasToBlockIds.put(tier.getTierAlias(), blockIdsOnTier);
    }
    Map<String, List<Long>> actual = mBlockStoreMetaFull.getBlockList();
    Assert.assertEquals(TieredBlockStoreTestUtils.TIER_ALIAS.length, actual.keySet().size());
    Assert.assertEquals(tierAliasToBlockIds, actual);
}
Also used : HashMap(java.util.HashMap) StorageTier(alluxio.worker.block.meta.StorageTier) ArrayList(java.util.ArrayList) StorageDir(alluxio.worker.block.meta.StorageDir) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 12 with StorageTier

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

the class BlockStoreMetaTest method getCapacityBytesOnDirs.

/**
   * Tests the {@link BlockStoreMeta#getCapacityBytes()} method.
   */
@Test
public void getCapacityBytesOnDirs() {
    Map<Pair<String, String>, Long> dirsToCapacityBytes = new HashMap<>();
    for (StorageTier tier : mMetadataManager.getTiers()) {
        for (StorageDir dir : tier.getStorageDirs()) {
            dirsToCapacityBytes.put(new Pair<>(tier.getTierAlias(), dir.getDirPath()), dir.getCapacityBytes());
        }
    }
    Assert.assertEquals(dirsToCapacityBytes, mBlockStoreMeta.getCapacityBytesOnDirs());
    Assert.assertEquals(TieredBlockStoreTestUtils.getDefaultDirNum(), mBlockStoreMeta.getCapacityBytesOnDirs().values().size());
}
Also used : HashMap(java.util.HashMap) StorageTier(alluxio.worker.block.meta.StorageTier) StorageDir(alluxio.worker.block.meta.StorageDir) Pair(alluxio.collections.Pair) Test(org.junit.Test)

Example 13 with StorageTier

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

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

the class EvictorContractTest method noNeedToEvictTest3.

/**
   * Tests that no eviction plan is created when all directories are filled except for one
   * directory.
   */
@Test
public void noNeedToEvictTest3() throws Exception {
    // fill in all dirs except for one directory, then request the capacity of
    // the directory with anyDirInTier
    StorageDir dirLeft = mTestDir;
    // start from BLOCK_ID
    long blockId = BLOCK_ID;
    for (StorageTier tier : mMetaManager.getTiers()) {
        for (StorageDir dir : tier.getStorageDirs()) {
            if (dir != dirLeft) {
                TieredBlockStoreTestUtils.cache(SESSION_ID, blockId, dir.getCapacityBytes(), dir, mMetaManager, mEvictor);
                blockId++;
            }
        }
    }
    Assert.assertTrue(mEvictor.freeSpaceWithView(dirLeft.getCapacityBytes(), BlockStoreLocation.anyDirInTier(dirLeft.getParentTier().getTierAlias()), mManagerView).isEmpty());
}
Also used : StorageTier(alluxio.worker.block.meta.StorageTier) StorageDir(alluxio.worker.block.meta.StorageDir) Test(org.junit.Test)

Aggregations

StorageTier (alluxio.worker.block.meta.StorageTier)14 StorageDir (alluxio.worker.block.meta.StorageDir)11 Test (org.junit.Test)11 BlockMeta (alluxio.worker.block.meta.BlockMeta)3 HashMap (java.util.HashMap)3 Pair (alluxio.collections.Pair)2 StorageTierView (alluxio.worker.block.meta.StorageTierView)2 TempBlockMeta (alluxio.worker.block.meta.TempBlockMeta)2 BlockDoesNotExistException (alluxio.exception.BlockDoesNotExistException)1 WorkerOutOfSpaceException (alluxio.exception.WorkerOutOfSpaceException)1 AbstractBlockMeta (alluxio.worker.block.meta.AbstractBlockMeta)1 StorageDirView (alluxio.worker.block.meta.StorageDirView)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ExpectedException (org.junit.rules.ExpectedException)1