override fun createActionRequestsThrottler()

in plugin-azure-server/src/main/kotlin/jetbrains/buildServer/clouds/azure/arm/throttler/AzureThrottlerFactoryImpl.kt [96:162]


    override fun createActionRequestsThrottler(
        credentials: AzureTokenCredentials,
        subscriptionId: String?,
        taskNotifications: AzureTaskNotifications,
        timeManager: AzureTimeManager,
    ): AzureThrottler<AzureApi, AzureThrottlerActionTasks.Values> {
        val azureActionAdapter = AzureThrottlerAdapterImpl(
                AzureThrottlerConfigurableImpl(),
                ReqourceGraphConfigurableImpl(),
                credentials,
                subscriptionId,
                timeManager,
                mySchedulersProvider.getActionRequestsSchedulers().requestScheduler,
                "${throttlerId.incrementAndGet()}-ActionAdapter")

        val randomTaskReservation = { TeamCityProperties.getInteger(TEAMCITY_CLOUDS_AZURE_ACTION_THROTTLER_RANDOM_TASK_RESERVATION, 50) }
        val taskReservation = { TeamCityProperties.getInteger(TEAMCITY_CLOUDS_AZURE_ACTION_THROTTLER_TASK_RESERVATION, 10) }
        val aggressiveThrottlingLimit = { TeamCityProperties.getInteger(TEAMCITY_CLOUDS_AZURE_ACTION_THROTTLER_AGGRESSIVE_THROTTLING_LIMIT, 90) }
        val adapterThrottlerTimeInMs = {
            if (TeamCityProperties.getBoolean(TEAMCITY_CLOUDS_AZURE_THROTTLER_TIMEMANAGER_NEW_THROTTLING_MODEL_DISABLE))
                TeamCityProperties.getLong(TEAMCITY_CLOUDS_AZURE_ACTION_THROTTLER_DEFAULT_DELAY_IN_MS, 100)
            else
                0
        }
        val maxAdapterThrottlerTimeInMs = { TeamCityProperties.getLong(TEAMCITY_CLOUDS_AZURE_ACTION_THROTTLER_MAX_DELAY_IN_MS, 1000) }

        val actionsStrategy = AzureThrottlerStrategyImpl<AzureApi, AzureThrottlerActionTasks.Values>(
                azureActionAdapter,
                randomTaskReservation,
                taskReservation,
                aggressiveThrottlingLimit,
                adapterThrottlerTimeInMs,
                maxAdapterThrottlerTimeInMs)

        val randomTaskCacheTimeout = TeamCityProperties.getLong(TEAMCITY_CLOUDS_AZURE_ACTION_THROTTLER_RANDOM_TASK_CACHE_TIMEOUT, 60)

        val throttler = AzureThrottlerImpl(
                azureActionAdapter,
                actionsStrategy,
                mySchedulersProvider.getActionRequestsSchedulers(),
                AzureThrottlerScheduledExecutorFactortyImpl(),
                taskNotifications
        )

        return throttler
                .registerTask(AzureThrottlerActionTasks.CreateDeployment,
                        AzureThrottlerTaskTimeExecutionType.Random,
                        randomTaskCacheTimeout)
                .registerTask(AzureThrottlerActionTasks.CreateResourceGroup,
                        AzureThrottlerTaskTimeExecutionType.Random,
                        randomTaskCacheTimeout)
                .registerTask(AzureThrottlerActionTasks.DeleteResourceGroup,
                        AzureThrottlerTaskTimeExecutionType.Random,
                        randomTaskCacheTimeout)
                .registerTask(AzureThrottlerActionTasks.StopVirtualMachine,
                        AzureThrottlerTaskTimeExecutionType.Random,
                        randomTaskCacheTimeout)
                .registerTask(AzureThrottlerActionTasks.StartVirtualMachine,
                        AzureThrottlerTaskTimeExecutionType.Random,
                        randomTaskCacheTimeout)
                .registerTask(AzureThrottlerActionTasks.RestartVirtualMachine,
                        AzureThrottlerTaskTimeExecutionType.Random,
                        randomTaskCacheTimeout)
                .registerTask(AzureThrottlerActionTasks.DeleteDeployment,
                        AzureThrottlerTaskTimeExecutionType.Random,
                        randomTaskCacheTimeout)
    }