You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2015/05/29 17:06:52 UTC

[1/4] camel git commit: CAMEL-8816 Fixed the elasticsearch component start up issue when using the local elasticsearch instance

Repository: camel
Updated Branches:
  refs/heads/camel-2.14.x f0443ae89 -> 920429bd7
  refs/heads/camel-2.15.x 7dfb61aa8 -> b2188887a


CAMEL-8816 Fixed the elasticsearch component start up issue when using the local elasticsearch instance

Conflicts:
	components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchEndpoint.java


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

Branch: refs/heads/camel-2.15.x
Commit: c17f8c95ab25cd0f025bfb80b5beadd9649fa62c
Parents: 7dfb61a
Author: Willem Jiang <wi...@gmail.com>
Authored: Fri May 29 11:15:18 2015 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Fri May 29 22:34:54 2015 +0800

----------------------------------------------------------------------
 .../component/elasticsearch/ElasticsearchEndpoint.java    | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c17f8c95/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchEndpoint.java b/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchEndpoint.java
index da49c12..eb83171 100644
--- a/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchEndpoint.java
+++ b/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchEndpoint.java
@@ -31,9 +31,12 @@ import org.elasticsearch.common.settings.ImmutableSettings;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.transport.InetSocketTransportAddress;
 import org.elasticsearch.node.Node;
+import org.elasticsearch.node.NodeBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
+
 /**
  * Represents an Elasticsearch endpoint.
  */
@@ -89,7 +92,12 @@ public class ElasticsearchEndpoint extends DefaultEndpoint {
                     .addTransportAddress(new InetSocketTransportAddress(configuration.getIp(), configuration.getPort()));
             this.client = client;
         } else {
-            node = configuration.buildNode();
+            NodeBuilder builder = nodeBuilder().local(configuration.isLocal()).data(configuration.isData());
+            if (!configuration.isLocal() && configuration.getClusterName() != null) {
+                builder.clusterName(configuration.getClusterName());
+            }
+            builder.getSettings().classLoader(Settings.class.getClassLoader());
+            node = builder.node();
             client = node.client();
         }
     }


[2/4] camel git commit: CAMEL-8816 Fixed the elasticsearch component start up issue when using the local elasticsearch instance

Posted by ni...@apache.org.
CAMEL-8816 Fixed the elasticsearch component start up issue when using the local elasticsearch instance

Conflicts:
	components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchEndpoint.java


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

Branch: refs/heads/camel-2.14.x
Commit: 920429bd7e705c5ff24bf97715d94cd4e775ccf3
Parents: f0443ae
Author: Willem Jiang <wi...@gmail.com>
Authored: Fri May 29 11:15:18 2015 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Fri May 29 22:35:19 2015 +0800

----------------------------------------------------------------------
 .../component/elasticsearch/ElasticsearchEndpoint.java    | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/920429bd/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchEndpoint.java b/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchEndpoint.java
index 108ce01..584229b 100644
--- a/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchEndpoint.java
+++ b/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchEndpoint.java
@@ -31,9 +31,12 @@ import org.elasticsearch.common.settings.ImmutableSettings;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.transport.InetSocketTransportAddress;
 import org.elasticsearch.node.Node;
+import org.elasticsearch.node.NodeBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
+
 /**
  * Represents an Elasticsearch endpoint.
  */
@@ -89,7 +92,12 @@ public class ElasticsearchEndpoint extends DefaultEndpoint {
                     .addTransportAddress(new InetSocketTransportAddress(configuration.getIp(), configuration.getPort()));
             this.client = client;
         } else {
-            node = configuration.buildNode();
+            NodeBuilder builder = nodeBuilder().local(configuration.isLocal()).data(configuration.isData());
+            if (!configuration.isLocal() && configuration.getClusterName() != null) {
+                builder.clusterName(configuration.getClusterName());
+            }
+            builder.getSettings().classLoader(Settings.class.getClassLoader());
+            node = builder.node();
             client = node.client();
         }
     }


[4/4] camel git commit: CAMEL-8812 Added the HL7MLLPNettyDecoderResourceLeakTest file

Posted by ni...@apache.org.
CAMEL-8812 Added the HL7MLLPNettyDecoderResourceLeakTest file


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

Branch: refs/heads/camel-2.15.x
Commit: b2188887abddb08aae39541112e6912509a69117
Parents: 38a856d
Author: Willem Jiang <wi...@gmail.com>
Authored: Fri May 29 23:05:08 2015 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Fri May 29 23:06:27 2015 +0800

----------------------------------------------------------------------
 .../component/hl7/HL7MLLPNettyDecoder.java      |  1 +
 .../HL7MLLPNettyDecoderResourceLeakTest.java    | 69 ++++++++++++++++++++
 2 files changed, 70 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/b2188887/components/camel-hl7/src/main/java/org/apache/camel/component/hl7/HL7MLLPNettyDecoder.java
