Merge pull request #30 from pymma/V1.0.x
Define our ServerStateRepository implementation to retrieve list of …
This commit is contained in:
commit
7117e6e82c
9 changed files with 115 additions and 25 deletions
|
|
@ -4,4 +4,5 @@ kieserver.login=kieserver
|
||||||
kieserver.password=kieserver1
|
kieserver.password=kieserver1
|
||||||
|
|
||||||
spring.data.mongodb.database=businessProxyDB
|
spring.data.mongodb.database=businessProxyDB
|
||||||
spring.data.mongodb.host=localhost:27017
|
spring.data.mongodb.host=localhost:28017
|
||||||
|
server.port=5547
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
package org.chtijbug.drools.proxy;
|
||||||
|
|
||||||
|
import org.chtijbug.drools.proxy.persistence.model.ContainerPojoPersist;
|
||||||
|
import org.chtijbug.drools.proxy.persistence.repository.ContainerRepository;
|
||||||
|
import org.chtijbug.drools.proxy.service.KieServiceCommon;
|
||||||
|
import org.kie.server.api.model.KieContainerResource;
|
||||||
|
import org.kie.server.api.model.KieServerConfig;
|
||||||
|
import org.kie.server.api.model.ReleaseId;
|
||||||
|
import org.kie.server.services.impl.storage.KieServerState;
|
||||||
|
import org.kie.server.services.impl.storage.KieServerStateRepository;
|
||||||
|
import org.kie.server.services.impl.storage.KieServerStateRepositoryUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PlatfomKieServerStateRepository implements KieServerStateRepository {
|
||||||
|
|
||||||
|
|
||||||
|
private ContainerRepository containerRepository;
|
||||||
|
|
||||||
|
private KieServiceCommon kieServiceCommon;
|
||||||
|
|
||||||
|
private KieServerState kieServerState = new KieServerState();
|
||||||
|
|
||||||
|
public PlatfomKieServerStateRepository(ContainerRepository containerRepository, KieServiceCommon kieServiceCommon) {
|
||||||
|
this.containerRepository = containerRepository;
|
||||||
|
this.kieServiceCommon = kieServiceCommon;
|
||||||
|
KieServerConfig config = new KieServerConfig();
|
||||||
|
KieServerStateRepositoryUtils.populateWithSystemProperties(config);
|
||||||
|
kieServerState.setConfiguration(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void store(String s, KieServerState kieServerState) {
|
||||||
|
System.out.println("coucou");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KieServerState load(String serverID) {
|
||||||
|
|
||||||
|
String serverName = KieServiceCommon.getKieServerID();
|
||||||
|
|
||||||
|
List<ContainerPojoPersist> containers = containerRepository.findByServerNameAndStatus(serverName, ContainerPojoPersist.STATUS.UP.toString());
|
||||||
|
for (ContainerPojoPersist element : containers) {
|
||||||
|
KieContainerResource newContainer = new KieContainerResource();
|
||||||
|
newContainer.setContainerId(element.getContainerId());
|
||||||
|
newContainer.setReleaseId(new ReleaseId());
|
||||||
|
newContainer.getReleaseId().setArtifactId(element.getArtifactId());
|
||||||
|
newContainer.getReleaseId().setGroupId(element.getGroupId());
|
||||||
|
newContainer.getReleaseId().setVersion(element.getVersion());
|
||||||
|
kieServerState.getContainers().add(newContainer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return kieServerState;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -22,8 +22,6 @@ public class AdminRouter extends RouteBuilder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configure() throws Exception {
|
public void configure() throws Exception {
|
||||||
System.out.println("coucou");
|
|
||||||
|
|
||||||
restConfiguration()
|
restConfiguration()
|
||||||
.component("servlet")
|
.component("servlet")
|
||||||
.bindingMode(RestBindingMode.json)
|
.bindingMode(RestBindingMode.json)
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package org.chtijbug.drools.proxy.service;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.apache.camel.CamelContext;
|
import org.apache.camel.CamelContext;
|
||||||
import org.apache.camel.Route;
|
import org.apache.camel.Route;
|
||||||
|
import org.chtijbug.drools.proxy.PlatfomKieServerStateRepository;
|
||||||
import org.chtijbug.drools.proxy.camel.DroolsRouter;
|
import org.chtijbug.drools.proxy.camel.DroolsRouter;
|
||||||
import org.chtijbug.drools.proxy.persistence.model.ContainerPojoPersist;
|
import org.chtijbug.drools.proxy.persistence.model.ContainerPojoPersist;
|
||||||
import org.chtijbug.drools.proxy.persistence.model.RuntimePersist;
|
import org.chtijbug.drools.proxy.persistence.model.RuntimePersist;
|
||||||
|
|
@ -30,7 +31,6 @@ import org.kie.server.services.api.KieServerExtension;
|
||||||
import org.kie.server.services.api.KieServerRegistry;
|
import org.kie.server.services.api.KieServerRegistry;
|
||||||
import org.kie.server.services.impl.KieContainerInstanceImpl;
|
import org.kie.server.services.impl.KieContainerInstanceImpl;
|
||||||
import org.kie.server.services.impl.KieServerImpl;
|
import org.kie.server.services.impl.KieServerImpl;
|
||||||
import org.kie.server.services.impl.KieServerLocator;
|
|
||||||
import org.kie.server.services.impl.marshal.MarshallerHelper;
|
import org.kie.server.services.impl.marshal.MarshallerHelper;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
@ -71,10 +71,21 @@ public class KieServiceCommon {
|
||||||
|
|
||||||
public KieServiceCommon() {
|
public KieServiceCommon() {
|
||||||
// for now, if no server impl is passed as parameter, create one
|
// for now, if no server impl is passed as parameter, create one
|
||||||
this.server = KieServerLocator.getInstance();
|
// this.server = KieServerLocator.getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getKieServerID(){
|
||||||
|
return System.getProperty("org.kie.server.id");
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
private void initCamelBusinessRoutes() {
|
||||||
|
|
||||||
|
this.server = new KieServerImpl(new PlatfomKieServerStateRepository(containerRepository,this));
|
||||||
|
this.server.init();
|
||||||
|
|
||||||
List<KieServerExtension> serverExtensions = this.server.getServerExtensions();
|
List<KieServerExtension> serverExtensions = this.server.getServerExtensions();
|
||||||
|
if (registry==null || droolsChtijbugKieServerExtension==null) {
|
||||||
for (KieServerExtension serverExtension : serverExtensions) {
|
for (KieServerExtension serverExtension : serverExtensions) {
|
||||||
if (serverExtension instanceof DroolsChtijbugKieServerExtension) {
|
if (serverExtension instanceof DroolsChtijbugKieServerExtension) {
|
||||||
droolsChtijbugKieServerExtension = (DroolsChtijbugKieServerExtension) serverExtension;
|
droolsChtijbugKieServerExtension = (DroolsChtijbugKieServerExtension) serverExtension;
|
||||||
|
|
@ -86,15 +97,10 @@ public class KieServiceCommon {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.marshallerHelper = new MarshallerHelper(this.server.getServerRegistry());
|
this.marshallerHelper = new MarshallerHelper(this.server.getServerRegistry());
|
||||||
}
|
|
||||||
|
|
||||||
public static String getKieServerID(){
|
|
||||||
return System.getProperty("org.kie.server.id");
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
private void initCamelBusinessRoutes() {
|
|
||||||
String serverName = KieServiceCommon.getKieServerID();
|
String serverName = KieServiceCommon.getKieServerID();
|
||||||
String sftpPort = System.getProperty("org.chtijbug.server.sftpPort");
|
String sftpPort = System.getProperty("org.chtijbug.server.sftpPort");
|
||||||
List<RuntimePersist> itIsMes = runtimeRepository.findByServerName(serverName);
|
List<RuntimePersist> itIsMes = runtimeRepository.findByServerName(serverName);
|
||||||
|
|
@ -131,9 +137,16 @@ public class KieServiceCommon {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
||||||
List<ContainerPojoPersist> containers = containerRepository.findByServerName(serverName);
|
for (KieContainerResource kieContainerResource : this.server.getServerState().getResult().getContainers()){
|
||||||
for (ContainerPojoPersist container : containers) {
|
|
||||||
this.initCamelBusinessRoute(container);
|
|
||||||
|
// this.createContainer(container.getContainerId(),)
|
||||||
|
|
||||||
|
this.createContainer(kieContainerResource.getContainerId(), kieContainerResource);
|
||||||
|
List<ContainerPojoPersist> containers = containerRepository.findByContainerId(kieContainerResource.getContainerId());
|
||||||
|
if (containers.size()==1) {
|
||||||
|
this.initCamelBusinessRoute(containers.get(0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.info("initCamelBusinessRoutes", e);
|
logger.info("initCamelBusinessRoutes", e);
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,6 @@ import org.springframework.stereotype.Component;
|
||||||
public class AutodeployRouter extends RouteBuilder {
|
public class AutodeployRouter extends RouteBuilder {
|
||||||
@Override
|
@Override
|
||||||
public void configure() throws Exception {
|
public void configure() throws Exception {
|
||||||
from("quartz2://myGroup/myTimerName?cron=0/5+*+*+?+*+*").to("bean:updateService?method=updateConfig()");
|
from("quartz2://myGroup/myTimerName?cron=0/30+*+*+?+*+*").to("bean:updateService?method=updateConfig()");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package org.chtijbug.drools.reverseproxy.mappings;
|
||||||
|
|
||||||
|
import com.github.mkopylec.charon.configuration.MappingProperties;
|
||||||
|
import com.github.mkopylec.charon.core.http.ForwardedRequestInterceptor;
|
||||||
|
import com.github.mkopylec.charon.core.http.RequestData;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class CustomForwardedRequestInterceptor implements ForwardedRequestInterceptor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void intercept(RequestData data, MappingProperties mapping) {
|
||||||
|
System.out.println("tptp");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -34,12 +34,15 @@ public class UpdateService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateConfig() {
|
public void updateConfig() {
|
||||||
|
/**
|
||||||
if (this.toUpdate==false) {
|
if (this.toUpdate==false) {
|
||||||
this.toUpdate = isToUpdate();
|
this.toUpdate = isToUpdate();
|
||||||
if (this.toUpdate==true){
|
if (this.toUpdate==true){
|
||||||
generateMappings();
|
generateMappings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
**/
|
||||||
|
generateMappings();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isToUpdate() {
|
private boolean isToUpdate() {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
server.port=9500
|
server.port=9500
|
||||||
spring.data.mongodb.database=businessProxyDB
|
spring.data.mongodb.database=businessProxyDB
|
||||||
spring.data.mongodb.host=localhost:27017
|
spring.data.mongodb.host=localhost:28017
|
||||||
|
charon.tracing.enabled=true
|
||||||
2
pom.xml
2
pom.xml
|
|
@ -20,7 +20,9 @@
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<jbpm.version>7.20.0.Final</jbpm.version>
|
<jbpm.version>7.20.0.Final</jbpm.version>
|
||||||
|
|
||||||
<spring.boot.version>2.1.2.RELEASE</spring.boot.version>
|
<spring.boot.version>2.1.2.RELEASE</spring.boot.version>
|
||||||
|
|
||||||
<spring.version>4.3.16.RELEASE</spring.version>
|
<spring.version>4.3.16.RELEASE</spring.version>
|
||||||
<version.thorntail>2.2.1.Final</version.thorntail>
|
<version.thorntail>2.2.1.Final</version.thorntail>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
|
||||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue