use of com.amazonaws.services.cloudwatch.AmazonCloudWatchClient in project camel by apache.
the class CwEndpoint method createCloudWatchClient.
AmazonCloudWatch createCloudWatchClient() {
AmazonCloudWatch client = null;
ClientConfiguration clientConfiguration = null;
boolean isClientConfigFound = false;
if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
clientConfiguration = new ClientConfiguration();
clientConfiguration.setProxyHost(configuration.getProxyHost());
clientConfiguration.setProxyPort(configuration.getProxyPort());
isClientConfigFound = true;
}
if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) {
AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
if (isClientConfigFound) {
client = new AmazonCloudWatchClient(credentials, clientConfiguration);
} else {
client = new AmazonCloudWatchClient(credentials);
}
} else {
if (isClientConfigFound) {
client = new AmazonCloudWatchClient();
} else {
client = new AmazonCloudWatchClient(clientConfiguration);
}
}
return client;
}
use of com.amazonaws.services.cloudwatch.AmazonCloudWatchClient in project jmxtrans by jmxtrans.
the class CloudWatchWriter method createCloudWatchClient.
/**
* Configuring the CloudWatch client.
*
* Credentials are loaded from the Amazon EC2 Instance Metadata Service
*/
private AmazonCloudWatchClient createCloudWatchClient() {
AmazonCloudWatchClient cloudWatchClient = new AmazonCloudWatchClient(new InstanceProfileCredentialsProvider());
cloudWatchClient.setRegion(checkNotNull(Regions.getCurrentRegion(), "Problems getting AWS metadata"));
return cloudWatchClient;
}
use of com.amazonaws.services.cloudwatch.AmazonCloudWatchClient in project chassis by Kixeye.
the class DefaultCloudWatchFactory method getCloudWatchClient.
@Override
public AmazonCloudWatchClient getCloudWatchClient() {
AmazonCloudWatchClient client;
if (StringUtils.isBlank(accessKeyId) || StringUtils.isBlank(secretKey)) {
LOGGER.debug("Constructing AmazonCloudWatchClient using DefaultAWSCredentialsProviderChain for region {}.", region);
client = new AmazonCloudWatchClient(new DefaultAWSCredentialsProviderChain());
} else {
LOGGER.debug("Constructing AmazonCloudWatchClient from given credentials for region {}.", region);
client = new AmazonCloudWatchClient(new BasicAWSCredentials(accessKeyId, secretKey));
}
client.setRegion(region);
return client;
}
Aggregations