camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [3/3] camel git commit: CAMEL-8712 - User the Netty Timer per Component
Date Tue, 28 Apr 2015 14:00:11 GMT
CAMEL-8712 - User the Netty Timer per Component


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

Branch: refs/heads/camel-2.15.x
Commit: fa726cd0e06f9723f5ed35eed588978efa1c8aa1
Parents: 77b4c69
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Tue Apr 28 21:53:31 2015 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Tue Apr 28 22:00:18 2015 +0800

----------------------------------------------------------------------
 .../component/netty/http/HttpClientPipelineFactory.java      | 2 +-
 .../camel/component/netty/DefaultClientPipelineFactory.java  | 2 +-
 .../org/apache/camel/component/netty/NettyComponent.java     | 8 ++++++--
 .../camel/component/netty/NettyManualEndpointTest.java       | 2 +-
 4 files changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/fa726cd0/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientPipelineFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientPipelineFactory.java
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientPipelineFactory.java
index ee77dce..6fde363 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientPipelineFactory.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientPipelineFactory.java
@@ -108,7 +108,7 @@ public class HttpClientPipelineFactory extends ClientPipelineFactory {
             if (LOG.isTraceEnabled()) {
                 LOG.trace("Using request timeout {} millis", producer.getConfiguration().getRequestTimeout());
             }
-            ChannelHandler timeout = new ReadTimeoutHandler(NettyComponent.getTimer(), producer.getConfiguration().getRequestTimeout(),
TimeUnit.MILLISECONDS);
+            ChannelHandler timeout = new ReadTimeoutHandler(producer.getEndpoint().getTimer(),
producer.getConfiguration().getRequestTimeout(), TimeUnit.MILLISECONDS);
             pipeline.addLast("timeout", timeout);
         }
         

http://git-wip-us.apache.org/repos/asf/camel/blob/fa726cd0/components/camel-netty/src/main/java/org/apache/camel/component/netty/DefaultClientPipelineFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/DefaultClientPipelineFactory.java
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/DefaultClientPipelineFactory.java
index 556ee98..1e40f4c 100644
--- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/DefaultClientPipelineFactory.java
+++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/DefaultClientPipelineFactory.java
@@ -85,7 +85,7 @@ public class DefaultClientPipelineFactory extends ClientPipelineFactory
 {
             if (LOG.isTraceEnabled()) {
                 LOG.trace("Using request timeout {} millis", producer.getConfiguration().getRequestTimeout());
             }
-            ChannelHandler timeout = new ReadTimeoutHandler(NettyComponent.getTimer(), producer.getConfiguration().getRequestTimeout(),
TimeUnit.MILLISECONDS);
+            ChannelHandler timeout = new ReadTimeoutHandler(producer.getEndpoint().getTimer(),
producer.getConfiguration().getRequestTimeout(), TimeUnit.MILLISECONDS);
             addToPipeline("timeout", channelPipeline, timeout);
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/fa726cd0/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java
index b140cba..ac622d0 100644
--- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java
+++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java
@@ -33,7 +33,7 @@ import org.jboss.netty.util.Timer;
 
 public class NettyComponent extends UriEndpointComponent {
     // use a shared timer for Netty (see javadoc for HashedWheelTimer)
-    private static volatile Timer timer;
+    private Timer timer;
     private NettyConfiguration configuration;
     private int maximumPoolSize = 16;
     private OrderedMemoryAwareThreadPoolExecutor executorService;
@@ -104,7 +104,7 @@ public class NettyComponent extends UriEndpointComponent {
         this.maximumPoolSize = maximumPoolSize;
     }
 
-    public static Timer getTimer() {
+    public Timer getTimer() {
         return timer;
     }
 
@@ -146,6 +146,10 @@ public class NettyComponent extends UriEndpointComponent {
 
     @Override
     protected void doStop() throws Exception {
+        if (timer != null) {
+            timer.stop();
+            timer = null;
+        }
         if (executorService != null) {
             getCamelContext().getExecutorServiceManager().shutdownNow(executorService);
             executorService = null;

http://git-wip-us.apache.org/repos/asf/camel/blob/fa726cd0/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyManualEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyManualEndpointTest.java
b/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyManualEndpointTest.java
index c95147d..770bf8f 100644
--- a/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyManualEndpointTest.java
+++ b/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyManualEndpointTest.java
@@ -69,7 +69,7 @@ public class NettyManualEndpointTest extends BaseNettyTest {
                 // create and start endpoint, pass in null as endpoint uri
                 // as we create this endpoint manually
                 endpoint = new NettyEndpoint(null, component, nettyConfig);
-                endpoint.setTimer(NettyComponent.getTimer());
+                endpoint.setTimer(component.getTimer());
                 endpoint.start();
 
                 from(endpoint).to("mock:result");


Mime
View raw message