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 2017/07/10 12:39:58 UTC

[2/2] camel git commit: CAMEL-10659: Camel-InfluxDB: Check if Database exists and if not create it

CAMEL-10659: Camel-InfluxDB: Check if Database exists and if not create it


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8bba4140
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8bba4140
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8bba4140

Branch: refs/heads/master
Commit: 8bba41405f7e253f7f7592767c6bb67c201c7ba4
Parents: 45ddde1
Author: Andrea Cosentino <an...@gmail.com>
Authored: Mon Jul 10 14:38:59 2017 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Mon Jul 10 14:38:59 2017 +0200

----------------------------------------------------------------------
 .../org/apache/camel/component/influxdb/InfluxDbProducer.java  | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8bba4140/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbProducer.java
----------------------------------------------------------------------
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 c33dddc..5d318a3 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
@@ -79,7 +79,11 @@ public class InfluxDbProducer extends DefaultProducer {
 
             try {
                 LOG.debug("Writing point {}", p.lineProtocol());
-
+                
+                if (!connection.databaseExists(dataBaseName)) {
+                	LOG.debug("Database {} doesn't exist. Creating it...", dataBaseName);
+                	connection.createDatabase(dataBaseName);
+                }
                 connection.write(dataBaseName, retentionPolicy, p);
             } catch (Exception ex) {
                 exchange.setException(new CamelInfluxDbException(ex));