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 2015/03/28 07:52:20 UTC
[1/3] camel git commit: CAMEL-8562: Removing a route - Should check
if the route input endpoint is static and used by other routes
Repository: camel
Updated Branches:
refs/heads/camel-2.15.x 1648cd66c -> 4bc81b1f6
CAMEL-8562: Removing a route - Should check if the route input endpoint is static and used by other routes
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b18adddf
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b18adddf
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b18adddf
Branch: refs/heads/camel-2.15.x
Commit: b18adddfdbf08a22f5a3b18da4447ed4998e0038
Parents: 1648cd6
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Mar 27 17:56:50 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Mar 28 07:54:18 2015 +0100
----------------------------------------------------------------------
.../apache/camel/impl/DefaultCamelContext.java | 3 +-
.../org/apache/camel/impl/RouteService.java | 5 +-
...ointRegistryKeepRouteInputEndpointsTest.java | 132 +++++++++++++++++++
3 files changed, 136 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/b18adddf/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
index 9ac71b6..0622af6 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
@@ -1002,7 +1002,8 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon
}
}
for (Endpoint endpoint : toRemove) {
- log.debug("Removing: {} which was only in use by route: {}", endpoint, routeId);
+ log.debug("Stopping and removing: {} which was only in use by route: {}", endpoint, routeId);
+ ServiceHelper.stopAndShutdownService(endpoint);
removeEndpoint(endpoint);
}
return true;
http://git-wip-us.apache.org/repos/asf/camel/blob/b18adddf/camel-core/src/main/java/org/apache/camel/impl/RouteService.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/RouteService.java b/camel-core/src/main/java/org/apache/camel/impl/RouteService.java
index 2139d5c..ed4f947 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/RouteService.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/RouteService.java
@@ -105,6 +105,8 @@ public class RouteService extends ChildServiceSupport {
public Set<Endpoint> gatherEndpoints() {
Set<Endpoint> answer = new LinkedHashSet<Endpoint>();
for (Route route : routes) {
+ // the input endpoint itself
+ answer.add(route.getEndpoint());
Set<Service> services = gatherChildServices(route, true);
for (Service service : services) {
if (service instanceof EndpointAware) {
@@ -273,9 +275,6 @@ public class RouteService extends ChildServiceSupport {
// shutdown the route itself
ServiceHelper.stopAndShutdownServices(route);
- // endpoints should only be stopped when Camel is shutting down
- // see more details in the warmUp method
- ServiceHelper.stopAndShutdownServices(route.getEndpoint());
// invoke callbacks on route policy
if (route.getRouteContext().getRoutePolicyList() != null) {
for (RoutePolicy routePolicy : route.getRouteContext().getRoutePolicyList()) {
http://git-wip-us.apache.org/repos/asf/camel/blob/b18adddf/camel-core/src/test/java/org/apache/camel/impl/EndpointRegistryKeepRouteInputEndpointsTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/impl/EndpointRegistryKeepRouteInputEndpointsTest.java b/camel-core/src/test/java/org/apache/camel/impl/EndpointRegistryKeepRouteInputEndpointsTest.java
new file mode 100644
index 0000000..1a1434b
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/impl/EndpointRegistryKeepRouteInputEndpointsTest.java
@@ -0,0 +1,132 @@
+/**
+ * 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.impl;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Endpoint;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.support.ServiceSupport;
+
+public class EndpointRegistryKeepRouteInputEndpointsTest extends ContextTestSupport {
+
+ public void testEndpointRegistryKeepRouteEndpoints() throws Exception {
+ Endpoint seda = context.hasEndpoint("seda://start?multipleConsumers=true");
+ assertNotNull(seda);
+ assertTrue("Should be started", ((ServiceSupport) seda).isStarted());
+
+ assertTrue(context.hasEndpoint("seda://start?multipleConsumers=true") != null);
+ assertTrue(context.hasEndpoint("log://foo") != null);
+ assertTrue(context.hasEndpoint("log://bar") != null);
+ assertTrue(context.hasEndpoint("mock://result") != null);
+ assertTrue(context.hasEndpoint("seda://stop") != null);
+ assertTrue(context.hasEndpoint("mock://stop") != null);
+
+ // stop and remove bar route
+ context.stopRoute("bar");
+ context.removeRoute("bar");
+
+ assertTrue(context.hasEndpoint("seda://start?multipleConsumers=true") != null);
+ assertTrue(context.hasEndpoint("log://foo") != null);
+ assertFalse(context.hasEndpoint("log://bar") != null);
+ assertTrue(context.hasEndpoint("mock://result") != null);
+ assertTrue(context.hasEndpoint("seda://stop") != null);
+ assertTrue(context.hasEndpoint("mock://stop") != null);
+
+ // stop and remove baz route
+ context.stopRoute("baz");
+ context.removeRoute("baz");
+
+ assertTrue(context.hasEndpoint("seda://start?multipleConsumers=true") != null);
+ assertTrue(context.hasEndpoint("log://foo") != null);
+ assertFalse(context.hasEndpoint("log://bar") != null);
+ assertTrue(context.hasEndpoint("mock://result") != null);
+ assertFalse(context.hasEndpoint("seda://stop") != null);
+ assertFalse(context.hasEndpoint("mock://stop") != null);
+
+ // stop and remove foo route
+ context.stopRoute("foo");
+ context.removeRoute("foo");
+
+ assertFalse(context.hasEndpoint("seda://start?multipleConsumers=true") != null);
+ assertFalse(context.hasEndpoint("log://foo") != null);
+ assertFalse(context.hasEndpoint("log://bar") != null);
+ assertFalse(context.hasEndpoint("mock://result") != null);
+ assertFalse(context.hasEndpoint("seda://stop") != null);
+ assertFalse(context.hasEndpoint("mock://stop") != null);
+
+ assertFalse("Should not be started", ((ServiceSupport) seda).isStarted());
+ }
+
+ public void testEndpointRegistryKeepRouteEndpointsContextStop() throws Exception {
+ Endpoint seda = context.hasEndpoint("seda://start?multipleConsumers=true");
+ assertNotNull(seda);
+ assertTrue("Should be started", ((ServiceSupport) seda).isStarted());
+
+ assertTrue(context.hasEndpoint("seda://start?multipleConsumers=true") != null);
+ assertTrue(context.hasEndpoint("log://foo") != null);
+ assertTrue(context.hasEndpoint("log://bar") != null);
+ assertTrue(context.hasEndpoint("mock://result") != null);
+ assertTrue(context.hasEndpoint("seda://stop") != null);
+ assertTrue(context.hasEndpoint("mock://stop") != null);
+
+ // stop and remove bar route
+ context.stopRoute("bar");
+ context.removeRoute("bar");
+
+ assertTrue(context.hasEndpoint("seda://start?multipleConsumers=true") != null);
+ assertTrue(context.hasEndpoint("log://foo") != null);
+ assertFalse(context.hasEndpoint("log://bar") != null);
+ assertTrue(context.hasEndpoint("mock://result") != null);
+ assertTrue(context.hasEndpoint("seda://stop") != null);
+ assertTrue(context.hasEndpoint("mock://stop") != null);
+
+ // stop and remove baz route
+ context.stopRoute("baz");
+ context.removeRoute("baz");
+
+ assertTrue(context.hasEndpoint("seda://start?multipleConsumers=true") != null);
+ assertTrue(context.hasEndpoint("log://foo") != null);
+ assertFalse(context.hasEndpoint("log://bar") != null);
+ assertTrue(context.hasEndpoint("mock://result") != null);
+ assertFalse(context.hasEndpoint("seda://stop") != null);
+ assertFalse(context.hasEndpoint("mock://stop") != null);
+
+ // stop camel which should stop the endpoint
+
+ context.stop();
+
+ assertFalse("Should not be started", ((ServiceSupport) seda).isStarted());
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("seda:start?multipleConsumers=true").routeId("foo")
+ .to("log:foo").to("mock:result");
+
+ from("seda:start?multipleConsumers=true").routeId("bar")
+ .to("log:bar").to("log:bar").to("mock:result");
+
+ from("seda:stop").routeId("baz")
+ .to("mock:stop");
+ }
+ };
+ }
+
+}
[2/3] camel git commit: CAMEL-8562: Removing a route - Should check
if the route input endpoint is static and used by other routes
Posted by da...@apache.org.
CAMEL-8562: Removing a route - Should check if the route input endpoint is static and used by other routes
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9e807e0a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9e807e0a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9e807e0a
Branch: refs/heads/camel-2.15.x
Commit: 9e807e0a6d6fee36702ee9ef3028f7ee3a3d87c5
Parents: b18addd
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Mar 27 18:47:35 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Mar 28 07:54:23 2015 +0100
----------------------------------------------------------------------
.../src/main/java/org/apache/camel/impl/RouteService.java | 5 +++++
.../Endpoint2MustBeStartedBeforeSendProcessorTest.java | 2 ++
.../processor/EndpointMustBeStartedBeforeSendProcessorTest.java | 2 ++
3 files changed, 9 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/9e807e0a/camel-core/src/main/java/org/apache/camel/impl/RouteService.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/RouteService.java b/camel-core/src/main/java/org/apache/camel/impl/RouteService.java
index ed4f947..462fb5e 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/RouteService.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/RouteService.java
@@ -142,6 +142,11 @@ public class RouteService extends ChildServiceSupport {
// endpoints should only be started once as they can be reused on other routes
// and whatnot, thus their lifecycle is to start once, and only to stop when Camel shutdown
for (Route route : routes) {
+ // ensure endpoints is registered in the registry
+ String uri = route.getEndpoint().getEndpointUri();
+ if (camelContext.hasEndpoint(uri) == null) {
+ camelContext.addEndpoint(uri, route.getEndpoint());
+ }
// ensure endpoint is started first (before the route services, such as the consumer)
ServiceHelper.startService(route.getEndpoint());
}
http://git-wip-us.apache.org/repos/asf/camel/blob/9e807e0a/camel-core/src/test/java/org/apache/camel/processor/Endpoint2MustBeStartedBeforeSendProcessorTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/Endpoint2MustBeStartedBeforeSendProcessorTest.java b/camel-core/src/test/java/org/apache/camel/processor/Endpoint2MustBeStartedBeforeSendProcessorTest.java
index 29cfb68..637c80a 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/Endpoint2MustBeStartedBeforeSendProcessorTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/Endpoint2MustBeStartedBeforeSendProcessorTest.java
@@ -95,6 +95,8 @@ public class Endpoint2MustBeStartedBeforeSendProcessorTest extends ContextTestSu
});
context.start();
+ assertTrue("Should be static endpoint", context.getEndpointRegistry().isStatic(myendpoint.getEndpointKey()));
+
assertEquals("EndpointProducerConsumer", order);
order = "";
http://git-wip-us.apache.org/repos/asf/camel/blob/9e807e0a/camel-core/src/test/java/org/apache/camel/processor/EndpointMustBeStartedBeforeSendProcessorTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/EndpointMustBeStartedBeforeSendProcessorTest.java b/camel-core/src/test/java/org/apache/camel/processor/EndpointMustBeStartedBeforeSendProcessorTest.java
index 19cd537..0e3a347 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/EndpointMustBeStartedBeforeSendProcessorTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/EndpointMustBeStartedBeforeSendProcessorTest.java
@@ -95,6 +95,8 @@ public class EndpointMustBeStartedBeforeSendProcessorTest extends ContextTestSup
});
context.start();
+ assertTrue("Should be static endpoint", context.getEndpointRegistry().isStatic(myendpoint.getEndpointKey()));
+
assertEquals("EndpointProducerConsumer", order);
order = "";
[3/3] camel git commit: CAMEL-8563: camel-ftp - Add support for
account option for login
Posted by da...@apache.org.
CAMEL-8563: camel-ftp - Add support for account option for login
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/4bc81b1f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4bc81b1f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4bc81b1f
Branch: refs/heads/camel-2.15.x
Commit: 4bc81b1f692561119b76d611a5538b000800daf9
Parents: 9e807e0
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Mar 28 07:40:48 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Mar 28 07:54:29 2015 +0100
----------------------------------------------------------------------
.../component/file/remote/FtpConfiguration.java | 14 ++++++++++
.../component/file/remote/FtpOperations.java | 20 +++++++++++---
.../file/remote/FromFtpNoopAccountTest.java | 29 ++++++++++++++++++++
.../component/file/remote/FromFtpNoopTest.java | 2 +-
4 files changed, 60 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/4bc81b1f/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConfiguration.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConfiguration.java
index ec5ca4c..f2eb42e 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConfiguration.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConfiguration.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.file.remote;
import java.net.URI;
+import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriParams;
/**
@@ -28,6 +29,9 @@ public class FtpConfiguration extends RemoteFileConfiguration {
public static final int DEFAULT_FTP_PORT = 21;
+ @UriParam
+ private String account;
+
public FtpConfiguration() {
setProtocol("ftp");
}
@@ -41,4 +45,14 @@ public class FtpConfiguration extends RemoteFileConfiguration {
setPort(DEFAULT_FTP_PORT);
}
+ public String getAccount() {
+ return account;
+ }
+
+ /**
+ * Account to use for login
+ */
+ public void setAccount(String account) {
+ this.account = account;
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/4bc81b1f/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
----------------------------------------------------------------------
diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
index b5384ef..74dbf6f 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
@@ -73,6 +73,7 @@ public class FtpOperations implements RemoteFileOperations<FTPFile> {
String host = configuration.getHost();
int port = configuration.getPort();
String username = configuration.getUsername();
+ String account = ((FtpConfiguration) configuration).getAccount();
if (clientConfig != null) {
log.trace("Configuring FTPClient with config: {}", clientConfig);
@@ -155,11 +156,22 @@ public class FtpOperations implements RemoteFileOperations<FTPFile> {
try {
boolean login;
if (username != null) {
- log.trace("Attempting to login user: {} using password: {}", username, configuration.getPassword());
- login = client.login(username, configuration.getPassword());
+ if (account != null) {
+ log.trace("Attempting to login user: {} using password: {} and account: {}", new Object[]{username, configuration.getPassword(), account});
+ login = client.login(username, configuration.getPassword(), account);
+ } else {
+ log.trace("Attempting to login user: {} using password: {}", username, configuration.getPassword());
+ login = client.login(username, configuration.getPassword());
+ }
} else {
- log.trace("Attempting to login anonymous");
- login = client.login("anonymous", "");
+ if (account != null) {
+ // not sure if it makes sense to login anonymous with account?
+ log.trace("Attempting to login anonymous using account: {}", account);
+ login = client.login("anonymous", "", account);
+ } else {
+ log.trace("Attempting to login anonymous");
+ login = client.login("anonymous", "");
+ }
}
log.trace("User {} logged in: {}", username != null ? username : "anonymous", login);
if (!login) {
http://git-wip-us.apache.org/repos/asf/camel/blob/4bc81b1f/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopAccountTest.java
----------------------------------------------------------------------
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopAccountTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopAccountTest.java
new file mode 100644
index 0000000..2601bc7
--- /dev/null
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopAccountTest.java
@@ -0,0 +1,29 @@
+/**
+ * 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.file.remote;
+
+/**
+ * Unit test to test account option.
+ */
+public class FromFtpNoopAccountTest extends FromFtpNoopTest {
+
+ @Override
+ protected String getFtpUrl() {
+ return "ftp://admin@localhost:" + getPort() + "/noop?password=admin&account=me&binary=false&noop=true";
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/4bc81b1f/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopTest.java
----------------------------------------------------------------------
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopTest.java
index 1e3cca4..d102251 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopTest.java
@@ -31,7 +31,7 @@ import org.junit.Test;
*/
public class FromFtpNoopTest extends FtpServerTestSupport {
- private String getFtpUrl() {
+ protected String getFtpUrl() {
return "ftp://admin@localhost:" + getPort() + "/noop?password=admin&binary=false&noop=true";
}