----------------------------------------------------------------------
diff --git a/components/camel-hl7/src/main/java/org/apache/camel/component/hl7/HL7MLLPNettyDecoder.java b/components/camel-hl7/src/main/java/org/apache/camel/component/hl7/HL7MLLPNettyDecoder.java
index 9c04448..2ced9b4 100644
--- a/components/camel-hl7/src/main/java/org/apache/camel/component/hl7/HL7MLLPNettyDecoder.java
+++ b/components/camel-hl7/src/main/java/org/apache/camel/component/hl7/HL7MLLPNettyDecoder.java
@@ -69,6 +69,7 @@ class HL7MLLPNettyDecoder extends DelimiterBasedFrameDecoder {
                     throw new DecoderException("Did not find start byte " + (int) config.getStartByte());
                 }
             } finally {
+                // We need to release the buf here to avoid the memory leak
                 buf.release();
             }
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/b2188887/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPNettyDecoderResourceLeakTest.java
----------------------------------------------------------------------
diff --git a/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPNettyDecoderResourceLeakTest.java b/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPNettyDecoderResourceLeakTest.java
new file mode 100644
index 0000000..81cee04
--- /dev/null
+++ b/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPNettyDecoderResourceLeakTest.java
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.hl7;
+
+import ca.uhn.hl7v2.model.Message;
+import io.netty.util.ResourceLeakDetector;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.JndiRegistry;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class HL7MLLPNettyDecoderResourceLeakTest extends HL7TestSupport {
+
+    @BeforeClass
+    // As the ResourceLeakDetector just write error log when it find the leak,  
+    // We need to check the log file to see if there is a leak. 
+    public static void enableNettyResourceLeakDetector() {
+        ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.PARANOID);
+    }
+
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry jndi = super.createRegistry();
+
+        jndi.bind("hl7decoder", new HL7MLLPNettyDecoderFactory());
+        jndi.bind("hl7encoder", new HL7MLLPNettyEncoderFactory());
+
+        return jndi;
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("netty4:tcp://127.0.0.1:" + getPort() + "?decoder=#hl7decoder&encoder=#hl7encoder")
+                        .process(new Processor() {
+                            public void process(Exchange exchange) throws Exception {
+                                Message input = exchange.getIn().getBody(Message.class);
+                                exchange.getOut().setBody(input.generateACK());
+                            }
+                        })
+                        .to("mock:result");
+            }
+        };
+    }
+
+    @Test
+    public void testSendHL7Message() throws Exception {
+        String message = "MSH|^~\\&|MYSENDER|MYRECEIVER|MYAPPLICATION||200612211200||QRY^A19|1234|P|2.4";
+
+        for (int i = 0; i < 10; i++) {
+            template.sendBody("netty4:tcp://127.0.0.1:" + getPort() + "?decoder=#hl7decoder&encoder=#hl7encoder", message);
+        }
+    }
+}


[3/4] camel git commit: CAMEL-8812 Fixed the Memory leak in HL7MLLPNettyDecoder with thanks to Gijsbert

Posted by ni...@apache.org.
CAMEL-8812 Fixed the Memory leak in HL7MLLPNettyDecoder with thanks to Gijsbert


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

Branch: refs/heads/camel-2.15.x
Commit: 38a856d53660c27986250f27baaca0b4c88961e2
Parents: c17f8c9
Author: Willem Jiang <wi...@gmail.com>
Authored: Fri May 29 22:23:00 2015 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Fri May 29 23:03:57 2015 +0800

----------------------------------------------------------------------
 .../camel/component/hl7/HL7MLLPNettyDecoder.java  | 18 +++++++++++-------
 .../camel/component/hl7/HL7MLLPCodecTest.java     |  2 +-
 2 files changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/38a856d5/components/camel-hl7/src/main/java/org/apache/camel/component/hl7/HL7MLLPNettyDecoder.java
----------------------------------------------------------------------
diff --git a/components/camel-hl7/src/main/java/org/apache/camel/component/hl7/HL7MLLPNettyDecoder.java b/components/camel-hl7/src/main/java/org/apache/camel/component/hl7/HL7MLLPNettyDecoder.java
index 4938cd5..9c04448 100644
--- a/components/camel-hl7/src/main/java/org/apache/camel/component/hl7/HL7MLLPNettyDecoder.java
+++ b/components/camel-hl7/src/main/java/org/apache/camel/component/hl7/HL7MLLPNettyDecoder.java
@@ -59,13 +59,17 @@ class HL7MLLPNettyDecoder extends DelimiterBasedFrameDecoder {
     protected Object decode(ChannelHandlerContext ctx, ByteBuf buffer) throws Exception {
         ByteBuf buf = (ByteBuf) super.decode(ctx, buffer);
         if (buf != null) {
-            int pos = buf.bytesBefore((byte) config.getStartByte());
-            if (pos >= 0) {
-                ByteBuf msg = buf.readerIndex(pos + 1).slice();
-                LOG.debug("Message ends with length {}", msg.readableBytes());
-                return config.isProduceString() ? asString(msg) : asByteArray(msg);
-            } else {
-                throw new DecoderException("Did not find start byte " + (int) config.getStartByte());
+            try {
+                int pos = buf.bytesBefore((byte) config.getStartByte());
+                if (pos >= 0) {
+                    ByteBuf msg = buf.readerIndex(pos + 1).slice();
+                    LOG.debug("Message ends with length {}", msg.readableBytes());
+                    return config.isProduceString() ? asString(msg) : asByteArray(msg);
+                } else {
+                    throw new DecoderException("Did not find start byte " + (int) config.getStartByte());
+                }
+            } finally {
+                buf.release();
             }
         }
         // Message not complete yet - return null to be called again

http://git-wip-us.apache.org/repos/asf/camel/blob/38a856d5/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecTest.java
----------------------------------------------------------------------
diff --git a/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecTest.java b/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecTest.java
index 1d9afef..96d6396 100644
--- a/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecTest.java
+++ b/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecTest.java
@@ -21,7 +21,6 @@ import ca.uhn.hl7v2.model.v24.message.ADR_A19;
 import ca.uhn.hl7v2.model.v24.segment.MSA;
 import ca.uhn.hl7v2.model.v24.segment.MSH;
 import ca.uhn.hl7v2.model.v24.segment.QRD;
-
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
@@ -32,6 +31,7 @@ import org.junit.Test;
  * Unit test for the HL7MLLP Codec.
  */
 public class HL7MLLPCodecTest extends HL7TestSupport {
+    
 
     protected JndiRegistry createRegistry() throws Exception {
         JndiRegistry jndi = super.createRegistry();