Search in sources :

Example 1 with RegisterScalableTargetResult

use of com.amazonaws.services.applicationautoscaling.model.RegisterScalableTargetResult in project titus-control-plane by Netflix.

the class AWSAppAutoScalingClient method createScalableTarget.

@Override
public Completable createScalableTarget(String jobId, int minCapacity, int maxCapacity) {
    RegisterScalableTargetRequest registerScalableTargetRequest = new RegisterScalableTargetRequest();
    registerScalableTargetRequest.setMinCapacity(minCapacity);
    registerScalableTargetRequest.setMaxCapacity(maxCapacity);
    registerScalableTargetRequest.setResourceId(AWSAppAutoScalingUtil.buildGatewayResourceId(jobId, awsAppScalingConfig.getAWSGatewayEndpointPrefix(), awsAppScalingConfig.getRegion(), awsAppScalingConfig.getAWSGatewayEndpointTargetStage()));
    registerScalableTargetRequest.setServiceNamespace(SERVICE_NAMESPACE);
    registerScalableTargetRequest.setScalableDimension(SCALABLE_DIMENSION);
    logger.info("RegisterScalableTargetRequest {}", registerScalableTargetRequest);
    return RetryWrapper.wrapWithExponentialRetry(String.format("createScalableTarget for job %s", jobId), Observable.create(emitter -> awsAppAutoScalingClientAsync.registerScalableTargetAsync(registerScalableTargetRequest, new AsyncHandler<RegisterScalableTargetRequest, RegisterScalableTargetResult>() {

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

        @Override
        public void onSuccess(RegisterScalableTargetRequest request, RegisterScalableTargetResult registerScalableTargetResult) {
            int httpStatusCode = registerScalableTargetResult.getSdkHttpMetadata().getHttpStatusCode();
            logger.info("Registered scalable target for success {} - status {}", jobId, httpStatusCode);
            awsAppAutoScalingMetrics.registerAwsCreateTargetSuccess();
            emitter.onCompleted();
        }
    }), Emitter.BackpressureMode.NONE)).toCompletable();
}
Also used : RegisterScalableTargetRequest(com.amazonaws.services.applicationautoscaling.model.RegisterScalableTargetRequest) AsyncHandler(com.amazonaws.handlers.AsyncHandler) RegisterScalableTargetResult(com.amazonaws.services.applicationautoscaling.model.RegisterScalableTargetResult) AutoScalePolicyException(com.netflix.titus.api.appscale.service.AutoScalePolicyException) ValidationException(com.amazonaws.services.applicationautoscaling.model.ValidationException) ObjectNotFoundException(com.amazonaws.services.applicationautoscaling.model.ObjectNotFoundException)

Aggregations

AsyncHandler (com.amazonaws.handlers.AsyncHandler)1 ObjectNotFoundException (com.amazonaws.services.applicationautoscaling.model.ObjectNotFoundException)1 RegisterScalableTargetRequest (com.amazonaws.services.applicationautoscaling.model.RegisterScalableTargetRequest)1 RegisterScalableTargetResult (com.amazonaws.services.applicationautoscaling.model.RegisterScalableTargetResult)1 ValidationException (com.amazonaws.services.applicationautoscaling.model.ValidationException)1 AutoScalePolicyException (com.netflix.titus.api.appscale.service.AutoScalePolicyException)1