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/09/13 09:31:46 UTC

[camel] branch camel-3.11.x updated (47035ea -> 0266f17)

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

acosentino pushed a change to branch camel-3.11.x
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from 47035ea  CAMEL-16936 - camel-aws2-s3: Not setting CONTENT-MD5 header which breaks putObject with object locks
     new a78dfd1  CAMEL-16892 - Camel-InfluxDB: Don't check database existence each time we perform a producer operation
     new 24d7d4f  CAMEL-16892 - Camel-InfluxDB: Don't check database existence each time we perform a producer operation
     new 0266f17  CAMEL-16892 - Camel-InfluxDB: Don't check database existence each time we perform a producer operation

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/camel/catalog/components/influxdb.json  |  2 +
 .../influxdb/InfluxDbEndpointConfigurer.java       | 12 ++++
 .../influxdb/InfluxDbEndpointUriFactory.java       |  4 +-
 .../apache/camel/component/influxdb/influxdb.json  |  2 +
 .../src/main/docs/influxdb-component.adoc          |  4 +-
 .../camel/component/influxdb/InfluxDbEndpoint.java | 62 ++++++++++++++++++++
 .../camel/component/influxdb/InfluxDbProducer.java | 21 -------
 .../influxdb/InfluxDbEnsureDatabaseExistsTest.java |  4 +-
 .../dsl/InfluxDbEndpointBuilderFactory.java        | 68 ++++++++++++++++++++++
 .../modules/ROOT/pages/influxdb-component.adoc     |  4 +-
 10 files changed, 157 insertions(+), 26 deletions(-)

[camel] 02/03: CAMEL-16892 - Camel-InfluxDB: Don't check database existence each time we perform a producer operation

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 24d7d4fb052d0f4d1609eee9c3c0582f4f18982b
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Sep 13 11:21:12 2021 +0200

    CAMEL-16892 - Camel-InfluxDB: Don't check database existence each time we perform a producer operation
---
 .../influxdb/InfluxDbEndpointConfigurer.java       | 12 ++++
 .../influxdb/InfluxDbEndpointUriFactory.java       |  4 +-
 .../apache/camel/component/influxdb/influxdb.json  |  2 +
 .../src/main/docs/influxdb-component.adoc          |  4 +-
 .../camel/component/influxdb/InfluxDbEndpoint.java |  4 +-
 .../influxdb/InfluxDbEnsureDatabaseExistsTest.java |  4 +-
 .../dsl/InfluxDbEndpointBuilderFactory.java        | 68 ++++++++++++++++++++++
 .../modules/ROOT/pages/influxdb-component.adoc     |  4 +-
 8 files changed, 95 insertions(+), 7 deletions(-)

