[ 
https://issues.apache.org/jira/browse/CAMEL-12418?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16429904#comment-16429904
 ] 

ASF GitHub Bot commented on CAMEL-12418:
----------------------------------------

GitHub user Gr1f0n6x opened a pull request:

    https://github.com/apache/camel/pull/2283

    CAMEL-12418: High CPU load on events watching

    I believe that scheduledExecutorService with schedule method will be a 
little better then Thread.sleep(mills) (maybe i'm wrong).
    
    Also, i didn't add default value as proposed in description of this problem 
beecause as i found in `ConsulClientConfiguration` the default value of  
`blockSeconds` is 10:
    ```
    @UriParams
    public class ConsulClientConfiguration implements Cloneable {
        . . . 
        @UriParam(label = "consumer,watch", defaultValue = "10")
        private Integer blockSeconds = 10;
        . . . 
    }
    ```
    
    ## Check style
    Result of `mvn clean install -Psourcecheck`:
    ```
    [INFO] Scanning for projects...
    [INFO]                                                                      
   
    [INFO] 
------------------------------------------------------------------------
    [INFO] Building Camel :: Consul 2.22.0-SNAPSHOT
    [INFO] 
------------------------------------------------------------------------
    [INFO] 
    [INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ camel-consul ---
    [INFO] Deleting D:\Program 
Files\WORK\WORK_Java\camel\components\camel-consul\target
    [INFO] 
    [INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce-maven) @ 
camel-consul ---
    [INFO] 
    [INFO] --- maven-bundle-plugin:3.5.0:cleanVersions (versions) @ 
camel-consul ---
    [INFO] 
    [INFO] --- maven-checkstyle-plugin:3.0.0:checkstyle (default-cli) @ 
camel-consul ---
    [INFO] Starting audit...
    Audit done.
    [INFO] 
    [INFO] --- maven-remote-resources-plugin:1.5:process 
(process-resource-bundles) @ camel-consul ---
    [INFO] 
    [INFO] --- camel-package-maven-plugin:2.22.0-SNAPSHOT:prepare-components 
(prepare) @ camel-consul ---
    [INFO] Generated D:\Program 
Files\WORK\WORK_Java\camel\components\camel-consul\target\generated\camel\components\META-INF\services\org\apache\camel\component.properties
 containing 1 Camel component: consul
    [INFO] 
    [INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ 
camel-consul ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] Copying 4 resources
    [INFO] Copying 3 resources
    [INFO] Copying 1 resource
    [INFO] skip non existing resourceDirectory D:\Program 
Files\WORK\WORK_Java\camel\components\camel-consul\target\generated\camel\dataformats
    [INFO] skip non existing resourceDirectory D:\Program 
Files\WORK\WORK_Java\camel\components\camel-consul\target\generated\camel\languages
    [INFO] 
    [INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ 
camel-consul ---
    [INFO] Changes detected - recompiling the module!
    [INFO] Compiling 37 source files to D:\Program 
Files\WORK\WORK_Java\camel\components\camel-consul\target\classes
    [INFO] 
    [INFO] --- maven-resources-plugin:3.0.2:testResources 
(default-testResources) @ camel-consul ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] Copying 4 resources
    [INFO] Copying 3 resources
    [INFO] 
    [INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ 
camel-consul ---
    [INFO] Changes detected - recompiling the module!
    [INFO] Compiling 23 source files to D:\Program 
Files\WORK\WORK_Java\camel\components\camel-consul\target\test-classes
    [INFO] 
    [INFO] --- maven-surefire-plugin:2.20.1:test (default-test) @ camel-consul 
---
    [INFO] Tests are skipped.
    [INFO] 
    [INFO] --- maven-bundle-plugin:3.5.0:manifest (bundle-manifest) @ 
camel-consul ---
    [WARNING] Manifest org.apache.camel:camel-consul:jar:2.22.0-SNAPSHOT : 
Unused Import-Package instructions: [org.springframework.ws.*, 
org.springframework.xml.*, org.springframework.*, org.apache.cxf.*, 
org.apache.qpid.*, org.apache.abdera.*, org.apache.commons.httpclient.*, 
org.apache.velocity.*, org.apache.xmlbeans.*, org.eclipse.jetty.*, 
com.thoughtworks.xstream.*, org.antlr.stringtemplate.*, 
org.ccil.cowan.tagsoup.*, org.mortbay.cometd.*, net.sf.flatpack.*, 
net.sf.saxon.*, freemarker.*, javax.persistence.*, org.apache.lucene.*, 
org.apache.solr.*] 
    [INFO] 
    [INFO] --- camel-package-maven-plugin:2.22.0-SNAPSHOT:validate-components 
(validate) @ camel-consul ---
    [INFO] Validation complete
    [INFO] 
    [INFO] --- 
camel-package-maven-plugin:2.22.0-SNAPSHOT:prepare-spring-boot-starter 
(validate) @ camel-consul ---
    [INFO] Spring-Boot-Starter: starter dir for the component is: D:\Program 
Files\WORK\WORK_Java\camel\platforms\spring-boot\components-starter\camel-consul-starter
    [INFO] Reusing the existing pom.xml for the starter
    [INFO] 
    [INFO] --- 
camel-package-maven-plugin:2.22.0-SNAPSHOT:prepare-spring-boot-auto-configuration
 (validate) @ camel-consul ---
    [INFO] Updated existing file: D:\Program 
Files\WORK\WORK_Java\camel\platforms\spring-boot\components-starter\camel-consul-starter\src\main\java\org\apache\camel\component\consul\springboot\ConsulComponentConfiguration.java
    [INFO] Updated existing file: D:\Program 
Files\WORK\WORK_Java\camel\platforms\spring-boot\components-starter\camel-consul-starter\src\main\java\org\apache\camel\component\consul\springboot\ConsulComponentAutoConfiguration.java
    [INFO] 
    [INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ camel-consul ---
    [INFO] Building jar: D:\Program 
Files\WORK\WORK_Java\camel\components\camel-consul\target\camel-consul-2.22.0-SNAPSHOT.jar
    [INFO] 
    [INFO] --- maven-site-plugin:3.5.1:attach-descriptor (attach-descriptor) @ 
camel-consul ---
    [INFO] 
    [INFO] --- camel-package-maven-plugin:2.22.0-SNAPSHOT:update-readme 
(readme) @ camel-consul ---
    [INFO] 
    [INFO] --- maven-install-plugin:2.5.2:install (default-install) @ 
camel-consul ---
    [INFO] Installing D:\Program 
Files\WORK\WORK_Java\camel\components\camel-consul\target\camel-consul-2.22.0-SNAPSHOT.jar
 to 
C:\Users\GrIfOn\.m2\repository\org\apache\camel\camel-consul\2.22.0-SNAPSHOT\camel-consul-2.22.0-SNAPSHOT.jar
    [INFO] Installing D:\Program 
Files\WORK\WORK_Java\camel\components\camel-consul\pom.xml to 
C:\Users\GrIfOn\.m2\repository\org\apache\camel\camel-consul\2.22.0-SNAPSHOT\camel-consul-2.22.0-SNAPSHOT.pom
    [INFO] 
------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] 
------------------------------------------------------------------------
    [INFO] Total time: 16.378 s
    [INFO] Finished at: 2018-04-09T01:29:11+03:00
    [INFO] Final Memory: 53M/553M
    [INFO] 
------------------------------------------------------------------------
    ```

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/Gr1f0n6x/camel CAMEL-12418

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/camel/pull/2283.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #2283
    
----
commit 5ea5cbda3a52948669e7a2fe00eacb577dd674ba
Author: Nick <grifon52@...>
Date:   2018-04-08T22:30:46Z

    Add delay between listEvents requests

----


> camel-consul - High CPU load on events watching
> -----------------------------------------------
>
>                 Key: CAMEL-12418
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12418
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-consul
>    Affects Versions: 2.21.0
>            Reporter: Viachaslau Tsikhanovich
>            Priority: Major
>             Fix For: 2.22.0
>
>
> Camel-Consul library expects EventClient to block requests and [passes number 
> of seconds to block request to 
> EventClient|https://github.com/apache/camel/blob/camel-2.21.0/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulEventConsumer.java#L59].
>  However Event HTTP Endpoint [does not support Blocking 
> Queries|https://www.consul.io/api/event.html] and EventClient [ignores passed 
> queryOptions|https://github.com/rickfast/consul-client/blob/1.1.1/src/main/java/com/orbitz/consul/EventClient.java#L164].
>  This results in high CPU usage because ConsulEventConsumer constantly makes 
> requests to Consul without any delay or blocking.
>  Maybe some _Thread.sleep_ could be added to _EventWatcher.watch(EventClient 
> client)_ before _client.listEvents_ call or any other fix to introduce delay 
> between _listEvents_ requests.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to