You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2018/04/18 07:39:36 UTC

[camel] branch camel-2.21.x updated (7c2e54a -> 0db10ba)

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

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


    from 7c2e54a  12454: camel-kafka - AutoCommitEnabled=false should not auto commit. Thanks to John Culleton for reporting.
     new 4c0fd62  CAMEL-12418: High CPU load on events watching (#2283)
     new 0db10ba  CAMEL-12418: High CPU load on events watching (#2283)

The 2 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:
 .../consul/endpoint/ConsulEventConsumer.java       | 36 ++++++++++++++++++----
 1 file changed, 30 insertions(+), 6 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
davsclaus@apache.org.

[camel] 02/02: CAMEL-12418: High CPU load on events watching (#2283)

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

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

commit 0db10ba531b1ef37fca07bb65c1fea1bb3092f94
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Apr 18 09:38:04 2018 +0200

    CAMEL-12418: High CPU load on events watching (#2283)
---
 .../camel/component/consul/endpoint/ConsulEventConsumer.java  | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulEventConsumer.java b/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulEventConsumer.java
index 7133fec..b74615b 100644
--- a/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulEventConsumer.java
+++ b/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulEventConsumer.java
@@ -30,19 +30,18 @@ import com.orbitz.consul.option.QueryOptions;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
-import org.apache.camel.spi.ExecutorServiceManager;
 import org.apache.camel.component.consul.ConsulConfiguration;
 import org.apache.camel.component.consul.ConsulConstants;
 import org.apache.camel.component.consul.ConsulEndpoint;
+import org.apache.camel.spi.ExecutorServiceManager;
 
 public final class ConsulEventConsumer extends AbstractConsulConsumer<EventClient> {
-    private ExecutorServiceManager executorServiceManager;
+    private final ExecutorServiceManager executorServiceManager;
     private ScheduledExecutorService scheduledExecutorService;
 
     public ConsulEventConsumer(ConsulEndpoint endpoint, ConsulConfiguration configuration, Processor processor) {
         super(endpoint, configuration, processor, Consul::eventClient);
         this.executorServiceManager = endpoint.getCamelContext().getExecutorServiceManager();
-        this.scheduledExecutorService = this.executorServiceManager.newSingleThreadScheduledExecutor(this, "ConsulEventConsumer");
     }
 
     @Override
@@ -51,6 +50,12 @@ public final class ConsulEventConsumer extends AbstractConsulConsumer<EventClien
     }
 
     @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        this.scheduledExecutorService = this.executorServiceManager.newSingleThreadScheduledExecutor(this, "ConsulEventConsumer");
+    }
+
+    @Override
     protected void doStop() throws Exception {
         executorServiceManager.shutdownGraceful(scheduledExecutorService);
         super.doStop();

-- 
To stop receiving notification emails like this one, please contact
davsclaus@apache.org.

[camel] 01/02: CAMEL-12418: High CPU load on events watching (#2283)

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

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

commit 4c0fd62eda4260e6f5505dc75bfa2f7500657e54
Author: Nick <ry...@gmail.com>
AuthorDate: Wed Apr 18 10:35:04 2018 +0300

    CAMEL-12418: High CPU load on events watching (#2283)
    
    * Add delay between listEvents requests
    
    * Use ExecutorServiceManager got via CamelContext
    
    * Add explicit field executorServiceManager
    
    * Use ExecutorServiceManager.shutdownGraceful
---
 .../consul/endpoint/ConsulEventConsumer.java       | 31 +++++++++++++++++-----
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulEventConsumer.java b/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulEventConsumer.java
index 2e8a141..7133fec 100644
--- a/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulEventConsumer.java
+++ b/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulEventConsumer.java
@@ -18,6 +18,8 @@ package org.apache.camel.component.consul.endpoint;
 
 import java.math.BigInteger;
 import java.util.List;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
 
 import com.orbitz.consul.Consul;
 import com.orbitz.consul.EventClient;
@@ -28,14 +30,19 @@ import com.orbitz.consul.option.QueryOptions;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
+import org.apache.camel.spi.ExecutorServiceManager;
 import org.apache.camel.component.consul.ConsulConfiguration;
 import org.apache.camel.component.consul.ConsulConstants;
 import org.apache.camel.component.consul.ConsulEndpoint;
 
 public final class ConsulEventConsumer extends AbstractConsulConsumer<EventClient> {
+    private ExecutorServiceManager executorServiceManager;
+    private ScheduledExecutorService scheduledExecutorService;
 
     public ConsulEventConsumer(ConsulEndpoint endpoint, ConsulConfiguration configuration, Processor processor) {
         super(endpoint, configuration, processor, Consul::eventClient);
+        this.executorServiceManager = endpoint.getCamelContext().getExecutorServiceManager();
+        this.scheduledExecutorService = this.executorServiceManager.newSingleThreadScheduledExecutor(this, "ConsulEventConsumer");
     }
 
     @Override
@@ -43,22 +50,34 @@ public final class ConsulEventConsumer extends AbstractConsulConsumer<EventClien
         return new EventWatcher(client);
     }
 
+    @Override
+    protected void doStop() throws Exception {
+        executorServiceManager.shutdownGraceful(scheduledExecutorService);
+        super.doStop();
+    }
+
     // *************************************************************************
     // Watch
     // *************************************************************************
 
     private class EventWatcher extends AbstractWatcher implements EventResponseCallback {
+
         EventWatcher(EventClient client) {
             super(client);
         }
 
         @Override
-        public void watch(EventClient client) {
-            client.listEvents(
-                key,
-                QueryOptions.blockSeconds(configuration.getBlockSeconds(), index.get()).build(),
-                this
-            );
+        public void watch(final EventClient client) {
+            scheduledExecutorService.schedule(new Runnable() {
+                @Override
+                public void run() {
+                    client.listEvents(
+                        key,
+                        QueryOptions.blockSeconds(configuration.getBlockSeconds(), index.get()).build(),
+                        EventWatcher.this
+                    );
+                }
+            }, configuration.getBlockSeconds(), TimeUnit.SECONDS);
         }
 
         @Override

-- 
To stop receiving notification emails like this one, please contact
davsclaus@apache.org.