Source:
Map<String, Map<String, Long>> getValidDataSizeByContainer(long referenceTimeInMs) throws StoreException { if (!enabled.get()) { throw new StoreException(String.format("BlobStoreStats is not enabled or closing for store %s", storeId), StoreErrorCodes.Store_Shutting_Down); } Map<String, Map<String, Long>> retValue = null; ScanResults currentScanResults = scanResults.get(); if (currentScanResults != null && isWithinRange(currentScanResults.containerForecastStartTimeMs, currentScanResults.containerForecastEndTimeMs, referenceTimeInMs)) { retValue = currentScanResults.getValidSizePerContainer(referenceTimeInMs); } else { if (isScanning && isWithinRange(indexScanner.newScanResults.containerForecastStartTimeMs, indexScanner.newScanResults.containerForecastEndTimeMs, referenceTimeInMs)) { scanLock.lock(); try { if (isScanning) { if (waitCondition.await(waitTimeoutInSecs, TimeUnit.SECONDS)) { currentScanResults = scanResults.get(); if (isWithinRange(currentScanResults.containerForecastStartTimeMs, currentScanResults.containerForecastEndTimeMs, referenceTimeInMs)) { retValue = currentScanResults.getValidSizePerContainer(referenceTimeInMs); } } else { metrics.blobStoreStatsIndexScannerErrorCount.inc(); logger.error("BlobStoreStats index scan took too long to finish for store {}", storeId); } } } catch (InterruptedException e) { metrics.blobStoreStatsIndexScannerErrorCount.inc(); throw new IllegalStateException( String.format("Illegal state, wait for scan to complete is interrupted for store %s", storeId), e); } finally { scanLock.unlock(); } } if (retValue == null) { retValue = collectValidDataSizeByContainer(referenceTimeInMs); } } return retValue; }

Target:
Map<String, Map<String, Long>> getValidDataSizeByContainer(long referenceTimeInMs) throws StoreException { if (!enabled.get()) { throw new StoreException(String.format("BlobStoreStats is not enabled or closing for store %s", storeId), StoreErrorCodes.Store_Shutting_Down); } Map<String, Map<String, Long>> retValue = null; ScanResults currentScanResults = scanResults.get(); if (currentScanResults != null && isWithinRange(currentScanResults.containerForecastStartTimeMs, currentScanResults.containerForecastEndTimeMs, referenceTimeInMs)) { retValue = currentScanResults.getValidSizePerContainer(referenceTimeInMs); } else { if (isScanning && isWithinRange(indexScanner.newScanResults.containerForecastStartTimeMs, indexScanner.newScanResults.containerForecastEndTimeMs, referenceTimeInMs)) { scanLock.lock(); try { if (isScanning) { if (waitCondition.await(waitTimeoutInSecs, TimeUnit.SECONDS)) { currentScanResults = scanResults.get(); if (isWithinRange(currentScanResults.containerForecastStartTimeMs, currentScanResults.containerForecastEndTimeMs, referenceTimeInMs)) { retValue = currentScanResults.getValidSizePerContainer(referenceTimeInMs); } } else { metrics.blobStoreStatsIndexScannerErrorCount.inc(); logger.error("Timed out while waiting for BlobStoreStats index scan to complete for store {}", storeId); } } else { currentScanResults = scanResults.get(); if (isWithinRange(currentScanResults.containerForecastStartTimeMs, currentScanResults.containerForecastEndTimeMs, referenceTimeInMs)) { retValue = currentScanResults.getValidSizePerContainer(referenceTimeInMs); } } } catch (InterruptedException e) { metrics.blobStoreStatsIndexScannerErrorCount.inc(); throw new IllegalStateException( String.format("Illegal state, wait for scan to complete is interrupted for store %s", storeId), e); } finally { scanLock.unlock(); } } if (retValue == null) { retValue = collectValidDataSizeByContainer(referenceTimeInMs); } } return retValue; }