Search in sources :

Example 1 with AutoScalableTarget

use of com.netflix.titus.api.appscale.model.AutoScalableTarget in project titus-control-plane by Netflix.

the class DefaultAppScaleManager method addScalableTargetIfNew.

private void addScalableTargetIfNew(String jobId) {
    if (!scalableTargets.containsKey(jobId)) {
        metrics.reportNewScalableTarget();
        AutoScalableTarget autoScalableTarget = AutoScalableTarget.newBuilder().build();
        scalableTargets.put(jobId, autoScalableTarget);
    }
}
Also used : AutoScalableTarget(com.netflix.titus.api.appscale.model.AutoScalableTarget)

Example 2 with AutoScalableTarget

use of com.netflix.titus.api.appscale.model.AutoScalableTarget in project titus-control-plane by Netflix.

the class AWSAppAutoScalingClient method getScalableTargetsForJob.

@Override
public Observable<AutoScalableTarget> getScalableTargetsForJob(String jobId) {
    DescribeScalableTargetsRequest describeScalableTargetsRequest = new DescribeScalableTargetsRequest();
    describeScalableTargetsRequest.setServiceNamespace(SERVICE_NAMESPACE);
    describeScalableTargetsRequest.setScalableDimension(SCALABLE_DIMENSION);
    describeScalableTargetsRequest.setResourceIds(Collections.singletonList(AWSAppAutoScalingUtil.buildGatewayResourceId(jobId, awsAppScalingConfig.getAWSGatewayEndpointPrefix(), awsAppScalingConfig.getRegion(), awsAppScalingConfig.getAWSGatewayEndpointTargetStage())));
    return RetryWrapper.wrapWithExponentialRetry(String.format("getScalableTargetsForJob for job %s", jobId), Observable.create(emitter -> awsAppAutoScalingClientAsync.describeScalableTargetsAsync(describeScalableTargetsRequest, new AsyncHandler<DescribeScalableTargetsRequest, DescribeScalableTargetsResult>() {

        @Override
        public void onError(Exception exception) {
            logger.error("Get scalable target exception for {} - {}", jobId, exception.getMessage());
            awsAppAutoScalingMetrics.registerAwsGetTargetError(exception);
            emitter.onError(exception);
        }

        @Override
        public void onSuccess(DescribeScalableTargetsRequest request, DescribeScalableTargetsResult describeScalableTargetsResult) {
            awsAppAutoScalingMetrics.registerAwsGetTargetSuccess();
            List<ScalableTarget> scalableTargets = describeScalableTargetsResult.getScalableTargets();
            scalableTargets.stream().map(AWSAppAutoScalingUtil::toAutoScalableTarget).forEach(emitter::onNext);
            emitter.onCompleted();
        }
    }), Emitter.BackpressureMode.NONE));
}
Also used : ScalableTarget(com.amazonaws.services.applicationautoscaling.model.ScalableTarget) AutoScalePolicyException(com.netflix.titus.api.appscale.service.AutoScalePolicyException) Completable(rx.Completable) CustomizedMetricSpecification(com.amazonaws.services.applicationautoscaling.model.CustomizedMetricSpecification) DeleteScalingPolicyRequest(com.amazonaws.services.applicationautoscaling.model.DeleteScalingPolicyRequest) StepScalingPolicyConfiguration(com.amazonaws.services.applicationautoscaling.model.StepScalingPolicyConfiguration) LoggerFactory(org.slf4j.LoggerFactory) AutoScalableTarget(com.netflix.titus.api.appscale.model.AutoScalableTarget) AWSApplicationAutoScalingAsyncClientBuilder(com.amazonaws.services.applicationautoscaling.AWSApplicationAutoScalingAsyncClientBuilder) Singleton(javax.inject.Singleton) DescribeScalableTargetsRequest(com.amazonaws.services.applicationautoscaling.model.DescribeScalableTargetsRequest) TargetTrackingPolicy(com.netflix.titus.api.appscale.model.TargetTrackingPolicy) Observable(rx.Observable) Inject(javax.inject.Inject) DeleteScalingPolicyResult(com.amazonaws.services.applicationautoscaling.model.DeleteScalingPolicyResult) AWSApplicationAutoScalingAsync(com.amazonaws.services.applicationautoscaling.AWSApplicationAutoScalingAsync) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider) ValidationException(com.amazonaws.services.applicationautoscaling.model.ValidationException) ObjectNotFoundException(com.amazonaws.services.applicationautoscaling.model.ObjectNotFoundException) PutScalingPolicyResult(com.amazonaws.services.applicationautoscaling.model.PutScalingPolicyResult) RegisterScalableTargetResult(com.amazonaws.services.applicationautoscaling.model.RegisterScalableTargetResult) RetryWrapper(com.netflix.titus.ext.aws.RetryWrapper) Logger(org.slf4j.Logger) DeregisterScalableTargetResult(com.amazonaws.services.applicationautoscaling.model.DeregisterScalableTargetResult) StepAdjustment(com.amazonaws.services.applicationautoscaling.model.StepAdjustment) TargetTrackingScalingPolicyConfiguration(com.amazonaws.services.applicationautoscaling.model.TargetTrackingScalingPolicyConfiguration) AppAutoScalingClient(com.netflix.titus.api.connector.cloud.AppAutoScalingClient) Emitter(rx.Emitter) Collectors(java.util.stream.Collectors) PolicyType(com.netflix.titus.api.appscale.model.PolicyType) DescribeScalableTargetsResult(com.amazonaws.services.applicationautoscaling.model.DescribeScalableTargetsResult) List(java.util.List) AWSAppAutoScalingUtil.buildScalingPolicyName(com.netflix.titus.ext.aws.appscale.AWSAppAutoScalingUtil.buildScalingPolicyName) RegisterScalableTargetRequest(com.amazonaws.services.applicationautoscaling.model.RegisterScalableTargetRequest) AsyncHandler(com.amazonaws.handlers.AsyncHandler) Registry(com.netflix.spectator.api.Registry) DeregisterScalableTargetRequest(com.amazonaws.services.applicationautoscaling.model.DeregisterScalableTargetRequest) VisibleForTesting(com.google.common.annotations.VisibleForTesting) MetricDimension(com.amazonaws.services.applicationautoscaling.model.MetricDimension) PutScalingPolicyRequest(com.amazonaws.services.applicationautoscaling.model.PutScalingPolicyRequest) Collections(java.util.Collections) PolicyConfiguration(com.netflix.titus.api.appscale.model.PolicyConfiguration) DescribeScalableTargetsRequest(com.amazonaws.services.applicationautoscaling.model.DescribeScalableTargetsRequest) List(java.util.List) DescribeScalableTargetsResult(com.amazonaws.services.applicationautoscaling.model.DescribeScalableTargetsResult) AutoScalePolicyException(com.netflix.titus.api.appscale.service.AutoScalePolicyException) ValidationException(com.amazonaws.services.applicationautoscaling.model.ValidationException) ObjectNotFoundException(com.amazonaws.services.applicationautoscaling.model.ObjectNotFoundException)