diff --git a/components/camel-influxdb/src/generated/java/org/apache/camel/component/influxdb/InfluxDbEndpointConfigurer.java b/components/camel-influxdb/src/generated/java/org/apache/camel/component/influxdb/InfluxDbEndpointConfigurer.java
index 5fba76c..4a1696d 100644
--- a/components/camel-influxdb/src/generated/java/org/apache/camel/component/influxdb/InfluxDbEndpointConfigurer.java
+++ b/components/camel-influxdb/src/generated/java/org/apache/camel/component/influxdb/InfluxDbEndpointConfigurer.java
@@ -21,7 +21,11 @@ public class InfluxDbEndpointConfigurer extends PropertyConfigurerSupport implem
     public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) {
         InfluxDbEndpoint target = (InfluxDbEndpoint) obj;
         switch (ignoreCase ? name.toLowerCase() : name) {
+        case "autocreatedatabase":
+        case "autoCreateDatabase": target.setAutoCreateDatabase(property(camelContext, boolean.class, value)); return true;
         case "batch": target.setBatch(property(camelContext, boolean.class, value)); return true;
+        case "checkdatabaseexistence":
+        case "checkDatabaseExistence": target.setCheckDatabaseExistence(property(camelContext, boolean.class, value)); return true;
         case "databasename":
         case "databaseName": target.setDatabaseName(property(camelContext, java.lang.String.class, value)); return true;
         case "lazystartproducer":
@@ -37,7 +41,11 @@ public class InfluxDbEndpointConfigurer extends PropertyConfigurerSupport implem
     @Override
     public Class<?> getOptionType(String name, boolean ignoreCase) {
         switch (ignoreCase ? name.toLowerCase() : name) {
+        case "autocreatedatabase":
+        case "autoCreateDatabase": return boolean.class;
         case "batch": return boolean.class;
+        case "checkdatabaseexistence":
+        case "checkDatabaseExistence": return boolean.class;
         case "databasename":
         case "databaseName": return java.lang.String.class;
         case "lazystartproducer":
@@ -54,7 +62,11 @@ public class InfluxDbEndpointConfigurer extends PropertyConfigurerSupport implem
     public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
         InfluxDbEndpoint target = (InfluxDbEndpoint) obj;
         switch (ignoreCase ? name.toLowerCase() : name) {
+        case "autocreatedatabase":
+        case "autoCreateDatabase": return target.isAutoCreateDatabase();
         case "batch": return target.isBatch();
+        case "checkdatabaseexistence":
+        case "checkDatabaseExistence": return target.isCheckDatabaseExistence();
         case "databasename":
         case "databaseName": return target.getDatabaseName();
         case "lazystartproducer":
diff --git a/components/camel-influxdb/src/generated/java/org/apache/camel/component/influxdb/InfluxDbEndpointUriFactory.java b/components/camel-influxdb/src/generated/java/org/apache/camel/component/influxdb/InfluxDbEndpointUriFactory.java
index f2a59cd..5b22070 100644
--- a/components/camel-influxdb/src/generated/java/org/apache/camel/component/influxdb/InfluxDbEndpointUriFactory.java
+++ b/components/camel-influxdb/src/generated/java/org/apache/camel/component/influxdb/InfluxDbEndpointUriFactory.java
@@ -20,12 +20,14 @@ public class InfluxDbEndpointUriFactory extends org.apache.camel.support.compone
     private static final Set<String> PROPERTY_NAMES;
     private static final Set<String> SECRET_PROPERTY_NAMES;
     static {
-        Set<String> props = new HashSet<>(7);
+        Set<String> props = new HashSet<>(9);
         props.add("lazyStartProducer");
         props.add("connectionBean");
         props.add("databaseName");
+        props.add("autoCreateDatabase");
         props.add("query");
         props.add("batch");
+        props.add("checkDatabaseExistence");
         props.add("retentionPolicy");
         props.add("operation");
         PROPERTY_NAMES = Collections.unmodifiableSet(props);
diff --git a/components/camel-influxdb/src/generated/resources/org/apache/camel/component/influxdb/influxdb.json b/components/camel-influxdb/src/generated/resources/org/apache/camel/component/influxdb/influxdb.json
index 5102f64..951d455 100644
--- a/components/camel-influxdb/src/generated/resources/org/apache/camel/component/influxdb/influxdb.json
+++ b/components/camel-influxdb/src/generated/resources/org/apache/camel/component/influxdb/influxdb.json
@@ -28,7 +28,9 @@
   },
   "properties": {
     "connectionBean": { "kind": "path", "displayName": "Connection Bean", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Connection to the influx database, of class InfluxDB.class" },
+    "autoCreateDatabase": { "kind": "parameter", "displayName": "Auto Create Database", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Define if we want to auto create the database if it's not present" },
     "batch": { "kind": "parameter", "displayName": "Batch", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Define if this operation is a batch operation or not" },
+    "checkDatabaseExistence": { "kind": "parameter", "displayName": "Check Database Existence", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Define if we want to check the database existence while starting the endpoint" },
     "databaseName": { "kind": "parameter", "displayName": "Database Name", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The name of the database where the time series will be stored" },
     "lazyStartProducer": { "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during sta [...]
     "operation": { "kind": "parameter", "displayName": "Operation", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "insert", "description": "Define if this operation is an insert or a query" },
diff --git a/components/camel-influxdb/src/main/docs/influxdb-component.adoc b/components/camel-influxdb/src/main/docs/influxdb-component.adoc
index d76fd5e..fc624f2 100644
--- a/components/camel-influxdb/src/main/docs/influxdb-component.adoc
+++ b/components/camel-influxdb/src/main/docs/influxdb-component.adoc
@@ -86,13 +86,15 @@ with the following path and query parameters:
 |===
 
 
-=== Query Parameters (6 parameters):
+=== Query Parameters (8 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
+| *autoCreateDatabase* (producer) | Define if we want to auto create the database if it's not present | false | boolean
 | *batch* (producer) | Define if this operation is a batch operation or not | false | boolean
+| *checkDatabaseExistence* (producer) | Define if we want to check the database existence while starting the endpoint | false | boolean
 | *databaseName* (producer) | The name of the database where the time series will be stored |  | String
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
 | *operation* (producer) | Define if this operation is an insert or a query | insert | String
diff --git a/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbEndpoint.java b/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbEndpoint.java
index 7396e28..f2f19a7 100644
--- a/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbEndpoint.java
+++ b/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbEndpoint.java
@@ -59,8 +59,8 @@ public class InfluxDbEndpoint extends DefaultEndpoint {
     private String query;
     @UriParam(defaultValue = "false")
     private boolean checkDatabaseExistence;
-    @UriParam(defaultValue = "true")
-    private boolean autoCreateDatabase = true;
+    @UriParam(defaultValue = "false")
+    private boolean autoCreateDatabase;
 
     public InfluxDbEndpoint(String uri, InfluxDbComponent component) {
         super(uri, component);
diff --git a/components/camel-influxdb/src/test/java/org/apache/camel/component/influxdb/InfluxDbEnsureDatabaseExistsTest.java b/components/camel-influxdb/src/test/java/org/apache/camel/component/influxdb/InfluxDbEnsureDatabaseExistsTest.java
index c96e89e..e528aaf 100644
--- a/components/camel-influxdb/src/test/java/org/apache/camel/component/influxdb/InfluxDbEnsureDatabaseExistsTest.java
+++ b/components/camel-influxdb/src/test/java/org/apache/camel/component/influxdb/InfluxDbEnsureDatabaseExistsTest.java
@@ -48,7 +48,7 @@ public class InfluxDbEnsureDatabaseExistsTest extends AbstractInfluxDbTest {
 
                 //test route
                 from("direct:test")
-                        .to("influxdb:influxDbBean?databaseName=dbName")
+                        .to("influxdb:influxDbBean?databaseName=dbName&checkDatabaseExistence=true&autoCreateDatabase=true")
                         .to("mock:test");
             }
         };
@@ -79,7 +79,7 @@ public class InfluxDbEnsureDatabaseExistsTest extends AbstractInfluxDbTest {
         sendBody("direct:test", createPoint());
 
         //if db exist, there will be only 1 call to show databases.
-        Mockito.verify(mockedDbConnection, Mockito.times(1)).query(Mockito.any(Query.class));
+        Mockito.verify(mockedDbConnection, Mockito.times(2)).query(Mockito.any(Query.class));
 
         errorEndpoint.assertIsSatisfied();
         successEndpoint.assertIsSatisfied();
diff --git a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/InfluxDbEndpointBuilderFactory.java b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/InfluxDbEndpointBuilderFactory.java
index f763b292..6ff67f2 100644
--- a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/InfluxDbEndpointBuilderFactory.java
+++ b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/InfluxDbEndpointBuilderFactory.java
@@ -35,6 +35,39 @@ public interface InfluxDbEndpointBuilderFactory {
      */
     public interface InfluxDbEndpointBuilder extends EndpointProducerBuilder {
         /**
+         * Define if we want to auto create the database if it's not present.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: false
+         * Group: producer
+         * 
+         * @param autoCreateDatabase the value to set
+         * @return the dsl builder
+         */
+        default InfluxDbEndpointBuilder autoCreateDatabase(
+                boolean autoCreateDatabase) {
+            doSetProperty("autoCreateDatabase", autoCreateDatabase);
+            return this;
+        }
+        /**
+         * Define if we want to auto create the database if it's not present.
+         * 
+         * The option will be converted to a &lt;code&gt;boolean&lt;/code&gt;
+         * type.
+         * 
+         * Default: false
+         * Group: producer
+         * 
+         * @param autoCreateDatabase the value to set
+         * @return the dsl builder
+         */
+        default InfluxDbEndpointBuilder autoCreateDatabase(
+                String autoCreateDatabase) {
+            doSetProperty("autoCreateDatabase", autoCreateDatabase);
+            return this;
+        }
+        /**
          * Define if this operation is a batch operation or not.
          * 
          * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
@@ -66,6 +99,41 @@ public interface InfluxDbEndpointBuilderFactory {
             return this;
         }
         /**
+         * Define if we want to check the database existence while starting the
+         * endpoint.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: false
+         * Group: producer
+         * 
+         * @param checkDatabaseExistence the value to set
+         * @return the dsl builder
+         */
+        default InfluxDbEndpointBuilder checkDatabaseExistence(
+                boolean checkDatabaseExistence) {
+            doSetProperty("checkDatabaseExistence", checkDatabaseExistence);
+            return this;
+        }
+        /**
+         * Define if we want to check the database existence while starting the
+         * endpoint.
+         * 
+         * The option will be converted to a &lt;code&gt;boolean&lt;/code&gt;
+         * type.
+         * 
+         * Default: false
+         * Group: producer
+         * 
+         * @param checkDatabaseExistence the value to set
+         * @return the dsl builder
+         */
+        default InfluxDbEndpointBuilder checkDatabaseExistence(
+                String checkDatabaseExistence) {
+            doSetProperty("checkDatabaseExistence", checkDatabaseExistence);
+            return this;
+        }
+        /**
          * The name of the database where the time series will be stored.
          * 
          * The option is a: &lt;code&gt;java.lang.String&lt;/code&gt; type.
diff --git a/docs/components/modules/ROOT/pages/influxdb-component.adoc b/docs/components/modules/ROOT/pages/influxdb-component.adoc
index e07e334..6de36a3 100644
--- a/docs/components/modules/ROOT/pages/influxdb-component.adoc
+++ b/docs/components/modules/ROOT/pages/influxdb-component.adoc
@@ -88,13 +88,15 @@ with the following path and query parameters:
 |===
 
 
-=== Query Parameters (6 parameters):
+=== Query Parameters (8 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
+| *autoCreateDatabase* (producer) | Define if we want to auto create the database if it's not present | false | boolean
 | *batch* (producer) | Define if this operation is a batch operation or not | false | boolean
+| *checkDatabaseExistence* (producer) | Define if we want to check the database existence while starting the endpoint | false | boolean
 | *databaseName* (producer) | The name of the database where the time series will be stored |  | String
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
 | *operation* (producer) | Define if this operation is an insert or a query | insert | String

[camel] 01/03: CAMEL-16892 - Camel-InfluxDB: Don't check database existence each time we perform a producer operation

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit a78dfd19c49a29006a16c886ef97b6362cde8ab6
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Sep 13 11:18:07 2021 +0200

    CAMEL-16892 - Camel-InfluxDB: Don't check database existence each time we perform a producer operation
---
 .../camel/component/influxdb/InfluxDbEndpoint.java | 62 ++++++++++++++++++++++
 .../camel/component/influxdb/InfluxDbProducer.java | 21 --------
 2 files changed, 62 insertions(+), 21 deletions(-)

diff --git a/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbEndpoint.java b/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbEndpoint.java
index f51d1e7..7396e28 100644
--- a/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbEndpoint.java
+++ b/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbEndpoint.java
@@ -26,6 +26,8 @@ import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriPath;
 import org.apache.camel.support.DefaultEndpoint;
 import org.influxdb.InfluxDB;
+import org.influxdb.dto.Query;
+import org.influxdb.dto.QueryResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -37,6 +39,8 @@ import org.slf4j.LoggerFactory;
 public class InfluxDbEndpoint extends DefaultEndpoint {
 
     private static final Logger LOG = LoggerFactory.getLogger(InfluxDbEndpoint.class);
+    private static final String CREATE_DATABASE = "CREATE DATABASE ";
+    private static final String SHOW_DATABASES = "SHOW DATABASES";
 
     private InfluxDB influxDB;
 
@@ -53,6 +57,10 @@ public class InfluxDbEndpoint extends DefaultEndpoint {
     private String operation = InfluxDbOperations.INSERT;
     @UriParam
     private String query;
+    @UriParam(defaultValue = "false")
+    private boolean checkDatabaseExistence;
+    @UriParam(defaultValue = "true")
+    private boolean autoCreateDatabase = true;
 
     public InfluxDbEndpoint(String uri, InfluxDbComponent component) {
         super(uri, component);
@@ -68,6 +76,16 @@ public class InfluxDbEndpoint extends DefaultEndpoint {
         throw new UnsupportedOperationException("You cannot receive messages from this endpoint");
     }
 
+    @Override
+    protected void doInit() throws Exception {
+        super.doInit();
+
+        if (checkDatabaseExistence) {
+            ensureDatabaseExists();
+        }
+
+    }
+
     public InfluxDB getInfluxDB() {
         return influxDB;
     }
@@ -144,4 +162,48 @@ public class InfluxDbEndpoint extends DefaultEndpoint {
     public void setQuery(String query) {
         this.query = query;
     }
+
+    public boolean isCheckDatabaseExistence() {
+        return checkDatabaseExistence;
+    }
+
+    /**
+     * Define if we want to check the database existence while starting the endpoint
+     */
+    public void setCheckDatabaseExistence(boolean checkDatabaseExistence) {
+        this.checkDatabaseExistence = checkDatabaseExistence;
+    }
+
+    public boolean isAutoCreateDatabase() {
+        return autoCreateDatabase;
+    }
+
+    /**
+     * Define if we want to auto create the database if it's not present
+     */
+    public void setAutoCreateDatabase(boolean autoCreateDatabase) {
+        this.autoCreateDatabase = autoCreateDatabase;
+    }
+
+    private void ensureDatabaseExists() {
+        QueryResult result = getInfluxDB().query(new Query(SHOW_DATABASES));
+
+        //values are located in the first item in series, where list of values is the first item in the Serie's values,
+        //if any object on the 'path' is null, database does not exist
+        boolean exists;
+        try {
+            //NPE could be thrown from objects deep in the structure.
+            //try catch block with NullPointerException is used on purpose
+            exists = result.getResults().get(0).getSeries().get(0).getValues().get(0).contains(databaseName);
+        } catch (NullPointerException e) {
+            exists = false;
+        }
+
+        if (!exists) {
+            if (autoCreateDatabase) {
+                LOG.debug("Database {} doesn't exist. Creating it...", databaseName);
+                getInfluxDB().query(new Query(CREATE_DATABASE + databaseName, ""));
+            }
+        }
+    }
 }
diff --git a/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbProducer.java b/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbProducer.java
index 0363398..1900a84 100644
--- a/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbProducer.java
+++ b/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbProducer.java
@@ -78,7 +78,6 @@ public class InfluxDbProducer extends DefaultProducer {
             Point p = exchange.getIn().getMandatoryBody(Point.class);
             try {
                 LOG.debug("Writing point {}", p.lineProtocol());
-                ensureDatabaseExists(dataBaseName);
                 connection.write(dataBaseName, retentionPolicy, p);
             } catch (Exception ex) {
                 exchange.setException(new CamelInfluxDbException(ex));
@@ -137,24 +136,4 @@ public class InfluxDbProducer extends DefaultProducer {
         return query;
     }
 
-    private void ensureDatabaseExists(String dataBaseName) {
-        QueryResult result = connection.query(new Query(SHOW_DATABASES));
-
-        //values are located in the first item in series, where list of values is the first item in the Serie's values,
-        //if any object on the 'path' is null, database does not exist
-        boolean exists;
-        try {
-            //NPE could be thrown from objects deep in the structure.
-            //try catch block with NullPointerException is used on purpose
-            exists = result.getResults().get(0).getSeries().get(0).getValues().get(0).contains(dataBaseName);
-        } catch (NullPointerException e) {
-            exists = false;
-        }
-
-        if (!exists) {
-            LOG.debug("Database {} doesn't exist. Creating it...", dataBaseName);
-            connection.query(new Query(CREATE_DATABASE + dataBaseName, ""));
-        }
-    }
-
 }

[camel] 03/03: CAMEL-16892 - Camel-InfluxDB: Don't check database existence each time we perform a producer operation

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 0266f179a48ef54df058405713546c8251674097
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Sep 13 11:22:54 2021 +0200

    CAMEL-16892 - Camel-InfluxDB: Don't check database existence each time we perform a producer operation
---
 .../resources/org/apache/camel/catalog/components/influxdb.json         | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/influxdb.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/influxdb.json
index c9eebfb..217deb3 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/influxdb.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/influxdb.json
@@ -28,7 +28,9 @@
   },
   "properties": {
     "connectionBean": { "kind": "path", "displayName": "Connection Bean", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Connection to the influx database, of class InfluxDB.class" },
+    "autoCreateDatabase": { "kind": "parameter", "displayName": "Auto Create Database", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Define if we want to auto create the database if it's not present" },
     "batch": { "kind": "parameter", "displayName": "Batch", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Define if this operation is a batch operation or not" },
+    "checkDatabaseExistence": { "kind": "parameter", "displayName": "Check Database Existence", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Define if we want to check the database existence while starting the endpoint" },
     "databaseName": { "kind": "parameter", "displayName": "Database Name", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The name of the database where the time series will be stored" },
     "lazyStartProducer": { "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during sta [...]
     "operation": { "kind": "parameter", "displayName": "Operation", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "insert", "description": "Define if this operation is an insert or a query" },