Start Dockerized
Dynamic configuration started
This commit is contained in:
parent
30ccfa9604
commit
945c57ddfd
44 changed files with 1544 additions and 321 deletions
|
|
@ -66,6 +66,14 @@
|
|||
<orderEntry type="library" name="Maven: org.apache.camel:camel-spring-boot:2.23.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.camel:camel-spring:2.23.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.camel:camel-core-starter:2.23.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.camel:camel-quartz2:2.23.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.camel:camel-core:2.23.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.quartz-scheduler:quartz:2.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.mchange:mchange-commons-java:0.2.11" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.mchange:c3p0:0.9.5.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-core:2.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-impl:2.3.0" level="project" />
|
||||
<orderEntry type="module" module-name="drools-framework-business-indexer-persistence" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-elasticsearch:2.1.0.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-elasticsearch:3.1.2.RELEASE" level="project" />
|
||||
|
|
@ -122,14 +130,16 @@
|
|||
<orderEntry type="library" name="Maven: io.netty:netty-handler:4.1.29.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-resolver:4.1.29.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-transport:4.1.29.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.0" level="project" />
|
||||
<orderEntry type="module" module-name="drools-framewwork-business-proxy-persistence" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-mongodb:2.1.0.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mongodb:mongodb-driver:3.8.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mongodb:bson:3.8.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mongodb:mongodb-driver-core:3.8.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-mongodb:2.1.2.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.camel:camel-ftp:2.23.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.camel:camel-core:2.23.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.jcraft:jsch:0.1.54" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-net:commons-net:3.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-core:2.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-impl:2.3.0" level="project" />
|
||||
<orderEntry type="module" module-name="drools-framework-runtime-entity" />
|
||||
<orderEntry type="module" module-name="drools-framework-common" />
|
||||
<orderEntry type="library" name="Maven: junit:junit:4.12" level="project" />
|
||||
|
|
|
|||
|
|
@ -48,13 +48,20 @@
|
|||
<artifactId>camel-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.camel</groupId>
|
||||
<artifactId>camel-quartz2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pymmasoftware.jbpm</groupId>
|
||||
<artifactId>drools-framework-business-indexer-persistence</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.pymmasoftware.jbpm</groupId>
|
||||
<artifactId>drools-framework-business-proxy-persistence</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.camel</groupId>
|
||||
<artifactId>camel-ftp</artifactId>
|
||||
|
|
@ -83,4 +90,126 @@
|
|||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>docker-build</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>io.fabric8</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>0.21.0</version>
|
||||
|
||||
<configuration>
|
||||
<!--registry>192.168.1.184:12500</registry-->
|
||||
<dockerHost>${docker.Host}</dockerHost>
|
||||
|
||||
<!-- this is for Mac and Amazon Linux -->
|
||||
<!--dockerHost>unix:///var/run/docker.sock</dockerHost-->
|
||||
|
||||
<verbose>true</verbose>
|
||||
<images>
|
||||
<image>
|
||||
<name>runtime-indexer</name>
|
||||
<build>
|
||||
<dockerFileDir>${project.basedir}/src/main/docker</dockerFileDir>
|
||||
|
||||
<!--copies Jar to the maven directory (uses Assembly system)-->
|
||||
<assembly>
|
||||
<descriptorRef>artifact</descriptorRef>
|
||||
</assembly>
|
||||
<tags>
|
||||
<tag>latest</tag>
|
||||
</tags>
|
||||
|
||||
</build>
|
||||
|
||||
<run>
|
||||
<extraHosts>
|
||||
<host>mongodb:192.168.43.94</host>
|
||||
<host>elasticsearchhost:192.168.43.94</host>
|
||||
</extraHosts>
|
||||
|
||||
</run>
|
||||
</image>
|
||||
</images>
|
||||
</configuration>
|
||||
|
||||
<executions>
|
||||
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
|
||||
|
||||
</executions>
|
||||
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>docker-deploy</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>io.fabric8</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>0.21.0</version>
|
||||
|
||||
<configuration>
|
||||
<!--registry>192.168.1.184:12500</registry-->
|
||||
<dockerHost>${docker.Host}</dockerHost>
|
||||
|
||||
<!-- this is for Mac and Amazon Linux -->
|
||||
<!--dockerHost>unix:///var/run/docker.sock</dockerHost-->
|
||||
|
||||
<verbose>true</verbose>
|
||||
<images>
|
||||
<image>
|
||||
<name>runtime-indexer</name>
|
||||
<build>
|
||||
<dockerFileDir>${project.basedir}/src/main/docker</dockerFileDir>
|
||||
|
||||
<!--copies Jar to the maven directory (uses Assembly system)-->
|
||||
<assembly>
|
||||
<descriptorRef>artifact</descriptorRef>
|
||||
</assembly>
|
||||
<tags>
|
||||
<tag>latest</tag>
|
||||
</tags>
|
||||
|
||||
</build>
|
||||
|
||||
<run>
|
||||
<extraHosts>
|
||||
<host>mongodb:192.168.1.100</host>
|
||||
</extraHosts>
|
||||
|
||||
</run>
|
||||
</image>
|
||||
</images>
|
||||
</configuration>
|
||||
|
||||
<executions>
|
||||
|
||||
|
||||
<execution>
|
||||
<id>mydeploy</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>push</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
|
||||
</executions>
|
||||
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
FROM openjdk:8-jre-slim
|
||||
|
||||
|
||||
ADD application.properties /application.properties
|
||||
ADD maven/drools-framework-business-indexer-app-1.0-SNAPSHOT.jar app.jar
|
||||
|
||||
|
||||
|
||||
RUN bash -c 'touch /app.jar'
|
||||
|
||||
ENTRYPOINT ["java","-Dspring.config.location=file:./","-jar","/app.jar"]
|
||||
#ENTRYPOINT ["java","-jar","/app.jar"]
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
spring.data.elasticsearch.cluster-nodes=elasticsearchhost:9300
|
||||
|
||||
kieserver.login=kieserver
|
||||
kieserver.password=kieserver1
|
||||
server.port=8070
|
||||
spring.data.mongodb.database=businessProxyDB
|
||||
spring.data.mongodb.host=mongodb:27017
|
||||
|
|
@ -20,10 +20,12 @@ import org.springframework.boot.SpringApplication;
|
|||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
|
||||
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
|
||||
|
||||
// CHECKSTYLE:OFF
|
||||
@SpringBootApplication
|
||||
@Configuration
|
||||
@EnableMongoRepositories(basePackages = "org.chtijbug.drools.proxy.persistence.repository")
|
||||
@EnableElasticsearchRepositories(basePackages = "org.chtijbug.drools.indexer.persistence.repository")
|
||||
public class DroolsBusinessIndexerServer {
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
package org.chtijbug.drools.indexer.route;
|
||||
|
||||
import org.apache.camel.builder.RouteBuilder;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class DeclareNewSftpRouter extends RouteBuilder {
|
||||
@Override
|
||||
public void configure() throws Exception {
|
||||
from("quartz2://myGroup/myTimerName?cron=0+0/1+*+?+*+MON-FRI").to("bean:startRouteService?method=updateConfig()");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +1,37 @@
|
|||
package org.chtijbug.drools.indexer.route;
|
||||
|
||||
import org.apache.camel.builder.RouteBuilder;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
|
||||
public class IndexerRoute extends RouteBuilder {
|
||||
@Value("${kieserver.login}")
|
||||
|
||||
private String login;
|
||||
@Value("${kieserver.password}")
|
||||
|
||||
private String password;
|
||||
|
||||
private String host;
|
||||
|
||||
private String port;
|
||||
|
||||
private String id;
|
||||
|
||||
public IndexerRoute(String id,String login, String password, String host, String port) {
|
||||
this.login = login;
|
||||
this.password = password;
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.id=id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void configure() throws Exception {
|
||||
System.out.println("coucou");
|
||||
|
||||
//from("sftp://foo@myserver?password=secret&ftpClient.dataTimeout=30000").to("bean:foo");
|
||||
String url="sftp://"+login+"@localhost:9080?password="+password+"&move=.done";
|
||||
from(url).to("bean:storeService?method=store(${header.CamelFileName},${body})");
|
||||
String url="sftp://"+login+"@"+host+":"+port+"?password="+password+"&move=.done";
|
||||
from(url).routeId(id).to("bean:storeService?method=store(${header.CamelFileName},${body})");
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,69 @@
|
|||
package org.chtijbug.drools.indexer.service;
|
||||
|
||||
|
||||
import org.apache.camel.CamelContext;
|
||||
import org.chtijbug.drools.indexer.route.IndexerRoute;
|
||||
import org.chtijbug.drools.proxy.persistence.model.RuntimePersist;
|
||||
import org.chtijbug.drools.proxy.persistence.repository.RuntimeRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("startRouteService")
|
||||
public class StartRouteService {
|
||||
@Value("${kieserver.login}")
|
||||
private String login;
|
||||
@Value("${kieserver.password}")
|
||||
private String password;
|
||||
@Autowired
|
||||
CamelContext camelContext;
|
||||
@Autowired
|
||||
RuntimeRepository runtimeRepository;
|
||||
|
||||
|
||||
private Map<String,RuntimePersist> routes = new HashMap<>();
|
||||
private Map<String,IndexerRoute> routesCamel = new HashMap<>();
|
||||
|
||||
|
||||
|
||||
public void updateConfig() throws Exception {
|
||||
for (RuntimePersist runtime : runtimeRepository.findAll()){
|
||||
if (routes.containsKey(runtime.getId())==false){
|
||||
IndexerRoute indexerRoute =new IndexerRoute(runtime.getId(),login,password,runtime.getSftpHost(),runtime.getSftpPort());
|
||||
camelContext.addRoutes(indexerRoute);
|
||||
routes.put(runtime.getSftpHost()+":"+runtime.getSftpPort(),runtime.duplicate());
|
||||
routesCamel.put(runtime.getSftpHost()+":"+runtime.getSftpPort(),indexerRoute);
|
||||
}else{
|
||||
RuntimePersist existingRoutes = routes.get(runtime.getId());
|
||||
if (!existingRoutes.getSftpHost().equals(runtime.getSftpHost())
|
||||
|| !existingRoutes.getSftpPort().equals(runtime.getSftpPort())){
|
||||
//routes must be reloaded
|
||||
IndexerRoute routeToDelete=routesCamel.get(runtime.getId());
|
||||
routesCamel.remove(runtime.getId());
|
||||
camelContext.removeRoute(runtime.getId());
|
||||
routes.remove(runtime.getId());
|
||||
|
||||
IndexerRoute indexerRoute =new IndexerRoute(runtime.getId(),login,password,runtime.getSftpHost(),runtime.getSftpPort());
|
||||
camelContext.addRoutes(indexerRoute);
|
||||
routes.put(runtime.getId(),runtime.duplicate());
|
||||
routesCamel.put(runtime.getId(),indexerRoute);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void constructIndexerRoute() throws Exception {
|
||||
for (RuntimePersist runtime : runtimeRepository.findAll()){
|
||||
IndexerRoute indexerRoute =new IndexerRoute(runtime.getId(),login,password,runtime.getSftpHost(),runtime.getSftpPort());
|
||||
camelContext.addRoutes(indexerRoute);
|
||||
|
||||
routes.put(runtime.getId(),runtime.duplicate());
|
||||
routesCamel.put(runtime.getId(),indexerRoute);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,4 +2,6 @@ spring.data.elasticsearch.cluster-nodes=localhost:9300
|
|||
|
||||
kieserver.login=kieserver
|
||||
kieserver.password=kieserver1
|
||||
server.port=8070
|
||||
|
||||
spring.data.mongodb.database=businessProxyDB
|
||||
spring.data.mongodb.host=localhost:27017
|
||||
|
|
@ -230,5 +230,131 @@
|
|||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>docker-build</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>io.fabric8</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>0.21.0</version>
|
||||
|
||||
<configuration>
|
||||
<!--registry>192.168.1.184:12500</registry-->
|
||||
<dockerHost>${docker.Host}</dockerHost>
|
||||
|
||||
<!-- this is for Mac and Amazon Linux -->
|
||||
<!--dockerHost>unix:///var/run/docker.sock</dockerHost-->
|
||||
|
||||
<verbose>true</verbose>
|
||||
<images>
|
||||
<image>
|
||||
<name>runtime-proxy</name>
|
||||
<build>
|
||||
<dockerFileDir>${project.basedir}/src/main/docker</dockerFileDir>
|
||||
|
||||
<!--copies Jar to the maven directory (uses Assembly system)-->
|
||||
<assembly>
|
||||
<descriptorRef>artifact</descriptorRef>
|
||||
</assembly>
|
||||
<tags>
|
||||
<tag>latest</tag>
|
||||
</tags>
|
||||
|
||||
</build>
|
||||
|
||||
<run>
|
||||
<extraHosts>
|
||||
<host>mongodb:172.17.0.1</host>
|
||||
<host>kie-wb:172.17.0.1</host>
|
||||
</extraHosts>
|
||||
<ports>
|
||||
<port>8200:8200</port>
|
||||
<port>9080:9080</port>
|
||||
</ports>
|
||||
</run>
|
||||
</image>
|
||||
</images>
|
||||
</configuration>
|
||||
|
||||
<executions>
|
||||
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
|
||||
|
||||
</executions>
|
||||
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>docker-deploy</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>io.fabric8</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>0.21.0</version>
|
||||
|
||||
<configuration>
|
||||
<!--registry>192.168.1.184:12500</registry-->
|
||||
<dockerHost>${docker.Host}</dockerHost>
|
||||
|
||||
<!-- this is for Mac and Amazon Linux -->
|
||||
<!--dockerHost>unix:///var/run/docker.sock</dockerHost-->
|
||||
|
||||
<verbose>true</verbose>
|
||||
<images>
|
||||
<image>
|
||||
<name>runtime-proxy</name>
|
||||
<build>
|
||||
<dockerFileDir>${project.basedir}/src/main/docker</dockerFileDir>
|
||||
|
||||
<!--copies Jar to the maven directory (uses Assembly system)-->
|
||||
<assembly>
|
||||
<descriptorRef>artifact</descriptorRef>
|
||||
</assembly>
|
||||
<tags>
|
||||
<tag>latest</tag>
|
||||
</tags>
|
||||
|
||||
</build>
|
||||
|
||||
<run>
|
||||
<extraHosts>
|
||||
<host>mongodb:192.168.1.100</host>
|
||||
</extraHosts>
|
||||
<ports>
|
||||
<port>8080:8080</port>
|
||||
</ports>
|
||||
</run>
|
||||
</image>
|
||||
</images>
|
||||
</configuration>
|
||||
|
||||
<executions>
|
||||
|
||||
|
||||
<execution>
|
||||
<id>mydeploy</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>push</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
|
||||
</executions>
|
||||
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
FROM openjdk:8-jre-slim
|
||||
|
||||
EXPOSE 8200
|
||||
EXPOSE 9080
|
||||
ADD application.properties /application.properties
|
||||
ADD maven/drools-framework-business-proxy-app-1.0-SNAPSHOT.jar app.jar
|
||||
|
||||
RUN mkdir /m2_kieserver
|
||||
RUN mkdir /m2_kieserver/repository
|
||||
ADD settings.xml /m2_kieserver/settings.xml
|
||||
RUN mkdir /trace
|
||||
RUN mkdir /niodir-kieserver
|
||||
|
||||
|
||||
RUN bash -c 'touch /app.jar'
|
||||
|
||||
ENTRYPOINT ["java","-Dspring.config.location=file:/ -DM2_HOME=/m2_kieserver -Dorg.chtijbug.server.tracedir=/trace -Dorg.appformer.m2repo.url=http://kie-wb:8080/kie-wb/maven2 -Dorg.uberfire.nio.git.dir=/niodir-kieserver -Dkie.maven.settings.custom=/m2_kieserver/settings.xml -Dorg.kie.server.repo=/niodir-kieserver -Dfile.encoding=UTF-8 -Duser.language=fr -Duser.country=FR -Dorg.kie.server.id=server1 -Dorg.chtijbug.server.sftpPort=9080","-jar","/app.jar"]
|
||||
#ENTRYPOINT ["java","-jar","/app.jar"]
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
## ---------------------------------------------------------------------------
|
||||
## 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.
|
||||
## ---------------------------------------------------------------------------
|
||||
# the name of Camel
|
||||
server.port=8090
|
||||
camel.springboot.name=MyCamel
|
||||
# to reconfigure the camel servlet context-path mapping to use /api/* instead of /camel/*
|
||||
camel.component.servlet.mapping.context-path=/api/*
|
||||
spring.data.mongodb.database=businessProxyDB
|
||||
spring.data.mongodb.host=mongodb:27017
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
<settings>
|
||||
|
||||
<localRepository>/m2_kieserver/repository</localRepository>
|
||||
<servers>
|
||||
<server>
|
||||
<id>guvnor-m2-repo</id>
|
||||
<username>admin</username>
|
||||
<password>admin</password>
|
||||
<configuration>
|
||||
<wagonProvider>httpclient</wagonProvider>
|
||||
<httpConfiguration>
|
||||
<all>
|
||||
<usePreemptive>true</usePreemptive>
|
||||
</all>
|
||||
</httpConfiguration>
|
||||
</configuration>
|
||||
</server>
|
||||
</servers>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>kie</id>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>guvnor-m2-repo</id>
|
||||
<name>Guvnor M2 Repo</name>
|
||||
<url>http://kie-wb:8080/kie-wb/maven2/</url>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<layout>default</layout>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>guvnor-m2-repo</id>
|
||||
<name>Guvnor M2 Repo</name>
|
||||
<url>http://kie-wb:8080/kie-wb/maven2/</url>
|
||||
<layout>default</layout>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
</snapshots>
|
||||
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</profile>
|
||||
</profiles>
|
||||
<activeProfiles>
|
||||
<activeProfile>kie</activeProfile>
|
||||
</activeProfiles>
|
||||
</settings>
|
||||
|
|
@ -7,6 +7,6 @@ import org.springframework.stereotype.Component;
|
|||
public class AutodeployRouter extends RouteBuilder {
|
||||
@Override
|
||||
public void configure() throws Exception {
|
||||
from("quartz2://myGroup/myTimerName?cron=0+0/1+*+?+*+MON-FRI").to("bean:kieService?method=updateConfig()");
|
||||
from("quartz2://myGroup/myTimerName?cron=0/5+*+*+?+*+*").to("bean:kieService?method=updateConfig()");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ public class DroolsRouter extends RouteBuilder {
|
|||
@Override
|
||||
public void configure() throws Exception {
|
||||
rest("/" + containerId).description(containerId + " Rest service")
|
||||
|
||||
.consumes("application/json")
|
||||
.produces("application/json")
|
||||
|
||||
|
|
@ -34,6 +35,7 @@ public class DroolsRouter extends RouteBuilder {
|
|||
// .param().name("containerId").type(path).description("Container ID where the rule artefact id deployed").dataType("integer").endParam()
|
||||
.param().name("body").type(body).description("The Data drools should work on").endParam()
|
||||
.responseMessage().code(200).message("Data drools worked on").endResponseMessage()
|
||||
|
||||
.to("bean:ruleService?method=runSessionObject(${header.transactionId}," + this.containerId + "," + this.processID + ",${body})");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ package org.chtijbug.drools.proxy.service;
|
|||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.apache.camel.CamelContext;
|
||||
import org.apache.camel.Route;
|
||||
import org.chtijbug.drools.proxy.camel.DroolsRouter;
|
||||
import org.chtijbug.drools.proxy.persistence.model.ContainerPojoPersist;
|
||||
import org.chtijbug.drools.proxy.persistence.model.RuntimePersist;
|
||||
|
|
@ -38,15 +39,13 @@ import org.springframework.beans.factory.annotation.Value;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
import javax.inject.Inject;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
@Service("kieService")
|
||||
public class KieServiceCommon {
|
||||
|
|
@ -68,6 +67,8 @@ public class KieServiceCommon {
|
|||
@Value("${server.port}")
|
||||
private int serverPort;
|
||||
|
||||
private Map<String,DroolsRouter> routes = new HashMap<>();
|
||||
|
||||
public KieServiceCommon() {
|
||||
// for now, if no server impl is passed as parameter, create one
|
||||
this.server = KieServerLocator.getInstance();
|
||||
|
|
@ -104,7 +105,11 @@ public class KieServiceCommon {
|
|||
} catch (UnknownHostException e) {
|
||||
logger.info("initCamelBusinessRoutes.getLocalHost", e);
|
||||
}
|
||||
RuntimePersist runtimePersist = new RuntimePersist(serverName, version, "http://" + hostName + ":" + serverPort, String.valueOf(serverPort), sftpPort);
|
||||
RuntimePersist runtimePersist = new RuntimePersist(serverName, version, "http://" + hostName + ":" + serverPort, String.valueOf(serverPort), sftpPort,hostName,RuntimePersist.STATUS.UP.toString());
|
||||
runtimeRepository.save(runtimePersist);
|
||||
}else{
|
||||
RuntimePersist runtimePersist =itIsMes.get(0);
|
||||
runtimePersist.setStatus(RuntimePersist.STATUS.UP.toString());
|
||||
runtimeRepository.save(runtimePersist);
|
||||
}
|
||||
try {
|
||||
|
|
@ -118,6 +123,28 @@ public class KieServiceCommon {
|
|||
}
|
||||
|
||||
}
|
||||
@PreDestroy
|
||||
public void stopRuntime(){
|
||||
String serverName = System.getProperty("org.kie.server.id");
|
||||
List<RuntimePersist> itIsMes = runtimeRepository.findByServerName(serverName);
|
||||
if (itIsMes.size()==1){
|
||||
RuntimePersist runtimePersist =itIsMes.get(0);
|
||||
runtimePersist.setStatus(RuntimePersist.STATUS.DOWN.toString());
|
||||
runtimeRepository.save(runtimePersist);
|
||||
}
|
||||
}
|
||||
public void deleteCamelBusinessRoute(String containerId) throws Exception {
|
||||
if (routes.containsKey(containerId)){
|
||||
DroolsRouter routeToDelete = routes.get(containerId);
|
||||
String target = routeToDelete.getRouteCollection().getRoutes().get(0).getId();
|
||||
for (Route route : camelContext.getRoutes()){
|
||||
if (route.getId().equals(target)){
|
||||
camelContext.stopRoute(route.getId());
|
||||
camelContext.removeRoute(route.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void initCamelBusinessRoute(ContainerPojoPersist container) throws Exception {
|
||||
ClassLoader localClassLoader = null;
|
||||
|
|
@ -140,8 +167,10 @@ public class KieServiceCommon {
|
|||
Thread.currentThread().setContextClassLoader(classLoader);
|
||||
String projectName = container.getContainerId();
|
||||
String processId = container.getProcessID();
|
||||
this.deleteCamelBusinessRoute(projectName);
|
||||
DroolsRouter droolsRouter = new DroolsRouter(camelContext, theClass, projectName, kieContainerInstance, processId);
|
||||
camelContext.addRoutes(droolsRouter);
|
||||
routes.put(containerId,droolsRouter);
|
||||
} finally {
|
||||
if (localClassLoader != null) {
|
||||
Thread.currentThread().setContextClassLoader(localClassLoader);
|
||||
|
|
@ -181,8 +210,7 @@ public class KieServiceCommon {
|
|||
String serverName = System.getProperty("org.kie.server.id");
|
||||
List<ContainerPojoPersist> containers = containerRepository.findByServerNameAndStatus(serverName, ContainerPojoPersist.STATUS.TODEPLOY.toString());
|
||||
for (ContainerPojoPersist element : containers) {
|
||||
//this.disposeContainer(element.getContainerId());
|
||||
|
||||
this.disposeContainer(element.getContainerId());
|
||||
KieContainerResource newContainer = new KieContainerResource();
|
||||
newContainer.setContainerId(element.getContainerId());
|
||||
newContainer.setReleaseId(new ReleaseId());
|
||||
|
|
@ -194,7 +222,12 @@ public class KieServiceCommon {
|
|||
element.setStatus(ContainerPojoPersist.STATUS.UP.toString());
|
||||
containerRepository.save(element);
|
||||
}
|
||||
|
||||
List<ContainerPojoPersist> containersToDelete = containerRepository.findByServerNameAndStatus(serverName, ContainerPojoPersist.STATUS.TODELETE.toString());
|
||||
for (ContainerPojoPersist element : containersToDelete) {
|
||||
this.disposeContainer(element.getContainerId());
|
||||
this.deleteCamelBusinessRoute(element.getContainerId());
|
||||
containerRepository.delete(element);
|
||||
}
|
||||
}
|
||||
|
||||
public KieContainerResource createContainerWithRestBusinessService(String id, KieContainerResource container, String className, String processID) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="Spring" name="Spring">
|
||||
<configuration />
|
||||
|
|
@ -25,6 +25,15 @@
|
|||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="drools-framewwork-business-proxy-persistence" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-mongodb:2.1.0.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mongodb:mongodb-driver:3.8.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mongodb:bson:3.8.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mongodb:mongodb-driver-core:3.8.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-mongodb:2.1.2.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.1.2.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:2.1.2.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.mkopylec:charon-spring-boot-starter:3.1.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.1.0.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.1.0.RELEASE" level="project" />
|
||||
|
|
@ -33,7 +42,6 @@
|
|||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.1.0.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.11.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.11.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.25" level="project" />
|
||||
|
|
@ -41,7 +49,6 @@
|
|||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.yaml:snakeyaml:1.23" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.1.0.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.9.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.7" level="project" />
|
||||
|
|
@ -60,6 +67,18 @@
|
|||
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.1.2.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.1.2.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.1.2.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.camel:camel-spring-boot-starter:2.23.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.camel:camel-spring-boot:2.23.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.camel:camel-spring:2.23.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.camel:camel-core-starter:2.23.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.camel:camel-quartz2:2.23.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.camel:camel-core:2.23.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.quartz-scheduler:quartz:2.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.mchange:mchange-commons-java:0.2.11" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.mchange:c3p0:0.9.5.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-core:2.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-impl:2.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.8.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-collections4:4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-io:commons-io:2.6" level="project" />
|
||||
|
|
|
|||
|
|
@ -9,9 +9,14 @@
|
|||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>drools-framework-business-reverse-proxx</artifactId>
|
||||
<artifactId>drools-framework-business-reverse-proxy</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.pymmasoftware.jbpm</groupId>
|
||||
<artifactId>drools-framework-business-proxy-persistence</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.mkopylec</groupId>
|
||||
<artifactId>charon-spring-boot-starter</artifactId>
|
||||
|
|
@ -22,6 +27,15 @@
|
|||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.camel</groupId>
|
||||
<artifactId>camel-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.camel</groupId>
|
||||
<artifactId>camel-quartz2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
|
|
@ -67,7 +81,13 @@
|
|||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.camel</groupId>
|
||||
<artifactId>camel-spring-boot-dependencies</artifactId>
|
||||
<version>${camel.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
</project>
|
||||
|
|
@ -3,8 +3,10 @@ package org.chtijbug.drools.reverseproxy;
|
|||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableMongoRepositories(basePackages = "org.chtijbug.drools.proxy.persistence.repository")
|
||||
public class DroolsBusinessReverseProxyServer {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
package org.chtijbug.drools.reverseproxy.camel;
|
||||
|
||||
import org.apache.camel.builder.RouteBuilder;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class AutodeployRouter extends RouteBuilder {
|
||||
@Override
|
||||
public void configure() throws Exception {
|
||||
from("quartz2://myGroup/myTimerName?cron=0/5+*+*+?+*+*").to("bean:updateService?method=updateConfig()");
|
||||
}
|
||||
}
|
||||
|
|
@ -5,16 +5,22 @@ import com.github.mkopylec.charon.configuration.MappingProperties;
|
|||
import com.github.mkopylec.charon.core.http.HttpClientProvider;
|
||||
import com.github.mkopylec.charon.core.mappings.MappingsCorrector;
|
||||
import com.github.mkopylec.charon.core.mappings.MappingsProvider;
|
||||
import org.chtijbug.drools.reverseproxy.service.UpdateService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class CustomMappingsProvider extends MappingsProvider {
|
||||
|
||||
|
||||
@Autowired
|
||||
private UpdateService updateService;
|
||||
|
||||
|
||||
public CustomMappingsProvider(ServerProperties server, CharonProperties charon, MappingsCorrector mappingsCorrector, HttpClientProvider httpClientProvider) {
|
||||
super(server, charon, mappingsCorrector,httpClientProvider);
|
||||
}
|
||||
|
|
@ -23,28 +29,11 @@ public class CustomMappingsProvider extends MappingsProvider {
|
|||
|
||||
@Override
|
||||
protected boolean shouldUpdateMappings(HttpServletRequest httpServletRequest) {
|
||||
return false;
|
||||
return updateService.getToUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<MappingProperties> retrieveMappings() {
|
||||
List<MappingProperties> total = new ArrayList<>();
|
||||
MappingProperties mappingProperties = new MappingProperties();
|
||||
total.add(mappingProperties);
|
||||
mappingProperties.setName("fraud-doc");
|
||||
mappingProperties.setPath("/fraud-doc");
|
||||
mappingProperties.getCustomConfiguration().put("connect",200);
|
||||
mappingProperties.getCustomConfiguration().put("read",200);
|
||||
mappingProperties.setStripPath(true);
|
||||
mappingProperties.getDestinations().add("http://macbook-pro-de-nicolas-2.local:8091/api/");
|
||||
MappingProperties mappingProperties2 = new MappingProperties();
|
||||
total.add(mappingProperties2);
|
||||
mappingProperties2.setName("fraud-run");
|
||||
mappingProperties2.setPath("/fraud-Oney-fraud");
|
||||
mappingProperties2.getCustomConfiguration().put("connect",200);
|
||||
mappingProperties2.getCustomConfiguration().put("read",200);
|
||||
mappingProperties2.setStripPath(true);
|
||||
mappingProperties2.getDestinations().add("http://macbook-pro-de-nicolas-2.local:8091/api/fraud-Oney-fraud/");
|
||||
return total;
|
||||
return updateService.retrievePath();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,129 @@
|
|||
package org.chtijbug.drools.reverseproxy.service;
|
||||
|
||||
import com.github.mkopylec.charon.configuration.MappingProperties;
|
||||
import org.chtijbug.drools.proxy.persistence.model.ProjectPersist;
|
||||
import org.chtijbug.drools.proxy.persistence.model.RuntimePersist;
|
||||
import org.chtijbug.drools.proxy.persistence.repository.ProjectRepository;
|
||||
import org.chtijbug.drools.proxy.persistence.repository.RuntimeRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.*;
|
||||
|
||||
@Service("updateService")
|
||||
public class UpdateService {
|
||||
|
||||
@Autowired
|
||||
private ProjectRepository projectRepository;
|
||||
@Autowired
|
||||
private RuntimeRepository runtimeRepository;
|
||||
|
||||
private Map<String, RuntimePersist> runtimes = new HashMap<>();
|
||||
private Map<String, ProjectPersist> projects = new HashMap<>();
|
||||
|
||||
private Boolean toUpdate = false;
|
||||
|
||||
private List<MappingProperties> mappings=new ArrayList<>();
|
||||
|
||||
public Boolean getToUpdate() {
|
||||
return toUpdate;
|
||||
}
|
||||
|
||||
public void updateConfig() {
|
||||
if (this.toUpdate==false) {
|
||||
this.toUpdate = isToUpdate();
|
||||
if (this.toUpdate==true){
|
||||
generateMappings();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isToUpdate() {
|
||||
boolean result = false;
|
||||
runtimes.clear();
|
||||
List<RuntimePersist> runtimePersists = runtimeRepository.findAll();
|
||||
for (RuntimePersist runtimePersist : runtimePersists) {
|
||||
runtimes.put(runtimePersist.getServerName(), runtimePersist.duplicate());
|
||||
}
|
||||
List<ProjectPersist> projectPersists = projectRepository.findAll();
|
||||
List<String> projectOk = new ArrayList<>();
|
||||
for (ProjectPersist projectPersist : projectPersists) {
|
||||
if (projectPersist.getServerNames().size() > 0) {
|
||||
projectOk.add(projectPersist.getContainerID());
|
||||
if (projects.containsKey(projectPersist.getContainerID()) == false) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// if a new project is not in the already displayed
|
||||
|
||||
List<String> list1 = projectPersist.getServerNames();
|
||||
int l1 = list1.size();
|
||||
ProjectPersist run2 = projects.get(projectPersist.getContainerID());
|
||||
List<String> list2 = run2.getServerNames();
|
||||
if (list2.size() != list1.size()) {
|
||||
return true;
|
||||
}
|
||||
list1.retainAll(list2);
|
||||
if (list2.size() != list1.size()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// An existing project in the reverse is no more to be displayed
|
||||
for (String goodId : projects.keySet()) {
|
||||
if (projectOk.contains(goodId) == false) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<MappingProperties> retrievePath() {
|
||||
this.toUpdate=false;
|
||||
return mappings;
|
||||
}
|
||||
private void generateMappings(){
|
||||
projects.clear();
|
||||
List<MappingProperties> paths = new ArrayList<>();
|
||||
Collection<ProjectPersist> projectPersists = projectRepository.findAll();
|
||||
for (ProjectPersist projectPersist : projectPersists) {
|
||||
if (projectPersist.getServerNames().size() > 0) {
|
||||
projects.put(projectPersist.getContainerID(), projectPersist.duplicate());
|
||||
MappingProperties mappingProperties2 = new MappingProperties();
|
||||
for (String serverName : projectPersist.getServerNames()) {
|
||||
RuntimePersist runtimePersist = runtimes.get(serverName);
|
||||
String hostName = runtimePersist.getHostname() + "/api/" + projectPersist.getContainerID();
|
||||
mappingProperties2.getDestinations().add(hostName);
|
||||
}
|
||||
paths.add(mappingProperties2);
|
||||
mappingProperties2.setName(projectPersist.getContainerID());
|
||||
mappingProperties2.setPath("/" + projectPersist.getContainerID());
|
||||
mappingProperties2.getCustomConfiguration().put("connect", 2000);
|
||||
mappingProperties2.getCustomConfiguration().put("read", 2000);
|
||||
mappingProperties2.setStripPath(true);
|
||||
}
|
||||
|
||||
}
|
||||
mappings.clear();
|
||||
mappings.addAll(paths);
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void initConfig() {
|
||||
List<RuntimePersist> runtimePersists = runtimeRepository.findAll();
|
||||
for (RuntimePersist runtimePersist : runtimePersists) {
|
||||
runtimes.put(runtimePersist.getServerName(), runtimePersist);
|
||||
}
|
||||
List<ProjectPersist> projectPersists = projectRepository.findAll();
|
||||
for (ProjectPersist projectPersist : projectPersists) {
|
||||
if (projectPersist.getServerNames().size() > 0) {
|
||||
projects.put(projectPersist.getContainerID(), projectPersist.duplicate());
|
||||
}
|
||||
}
|
||||
generateMappings();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1 +1,3 @@
|
|||
server.port=9500
|
||||
server.port=9500
|
||||
spring.data.mongodb.database=businessProxyDB
|
||||
spring.data.mongodb.host=localhost:27017
|
||||
|
|
@ -9,7 +9,8 @@ public class ContainerPojoPersist {
|
|||
public enum STATUS {
|
||||
UP,
|
||||
DOWN,
|
||||
TODEPLOY
|
||||
TODEPLOY,
|
||||
TODELETE
|
||||
}
|
||||
@Id
|
||||
private String id;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
package org.chtijbug.drools.proxy.persistence.model;
|
||||
|
||||
import org.bson.types.ObjectId;
|
||||
import org.chtijbug.drools.proxy.persistence.json.KeyProject;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.index.Indexed;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Document
|
||||
|
|
@ -37,7 +37,7 @@ public class ProjectPersist implements Serializable {
|
|||
|
||||
private String containerID;
|
||||
|
||||
private String serverName;
|
||||
private List<String> serverNames= new ArrayList<>();
|
||||
|
||||
private String status;
|
||||
|
||||
|
|
@ -45,6 +45,19 @@ public class ProjectPersist implements Serializable {
|
|||
|
||||
public ProjectPersist(){}
|
||||
|
||||
public ProjectPersist(String deploymentName, KeyProject projectName, String mainClass, String groupID, String artifactID, String processID, String projectVersion, String containerID, List<String> serverNames, String status) {
|
||||
this.deploymentName = deploymentName;
|
||||
this.projectName = projectName;
|
||||
this.mainClass = mainClass;
|
||||
this.groupID = groupID;
|
||||
this.artifactID = artifactID;
|
||||
this.processID = processID;
|
||||
this.projectVersion = projectVersion;
|
||||
this.containerID = containerID;
|
||||
this.serverNames = serverNames;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getDeploymentName() {
|
||||
return deploymentName;
|
||||
}
|
||||
|
|
@ -109,12 +122,12 @@ public class ProjectPersist implements Serializable {
|
|||
this.projectVersion = projectVersion;
|
||||
}
|
||||
|
||||
public String getServerName() {
|
||||
return serverName;
|
||||
public List<String> getServerNames() {
|
||||
return serverNames;
|
||||
}
|
||||
|
||||
public void setServerName(String serverName) {
|
||||
this.serverName = serverName;
|
||||
public void setServerName(List<String> serverNames) {
|
||||
this.serverNames = serverNames;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
|
|
@ -132,4 +145,11 @@ public class ProjectPersist implements Serializable {
|
|||
public void setClassNameList(List<String> classNameList) {
|
||||
this.classNameList = classNameList;
|
||||
}
|
||||
|
||||
public ProjectPersist duplicate(){
|
||||
ArrayList<String> listServerNames = new ArrayList<String>();
|
||||
listServerNames.addAll(serverNames);
|
||||
ProjectPersist duplicate = new ProjectPersist(deploymentName,projectName,mainClass,groupID,artifactID,processID,projectVersion,containerID,listServerNames,status);
|
||||
return duplicate;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,10 @@ import org.springframework.data.mongodb.core.mapping.Document;
|
|||
|
||||
@Document
|
||||
public class RuntimePersist {
|
||||
|
||||
public enum STATUS {
|
||||
UP,
|
||||
DOWN
|
||||
}
|
||||
@Id
|
||||
private String id=new ObjectId().toString();
|
||||
|
||||
|
|
@ -20,14 +23,25 @@ public class RuntimePersist {
|
|||
|
||||
private String serverPort;
|
||||
|
||||
private String sftpHost;
|
||||
|
||||
private String sftpPort;
|
||||
|
||||
public RuntimePersist(String serverName, String version, String hostname,String serverPort,String sftpPort) {
|
||||
private String status;
|
||||
|
||||
public RuntimePersist(String serverName, String version, String hostname,String serverPort,String sftpPort,String sftpHost,String status) {
|
||||
this.serverName = serverName;
|
||||
this.version = version;
|
||||
this.hostname = hostname;
|
||||
this.serverPort = serverPort;
|
||||
this.sftpPort = sftpPort;
|
||||
this.sftpHost = sftpHost;
|
||||
this.status=status;
|
||||
}
|
||||
|
||||
public RuntimePersist duplicate(){
|
||||
RuntimePersist duplicate = new RuntimePersist(serverName,version,hostname,serverPort,sftpPort,sftpHost,status);
|
||||
return duplicate;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
|
@ -77,4 +91,20 @@ public class RuntimePersist {
|
|||
public void setServerPort(String serverPort) {
|
||||
this.serverPort = serverPort;
|
||||
}
|
||||
|
||||
public String getSftpHost() {
|
||||
return sftpHost;
|
||||
}
|
||||
|
||||
public void setSftpHost(String sftpHost) {
|
||||
this.sftpHost = sftpHost;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package org.chtijbug.drools.proxy.persistence.repository;
|
|||
|
||||
import org.chtijbug.drools.proxy.persistence.json.KeyProject;
|
||||
import org.chtijbug.drools.proxy.persistence.model.ProjectPersist;
|
||||
import org.chtijbug.drools.proxy.persistence.model.RuntimePersist;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
|
@ -13,7 +12,7 @@ public interface ProjectRepository extends MongoRepository<ProjectPersist, Strin
|
|||
|
||||
public ProjectPersist findByProjectName(KeyProject projectName);
|
||||
public ProjectPersist findByDeploymentName(String deploymentName);
|
||||
public List<ProjectPersist> findByServerName(String serverName);
|
||||
public List<ProjectPersist> findByServerNameAndDeploymentName(String serverName,String deploymentName);
|
||||
public List<ProjectPersist> findByServerNamesIn(List<String> serverNames);
|
||||
public List<ProjectPersist> findByServerNamesInAndDeploymentName(List<String> serverNames,String deploymentName);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,6 @@
|
|||
<module>drools-framewwork-business-proxy-persistence</module>
|
||||
<module>drools-framework-business-indexer-app</module>
|
||||
<module>drools-framework-business-indexer-persistence</module>
|
||||
<module>drools-framework-business-reverse-proxx</module>
|
||||
<module>drools-framework-business-reverse-proxy</module>
|
||||
</modules>
|
||||
</project>
|
||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue