@Test public void concurrencyTest() throws Exception { alloc = constructAllocator(); List<DiskSpaceRequirements> requirementsList = new ArrayList<>(); requirementsList.add(new DiskSpaceRequirements(storeId0, 10, 500, 1)); requirementsList.add(new DiskSpaceRequirements(storeId1, 5, 251, 0)); alloc.initializePool(requirementsList); verifyPoolState(new ExpectedState().addStoreSeg(storeId0, 10, 500).addStoreSeg(storeId1, 5, 251)); exec = Executors.newCachedThreadPool(); runConcurrencyTest(requirementsList, true, false); verifyPoolState(new ExpectedState().addStoreSeg(storeId0, 10, 0).addStoreSeg(storeId1, 5, 0)); runConcurrencyTest(requirementsList, false, true); verifyPoolState(new ExpectedState().addStoreSeg(storeId0, 10, 500).addStoreSeg(storeId1, 5, 251)); runConcurrencyTest(requirementsList, true, true); verifyPoolState(new ExpectedState().addStoreSeg(storeId0, 10, 500).addStoreSeg(storeId1, 5, 251)); runConcurrencyTest(requirementsList, true, false); verifyPoolState(new ExpectedState().addStoreSeg(storeId0, 10, 0).addStoreSeg(storeId1, 5, 0)); }
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);   }