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 2021/12/20 17:37:27 UTC

[camel] 01/03: CAMEL-15951 - Introduce configuration property to skip DescribeTable operation on start of aws2-ddb component

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 0e8d2664e2691f5f13fd0594062f7dbb4eb3d5ba
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Dec 20 18:05:56 2021 +0100

    CAMEL-15951 - Introduce configuration property to skip DescribeTable operation on start of aws2-ddb component
---
 .../component/aws2/ddb/Ddb2Configuration.java      | 13 ++++++++
 .../camel/component/aws2/ddb/Ddb2Endpoint.java     | 36 ++++++++++++----------
 2 files changed, 32 insertions(+), 17 deletions(-)

diff --git a/components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Configuration.java b/components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Configuration.java
index de82380..3d81fcf 100644
--- a/components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Configuration.java
+++ b/components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Configuration.java
@@ -67,6 +67,8 @@ public class Ddb2Configuration implements Cloneable {
     private String uriEndpointOverride;
     @UriParam(defaultValue = "false")
     private boolean useDefaultCredentialsProvider;
+    @UriParam(defaultValue = "true")
+    private boolean enabledInitialDescribeTable;
 
     public String getAccessKey() {
         return accessKey;
@@ -280,6 +282,17 @@ public class Ddb2Configuration implements Cloneable {
         return useDefaultCredentialsProvider;
     }
 
+    public boolean isEnabledInitialDescribeTable() {
+        return enabledInitialDescribeTable;
+    }
+
+    /**
+     * Set whether the initial Describe table operation in the DDB Endpoint must be done, or not.
+     */
+    public void setEnabledInitialDescribeTable(boolean enabledInitialDescribeTable) {
+        this.enabledInitialDescribeTable = enabledInitialDescribeTable;
+    }
+
     // *************************************************
     //
     // *************************************************
diff --git a/components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Endpoint.java b/components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Endpoint.java
index 9f74084..caec89d 100644
--- a/components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Endpoint.java
+++ b/components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Endpoint.java
@@ -85,24 +85,26 @@ public class Ddb2Endpoint extends ScheduledPollEndpoint {
         String tableName = getConfiguration().getTableName();
         LOG.trace("Querying whether table [{}] already exists...", tableName);
 
-        try {
-            DescribeTableRequest.Builder request = DescribeTableRequest.builder().tableName(tableName);
-            TableDescription tableDescription = ddbClient.describeTable(request.build()).table();
-            if (!isTableActive(tableDescription)) {
-                waitForTableToBecomeAvailable(tableName);
-            }
-
-            LOG.trace("Table [{}] already exists", tableName);
-            return;
-        } catch (ResourceNotFoundException e) {
-            LOG.trace("Table [{}] doesn't exist yet", tableName);
-            LOG.trace("Creating table [{}]...", tableName);
-            TableDescription tableDescription = createTable(tableName);
-            if (!isTableActive(tableDescription)) {
-                waitForTableToBecomeAvailable(tableName);
+        if (configuration.isEnabledInitialDescribeTable()) {
+            try {
+                DescribeTableRequest.Builder request = DescribeTableRequest.builder().tableName(tableName);
+                TableDescription tableDescription = ddbClient.describeTable(request.build()).table();
+                if (!isTableActive(tableDescription)) {
+                    waitForTableToBecomeAvailable(tableName);
+                }
+
+                LOG.trace("Table [{}] already exists", tableName);
+                return;
+            } catch (ResourceNotFoundException e) {
+                LOG.trace("Table [{}] doesn't exist yet", tableName);
+                LOG.trace("Creating table [{}]...", tableName);
+                TableDescription tableDescription = createTable(tableName);
+                if (!isTableActive(tableDescription)) {
+                    waitForTableToBecomeAvailable(tableName);
+                }
+
+                LOG.trace("Table [{}] created", tableName);
             }
-
-            LOG.trace("Table [{}] created", tableName);
         }
     }