You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2017/08/12 07:59:50 UTC
camel git commit: ClusteredRouteController: use spring-boot to spin
up the boostrap node
Repository: camel
Updated Branches:
refs/heads/master d043c7d0a -> 68bd833a6
ClusteredRouteController: use spring-boot to spin up the boostrap node
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/68bd833a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/68bd833a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/68bd833a
Branch: refs/heads/master
Commit: 68bd833a6ee330d48ee2f5d703ef2f9f1728d23d
Parents: d043c7d
Author: lburgazzoli <lb...@gmail.com>
Authored: Sat Aug 12 09:59:28 2017 +0200
Committer: lburgazzoli <lb...@gmail.com>
Committed: Sat Aug 12 09:59:28 2017 +0200
----------------------------------------------------------------------
.../cluster-bootstrap/pom.xml | 29 ++++---------
.../examples/cluster/ClusterBootstrap.java | 31 ++++++--------
.../cluster/ClusterBootstrapConfiguration.java | 44 ++++++++++++++++++++
.../src/main/resources/application.properties | 7 ++++
.../src/main/resources/log4j2.xml | 18 --------
.../readme.adoc | 2 +-
6 files changed, 74 insertions(+), 57 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/68bd833a/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/pom.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/pom.xml b/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/pom.xml
index f86fb3b..ce89de4 100644
--- a/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/pom.xml
+++ b/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/pom.xml
@@ -35,41 +35,30 @@
<dependencies>
<dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ <version>${spring-boot-version}</version>
+ </dependency>
+ <dependency>
<groupId>io.atomix</groupId>
<artifactId>atomix-all</artifactId>
<version>${atomix-version}</version>
</dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
- </dependency>
</dependencies>
<build>
<plugins>
<plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.6.0</version>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <version>${spring-boot-version}</version>
<executions>
<execution>
<goals>
- <goal>java</goal>
+ <goal>repackage</goal>
</goals>
</execution>
</executions>
- <configuration>
- <includeProjectDependencies>true</includeProjectDependencies>
- <mainClass>org.apache.camel.examples.cluster.ClusterBootstrap</mainClass>
- </configuration>
</plugin>
</plugins>
</build>
http://git-wip-us.apache.org/repos/asf/camel/blob/68bd833a/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/src/main/java/org/apache/camel/examples/cluster/ClusterBootstrap.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/src/main/java/org/apache/camel/examples/cluster/ClusterBootstrap.java b/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/src/main/java/org/apache/camel/examples/cluster/ClusterBootstrap.java
index 1115524..3f98fed 100644
--- a/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/src/main/java/org/apache/camel/examples/cluster/ClusterBootstrap.java
+++ b/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/src/main/java/org/apache/camel/examples/cluster/ClusterBootstrap.java
@@ -16,26 +16,21 @@
*/
package org.apache.camel.examples.cluster;
-import io.atomix.AtomixReplica;
-import io.atomix.catalyst.transport.Address;
-import io.atomix.catalyst.transport.netty.NettyTransport;
-import io.atomix.copycat.server.storage.Storage;
-import io.atomix.copycat.server.storage.StorageLevel;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
-public final class ClusterBootstrap {
- private ClusterBootstrap() {
- }
+//CHECKSTYLE:OFF
+/**
+ * A sample Spring Boot application that starts the Atomix boostsrap node.
+ */
+@SpringBootApplication
+public class ClusterBootstrap {
+ /**
+ * A main method to start this application.
+ */
public static void main(String[] args) {
- String address = System.getProperty("cluster.address", "127.0.0.1:8700");
-
- AtomixReplica.builder(new Address(address))
- .withTransport(new NettyTransport())
- .withStorage(Storage.builder()
- .withStorageLevel(StorageLevel.MEMORY)
- .build())
- .build()
- .bootstrap()
- .join();
+ SpringApplication.run(ClusterBootstrap.class, args);
}
}
+//CHECKSTYLE:ON
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/68bd833a/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/src/main/java/org/apache/camel/examples/cluster/ClusterBootstrapConfiguration.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/src/main/java/org/apache/camel/examples/cluster/ClusterBootstrapConfiguration.java b/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/src/main/java/org/apache/camel/examples/cluster/ClusterBootstrapConfiguration.java
new file mode 100644
index 0000000..9e80a95
--- /dev/null
+++ b/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/src/main/java/org/apache/camel/examples/cluster/ClusterBootstrapConfiguration.java
@@ -0,0 +1,44 @@
+/**
+ * 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.examples.cluster;
+
+import io.atomix.AtomixReplica;
+import io.atomix.catalyst.transport.Address;
+import io.atomix.catalyst.transport.netty.NettyTransport;
+import io.atomix.copycat.server.storage.Storage;
+import io.atomix.copycat.server.storage.StorageLevel;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class ClusterBootstrapConfiguration {
+ @Value("${cluster.address}")
+ private String address;
+
+ @Bean(destroyMethod = "shutdown")
+ public AtomixReplica atomix() {
+ return AtomixReplica.builder(new Address(address))
+ .withTransport(new NettyTransport())
+ .withStorage(Storage.builder()
+ .withStorageLevel(StorageLevel.MEMORY)
+ .build())
+ .build()
+ .bootstrap()
+ .join();
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/68bd833a/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/src/main/resources/application.properties
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/src/main/resources/application.properties b/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/src/main/resources/application.properties
new file mode 100644
index 0000000..1b4b220
--- /dev/null
+++ b/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/src/main/resources/application.properties
@@ -0,0 +1,7 @@
+
+debug = false
+
+logging.level.org.springframework = INFO
+logging.level.io.atomix = DEBUG
+
+cluster.address = 127.0.0.1:8700
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/68bd833a/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/src/main/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/src/main/resources/log4j2.xml b/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/src/main/resources/log4j2.xml
deleted file mode 100644
index 06e8664..0000000
--- a/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/src/main/resources/log4j2.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Configuration status="INFO">
- <Appenders>
- <Console name="Console" target="SYSTEM_OUT">
- <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
- </Console>
- <File name="File" fileName="target/cluster-bootstrap.log" immediateFlush="false" append="false">
- <PatternLayout pattern="%d{yyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
- </File>
- </Appenders>
- <Loggers>
- <Logger name="io.atomix" level="DEBUG"/>
-
- <Root level="INFO">
- <AppenderRef ref="Console" />
- </Root>
- </Loggers>
-</Configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/68bd833a/examples/camel-example-spring-boot-clustered-route-controller/readme.adoc
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-boot-clustered-route-controller/readme.adoc b/examples/camel-example-spring-boot-clustered-route-controller/readme.adoc
index 38cc96f..aff5405 100644
--- a/examples/camel-example-spring-boot-clustered-route-controller/readme.adoc
+++ b/examples/camel-example-spring-boot-clustered-route-controller/readme.adoc
@@ -10,7 +10,7 @@ This example shows how to work with a simple Apache Camel application using Spri
2. in a shell, run the cluster node
+
- mvn -pl cluster-bootstrap exec:java
+ mvn -pl cluster-bootstrap spring-boot:run
3. in a separate shell, run the first camel node
+