com.amazonaws.services.cloudwatch.model.DeleteAlarmsResult Java Examples

The following examples show how to use com.amazonaws.services.cloudwatch.model.DeleteAlarmsResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DeleteAlarm.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {

        final String USAGE =
            "To run this example, supply an alarm name\n" +
            "Ex: DeleteAlarm <alarm-name>\n";

        if (args.length != 1) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String alarm_name = args[0];

        final AmazonCloudWatch cw =
            AmazonCloudWatchClientBuilder.defaultClient();

        DeleteAlarmsRequest request = new DeleteAlarmsRequest()
            .withAlarmNames(alarm_name);

        DeleteAlarmsResult response = cw.deleteAlarms(request);

        System.out.printf("Successfully deleted alarm %s", alarm_name);
    }
 
Example #2
Source File: CloudWatchClient.java    From titus-control-plane with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #3
Source File: NoopCloudWatch.java    From dynamodb-cross-region-library with Apache License 2.0 4 votes vote down vote up
@Override
public DeleteAlarmsResult deleteAlarms(DeleteAlarmsRequest deleteAlarmsRequest) {
    return null;
}