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/01/10 13:52:58 UTC

[1/2] camel git commit: CAMEL-10688: Camel-influxdb - The component should not store state

Repository: camel
Updated Branches:
  refs/heads/master 6593cb72e -> 5508b51a0


CAMEL-10688: Camel-influxdb - The component should not store state


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

Branch: refs/heads/master
Commit: 4ac1b2355738cc9cd52fcae7c9f075f03ad04296
Parents: 6593cb7
Author: Andrea Cosentino <an...@gmail.com>
Authored: Tue Jan 10 14:44:14 2017 +0100
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Tue Jan 10 14:44:14 2017 +0100

----------------------------------------------------------------------
 .../component/influxdb/InfluxDbComponent.java   |  7 ++---
 .../component/influxdb/InfluxDbEndpoint.java    | 29 ++++++++++++--------
 2 files changed, 20 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4ac1b235/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbComponent.java b/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbComponent.java
index 9101a3f..fc950d9 100644
--- a/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbComponent.java
+++ b/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbComponent.java
@@ -20,8 +20,6 @@ import java.util.Map;
 
 import org.apache.camel.Endpoint;
 import org.apache.camel.impl.UriEndpointComponent;
-import org.apache.camel.util.CamelContextHelper;
-import org.influxdb.InfluxDB;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -35,7 +33,8 @@ public class InfluxDbComponent extends UriEndpointComponent {
 
     @Override
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
-        InfluxDB influxDbConnection = CamelContextHelper.mandatoryLookup(getCamelContext(), remaining, InfluxDB.class);
-        return new InfluxDbEndpoint(uri, this, influxDbConnection);
+        InfluxDbEndpoint endpoint = new InfluxDbEndpoint(uri, this);
+        endpoint.setConnectionBean(remaining);
+        return endpoint;
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/4ac1b235/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbEndpoint.java
----------------------------------------------------------------------
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 a1405b1..ee30ad3 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
@@ -24,6 +24,7 @@ import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriPath;
+import org.apache.camel.util.CamelContextHelper;
 import org.influxdb.InfluxDB;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -47,18 +48,9 @@ public class InfluxDbEndpoint extends DefaultEndpoint {
     private String retentionPolicy = "default";
     @UriParam(defaultValue = "false")
     private boolean batch;
-
-    public InfluxDbEndpoint(String uri, InfluxDbComponent influxDbComponent, InfluxDB dbConn) {
-        super(uri, influxDbComponent);
-
-        if (dbConn == null) {
-            throw new IllegalArgumentException("dbConn is null");
-        }
-
-        this.influxDB = dbConn;
-
-        LOG.debug("Preparing influxdb enpoint with uri {}", uri);
-        LOG.debug("Creating influx db producer connectionBean:{}, databaseName:{}, retentionPolicy:{}", connectionBean, databaseName, retentionPolicy);
+    
+    public InfluxDbEndpoint(String uri, InfluxDbComponent component) {
+        super(uri, component);
     }
 
     @Override
@@ -70,6 +62,19 @@ public class InfluxDbEndpoint extends DefaultEndpoint {
     public Consumer createConsumer(Processor processor) throws Exception {
         throw new UnsupportedOperationException("You cannot receive messages from this endpoint");
     }
+    
+    @Override
+    protected void doStart() throws Exception {
+    	influxDB = CamelContextHelper.mandatoryLookup(getCamelContext(), connectionBean, InfluxDB.class);
+    	LOG.debug("Resolved the connection with the name {} as {}", connectionBean, influxDB);
+        super.doStart();
+        
+    }
+    
+    @Override
+    protected void doStop() throws Exception {
+        super.doStop();
+    }
 
     @Override
     public boolean isSingleton() {


[2/2] camel git commit: CAMEL-10688: Fixed CS and remove unuseful check related to Debug

Posted by ac...@apache.org.
CAMEL-10688: Fixed CS and remove unuseful check related to Debug


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

Branch: refs/heads/master
Commit: 5508b51a0cc0f5f939880631324e83587e942f5b
Parents: 4ac1b23
Author: Andrea Cosentino <an...@gmail.com>
Authored: Tue Jan 10 14:51:23 2017 +0100
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Tue Jan 10 14:51:23 2017 +0100

----------------------------------------------------------------------
 .../apache/camel/component/influxdb/InfluxDbEndpoint.java    | 7 +++----
 .../apache/camel/component/influxdb/InfluxDbProducer.java    | 8 ++------
 2 files changed, 5 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/5508b51a/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbEndpoint.java
----------------------------------------------------------------------
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 ee30ad3..efd6d09 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
@@ -65,10 +65,9 @@ public class InfluxDbEndpoint extends DefaultEndpoint {
     
     @Override
     protected void doStart() throws Exception {
-    	influxDB = CamelContextHelper.mandatoryLookup(getCamelContext(), connectionBean, InfluxDB.class);
-    	LOG.debug("Resolved the connection with the name {} as {}", connectionBean, influxDB);
-        super.doStart();
-        
+        influxDB = CamelContextHelper.mandatoryLookup(getCamelContext(), connectionBean, InfluxDB.class);
+        LOG.debug("Resolved the connection with the name {} as {}", connectionBean, influxDB);
+        super.doStart();  
     }
     
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/5508b51a/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 4074931..b071c13 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
@@ -64,9 +64,7 @@ public class InfluxDbProducer extends DefaultProducer {
             Point p = exchange.getIn().getMandatoryBody(Point.class);
 
             try {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Writing point {}", p.lineProtocol());
-                }
+                LOG.debug("Writing point {}", p.lineProtocol());
 
                 connection.write(dataBaseName, retentionPolicy, p);
             } catch (Exception ex) {
@@ -76,9 +74,7 @@ public class InfluxDbProducer extends DefaultProducer {
             BatchPoints batchPoints = exchange.getIn().getMandatoryBody(BatchPoints.class);
 
             try {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Writing BatchPoints {}", batchPoints.lineProtocol());
-                }
+                LOG.debug("Writing BatchPoints {}", batchPoints.lineProtocol());
 
                 connection.write(batchPoints);
             } catch (Exception ex) {