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();
}
Aggregations