You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/03/11 10:31:20 UTC
[camel] branch master updated: CAMEL-14690 - Camel-AWS2: Better
logging when checking client instance in the registry, CloudWatch
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new 7485e8a CAMEL-14690 - Camel-AWS2: Better logging when checking client instance in the registry, CloudWatch
7485e8a is described below
commit 7485e8a7012349fc72c11bf41ef7bd3c07d5ecf4
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Mar 11 11:24:35 2020 +0100
CAMEL-14690 - Camel-AWS2: Better logging when checking client instance in the registry, CloudWatch
---
.../camel/component/aws2/cw/Cw2Component.java | 23 +++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/components/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Component.java b/components/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Component.java
index 42d58f4..35f7e17 100644
--- a/components/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Component.java
+++ b/components/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Component.java
@@ -24,6 +24,9 @@ import org.apache.camel.Endpoint;
import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.annotations.Component;
import org.apache.camel.support.DefaultComponent;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import software.amazon.awssdk.services.cloudwatch.CloudWatchClient;
/**
@@ -32,6 +35,8 @@ import software.amazon.awssdk.services.cloudwatch.CloudWatchClient;
@Component("aws2-cw")
public class Cw2Component extends DefaultComponent {
+ private static final Logger LOG = LoggerFactory.getLogger(Cw2Component.class);
+
@Metadata
private Cw2Configuration configuration = new Cw2Configuration();
@@ -58,7 +63,7 @@ public class Cw2Component extends DefaultComponent {
// parameters
setProperties(endpoint, parameters);
- checkAndSetRegistryClient(configuration);
+ checkAndSetRegistryClient(configuration, endpoint);
if (configuration.getAmazonCwClient() == null && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
throw new IllegalArgumentException("AmazonCwClient or accessKey and secretKey must be specified");
}
@@ -77,10 +82,18 @@ public class Cw2Component extends DefaultComponent {
this.configuration = configuration;
}
- private void checkAndSetRegistryClient(Cw2Configuration configuration) {
- Set<CloudWatchClient> clients = getCamelContext().getRegistry().findByType(CloudWatchClient.class);
- if (clients.size() == 1) {
- configuration.setAmazonCwClient(clients.stream().findFirst().get());
+ private void checkAndSetRegistryClient(Cw2Configuration configuration, Cw2Endpoint endpoint) {
+ if (ObjectHelper.isEmpty(endpoint.getConfiguration().getAmazonCwClient())) {
+ LOG.debug("Looking for an CloudWatchClient instance in the registry");
+ Set<CloudWatchClient> clients = getCamelContext().getRegistry().findByType(CloudWatchClient.class);
+ if (clients.size() == 1) {
+ LOG.debug("Found exactly one CloudWatchClient instance in the registry");
+ configuration.setAmazonCwClient(clients.stream().findFirst().get());
+ } else {
+ LOG.debug("No CloudWatchClient instance in the registry");
+ }
+ } else {
+ LOG.debug("CloudWatchClient instance is already set at endpoint level: skipping the check in the registry");
}
}
}