Example 3 with AutoScalableTarget

use of com.netflix.titus.api.appscale.model.AutoScalableTarget in project titus-control-plane by Netflix.

the class NoOpAppAutoScalingClient method getScalableTargetsForJob.

@Override
public Observable<AutoScalableTarget> getScalableTargetsForJob(String jobId) {
    AutoScalableTarget autoScalableTarget = AutoScalableTarget.newBuilder().withMinCapacity(1).withMaxCapacity(10).build();
    log.info("Scalable targets for JobId {} - {}", jobId, autoScalableTarget);
    return Observable.just(autoScalableTarget);
}
Also used : AutoScalableTarget(com.netflix.titus.api.appscale.model.AutoScalableTarget)

Aggregations

AutoScalableTarget (com.netflix.titus.api.appscale.model.AutoScalableTarget)3 AWSCredentialsProvider (com.amazonaws.auth.AWSCredentialsProvider)1 AsyncHandler (com.amazonaws.handlers.AsyncHandler)1 AWSApplicationAutoScalingAsync (com.amazonaws.services.applicationautoscaling.AWSApplicationAutoScalingAsync)1 AWSApplicationAutoScalingAsyncClientBuilder (com.amazonaws.services.applicationautoscaling.AWSApplicationAutoScalingAsyncClientBuilder)1 CustomizedMetricSpecification (com.amazonaws.services.applicationautoscaling.model.CustomizedMetricSpecification)1 DeleteScalingPolicyRequest (com.amazonaws.services.applicationautoscaling.model.DeleteScalingPolicyRequest)1 DeleteScalingPolicyResult (com.amazonaws.services.applicationautoscaling.model.DeleteScalingPolicyResult)1 DeregisterScalableTargetRequest (com.amazonaws.services.applicationautoscaling.model.DeregisterScalableTargetRequest)1 DeregisterScalableTargetResult (com.amazonaws.services.applicationautoscaling.model.DeregisterScalableTargetResult)1 DescribeScalableTargetsRequest (com.amazonaws.services.applicationautoscaling.model.DescribeScalableTargetsRequest)1 DescribeScalableTargetsResult (com.amazonaws.services.applicationautoscaling.model.DescribeScalableTargetsResult)1 MetricDimension (com.amazonaws.services.applicationautoscaling.model.MetricDimension)1 ObjectNotFoundException (com.amazonaws.services.applicationautoscaling.model.ObjectNotFoundException)1 PutScalingPolicyRequest (com.amazonaws.services.applicationautoscaling.model.PutScalingPolicyRequest)1 PutScalingPolicyResult (com.amazonaws.services.applicationautoscaling.model.PutScalingPolicyResult)1 RegisterScalableTargetRequest (com.amazonaws.services.applicationautoscaling.model.RegisterScalableTargetRequest)1 RegisterScalableTargetResult (com.amazonaws.services.applicationautoscaling.model.RegisterScalableTargetResult)1 ScalableTarget (com.amazonaws.services.applicationautoscaling.model.ScalableTarget)1 StepAdjustment (com.amazonaws.services.applicationautoscaling.model.StepAdjustment)1