use of com.amazonaws.services.applicationautoscaling.model.ScalableTarget 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));
}
Aggregations