@Test public void getAvailableBytes() { assertEquals(9000, mMetaManager.getAvailableBytes(BlockStoreLocation.anyTier())); assertEquals(1000, mMetaManager.getAvailableBytes(BlockStoreLocation.anyDirInTier("MEM"))); assertEquals(8000, mMetaManager.getAvailableBytes(BlockStoreLocation.anyDirInTier("HDD"))); assertEquals(1000, mMetaManager.getAvailableBytes(new BlockStoreLocation("MEM", 0))); assertEquals(3000, mMetaManager.getAvailableBytes(new BlockStoreLocation("HDD", 0))); assertEquals(5000, mMetaManager.getAvailableBytes(new BlockStoreLocation("HDD", 1))); }
public long getAvailableBytes(BlockStoreLocation location) { long spaceAvailable = 0; if (location.equals(BlockStoreLocation.anyTier())) { for (StorageTier tier : mTiers) { spaceAvailable += tier.getAvailableBytes(); } return spaceAvailable; } String tierAlias = location.tierAlias(); StorageTier tier = getTier(tierAlias); if (location.equals(BlockStoreLocation.anyDirInTier(tierAlias))) { return tier.getAvailableBytes(); } int dirIndex = location.dir(); StorageDir dir = tier.getDir(dirIndex); return dir == null ? 0 : dir.getAvailableBytes(); }
BlockMetadataManager { public long getAvailableBytes(BlockStoreLocation location) { long spaceAvailable = 0; if (location.equals(BlockStoreLocation.anyTier())) { for (StorageTier tier : mTiers) { spaceAvailable += tier.getAvailableBytes(); } return spaceAvailable; } String tierAlias = location.tierAlias(); StorageTier tier = getTier(tierAlias); if (location.equals(BlockStoreLocation.anyDirInTier(tierAlias))) { return tier.getAvailableBytes(); } int dirIndex = location.dir(); StorageDir dir = tier.getDir(dirIndex); return dir == null ? 0 : dir.getAvailableBytes(); } }
BlockMetadataManager { public long getAvailableBytes(BlockStoreLocation location) { long spaceAvailable = 0; if (location.equals(BlockStoreLocation.anyTier())) { for (StorageTier tier : mTiers) { spaceAvailable += tier.getAvailableBytes(); } return spaceAvailable; } String tierAlias = location.tierAlias(); StorageTier tier = getTier(tierAlias); if (location.equals(BlockStoreLocation.anyDirInTier(tierAlias))) { return tier.getAvailableBytes(); } int dirIndex = location.dir(); StorageDir dir = tier.getDir(dirIndex); return dir == null ? 0 : dir.getAvailableBytes(); } private  BlockMetadataManager(); }
BlockMetadataManager { public long getAvailableBytes(BlockStoreLocation location) { long spaceAvailable = 0; if (location.equals(BlockStoreLocation.anyTier())) { for (StorageTier tier : mTiers) { spaceAvailable += tier.getAvailableBytes(); } return spaceAvailable; } String tierAlias = location.tierAlias(); StorageTier tier = getTier(tierAlias); if (location.equals(BlockStoreLocation.anyDirInTier(tierAlias))) { return tier.getAvailableBytes(); } int dirIndex = location.dir(); StorageDir dir = tier.getDir(dirIndex); return dir == null ? 0 : dir.getAvailableBytes(); } private  BlockMetadataManager(); BlockIterator getBlockIterator(); static BlockMetadataManager createBlockMetadataManager(); void abortTempBlockMeta(TempBlockMeta tempBlockMeta); void addTempBlockMeta(TempBlockMeta tempBlockMeta); void commitTempBlockMeta(TempBlockMeta tempBlockMeta); void swapBlocks(BlockMeta blockMeta1, BlockMeta blockMeta2); @Deprecated void cleanupSessionTempBlocks(long sessionId, List<Long> tempBlockIds); long getAvailableBytes(BlockStoreLocation location); BlockMeta getBlockMeta(long blockId); @Nullable String getBlockPath(long blockId, BlockStoreLocation location); BlockStoreMeta getBlockStoreMeta(); BlockStoreMeta getBlockStoreMetaFull(); StorageDir getDir(BlockStoreLocation location); TempBlockMeta getTempBlockMeta(long blockId); @Nullable TempBlockMeta getTempBlockMetaOrNull(long blockId); StorageTier getTier(String tierAlias); List<StorageTier> getTiers(); List<StorageTier> getTiersBelow(String tierAlias); List<TempBlockMeta> getSessionTempBlocks(long sessionId); boolean hasBlockMeta(long blockId); boolean hasTempBlockMeta(long blockId); BlockMeta moveBlockMeta(BlockMeta blockMeta, TempBlockMeta tempBlockMeta); @Deprecated BlockMeta moveBlockMeta(BlockMeta blockMeta, BlockStoreLocation newLocation); void removeBlockMeta(BlockMeta block); void resizeTempBlockMeta(TempBlockMeta tempBlockMeta, long newSize); StorageTierAssoc getStorageTierAssoc(); }
BlockMetadataManager { public long getAvailableBytes(BlockStoreLocation location) { long spaceAvailable = 0; if (location.equals(BlockStoreLocation.anyTier())) { for (StorageTier tier : mTiers) { spaceAvailable += tier.getAvailableBytes(); } return spaceAvailable; } String tierAlias = location.tierAlias(); StorageTier tier = getTier(tierAlias); if (location.equals(BlockStoreLocation.anyDirInTier(tierAlias))) { return tier.getAvailableBytes(); } int dirIndex = location.dir(); StorageDir dir = tier.getDir(dirIndex); return dir == null ? 0 : dir.getAvailableBytes(); } private  BlockMetadataManager(); BlockIterator getBlockIterator(); static BlockMetadataManager createBlockMetadataManager(); void abortTempBlockMeta(TempBlockMeta tempBlockMeta); void addTempBlockMeta(TempBlockMeta tempBlockMeta); void commitTempBlockMeta(TempBlockMeta tempBlockMeta); void swapBlocks(BlockMeta blockMeta1, BlockMeta blockMeta2); @Deprecated void cleanupSessionTempBlocks(long sessionId, List<Long> tempBlockIds); long getAvailableBytes(BlockStoreLocation location); BlockMeta getBlockMeta(long blockId); @Nullable String getBlockPath(long blockId, BlockStoreLocation location); BlockStoreMeta getBlockStoreMeta(); BlockStoreMeta getBlockStoreMetaFull(); StorageDir getDir(BlockStoreLocation location); TempBlockMeta getTempBlockMeta(long blockId); @Nullable TempBlockMeta getTempBlockMetaOrNull(long blockId); StorageTier getTier(String tierAlias); List<StorageTier> getTiers(); List<StorageTier> getTiersBelow(String tierAlias); List<TempBlockMeta> getSessionTempBlocks(long sessionId); boolean hasBlockMeta(long blockId); boolean hasTempBlockMeta(long blockId); BlockMeta moveBlockMeta(BlockMeta blockMeta, TempBlockMeta tempBlockMeta); @Deprecated BlockMeta moveBlockMeta(BlockMeta blockMeta, BlockStoreLocation newLocation); void removeBlockMeta(BlockMeta block); void resizeTempBlockMeta(TempBlockMeta tempBlockMeta, long newSize); StorageTierAssoc getStorageTierAssoc();  }