in plugin-azure-server/src/main/kotlin/jetbrains/buildServer/clouds/azure/arm/throttler/AzureThrottlerFactoryImpl.kt [15:94]
override fun createReadRequestsThrottler(
credentials: AzureTokenCredentials,
subscriptionId: String?,
taskNotifications: AzureTaskNotifications,
timeManager: AzureTimeManager,
): AzureThrottler<AzureApi, AzureThrottlerReadTasks.Values> {
val azureAdapter = AzureThrottlerAdapterImpl(
AzureThrottlerConfigurableImpl(),
ReqourceGraphConfigurableImpl(),
credentials,
subscriptionId,
timeManager,
mySchedulersProvider.getReadRequestsSchedulers().requestScheduler,
"${throttlerId.incrementAndGet()}-ReadAdapter")
val randomTaskReservation = { TeamCityProperties.getInteger(TEAMCITY_CLOUDS_AZURE_READ_THROTTLER_RANDOM_TASK_RESERVATION, 20) }
val taskReservation = { TeamCityProperties.getInteger(TEAMCITY_CLOUDS_AZURE_READ_THROTTLER_TASK_RESERVATION, 10) }
val aggressiveThrottlingLimit = { TeamCityProperties.getInteger(TEAMCITY_CLOUDS_AZURE_READ_THROTTLER_AGGRESSIVE_THROTTLING_LIMIT, 90) }
val adapterThrottlerTimeInMs = {
if (TeamCityProperties.getBoolean(TEAMCITY_CLOUDS_AZURE_THROTTLER_TIMEMANAGER_NEW_THROTTLING_MODEL_DISABLE))
TeamCityProperties.getLong(TEAMCITY_CLOUDS_AZURE_READ_THROTTLER_DEFAULT_DELAY_IN_MS, 400)
else
0
}
val maxAdapterThrottlerTimeInMs = { TeamCityProperties.getLong(TEAMCITY_CLOUDS_AZURE_READ_THROTTLER_MAX_DELAY_IN_MS, 3000) }
val readsStrategy = AzureThrottlerStrategyImpl<AzureApi, AzureThrottlerReadTasks.Values>(
azureAdapter,
randomTaskReservation,
taskReservation,
aggressiveThrottlingLimit,
adapterThrottlerTimeInMs,
maxAdapterThrottlerTimeInMs)
val throttler = AzureThrottlerImpl(
azureAdapter,
readsStrategy,
mySchedulersProvider.getReadRequestsSchedulers(),
AzureThrottlerScheduledExecutorFactortyImpl(),
taskNotifications
)
val randomTaskCacheTimeout = TeamCityProperties.getLong(TEAMCITY_CLOUDS_AZURE_READ_THROTTLER_RANDOM_TASK_CACHE_TIMEOUT, 90)
val periodicalTaskCacheTimeout = TeamCityProperties.getLong(TEAMCITY_CLOUDS_AZURE_READ_THROTTLER_PERIODICAL_TASK_CACHE_TIMEOUT, 150)
return throttler
.registerTask(AzureThrottlerReadTasks.FetchResourceGroups,
AzureThrottlerTaskTimeExecutionType.Periodical,
periodicalTaskCacheTimeout)
.registerTask(AzureThrottlerReadTasks.FetchVirtualMachines,
AzureThrottlerTaskTimeExecutionType.Random,
randomTaskCacheTimeout)
.registerTask(AzureThrottlerReadTasks.FetchInstances,
AzureThrottlerTaskTimeExecutionType.Periodical,
periodicalTaskCacheTimeout)
.registerTask(AzureThrottlerReadTasks.FetchCustomImages,
AzureThrottlerTaskTimeExecutionType.Periodical,
periodicalTaskCacheTimeout)
.registerTask(AzureThrottlerReadTasks.FetchStorageAccounts,
AzureThrottlerTaskTimeExecutionType.Random,
randomTaskCacheTimeout)
.registerTask(AzureThrottlerReadTasks.FetchVirtualMachineSizes,
AzureThrottlerTaskTimeExecutionType.Random,
randomTaskCacheTimeout)
.registerTask(AzureThrottlerReadTasks.FetchSubscriptions,
AzureThrottlerTaskTimeExecutionType.Random,
randomTaskCacheTimeout)
.registerTask(AzureThrottlerReadTasks.FetchLocations,
AzureThrottlerTaskTimeExecutionType.Random,
randomTaskCacheTimeout)
.registerTask(AzureThrottlerReadTasks.FetchNetworks,
AzureThrottlerTaskTimeExecutionType.Random,
randomTaskCacheTimeout)
.registerTask(AzureThrottlerReadTasks.FetchServices,
AzureThrottlerTaskTimeExecutionType.Periodical,
periodicalTaskCacheTimeout)
.registerTask(AzureThrottlerReadTasks.FetchStorageAccountKeys,
AzureThrottlerTaskTimeExecutionType.Random,
randomTaskCacheTimeout)
}