@Test public void allocateBeforeInitializeTest() throws Exception { alloc = constructAllocator(); File f1 = allocateAndVerify(storeId1, "file1", 50, false); File f2 = allocateAndVerify(storeId1, "file2", 20, false); File f3 = allocateAndVerify(storeId1, "file3", 20, false); freeAndVerify(storeId1, f3, 20, false); verifyPoolState(new ExpectedState()); alloc.initializePool( Arrays.asList(new DiskSpaceRequirements(storeId0, 50, 2, 0), new DiskSpaceRequirements(storeId1, 21, 1, 0))); verifyPoolState(new ExpectedState().addStoreSeg(storeId0, 50, 2).addStoreSeg(storeId1, 21, 1)); freeAndVerify(storeId1, f1, 50, false); verifyPoolState( new ExpectedState().addStoreSeg(storeId0, 50, 2).addStoreSeg(storeId1, 21, 1).addStoreSeg(storeId1, 50, 1)); freeAndVerify(storeId1, f2, 20, false); verifyPoolState(new ExpectedState().addStoreSeg(storeId0, 50, 2) .addStoreSeg(storeId1, 20, 1) .addStoreSeg(storeId1, 21, 1) .addStoreSeg(storeId1, 50, 1)); File f4 = allocateAndVerify(storeId1, "file4", 50, false); verifyPoolState(new ExpectedState().addStoreSeg(storeId0, 50, 2) .addStoreSeg(storeId1, 20, 1) .addStoreSeg(storeId1, 21, 1) .addStoreSeg(storeId1, 50, 0)); freeAndVerify(storeId1, f4, 50, false); verifyPoolState(new ExpectedState().addStoreSeg(storeId0, 50, 2) .addStoreSeg(storeId1, 20, 1) .addStoreSeg(storeId1, 21, 1) .addStoreSeg(storeId1, 50, 1)); }
void initializePool(Collection<DiskSpaceRequirements> requirementsList) throws StoreException { long startTime = System.currentTimeMillis(); try { if (enablePooling) { if (poolState == PoolState.NOT_INVENTORIED) { throw inventoryException; } Map<String, Map<Long, Long>> overallRequirements = getOverallRequirements(requirementsList); deleteExtraSegments(overallRequirements); addRequiredSegments(overallRequirements, true); poolState = PoolState.INITIALIZED; } else { logger.info("Disk segment pooling disabled; pool will not be initialized."); } } catch (Exception e) { metrics.diskSpaceAllocatorInitFailureCount.inc(); poolState = PoolState.NOT_INVENTORIED; throw new StoreException("Exception while initializing DiskSpaceAllocator pool", e, StoreErrorCodes.Initialization_Error); } finally { long elapsedTime = System.currentTimeMillis() - startTime; logger.info("initializePool took {} ms", elapsedTime); metrics.diskSpaceAllocatorStartTimeMs.update(elapsedTime); } }
DiskSpaceAllocator { void initializePool(Collection<DiskSpaceRequirements> requirementsList) throws StoreException { long startTime = System.currentTimeMillis(); try { if (enablePooling) { if (poolState == PoolState.NOT_INVENTORIED) { throw inventoryException; } Map<String, Map<Long, Long>> overallRequirements = getOverallRequirements(requirementsList); deleteExtraSegments(overallRequirements); addRequiredSegments(overallRequirements, true); poolState = PoolState.INITIALIZED; } else { logger.info("Disk segment pooling disabled; pool will not be initialized."); } } catch (Exception e) { metrics.diskSpaceAllocatorInitFailureCount.inc(); poolState = PoolState.NOT_INVENTORIED; throw new StoreException("Exception while initializing DiskSpaceAllocator pool", e, StoreErrorCodes.Initialization_Error); } finally { long elapsedTime = System.currentTimeMillis() - startTime; logger.info("initializePool took {} ms", elapsedTime); metrics.diskSpaceAllocatorStartTimeMs.update(elapsedTime); } } }
DiskSpaceAllocator { void initializePool(Collection<DiskSpaceRequirements> requirementsList) throws StoreException { long startTime = System.currentTimeMillis(); try { if (enablePooling) { if (poolState == PoolState.NOT_INVENTORIED) { throw inventoryException; } Map<String, Map<Long, Long>> overallRequirements = getOverallRequirements(requirementsList); deleteExtraSegments(overallRequirements); addRequiredSegments(overallRequirements, true); poolState = PoolState.INITIALIZED; } else { logger.info("Disk segment pooling disabled; pool will not be initialized."); } } catch (Exception e) { metrics.diskSpaceAllocatorInitFailureCount.inc(); poolState = PoolState.NOT_INVENTORIED; throw new StoreException("Exception while initializing DiskSpaceAllocator pool", e, StoreErrorCodes.Initialization_Error); } finally { long elapsedTime = System.currentTimeMillis() - startTime; logger.info("initializePool took {} ms", elapsedTime); metrics.diskSpaceAllocatorStartTimeMs.update(elapsedTime); } } DiskSpaceAllocator(boolean enablePooling, File reserveDir, long requiredSwapSegmentsPerSize,
      StorageManagerMetrics metrics); }
DiskSpaceAllocator { void initializePool(Collection<DiskSpaceRequirements> requirementsList) throws StoreException { long startTime = System.currentTimeMillis(); try { if (enablePooling) { if (poolState == PoolState.NOT_INVENTORIED) { throw inventoryException; } Map<String, Map<Long, Long>> overallRequirements = getOverallRequirements(requirementsList); deleteExtraSegments(overallRequirements); addRequiredSegments(overallRequirements, true); poolState = PoolState.INITIALIZED; } else { logger.info("Disk segment pooling disabled; pool will not be initialized."); } } catch (Exception e) { metrics.diskSpaceAllocatorInitFailureCount.inc(); poolState = PoolState.NOT_INVENTORIED; throw new StoreException("Exception while initializing DiskSpaceAllocator pool", e, StoreErrorCodes.Initialization_Error); } finally { long elapsedTime = System.currentTimeMillis() - startTime; logger.info("initializePool took {} ms", elapsedTime); metrics.diskSpaceAllocatorStartTimeMs.update(elapsedTime); } } DiskSpaceAllocator(boolean enablePooling, File reserveDir, long requiredSwapSegmentsPerSize,
      StorageManagerMetrics metrics);  }
DiskSpaceAllocator { void initializePool(Collection<DiskSpaceRequirements> requirementsList) throws StoreException { long startTime = System.currentTimeMillis(); try { if (enablePooling) { if (poolState == PoolState.NOT_INVENTORIED) { throw inventoryException; } Map<String, Map<Long, Long>> overallRequirements = getOverallRequirements(requirementsList); deleteExtraSegments(overallRequirements); addRequiredSegments(overallRequirements, true); poolState = PoolState.INITIALIZED; } else { logger.info("Disk segment pooling disabled; pool will not be initialized."); } } catch (Exception e) { metrics.diskSpaceAllocatorInitFailureCount.inc(); poolState = PoolState.NOT_INVENTORIED; throw new StoreException("Exception while initializing DiskSpaceAllocator pool", e, StoreErrorCodes.Initialization_Error); } finally { long elapsedTime = System.currentTimeMillis() - startTime; logger.info("initializePool took {} ms", elapsedTime); metrics.diskSpaceAllocatorStartTimeMs.update(elapsedTime); } } DiskSpaceAllocator(boolean enablePooling, File reserveDir, long requiredSwapSegmentsPerSize,
      StorageManagerMetrics metrics);   }