Search in sources :

Example 1 with ResourceNotFoundException

use of com.amazonaws.services.cloudwatch.model.ResourceNotFoundException in project aws-sdk-android by aws-amplify.

the class ResourceNotFoundExceptionUnmarshaller method unmarshall.

public AmazonServiceException unmarshall(Node node) throws Exception {
    // Bail out if this isn't the right error code that this
    // marshaller understands.
    String errorCode = parseErrorCode(node);
    if (errorCode == null || !errorCode.equals("ResourceNotFound"))
        return null;
    ResourceNotFoundException e = (ResourceNotFoundException) super.unmarshall(node);
    return e;
}
Also used : ResourceNotFoundException(com.amazonaws.services.cloudwatch.model.ResourceNotFoundException)

Example 2 with ResourceNotFoundException

use of com.amazonaws.services.cloudwatch.model.ResourceNotFoundException in project titus-control-plane by Netflix.

the class CloudWatchClient method deleteAlarm.

@Override
public Completable deleteAlarm(String policyRefId, String jobId) {
    DeleteAlarmsRequest deleteAlarmsRequest = new DeleteAlarmsRequest();
    deleteAlarmsRequest.setAlarmNames(Arrays.asList(buildCloudWatchName(policyRefId, jobId)));
    return wrapWithExponentialRetry(String.format("deleteAlarm in policy %s for job %s", policyRefId, jobId), Observable.create(emitter -> awsCloudWatch.deleteAlarmsAsync(deleteAlarmsRequest, new AsyncHandler<DeleteAlarmsRequest, DeleteAlarmsResult>() {

        @Override
        public void onError(Exception exception) {
            deleteErrorCounter.increment();
            if (exception instanceof ResourceNotFoundException) {
                emitter.onError(AutoScalePolicyException.unknownScalingPolicy(policyRefId, exception.getMessage()));
            } else {
                emitter.onError(AutoScalePolicyException.errorDeletingAlarm(policyRefId, exception.getMessage()));
            }
        }

        @Override
        public void onSuccess(DeleteAlarmsRequest request, DeleteAlarmsResult deleteAlarmsResult) {
            int httpStatusCode = deleteAlarmsResult.getSdkHttpMetadata().getHttpStatusCode();
            log.info("Deleted cloud watch alarm for job-id {}, status {}", jobId, httpStatusCode);
            deleteAlarmCounter.increment();
            emitter.onCompleted();
        }
    }), Emitter.BackpressureMode.NONE)).toCompletable();
}
Also used : AsyncHandler(com.amazonaws.handlers.AsyncHandler) DeleteAlarmsRequest(com.amazonaws.services.cloudwatch.model.DeleteAlarmsRequest) DeleteAlarmsResult(com.amazonaws.services.cloudwatch.model.DeleteAlarmsResult) ResourceNotFoundException(com.amazonaws.services.cloudwatch.model.ResourceNotFoundException) AutoScalePolicyException(com.netflix.titus.api.appscale.service.AutoScalePolicyException) ResourceNotFoundException(com.amazonaws.services.cloudwatch.model.ResourceNotFoundException)

Aggregations

ResourceNotFoundException (com.amazonaws.services.cloudwatch.model.ResourceNotFoundException)2 AsyncHandler (com.amazonaws.handlers.AsyncHandler)1 DeleteAlarmsRequest (com.amazonaws.services.cloudwatch.model.DeleteAlarmsRequest)1 DeleteAlarmsResult (com.amazonaws.services.cloudwatch.model.DeleteAlarmsResult)1 AutoScalePolicyException (com.netflix.titus.api.appscale.service.AutoScalePolicyException)1