use of com.amazonaws.services.cloudwatch.model.DescribeAlarmsResult in project Synapse-Stack-Builder by Sage-Bionetworks.
the class ElbAlarmSetup method describeAlarms.
public DescribeAlarmsResult describeAlarms(EnvironmentDescription ed) throws InterruptedException {
String topicArn = resources.getStackInstanceNotificationTopicArn();
LoadBalancer loadBalancer = getLoadBalancerFromEnvironmentName(ed.getEnvironmentName());
DescribeAlarmsRequest req = createDescribeAlarmsRequest(ed.getEnvironmentName(), loadBalancer.getName(), topicArn);
DescribeAlarmsResult res = this.cloudWatchClient.describeAlarms(req);
return res;
}
use of com.amazonaws.services.cloudwatch.model.DescribeAlarmsResult in project Synapse-Stack-Builder by Sage-Bionetworks.
the class RdsAlarmSetup method setupAllAlarms.
/**
* Setup all alarms.
*/
public void setupAllAlarms() {
List<PutMetricAlarmRequest> l;
DescribeAlarmsResult r;
// This is the topic where all alarm notification are sent
String topicArn = resources.getStackInstanceNotificationTopicArn();
// setup the alarms for the id generator
DBInstance instance = resources.getIdGeneratorDatabase();
l = createAllAlarmsForDatabase(instance, topicArn);
r = describeAllAlarmsForDatabase(instance);
resources.setIdGeneratorDatabaseAlarms(r);
// setup the alarms for the stack instances database.
instance = resources.getStackInstancesDatabase();
l = createAllAlarmsForDatabase(instance, topicArn);
r = describeAllAlarmsForDatabase(instance);
resources.setStackInstancesDatabaseAlarms(r);
// setup the alarms for the stack table databases.
List<DescribeAlarmsResult> lr = new ArrayList<DescribeAlarmsResult>();
List<DBInstance> tblInstances = resources.getStackInstanceTablesDatabases();
for (DBInstance i : tblInstances) {
l = createAllAlarmsForDatabase(i, topicArn);
r = describeAllAlarmsForDatabase(i);
lr.add(r);
}
resources.setStackInstanceTablesDatabaseAlarms(lr);
}
use of com.amazonaws.services.cloudwatch.model.DescribeAlarmsResult in project Synapse-Stack-Builder by Sage-Bionetworks.
the class RdsAlarmSetup method describeAllAlarmsForDatabase.
public DescribeAlarmsResult describeAllAlarmsForDatabase(DBInstance instance) {
if (instance == null)
throw new IllegalArgumentException("DBInstance cannpt be null");
List<String> alarmsToDescribe = this.getAlarms(instance);
DescribeAlarmsRequest req = new DescribeAlarmsRequest().withAlarmNames(alarmsToDescribe);
DescribeAlarmsResult res = client.describeAlarms(req);
return res;
}
use of com.amazonaws.services.cloudwatch.model.DescribeAlarmsResult in project photon-model by vmware.
the class AWSClientManager method getOrCreateCloudWatchClient.
/**
* Get or create a CloudWatch Client instance that will be used to get stats from AWS.
*
* Note: ARN-based credentials will not be accepted unless they have already been exchanged to
* AWS for session credentials. If unset, this method will throw a
* {@link UnsupportedOperationException} exception in this circumstance. To enable ARN-based
* credentials, migrate to {@link #getOrCreateCloudWatchClientAsync(AuthCredentialsServiceState,
* String, StatelessService, boolean)}.
*
* @param credentials The auth credentials to be used for the client creation
* @param regionId The region of the AWS client
* @param service The stateless service for which the operation is being performed.
* @param isMock Indicates if this a mock request
* @return
*/
public AmazonCloudWatchAsyncClient getOrCreateCloudWatchClient(AuthCredentialsServiceState credentials, String regionId, StatelessService service, boolean isMock, Consumer<Throwable> failConsumer) {
if (this.awsClientType != AwsClientType.CLOUD_WATCH) {
throw new UnsupportedOperationException("This client manager supports only AWS " + this.awsClientType + " clients.");
}
if (isArnCredentials(credentials) && !isSetCredentials(credentials)) {
throw new UnsupportedOperationException("For ARN-based credentials, exchange for session-based access key/secret key first before retrieving the client.");
}
String cacheKey = createCredentialRegionCacheKey(credentials, regionId);
if (isCloudWatchClientInvalid(cacheKey)) {
failConsumer.accept(new IllegalStateException("Invalid cloud watch client for key: " + cacheKey));
return null;
}
AmazonCloudWatchAsyncClient amazonCloudWatchClient = null;
try {
amazonCloudWatchClient = this.cloudWatchClientCache.computeIfAbsent(cacheKey, key -> {
AmazonCloudWatchAsyncClient client = AWSUtils.getStatsAsyncClient(credentials, regionId, getExecutor(), isMock);
client.describeAlarmsAsync(new AsyncHandler<DescribeAlarmsRequest, DescribeAlarmsResult>() {
@Override
public void onError(Exception exception) {
markCloudWatchClientInvalid(service, cacheKey);
}
@Override
public void onSuccess(DescribeAlarmsRequest request, DescribeAlarmsResult result) {
// noop
}
});
return client;
});
} catch (Throwable e) {
service.logSevere(e);
failConsumer.accept(e);
}
return amazonCloudWatchClient;
}
use of com.amazonaws.services.cloudwatch.model.DescribeAlarmsResult in project aws-doc-sdk-examples by awsdocs.
the class DescribeAlarms method main.
public static void main(String[] args) {
final AmazonCloudWatch cw = AmazonCloudWatchClientBuilder.defaultClient();
boolean done = false;
DescribeAlarmsRequest request = new DescribeAlarmsRequest();
while (!done) {
DescribeAlarmsResult response = cw.describeAlarms(request);
for (MetricAlarm alarm : response.getMetricAlarms()) {
System.out.printf("Retrieved alarm %s", alarm.getAlarmName());
}
request.setNextToken(response.getNextToken());
if (response.getNextToken() == null) {
done = true;
}
}
}
Aggregations