Added data flow server with automated deploy on startup
This commit is contained in:
5
platform-services/data-flow-server/docker/Dockerfile
Normal file
5
platform-services/data-flow-server/docker/Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
||||
FROM anapsix/alpine-java:8
|
||||
VOLUME /tmp
|
||||
ADD data-flow-server-1.0-SNAPSHOT.jar app.jar
|
||||
RUN bash -c 'touch /app.jar'
|
||||
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
|
||||
83
platform-services/data-flow-server/pom.xml
Normal file
83
platform-services/data-flow-server/pom.xml
Normal file
@@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>data-flow-server</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>org.kbastani</groupId>
|
||||
<artifactId>platform-services</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-dataflow-server-local</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dataflow-rest-client</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dataflow-dependencies</artifactId>
|
||||
<version>1.1.0.RELEASE</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>0.4.13</version>
|
||||
<configuration>
|
||||
<imageName>${project.artifactId}</imageName>
|
||||
<dockerDirectory>${project.basedir}/docker</dockerDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>/</targetPath>
|
||||
<directory>${project.build.directory}</directory>
|
||||
<include>${project.build.finalName}.jar</include>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build-image</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.example;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.dataflow.server.EnableDataFlowServer;
|
||||
|
||||
@EnableDataFlowServer
|
||||
@SpringBootApplication
|
||||
public class DataFlowApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DataFlowApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.example;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.cloud.dataflow.rest.client.DataFlowTemplate;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class ImportResources implements ApplicationListener<ApplicationReadyEvent> {
|
||||
|
||||
@Value("${server.port}")
|
||||
private String port;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationReadyEvent event) {
|
||||
URI baseUri = URI.create("http://localhost:" + port);
|
||||
DataFlowTemplate dataFlowTemplate = new DataFlowTemplate(baseUri);
|
||||
try {
|
||||
// Import event stream apps
|
||||
dataFlowTemplate.appRegistryOperations()
|
||||
.importFromResource(new URL(baseUri.toURL(), "app.properties").toString(), false);
|
||||
|
||||
// Import RabbitMQ stream apps
|
||||
dataFlowTemplate.appRegistryOperations()
|
||||
.importFromResource("http://bit.ly/stream-applications-rabbit-maven", false);
|
||||
|
||||
// Deploy a set of event stream definitions
|
||||
List<StreamApp> streams = Arrays.asList(
|
||||
new StreamApp("account-stream",
|
||||
"account-web: account-web | account-worker: account-worker"),
|
||||
new StreamApp("order-stream",
|
||||
"order-web: order-web | order-worker: order-worker"),
|
||||
new StreamApp("payment-stream",
|
||||
"payment-web: payment-web | payment-worker: payment-worker"),
|
||||
new StreamApp("warehouse-stream",
|
||||
"warehouse-web: warehouse-web | warehouse-worker: warehouse-worker"));
|
||||
|
||||
// Deploy the streams in parallel
|
||||
streams.parallelStream()
|
||||
.forEach(stream -> dataFlowTemplate.streamOperations()
|
||||
.createStream(stream.getName(), stream.getDefinition(), true));
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
static class StreamApp {
|
||||
private String name;
|
||||
private String definition;
|
||||
|
||||
public StreamApp(String name, String definition) {
|
||||
this.name = name;
|
||||
this.definition = definition;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDefinition() {
|
||||
return definition;
|
||||
}
|
||||
|
||||
public void setDefinition(String definition) {
|
||||
this.definition = definition;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
server:
|
||||
port: ${PORT:9393}
|
||||
spring:
|
||||
application:
|
||||
name: data-flow-server
|
||||
@@ -0,0 +1,8 @@
|
||||
source.account-web=maven://org.kbastani:account-web:0.0.1-SNAPSHOT
|
||||
sink.account-worker=maven://org.kbastani:account-worker:0.0.1-SNAPSHOT
|
||||
source.order-web=maven://org.kbastani:order-web:0.0.1-SNAPSHOT
|
||||
sink.order-worker=maven://org.kbastani:order-worker:0.0.1-SNAPSHOT
|
||||
source.payment-web=maven://org.kbastani:payment-web:0.0.1-SNAPSHOT
|
||||
sink.payment-worker=maven://org.kbastani:payment-worker:0.0.1-SNAPSHOT
|
||||
source.warehouse-web=maven://org.kbastani:warehouse-web:0.0.1-SNAPSHOT
|
||||
sink.warehouse-worker=maven://org.kbastani:warehouse-worker:0.0.1-SNAPSHOT
|
||||
@@ -25,5 +25,6 @@
|
||||
|
||||
<modules>
|
||||
<module>discovery</module>
|
||||
<module>data-flow-server</module>
|
||||
</modules>
|
||||
</project>
|
||||
Reference in New Issue
Block a user