long (SystemOpsStatistic systemOpsStatistic, int projectModulesCount) { double magicCoefficient = 1.3; long decompressionSpeed; if (JpsCacheLoadingSystemStats.getDecompressionSpeedBytesPesSec() > 0) { decompressionSpeed = JpsCacheLoadingSystemStats.getDecompressionSpeedBytesPesSec(); LOG.info("Using previously saved statistic about decompression speed: " + StringUtil.formatFileSize(decompressionSpeed) + "/s"); } else { decompressionSpeed = systemOpsStatistic.getDecompressionSpeedBytesPesSec(); } long deletionSpeed; if (JpsCacheLoadingSystemStats.getDeletionSpeedBytesPerSec() > 0) { deletionSpeed = JpsCacheLoadingSystemStats.getDeletionSpeedBytesPerSec(); LOG.info("Using previously saved statistic about deletion speed: " + StringUtil.formatFileSize(deletionSpeed) + "/s"); } else { deletionSpeed = systemOpsStatistic.getDeletionSpeedBytesPerSec(); } int approximateSizeToDelete = projectModulesCount * PROJECT_MODULE_SIZE_DISK_BYTES; int approximateDownloadSize = projectModulesCount * PROJECT_MODULE_DOWNLOAD_SIZE_BYTES + AVERAGE_CACHE_SIZE_BYTES; long expectedDownloadTimeSec = approximateDownloadSize / systemOpsStatistic.getConnectionSpeedBytesPerSec(); long expectedDecompressionTimeSec = approximateDownloadSize / decompressionSpeed; long expectedDeleteTimeSec = approximateSizeToDelete / deletionSpeed; long expectedTimeOfWorkMs = ((long)(expectedDeleteTimeSec * magicCoefficient) + expectedDownloadTimeSec + expectedDecompressionTimeSec) * 1000; LOG.info("Expected download size: " + StringUtil.formatFileSize(approximateDownloadSize) + ". Expected download time: " + expectedDownloadTimeSec + "sec. " + "Expected decompression time: " + expectedDecompressionTimeSec + "sec. " + "Expected size to delete: " + StringUtil.formatFileSize(approximateDownloadSize) + ". Expected delete time: " + expectedDeleteTimeSec + "sec. " + "Total time of work: " + StringUtil.formatDuration(expectedTimeOfWorkMs)); if (expectedDownloadTimeSec >= myMaxDownloadDuration) { LOG.info("Downloading can consume more than 10 mins, connection speed is too small for caches usages"); return 0; } return expectedTimeOfWorkMs; }