Start Dockerized
Dynamic configuration started
This commit is contained in:
parent
30ccfa9604
commit
945c57ddfd
44 changed files with 1544 additions and 321 deletions
84
docker-compose.yaml
Normal file
84
docker-compose.yaml
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
version: "3"
|
||||
|
||||
|
||||
networks:
|
||||
drools-network:
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 172.27.0.0/24
|
||||
|
||||
|
||||
services:
|
||||
|
||||
kie-wb:
|
||||
image: kie-wb
|
||||
container_name: "businessCentral"
|
||||
volumes:
|
||||
- gitdata:/home/niodir
|
||||
networks:
|
||||
drools-network:
|
||||
ipv4_address: 172.27.0.5
|
||||
ports:
|
||||
- 8080:8080
|
||||
- 8001:8001
|
||||
|
||||
restart: always
|
||||
|
||||
|
||||
admin-console:
|
||||
image: runtime-admin-console
|
||||
container_name: "admin-console"
|
||||
volumes:
|
||||
- gitdata:/home/niodir
|
||||
networks:
|
||||
drools-network:
|
||||
ipv4_address: 172.27.0.6
|
||||
ports:
|
||||
- 8200:8200
|
||||
links:
|
||||
- businessProxyDB:mongodb
|
||||
- elasticsearchhost
|
||||
- kie-wb
|
||||
depends_on:
|
||||
- businessProxyDB
|
||||
- elasticsearchhost
|
||||
- kie-wb
|
||||
restart: always
|
||||
|
||||
|
||||
elasticsearchhost:
|
||||
image: docker.elastic.co/elasticsearch/elasticsearch:6.6.1
|
||||
container_name: "elasticsearchhost"
|
||||
ulimits:
|
||||
memlock:
|
||||
soft: -1
|
||||
hard: -1
|
||||
volumes:
|
||||
- esdata2:/usr/share/elasticsearch/data
|
||||
networks:
|
||||
drools-network:
|
||||
ipv4_address: 172.27.0.7
|
||||
ports:
|
||||
- 9300:9300
|
||||
restart: always
|
||||
|
||||
businessProxyDB:
|
||||
image: mongo
|
||||
container_name: "businessProxyDB"
|
||||
volumes:
|
||||
- mongodb:/data/db
|
||||
- mongodb_config:/data/configdb
|
||||
networks:
|
||||
drools-network:
|
||||
ipv4_address: 172.27.0.3
|
||||
ports:
|
||||
- 28017:27017
|
||||
command: mongod
|
||||
restart: always
|
||||
|
||||
|
||||
volumes:
|
||||
mongodb:
|
||||
mongodb_config:
|
||||
gitdata:
|
||||
esdata2:
|
||||
84
docker-compose.yaml.copy
Normal file
84
docker-compose.yaml.copy
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
version: "3"
|
||||
|
||||
|
||||
networks:
|
||||
drools-network:
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 172.27.0.0/24
|
||||
|
||||
|
||||
services:
|
||||
|
||||
kie-wb:
|
||||
image: kie-wb
|
||||
container_name: "businessCentral"
|
||||
volumes:
|
||||
- gitdata:/home/niodir
|
||||
networks:
|
||||
drools-network:
|
||||
ipv4_address: 172.27.0.5
|
||||
ports:
|
||||
- 8080:8080
|
||||
- 8001:8001
|
||||
|
||||
restart: always
|
||||
|
||||
admin-console:
|
||||
image: runtime-admin-console
|
||||
container_name: "admin-console"
|
||||
volumes:
|
||||
- gitdata:/home/niodir
|
||||
networks:
|
||||
drools-network:
|
||||
ipv4_address: 172.27.0.6
|
||||
ports:
|
||||
- 8200:8200
|
||||
links:
|
||||
- businessProxyDB
|
||||
- elasticsearchhost
|
||||
- kie-wb
|
||||
depends_on:
|
||||
- businessProxyDB
|
||||
- elasticsearchhost
|
||||
- kie-wb
|
||||
restart: always
|
||||
|
||||
|
||||
|
||||
|
||||
elasticsearchhost:
|
||||
image: docker.elastic.co/elasticsearch/elasticsearch:6.6.1
|
||||
container_name: "elasticsearchhost"
|
||||
ulimits:
|
||||
memlock:
|
||||
soft: -1
|
||||
hard: -1
|
||||
volumes:
|
||||
- esdata2:/usr/share/elasticsearch/data
|
||||
networks:
|
||||
drools-network:
|
||||
ipv4_address: 172.27.0.7
|
||||
ports:
|
||||
- 9300:9300
|
||||
restart: always
|
||||
|
||||
businessProxyDB:
|
||||
image: mongo
|
||||
container_name: "businessProxyDB"
|
||||
volumes:
|
||||
- mongodb:/data/db
|
||||
- mongodb_config:/data/configdb
|
||||
networks:
|
||||
drools-network:
|
||||
ipv4_address: 172.27.0.3
|
||||
ports:
|
||||
- 28017:27017
|
||||
command: mongod
|
||||
restart: always
|
||||
|
||||
volumes:
|
||||
mongodb:
|
||||
mongodb_config:
|
||||
gitdata:
|
||||
esdata2:
|
||||
75
docker-compose.yaml.initial
Normal file
75
docker-compose.yaml.initial
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
version: "3"
|
||||
|
||||
|
||||
networks:
|
||||
assurfleet-network:
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 172.26.0.0/24
|
||||
|
||||
|
||||
services:
|
||||
|
||||
assurfleet-webapp:
|
||||
image: assurfleet-webapp
|
||||
container_name: "assurfleet-webapp"
|
||||
networks:
|
||||
assurfleet-network:
|
||||
ipv4_address: 172.26.0.5
|
||||
ports:
|
||||
- 8099:8099
|
||||
- 9091:9091
|
||||
- 9095:9095
|
||||
links:
|
||||
- petiteFlotteDB
|
||||
depends_on:
|
||||
- petiteFlotteDB
|
||||
restart: always
|
||||
|
||||
assurfleet-courtier:
|
||||
image: assurfleet-front-courtier-petiteflotte
|
||||
container_name: "assurfleet-courtier"
|
||||
networks:
|
||||
assurfleet-network:
|
||||
ipv4_address: 172.26.0.4
|
||||
ports:
|
||||
- 8200:8200
|
||||
restart: always
|
||||
|
||||
assurfleet-grossiste:
|
||||
image: assurfleet-front-grossiste-petiteflotte
|
||||
container_name: "assurfleet-grossiste"
|
||||
networks:
|
||||
assurfleet-network:
|
||||
ipv4_address: 172.26.0.2
|
||||
ports:
|
||||
- 8101:8101
|
||||
restart: always
|
||||
|
||||
green-card-portail-front:
|
||||
image: green-card-portail-front
|
||||
container_name: "green-card-portail-front"
|
||||
networks:
|
||||
assurfleet-network:
|
||||
ipv4_address: 172.26.0.9
|
||||
ports:
|
||||
- 8600:8600
|
||||
restart: always
|
||||
|
||||
petiteFlotteDB:
|
||||
image: mongo
|
||||
container_name: "petiteFlotteDB"
|
||||
volumes:
|
||||
- mongodb:/data/db
|
||||
- mongodb_config:/data/configdb
|
||||
networks:
|
||||
assurfleet-network:
|
||||
ipv4_address: 172.26.0.3
|
||||
ports:
|
||||
- 8098:27017
|
||||
command: mongod
|
||||
restart: always
|
||||
|
||||
volumes:
|
||||
mongodb:
|
||||
mongodb_config:
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>war</packaging>
|
||||
<packaging>jar</packaging>
|
||||
<artifactId>drools-framework-admin-console</artifactId>
|
||||
|
||||
<properties>
|
||||
|
|
@ -220,32 +220,10 @@
|
|||
|
||||
<build>
|
||||
<finalName>drools-framework-admin-console</finalName>
|
||||
<pluginManagement>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>3.2.2</version>
|
||||
<configuration>
|
||||
<packagingExcludes>
|
||||
%regex[WEB-INF/lib/slf4j-simple.*.jar],
|
||||
%regex[WEB-INF/lib/tomcat.*.jar]
|
||||
</packagingExcludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>3.2.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
</plugin>
|
||||
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
|
|
@ -264,23 +242,17 @@
|
|||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
|
||||
<configuration>
|
||||
<jvmArguments>-Dvaadin.productionMode</jvmArguments>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<classifier>spring-boot</classifier>
|
||||
<mainClass>
|
||||
org.chtijbug.drools.console.DroolsSpringBootConsoleApplication
|
||||
</mainClass>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<executable>true</executable>
|
||||
</configuration>
|
||||
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
|
|
@ -288,11 +260,9 @@
|
|||
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<!--profile>
|
||||
<id>productionMode</id>
|
||||
<!--activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation!-->
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
|
@ -327,6 +297,130 @@
|
|||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile-->
|
||||
|
||||
<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-admin-console</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>
|
||||
<host>kie-wb:192.168.43.94</host>
|
||||
</extraHosts>
|
||||
<ports>
|
||||
<port>8200:8200</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-admin-console</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-admin-console.jar app.jar
|
||||
|
||||
EXPOSE 8200
|
||||
|
||||
RUN bash -c 'touch /app.jar'
|
||||
|
||||
ENTRYPOINT ["java","-Dspring.config.location=file:./","-jar","/app.jar"]
|
||||
#ENTRYPOINT ["java","-jar","/app.jar"]
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
spring.data.elasticsearch.cluster-nodes=elasticsearchhost:9300
|
||||
|
||||
|
||||
spring.data.mongodb.database=businessProxyDB
|
||||
spring.data.mongodb.host=mongodb:27017
|
||||
|
||||
server.port=${port:8200}
|
||||
kie-wb.baseurl=http://kie-wb:8080/kie-wb/rest
|
||||
kie-wb.username=admin
|
||||
kie-wb.password=admin
|
||||
|
||||
spring.servlet.multipart.enabled=false
|
||||
|
|
@ -18,6 +18,7 @@ import org.chtijbug.guvnor.server.jaxrs.model.PlatformProjectResponse;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -49,6 +50,13 @@ public class ProjectPersistService {
|
|||
|
||||
}
|
||||
|
||||
public static String getPROJECT() {
|
||||
return PROJECT;
|
||||
}
|
||||
|
||||
public static void setPROJECT(String PROJECT) {
|
||||
ProjectPersistService.PROJECT = PROJECT;
|
||||
}
|
||||
|
||||
public void saveIfnotExist(List<PlatformProjectResponse> platformProjectResponses) {
|
||||
|
||||
|
|
@ -92,15 +100,20 @@ public class ProjectPersistService {
|
|||
|
||||
VaadinSession.getCurrent().setAttribute(PROJECT, projectPersists);
|
||||
}
|
||||
public boolean associate(ProjectPersist projectPersist, RuntimePersist runtimePersist){
|
||||
|
||||
List<ProjectPersist> projectPersists=projectRepository.findByServerNameAndDeploymentName(runtimePersist.getServerName(),projectPersist.getDeploymentName());
|
||||
public boolean associate(ProjectPersist projectPersist, List<RuntimePersist> runtimePersists) {
|
||||
|
||||
if(projectPersists.size()!=0){
|
||||
return false;
|
||||
}else {
|
||||
projectPersist.getServerNames().clear();
|
||||
for (RuntimePersist runtimePersist : runtimePersists) {
|
||||
List<String> names = new ArrayList<String>();
|
||||
names.add(runtimePersist.getServerName());
|
||||
List<ProjectPersist> projectPersists = projectRepository.findByServerNamesInAndDeploymentName(names, projectPersist.getDeploymentName());
|
||||
//if (projectPersists.size() != 0) {
|
||||
// return false;
|
||||
// }
|
||||
projectPersist.getServerNames().add(runtimePersist.getServerName());
|
||||
}
|
||||
|
||||
projectPersist.setServerName(runtimePersist.getServerName());
|
||||
projectPersist.setStatus(ProjectPersist.Deployable);
|
||||
projectPersist.setContainerID(projectPersist.getDeploymentName() + "-" + projectPersist.getProjectName());
|
||||
projectRepository.save(projectPersist);
|
||||
|
|
@ -108,7 +121,6 @@ public class ProjectPersistService {
|
|||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean deployer(ProjectPersist projectPersist, AddLog addLog, UI ui) {
|
||||
|
||||
|
|
@ -119,7 +131,6 @@ public class ProjectPersistService {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
public ProjectPersist platformProjectResponseToProjectPersist(PlatformProjectResponse platformProjectResponse) {
|
||||
ProjectPersist projectPersist = new ProjectPersist();
|
||||
projectPersist.setArtifactID(platformProjectResponse.getArtifactId());
|
||||
|
|
@ -147,25 +158,19 @@ public class ProjectPersistService {
|
|||
userConnected.getUserPassword(), projectPersist.getProjectName().getSpaceName(), projectPersist.getProjectName().getName(), "install", workOnGoingView, ui);
|
||||
|
||||
executeWrite(url, username, password, workOnGoingView, result.getJobId(), ui);
|
||||
/**
|
||||
if (projectPersist.getContainerID() != null) {
|
||||
KieServerJobStatus jobresult = kieServerRepositoryService.stopContainer(config.getKieserverUrl(), config.getKieserverUserName(), config.getKieserverPassword(), projectPersist.getContainerID(), workOnGoingView,ui);
|
||||
if (jobresult != null
|
||||
&& "SUCCESS".equals(jobresult.getType())) {
|
||||
}
|
||||
}
|
||||
**/
|
||||
|
||||
// ContainerPojoPersist toto = containerRepository.findByServerNameAndContainerId(projectPersist.getContainerID());
|
||||
List<RuntimePersist> kieservers = runtimeRepository.findByServerName(projectPersist.getServerName());
|
||||
for (String serverName : projectPersist.getServerNames()) {
|
||||
List<RuntimePersist> kieservers = runtimeRepository.findByServerName(serverName);
|
||||
if (kieservers.size() == 1) {
|
||||
ContainerPojoPersist existingContainer = containerRepository.findByServerNameAndContainerId(projectPersist.getServerName(),projectPersist.getContainerID());
|
||||
ContainerPojoPersist existingContainer = containerRepository.findByServerNameAndContainerId(serverName, projectPersist.getContainerID());
|
||||
if (existingContainer == null) {
|
||||
ContainerPojoPersist newContainer = new ContainerPojoPersist();
|
||||
newContainer.setStatus(ContainerPojoPersist.STATUS.TODEPLOY.toString());
|
||||
newContainer.setClassName(projectPersist.getMainClass());
|
||||
newContainer.setProcessID(projectPersist.getProcessID());
|
||||
newContainer.setContainerId(projectPersist.getContainerID());
|
||||
newContainer.setServerName(projectPersist.getServerName());
|
||||
newContainer.setServerName(serverName);
|
||||
newContainer.setGroupId(projectPersist.getGroupID());
|
||||
newContainer.setArtifactId(projectPersist.getArtifactID());
|
||||
newContainer.setVersion(projectPersist.getProjectVersion());
|
||||
|
|
@ -175,22 +180,23 @@ public class ProjectPersistService {
|
|||
containerRepository.save(existingContainer);
|
||||
}
|
||||
|
||||
/**
|
||||
KieContainerResource newContainer = new KieContainerResource();
|
||||
newContainer.setContainerId(projectPersist.getContainerID());
|
||||
newContainer.setReleaseId(new ReleaseId());
|
||||
newContainer.getReleaseId().setArtifactId(projectPersist.getArtifactID());
|
||||
newContainer.getReleaseId().setGroupId(projectPersist.getGroupID());
|
||||
newContainer.getReleaseId().setVersion(projectPersist.getProjectVersion());
|
||||
KieContainerInfo createdContainer = kieServerRepositoryService.createContainerWithBusinessInterface(config.getKieserverUrl(), config.getKieserverUserName(), config.getKieserverPassword(), projectPersist, newContainer, workOnGoingView, ui);
|
||||
**/
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//remove container from other runtime
|
||||
List<ContainerPojoPersist> containerPojoPersists = containerRepository.findByContainerId(projectPersist.getContainerID());
|
||||
for (ContainerPojoPersist container : containerPojoPersists){
|
||||
if (projectPersist.getServerNames().contains(container.getServerName())==false){
|
||||
container.setStatus(ContainerPojoPersist.STATUS.TODELETE.toString());
|
||||
containerRepository.save(container);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
thread.start();
|
||||
|
||||
}
|
||||
|
||||
private void executeWrite(String url, String username, String password, AddLog workOnGoingView, String jobID, UI ui) {
|
||||
|
||||
String isJobDone = "NO";
|
||||
|
|
@ -218,14 +224,6 @@ public class ProjectPersistService {
|
|||
}
|
||||
}
|
||||
|
||||
public static String getPROJECT() {
|
||||
return PROJECT;
|
||||
}
|
||||
|
||||
public static void setPROJECT(String PROJECT) {
|
||||
ProjectPersistService.PROJECT = PROJECT;
|
||||
}
|
||||
|
||||
public ProjectRepository getProjectRepository() {
|
||||
return projectRepository;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ public class UserConnectedService {
|
|||
public static String ASSET = "2";
|
||||
public static String SPACE = "3";
|
||||
public static String PROJECT = "4";
|
||||
public static String CURRENTPROJECT = "5";
|
||||
|
||||
|
||||
public UserConnected getUserConnected() {
|
||||
return (UserConnected) VaadinSession.getCurrent().getAttribute(USER);
|
||||
|
|
@ -41,10 +43,10 @@ public class UserConnectedService {
|
|||
}
|
||||
|
||||
public void addProjectToSession(String projectName) {
|
||||
VaadinSession.getCurrent().setAttribute(PROJECT, projectName);
|
||||
VaadinSession.getCurrent().setAttribute(CURRENTPROJECT, projectName);
|
||||
}
|
||||
|
||||
public String getProject() {
|
||||
return (String) VaadinSession.getCurrent().getAttribute(PROJECT);
|
||||
return (String) VaadinSession.getCurrent().getAttribute(CURRENTPROJECT);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ import org.chtijbug.drools.console.service.util.AppContext;
|
|||
import org.chtijbug.drools.console.view.DeploymentView;
|
||||
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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AssociateProjectKie extends VerticalLayout {
|
||||
|
|
@ -32,28 +32,29 @@ public class AssociateProjectKie extends VerticalLayout {
|
|||
|
||||
setClassName("creation-runtime-content");
|
||||
|
||||
label=new Label("Define your project : "+projectPersist.getProjectName());
|
||||
label = new Label("Define the runtime(s) for the project : " + projectPersist.getProjectName());
|
||||
label.setClassName("creation-runtime-title");
|
||||
add(label);
|
||||
|
||||
label2=new Label("this step is essential before you can associate your project with a workbench");
|
||||
label2 = new Label("This step is essential to be able to execute the rules defined in the project");
|
||||
label2.setClassName("creation-runtime-title2");
|
||||
add(label2);
|
||||
|
||||
gridRuntime=new GridRuntime();
|
||||
gridRuntime = new GridRuntime(projectPersist);
|
||||
add(gridRuntime);
|
||||
|
||||
associer=new Button("Associer");
|
||||
associer = new Button("Link and Save");
|
||||
associer.setEnabled(false);
|
||||
associer.setClassName("login-application-connexion");
|
||||
add(associer);
|
||||
associer.addClickListener(buttonClickEvent -> {
|
||||
List<RuntimePersist> lstToSave = new ArrayList<>();
|
||||
for (RuntimePersist runtimePersist : gridRuntime.getSelectedItems()) {
|
||||
lstToSave.add(runtimePersist);
|
||||
}
|
||||
if (lstToSave.size()>0) {
|
||||
|
||||
RuntimePersist runtimePersist=gridRuntime.getSelectedItems().stream().findFirst().get();
|
||||
|
||||
if(runtimePersist!=null) {
|
||||
|
||||
boolean tmp = projectPersistService.associate(projectPersist,runtimePersist);
|
||||
boolean tmp = projectPersistService.associate(projectPersist,lstToSave);
|
||||
|
||||
if (tmp == true) {
|
||||
deploymentView.setDataProvider();
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ public class DefineProject extends VerticalLayout {
|
|||
private UserConnectedService userConnectedService;
|
||||
|
||||
private ProjectPersistService projectPersistService;
|
||||
private boolean createMode;
|
||||
|
||||
public DefineProject(DeploymentView deploymentView,Dialog dialog, ProjectPersist projectPersist){
|
||||
|
||||
|
|
@ -52,8 +53,12 @@ public class DefineProject extends VerticalLayout {
|
|||
label2.setClassName("creation-runtime-title2");
|
||||
add(label2);
|
||||
|
||||
nameDeploy=new TextFieldPerso("Name Deployment","",VaadinIcon.FILE_TEXT.create());
|
||||
nameDeploy=new TextFieldPerso("Deployment Name ","",VaadinIcon.FILE_TEXT.create());
|
||||
nameDeploy.getTextField().setRequired(true);
|
||||
if (projectPersist.getDeploymentName()!=null
|
||||
&& projectPersist.getDeploymentName().length()>0){
|
||||
nameDeploy.getTextField().setValue((projectPersist.getDeploymentName()));
|
||||
}
|
||||
nameDeploy.getTextField().addValueChangeListener(textFieldStringComponentValueChangeEvent -> {
|
||||
verify();
|
||||
projectPersist.setDeploymentName(nameDeploy.getTextField().getValue().replaceAll(" ","_"));
|
||||
|
|
@ -69,6 +74,10 @@ public class DefineProject extends VerticalLayout {
|
|||
mainClass=new ComboBoxPerso("MainClass", VaadinIcon.TREE_TABLE.create());
|
||||
mainClass.getComboBox().setItems(projectPersist.getClassNameList());
|
||||
mainClass.getComboBox().setRequired(true);
|
||||
if (projectPersist.getMainClass()!= null
|
||||
&& projectPersist.getMainClass().length()>0){
|
||||
mainClass.getComboBox().setValue("class="+(String)projectPersist.getMainClass());
|
||||
}
|
||||
mainClass.getComboBox().addValueChangeListener(textFieldStringComponentValueChangeEvent -> {
|
||||
verify();
|
||||
String mainClassName=(String)mainClass.getComboBox().getValue();
|
||||
|
|
@ -82,6 +91,10 @@ public class DefineProject extends VerticalLayout {
|
|||
|
||||
processID=new TextFieldPerso("Process ID","",VaadinIcon.TASKS.create());
|
||||
processID.getTextField().setRequired(true);
|
||||
if (projectPersist.getProcessID()!= null
|
||||
&& projectPersist.getProcessID().length()>0){
|
||||
processID.getTextField().setValue(projectPersist.getProcessID());
|
||||
}
|
||||
processID.getTextField().setValueChangeMode(ValueChangeMode.EAGER);
|
||||
processID.getTextField().addValueChangeListener(textFieldStringComponentValueChangeEvent -> {
|
||||
verify();
|
||||
|
|
@ -90,11 +103,20 @@ public class DefineProject extends VerticalLayout {
|
|||
|
||||
add(processID);
|
||||
|
||||
valider=new Button("Valider");
|
||||
valider=new Button("Save");
|
||||
if (projectPersist.getProcessID()!= null
|
||||
&& projectPersist.getProcessID().length()>0){
|
||||
valider.setEnabled(true);
|
||||
createMode=false;
|
||||
}else {
|
||||
valider.setEnabled(false);
|
||||
createMode=true;
|
||||
}
|
||||
valider.setClassName("login-application-connexion");
|
||||
valider.addClickListener(buttonClickEvent -> {
|
||||
if (createMode==true) {
|
||||
projectPersist.setStatus(ProjectPersist.DEFINI);
|
||||
}
|
||||
projectPersistService.addProjectToSession(projectPersist,true);
|
||||
projectPersistService.getProjectRepository().save(projectPersist);
|
||||
deploymentView.setDataProvider();
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import org.chtijbug.drools.proxy.persistence.model.ProjectPersist;
|
|||
import org.chtijbug.drools.proxy.persistence.model.RuntimePersist;
|
||||
import com.vaadin.flow.component.html.Label;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GridRuntime extends Grid<RuntimePersist> {
|
||||
|
|
@ -24,6 +25,7 @@ public class GridRuntime extends Grid<RuntimePersist> {
|
|||
|
||||
private TextField version;
|
||||
|
||||
private TextField status;
|
||||
|
||||
private String strRuntimeName="Runtime Name";
|
||||
|
||||
|
|
@ -31,6 +33,7 @@ public class GridRuntime extends Grid<RuntimePersist> {
|
|||
|
||||
private String strVersion="Version";
|
||||
|
||||
private String strStatus="State";
|
||||
|
||||
private ProjectPersistService projectPersistService;
|
||||
private RuntimeService runtimeService;
|
||||
|
|
@ -38,14 +41,30 @@ public class GridRuntime extends Grid<RuntimePersist> {
|
|||
private ListDataProvider<RuntimePersist> dataProvider;
|
||||
private ConfigurableFilterDataProvider<RuntimePersist,Void,SerializablePredicate<RuntimePersist>> filterDataProvider;
|
||||
|
||||
private ProjectPersist projectPersist;
|
||||
|
||||
public GridRuntime(ProjectPersist projectPersist){
|
||||
this.projectPersist = projectPersist;
|
||||
init();
|
||||
//dataProvider.get
|
||||
for (RuntimePersist runtimePersist : dataProvider.getItems()){
|
||||
if (projectPersist.getServerNames().contains(runtimePersist.getServerName())){
|
||||
getSelectionModel().select(runtimePersist);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public GridRuntime() {
|
||||
init();
|
||||
|
||||
}
|
||||
private void init(){
|
||||
projectPersistService = AppContext.getApplicationContext().getBean(ProjectPersistService.class);
|
||||
runtimeService= AppContext.getApplicationContext().getBean(RuntimeService.class);
|
||||
|
||||
setClassName("deployment-grid-perso");
|
||||
setSelectionMode(Grid.SelectionMode.SINGLE);
|
||||
setSelectionMode(Grid.SelectionMode.MULTI);
|
||||
|
||||
Grid.Column<RuntimePersist> runtimeNameCo=addColumn(runtimePersist -> runtimePersist.getServerName());
|
||||
runtimeName=new TextField(strRuntimeName);
|
||||
|
|
@ -70,11 +89,18 @@ public class GridRuntime extends Grid<RuntimePersist> {
|
|||
refreshtGrid(version.getValue(), strVersion);
|
||||
});
|
||||
versionCo.setHeader(version);
|
||||
|
||||
Grid.Column<RuntimePersist> statusCo=addColumn(runtimePersist -> runtimePersist.getStatus());
|
||||
status=new TextField(strStatus);
|
||||
status.setValueChangeMode(ValueChangeMode.EAGER);
|
||||
status.addValueChangeListener(e -> {
|
||||
refreshtGrid(status.getValue(), strVersion);
|
||||
});
|
||||
statusCo.setHeader(status);
|
||||
|
||||
addColumn(new ComponentRenderer<>(runtimePersist -> {
|
||||
|
||||
List<ProjectPersist> projectPersists=projectPersistService.getProjectRepository().findByServerName(runtimePersist.getServerName());
|
||||
List<String> serverList = new ArrayList<>();
|
||||
serverList.add(runtimePersist.getServerName());
|
||||
List<ProjectPersist> projectPersists=projectPersistService.getProjectRepository().findByServerNamesIn(serverList);
|
||||
|
||||
Label label=new Label(projectPersists!=null?projectPersists.size()+"":"0");
|
||||
|
||||
|
|
|
|||
|
|
@ -19,13 +19,11 @@ import org.chtijbug.drools.console.service.ProjectPersistService;
|
|||
import org.chtijbug.drools.console.service.util.AppContext;
|
||||
import org.chtijbug.drools.console.vaadinComponent.Squelette.SqueletteComposant;
|
||||
import org.chtijbug.drools.console.vaadinComponent.leftMenu.Action.DeploymentAction;
|
||||
import org.chtijbug.drools.proxy.persistence.json.KeyProject;
|
||||
import org.chtijbug.drools.proxy.persistence.model.ProjectPersist;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
@StyleSheet("css/accueil.css")
|
||||
public class DeploymentView extends VerticalLayout implements AddLog {
|
||||
|
|
@ -33,49 +31,30 @@ public class DeploymentView extends VerticalLayout implements AddLog{
|
|||
public static final String pageName = "Deployment";
|
||||
|
||||
//GRID composant
|
||||
|
||||
private Grid<ProjectPersist> projectPersistGrid;
|
||||
|
||||
private ListDataProvider<ProjectPersist> dataProvider;
|
||||
|
||||
private ConfigurableFilterDataProvider<ProjectPersist,Void,SerializablePredicate<ProjectPersist>> filterDataProvider;
|
||||
|
||||
private DeploymentAction deploymentAction;
|
||||
|
||||
//TEXTFIELD search
|
||||
|
||||
private TextField nameDeploy;
|
||||
|
||||
private TextField nameProject;
|
||||
|
||||
private TextField groupeId;
|
||||
|
||||
private TextField artifactId;
|
||||
|
||||
private TextField processId;
|
||||
|
||||
private TextField serverName;
|
||||
|
||||
private ComboBox status;
|
||||
|
||||
//CONSTANTE Textfield
|
||||
|
||||
private final String strNameDeploy = "Deploy name";
|
||||
|
||||
private final String strNameProject = "Project name";
|
||||
|
||||
private final String strGroupeId = "Groupe ID";
|
||||
|
||||
private final String strArtefactID = "Artefact ID";
|
||||
|
||||
//TEXTFIELD search
|
||||
private final String strProcessID = "Process ID";
|
||||
|
||||
private final String strServerName = "Server Name";
|
||||
|
||||
private final String strStatus = "Status";
|
||||
private Grid<ProjectPersist> projectPersistGrid;
|
||||
private ListDataProvider<ProjectPersist> dataProvider;
|
||||
private ConfigurableFilterDataProvider<ProjectPersist, Void, SerializablePredicate<ProjectPersist>> filterDataProvider;
|
||||
private DeploymentAction deploymentAction;
|
||||
|
||||
//CONSTANTE Textfield
|
||||
private TextField nameDeploy;
|
||||
private TextField nameProject;
|
||||
private TextField groupeId;
|
||||
private TextField artifactId;
|
||||
private TextField processId;
|
||||
private TextField serverName;
|
||||
private ComboBox status;
|
||||
|
||||
//SERVICE
|
||||
|
||||
private ProjectPersistService projectPersistService;
|
||||
|
||||
private SqueletteComposant squeletteComposant;
|
||||
|
|
@ -138,7 +117,17 @@ public class DeploymentView extends VerticalLayout implements AddLog{
|
|||
processIDco.setHeader(processId);
|
||||
|
||||
|
||||
Grid.Column<ProjectPersist> serverNameCo=projectPersistGrid.addColumn(projectPersist -> projectPersist.getServerName());
|
||||
Grid.Column<ProjectPersist> serverNameCo = projectPersistGrid.addColumn(projectPersist -> {
|
||||
String result = null;
|
||||
for (String serverName : projectPersist.getServerNames()) {
|
||||
if (result != null) {
|
||||
result = result + ":" + serverName;
|
||||
} else {
|
||||
result = serverName;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
});
|
||||
serverName = new TextField(strServerName);
|
||||
serverName.setValueChangeMode(ValueChangeMode.EAGER);
|
||||
serverName.addValueChangeListener(e -> {
|
||||
|
|
@ -188,6 +177,7 @@ public class DeploymentView extends VerticalLayout implements AddLog{
|
|||
filterDataProvider.setFilter(filterGrid(value.toUpperCase(), type));
|
||||
projectPersistGrid.getDataProvider().refreshAll();
|
||||
}
|
||||
|
||||
private SerializablePredicate<ProjectPersist> filterGrid(String value, String type) {
|
||||
SerializablePredicate<ProjectPersist> columnPredicate = null;
|
||||
|
||||
|
|
@ -199,8 +189,7 @@ public class DeploymentView extends VerticalLayout implements AddLog{
|
|||
asset.getArtifactID() != null && asset.getArtifactID().toUpperCase().contains(value.toUpperCase()));
|
||||
} else if (type.equals(strGroupeId)) {
|
||||
columnPredicate = asset -> (asset.getGroupID() != null && asset.getGroupID().toUpperCase().contains(value.toUpperCase()));
|
||||
}
|
||||
else if(type.equals(strNameDeploy)){
|
||||
} else if (type.equals(strNameDeploy)) {
|
||||
columnPredicate = asset -> (asset.getDeploymentName() != null && asset.getDeploymentName().toUpperCase().contains(value.toUpperCase()));
|
||||
} else if (type.equals(strNameProject)) {
|
||||
columnPredicate = asset -> (asset.getProjectName() != null && asset.getProjectName().toString().toUpperCase().contains(value.toUpperCase()));
|
||||
|
|
@ -208,12 +197,11 @@ public class DeploymentView extends VerticalLayout implements AddLog{
|
|||
columnPredicate = asset -> (asset.getProcessID() != null && asset.getProcessID().toUpperCase().contains(value.toUpperCase()));
|
||||
} else if (type.equals(strStatus)) {
|
||||
columnPredicate = asset -> (asset.getStatus() != null && asset.getStatus().toUpperCase().equals(value.toUpperCase()));
|
||||
}else if(type.equals(strServerName)){
|
||||
columnPredicate = asset -> (asset.getServerName()!=null&&asset.getServerName().toUpperCase().equals(value.toUpperCase()));
|
||||
}
|
||||
}
|
||||
return columnPredicate;
|
||||
}
|
||||
|
||||
public void setDataProvider() {
|
||||
|
||||
HashMap<String, ProjectPersist> projectPersists = projectPersistService.getProjectsSession();
|
||||
|
|
@ -229,6 +217,7 @@ public class DeploymentView extends VerticalLayout implements AddLog{
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
public void reinitFilter() {
|
||||
|
||||
artifactId.setValue("");
|
||||
|
|
@ -237,6 +226,7 @@ public class DeploymentView extends VerticalLayout implements AddLog{
|
|||
nameProject.setValue("");
|
||||
nameDeploy.setValue("");
|
||||
}
|
||||
|
||||
public void majAction(ProjectPersist projectPersist) {
|
||||
if (projectPersist.getStatus().equals(ProjectPersist.DEFINI)) {
|
||||
|
||||
|
|
@ -251,12 +241,13 @@ public class DeploymentView extends VerticalLayout implements AddLog{
|
|||
getDeploymentAction().getDeployer().setEnabled(false);
|
||||
} else if (projectPersist.getStatus().equals(ProjectPersist.Deployable)) {
|
||||
|
||||
getDeploymentAction().getAssociateKieServer().setEnabled(false);
|
||||
getDeploymentAction().getDefinirProject().setEnabled(false);
|
||||
getDeploymentAction().getAssociateKieServer().setEnabled(true);
|
||||
getDeploymentAction().getDefinirProject().setEnabled(true);
|
||||
getDeploymentAction().getDeployer().setEnabled(true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRow(String textToAdd, UI ui) {
|
||||
|
||||
|
|
@ -285,6 +276,7 @@ public class DeploymentView extends VerticalLayout implements AddLog{
|
|||
ui.getSession().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public Grid<ProjectPersist> getProjectPersistGrid() {
|
||||
return projectPersistGrid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -177,11 +177,12 @@
|
|||
|
||||
<run>
|
||||
<extraHosts>
|
||||
<host>mongodb:192.168.1.102</host>
|
||||
<host>declasin:192.168.1.184</host>
|
||||
<host>mongodb:172.17.0.1</host>
|
||||
<host>kie-wb:172.17.0.1</host>
|
||||
</extraHosts>
|
||||
<ports>
|
||||
<port>8080:8080</port>
|
||||
<port>10080:8080</port>
|
||||
<port>10001:8001</port>
|
||||
</ports>
|
||||
</run>
|
||||
</image>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ ENV KIE_SERVER_PROFILE standalone-full
|
|||
ENV CHTIJBUG_VERSION 2.0.10
|
||||
# Do NOT use demo neither examples by default in this image (no internet connection required).
|
||||
ENV KIE_DEMO false
|
||||
ENV JAVA_OPTS -Xms256m -Xmx2512m
|
||||
ENV JAVA_OPTS -Xms256m -Xmx4512m
|
||||
|
||||
|
||||
|
||||
|
|
@ -33,10 +33,6 @@ ADD maven/kie-wb.war /opt/jboss/wildfly/standalone/deployments/$KIE_CONTEXT_PAT
|
|||
#touch $JBOSS_HOME/standalone/deployments/$KIE_CONTEXT_PATH.war.dodeploy && \
|
||||
# rm -rf $HOME/$KIE_CONTEXT_PATH.war
|
||||
|
||||
####### MVN REPO ############
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=1263738
|
||||
RUN mkdir -p $HOME/.m2/repository/org/guvnor/guvnor-asset-mgmt-project/$KIE_VERSION && \
|
||||
curl -o $HOME/.m2/repository/org/guvnor/guvnor-asset-mgmt-project/$KIE_VERSION/guvnor-asset-mgmt-project-$KIE_VERSION.jar $KIE_REPOSITORY/org/guvnor/guvnor-asset-mgmt-project/$KIE_VERSION/guvnor-asset-mgmt-project-$KIE_VERSION.jar
|
||||
|
||||
####### SCRIPTS ############
|
||||
USER root
|
||||
|
|
@ -66,20 +62,32 @@ chown jboss:jboss $JBOSS_HOME/standalone/configuration/application-roles.propert
|
|||
|
||||
# Switchback to jboss user
|
||||
USER root
|
||||
RUN yum install -y git
|
||||
#RUN yum install -y git
|
||||
RUN mkdir /home/db
|
||||
RUN mkdir /home/lucene
|
||||
RUN mkdir /home/niodir
|
||||
RUN mkdir /home/kie-example
|
||||
RUN mkdir /m2_kiewb
|
||||
ADD settings.xml /m2_kiewb/settings.xml
|
||||
RUN mkdir /m2_kiewb/repository
|
||||
####### MVN REPO ############
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=1263738
|
||||
RUN mkdir -p /m2_kiewb/repository/org/guvnor/guvnor-asset-mgmt-project/$KIE_VERSION && \
|
||||
curl -o /m2_kiewb/repository/org/guvnor/guvnor-asset-mgmt-project/$KIE_VERSION/guvnor-asset-mgmt-project-$KIE_VERSION.jar $KIE_REPOSITORY/org/guvnor/guvnor-asset-mgmt-project/$KIE_VERSION/guvnor-asset-mgmt-project-$KIE_VERSION.jar
|
||||
|
||||
RUN chown jboss:jboss /home/db
|
||||
RUN chown jboss:jboss /home/lucene
|
||||
RUN chown jboss:jboss /home/niodir
|
||||
RUN chown jboss:jboss /home/kie-example
|
||||
RUN chown jboss:jboss /m2_kiewb
|
||||
RUN chown -R jboss:jboss /m2_kiewb/repository
|
||||
|
||||
#RUN cd /home/kie-example && git clone https://github.com/chtiJBUG/onboarding-nautic-project.git
|
||||
#RUN cd /home/kie-example && git clone https://github.com/chtiJBUG/onboarding-carinsurance-project.git
|
||||
#RUN cd /home/kie-example && git clone https://github.com/chtiJBUG/onboarding-loyalty-project.git
|
||||
####### EXPOSE INTERNAL JBPM GIT PORT ############
|
||||
EXPOSE 8001
|
||||
EXPOSE 8080
|
||||
|
||||
####### RUNNING DROOLS-WB ############
|
||||
VOLUME /home/db
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
# Start Wildfly with the given arguments.
|
||||
echo "Running Drools Workbench on JBoss Wildfly..."
|
||||
exec ./standalone.sh -b $JBOSS_BIND_ADDRESS -c $KIE_SERVER_PROFILE.xml -Dorg.kie.demo=$KIE_DEMO -Dorg.kie.example=$KIE_DEMO -Djava.net.preferIPv4Stack=true -Dorg.kie.example.repositories=/home/kie-example -Dorg.kie.example=true -Dorg.uberfire.metadata.index.dir=/home/lucene -Dorg.uberfire.nio.git.daemon.host=0.0.0.0 -Dorg.guvnor.m2repo.dir=$JBOSS_HOME/.m2/repository -DM2_HOME==$JBOSS_HOME/.m2/repository -Dorg.uberfire.nio.git.dir=/home/niodir -Derrai.bus.enable_sse_support=false
|
||||
exec ./standalone.sh -b $JBOSS_BIND_ADDRESS -c $KIE_SERVER_PROFILE.xml -Djava.net.preferIPv4Stack=true -Dorg.uberfire.metadata.index.dir=/home/lucene -Dorg.uberfire.nio.git.daemon.host=0.0.0.0 -Dorg.guvnor.m2repo.dir=/m2_kiewb/repository -DM2_HOME=/m2_kiewb/repository -Dorg.uberfire.nio.git.dir=/home/niodir -Dorg.appformer.m2repo.url=http://localhost:8080/kie-wb/maven2 -Dkie.maven.settings.custom=/m2_kiewb/settings.xml -Dfile.encoding=UTF-8 -Duser.language=fr -Duser.country=FR
|
||||
exit $?
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,68 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
|
||||
<localRepository>/m2_kiewb/repository</localRepository>
|
||||
|
||||
<servers>
|
||||
|
||||
<server>
|
||||
<id>pymma-release</id>
|
||||
<username>pymma-dev</username>
|
||||
<password>VlcBe38jE9eNIu5H</password>
|
||||
</server>
|
||||
<server>
|
||||
<id>pymma-snapshot</id>
|
||||
<username>pymma-dev</username>
|
||||
<password>VlcBe38jE9eNIu5H</password>
|
||||
</server>
|
||||
|
||||
|
||||
|
||||
</servers>
|
||||
|
||||
|
||||
<mirrors>
|
||||
</mirrors>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>pymma-declasin</id>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>pymma-release</id>
|
||||
<name>pymma repo release</name>
|
||||
<url>https://nexus.pymma-software.com/nexus/content/repositories/pymma-release/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
<checksumPolicy>ignore</checksumPolicy>
|
||||
</releases>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>pymma-snapshot</id>
|
||||
<name>pymma repo release</name>
|
||||
<url>https://nexus.pymma-software.com/nexus/content/repositories/pymma-snapshot/</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
<checksumPolicy>ignore</checksumPolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
|
||||
</repositories>
|
||||
|
||||
|
||||
</profile>
|
||||
|
||||
|
||||
|
||||
</profiles>
|
||||
<activeProfiles>
|
||||
|
||||
|
||||
<activeProfile>pymma-declasin</activeProfile>
|
||||
</activeProfiles>
|
||||
|
||||
</settings>
|
||||
|
|
@ -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
|
||||
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