Refactoring for running in a docker swarm cluster
and upgrade to version 7.28.0
This commit is contained in:
parent
30600ac30e
commit
e2c87e9d20
15 changed files with 254 additions and 117 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
package org.chtijbug.drools.console.vaadinComponent.componentView;
|
package org.chtijbug.drools.console.vaadinComponent.componentView;
|
||||||
|
|
||||||
import com.vaadin.flow.component.grid.Grid;
|
import com.vaadin.flow.component.grid.Grid;
|
||||||
|
import com.vaadin.flow.component.html.Label;
|
||||||
import com.vaadin.flow.component.textfield.TextField;
|
import com.vaadin.flow.component.textfield.TextField;
|
||||||
import com.vaadin.flow.data.provider.ConfigurableFilterDataProvider;
|
import com.vaadin.flow.data.provider.ConfigurableFilterDataProvider;
|
||||||
import com.vaadin.flow.data.provider.ListDataProvider;
|
import com.vaadin.flow.data.provider.ListDataProvider;
|
||||||
|
|
@ -12,10 +13,11 @@ import org.chtijbug.drools.console.service.RuntimeService;
|
||||||
import org.chtijbug.drools.console.service.util.AppContext;
|
import org.chtijbug.drools.console.service.util.AppContext;
|
||||||
import org.chtijbug.drools.proxy.persistence.model.ProjectPersist;
|
import org.chtijbug.drools.proxy.persistence.model.ProjectPersist;
|
||||||
import org.chtijbug.drools.proxy.persistence.model.RuntimePersist;
|
import org.chtijbug.drools.proxy.persistence.model.RuntimePersist;
|
||||||
import com.vaadin.flow.component.html.Label;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class GridRuntime extends Grid<RuntimePersist> {
|
public class GridRuntime extends Grid<RuntimePersist> {
|
||||||
|
|
||||||
|
|
@ -41,17 +43,12 @@ public class GridRuntime extends Grid<RuntimePersist> {
|
||||||
private ListDataProvider<RuntimePersist> dataProvider;
|
private ListDataProvider<RuntimePersist> dataProvider;
|
||||||
private ConfigurableFilterDataProvider<RuntimePersist, Void, SerializablePredicate<RuntimePersist>> filterDataProvider;
|
private ConfigurableFilterDataProvider<RuntimePersist, Void, SerializablePredicate<RuntimePersist>> filterDataProvider;
|
||||||
|
|
||||||
private ProjectPersist projectPersist;
|
private ProjectPersist projectPersist = null;
|
||||||
|
|
||||||
public GridRuntime(ProjectPersist projectPersist) {
|
public GridRuntime(ProjectPersist projectPersist) {
|
||||||
this.projectPersist = projectPersist;
|
this.projectPersist = projectPersist;
|
||||||
init();
|
init();
|
||||||
//dataProvider.get
|
|
||||||
for (RuntimePersist runtimePersist : dataProvider.getItems()){
|
|
||||||
if (projectPersist.getServerNames().contains(runtimePersist.getServerName())){
|
|
||||||
getSelectionModel().select(runtimePersist);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -59,6 +56,7 @@ public class GridRuntime extends Grid<RuntimePersist> {
|
||||||
init();
|
init();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
projectPersistService = AppContext.getApplicationContext().getBean(ProjectPersistService.class);
|
projectPersistService = AppContext.getApplicationContext().getBean(ProjectPersistService.class);
|
||||||
runtimeService = AppContext.getApplicationContext().getBean(RuntimeService.class);
|
runtimeService = AppContext.getApplicationContext().getBean(RuntimeService.class);
|
||||||
|
|
@ -74,7 +72,7 @@ public class GridRuntime extends Grid<RuntimePersist> {
|
||||||
});
|
});
|
||||||
runtimeNameCo.setHeader(runtimeName);
|
runtimeNameCo.setHeader(runtimeName);
|
||||||
|
|
||||||
Grid.Column<RuntimePersist> hostnameCo=addColumn(runtimePersist -> runtimePersist.getHostname());
|
Grid.Column<RuntimePersist> hostnameCo = addColumn(runtimePersist -> runtimePersist.getServerUrl());
|
||||||
hostName = new TextField(strHostName);
|
hostName = new TextField(strHostName);
|
||||||
hostName.setValueChangeMode(ValueChangeMode.EAGER);
|
hostName.setValueChangeMode(ValueChangeMode.EAGER);
|
||||||
hostName.addValueChangeListener(e -> {
|
hostName.addValueChangeListener(e -> {
|
||||||
|
|
@ -109,18 +107,20 @@ public class GridRuntime extends Grid<RuntimePersist> {
|
||||||
|
|
||||||
setDataProvider();
|
setDataProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshtGrid(String value, String type) {
|
private void refreshtGrid(String value, String type) {
|
||||||
|
|
||||||
filterDataProvider.setFilter(filterGrid(value.toUpperCase(), type));
|
filterDataProvider.setFilter(filterGrid(value.toUpperCase(), type));
|
||||||
getDataProvider().refreshAll();
|
getDataProvider().refreshAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
private SerializablePredicate<RuntimePersist> filterGrid(String value, String type) {
|
private SerializablePredicate<RuntimePersist> filterGrid(String value, String type) {
|
||||||
SerializablePredicate<RuntimePersist> columnPredicate = null;
|
SerializablePredicate<RuntimePersist> columnPredicate = null;
|
||||||
if (value.equals(" ") || type.equals(" ")) {
|
if (value.equals(" ") || type.equals(" ")) {
|
||||||
columnPredicate = runtimePersist -> (true);
|
columnPredicate = runtimePersist -> (true);
|
||||||
} else {
|
} else {
|
||||||
if (type.equals(strHostName)) {
|
if (type.equals(strHostName)) {
|
||||||
columnPredicate = runtimePersist -> (runtimePersist.getHostname()!=null&&runtimePersist.getHostname().toUpperCase().contains(value));
|
columnPredicate = runtimePersist -> (runtimePersist.getServerUrl() != null && runtimePersist.getServerUrl().toUpperCase().contains(value));
|
||||||
|
|
||||||
} else if (type.equals(strRuntimeName)) {
|
} else if (type.equals(strRuntimeName)) {
|
||||||
columnPredicate = runtimePersist -> (runtimePersist.getServerName() != null && runtimePersist.getServerName().toUpperCase().contains(value));
|
columnPredicate = runtimePersist -> (runtimePersist.getServerName() != null && runtimePersist.getServerName().toUpperCase().contains(value));
|
||||||
|
|
@ -136,8 +136,29 @@ public class GridRuntime extends Grid<RuntimePersist> {
|
||||||
|
|
||||||
List<RuntimePersist> runtimePersists = runtimeService.getRuntimeRepository().findAll();
|
List<RuntimePersist> runtimePersists = runtimeService.getRuntimeRepository().findAll();
|
||||||
if (runtimePersists != null) {
|
if (runtimePersists != null) {
|
||||||
dataProvider = new ListDataProvider<>(runtimePersists);
|
List<RuntimePersist> runtimeToShow = new ArrayList<>();
|
||||||
|
Map<String, String> urlMap = new HashMap<>();
|
||||||
|
for (RuntimePersist runtimePersist : runtimePersists) {
|
||||||
|
if (urlMap.containsKey(runtimePersist.getServerName()) == false) {
|
||||||
|
|
||||||
|
urlMap.put(runtimePersist.getServerName(), runtimePersist.getServerUrl());
|
||||||
|
RuntimePersist runtimePersist1 = runtimePersist.duplicate();
|
||||||
|
if (projectPersist != null) {
|
||||||
|
if (projectPersist.getServerNames().contains(runtimePersist1.getServerName())) {
|
||||||
|
runtimeToShow.add(runtimePersist1);
|
||||||
|
getSelectionModel().select(runtimePersist1);
|
||||||
|
} else {
|
||||||
|
if (projectPersist.getServerNames().size() == 0){
|
||||||
|
runtimeToShow.add(runtimePersist1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
runtimeToShow.add(runtimePersist1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dataProvider = new ListDataProvider<>(runtimeToShow);
|
||||||
filterDataProvider = dataProvider.withConfigurableFilter();
|
filterDataProvider = dataProvider.withConfigurableFilter();
|
||||||
setDataProvider(filterDataProvider);
|
setDataProvider(filterDataProvider);
|
||||||
|
|
||||||
|
|
@ -145,6 +166,7 @@ public class GridRuntime extends Grid<RuntimePersist> {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reinitFilter() {
|
public void reinitFilter() {
|
||||||
hostName.setValue("");
|
hostName.setValue("");
|
||||||
version.setValue("");
|
version.setValue("");
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,13 @@ import org.chtijbug.drools.console.service.model.kie.KieConfigurationData;
|
||||||
import org.chtijbug.drools.console.service.util.AppContext;
|
import org.chtijbug.drools.console.service.util.AppContext;
|
||||||
import org.chtijbug.drools.console.vaadinComponent.ComponentPerso.DialogPerso;
|
import org.chtijbug.drools.console.vaadinComponent.ComponentPerso.DialogPerso;
|
||||||
import org.chtijbug.drools.console.vaadinComponent.componentView.AssetEdit;
|
import org.chtijbug.drools.console.vaadinComponent.componentView.AssetEdit;
|
||||||
|
import org.chtijbug.drools.console.vaadinComponent.componentView.service.dtmodel.ColumnDefinition;
|
||||||
|
import org.chtijbug.drools.console.vaadinComponent.componentView.service.dtmodel.DecisionTable;
|
||||||
|
import org.chtijbug.drools.console.vaadinComponent.componentView.service.dtmodel.GuidedException;
|
||||||
|
import org.chtijbug.drools.console.vaadinComponent.componentView.service.dtmodel.Row;
|
||||||
import org.drools.workbench.models.datamodel.rule.InterpolationVariable;
|
import org.drools.workbench.models.datamodel.rule.InterpolationVariable;
|
||||||
|
import org.drools.workbench.models.guided.dtable.backend.GuidedDTXMLPersistence;
|
||||||
|
import org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52;
|
||||||
import org.drools.workbench.models.guided.template.backend.RuleTemplateModelXMLPersistenceImpl;
|
import org.drools.workbench.models.guided.template.backend.RuleTemplateModelXMLPersistenceImpl;
|
||||||
import org.drools.workbench.models.guided.template.shared.TemplateModel;
|
import org.drools.workbench.models.guided.template.shared.TemplateModel;
|
||||||
import org.vaadin.olli.FileDownloadWrapper;
|
import org.vaadin.olli.FileDownloadWrapper;
|
||||||
|
|
@ -114,7 +120,6 @@ public class EditTemplateView extends VerticalLayout {
|
||||||
TemplateModel model = RuleTemplateModelXMLPersistenceImpl.getInstance().unmarshal(assetSource);
|
TemplateModel model = RuleTemplateModelXMLPersistenceImpl.getInstance().unmarshal(assetSource);
|
||||||
int id=model.getColsCount();
|
int id=model.getColsCount();
|
||||||
model.clearRows();
|
model.clearRows();
|
||||||
Map<String, List<String>> existingData = model.getTable();
|
|
||||||
for (Map<String,Object> line : objects){
|
for (Map<String,Object> line : objects){
|
||||||
String[] cols =new String[model.getColsCount()];
|
String[] cols =new String[model.getColsCount()];
|
||||||
int k=0;
|
int k=0;
|
||||||
|
|
@ -142,11 +147,35 @@ public class EditTemplateView extends VerticalLayout {
|
||||||
} else {
|
} else {
|
||||||
List<HashMap<String, Object>> objects = decisionTableExcelService.importExcel(fileBuffer.getInputStream());
|
List<HashMap<String, Object>> objects = decisionTableExcelService.importExcel(fileBuffer.getInputStream());
|
||||||
if (objects != null && objects.size() > 0) {
|
if (objects != null && objects.size() > 0) {
|
||||||
|
Notification.show("Unable to add columns with the excel import for the moment");
|
||||||
|
}else{
|
||||||
|
remove(assetEdit);
|
||||||
|
assetEdit = new AssetEdit(objects);
|
||||||
|
add(assetEdit);
|
||||||
|
String assetSource=this.getAssetContent();
|
||||||
|
GuidedDecisionTable52 model = GuidedDTXMLPersistence.getInstance().unmarshal(assetSource);
|
||||||
|
org.chtijbug.drools.console.vaadinComponent.componentView.service.dtmodel.DecisionTable decisionTable = new DecisionTable(model);
|
||||||
|
decisionTable.getRows().clear();
|
||||||
|
List<ColumnDefinition> columnDefinitions = decisionTable.getColumnDefinitionList();
|
||||||
|
int k=0;
|
||||||
|
for (HashMap<String, Object> line : objects){
|
||||||
|
Row row = decisionTable.createEmptyRow(k);
|
||||||
|
for (ColumnDefinition columnDefinition : columnDefinitions){
|
||||||
|
line.get(columnDefinition.getHeader());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//row.
|
||||||
|
}
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
|
||||||
Notification.show("The file is incompatible, it must be in xlsx format");
|
Notification.show("The file is incompatible, it must be in xlsx format");
|
||||||
|
} catch (GuidedException e) {
|
||||||
|
Notification.show("error "+e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ public class RuntimesView extends VerticalLayout {
|
||||||
|
|
||||||
public RuntimesView(){
|
public RuntimesView(){
|
||||||
|
|
||||||
add(new Label("Runtimes enrigistré"));
|
add(new Label("Runtimes stored"));
|
||||||
add(new GridRuntime());
|
add(new GridRuntime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,9 @@
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="Maven: org.kie:kie-internal:7.23.0.Final" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.kie:kie-api:7.23.0.Final" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.kie.soup:kie-soup-maven-support:7.23.0.Final" 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-web:2.1.0.RELEASE" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.1.0.RELEASE" level="project" />
|
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.1.0.RELEASE" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.1.0.RELEASE" level="project" />
|
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.1.0.RELEASE" level="project" />
|
||||||
|
|
@ -147,8 +150,8 @@
|
||||||
<orderEntry type="library" name="Maven: com.google.guava:guava:13.0.1" level="project" />
|
<orderEntry type="library" name="Maven: com.google.guava:guava:13.0.1" level="project" />
|
||||||
<orderEntry type="library" name="Maven: commons-io:commons-io:2.6" level="project" />
|
<orderEntry type="library" name="Maven: commons-io:commons-io:2.6" 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-databind:2.9.7" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.kie:kie-internal:7.23.0.Final" level="project" />
|
<orderEntry type="library" name="Maven: org.kie:kie-internal:7.28.0.Final" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.kie:kie-api:7.23.0.Final" level="project" />
|
<orderEntry type="library" name="Maven: org.kie:kie-api:7.28.0.Final" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.kie.soup:kie-soup-maven-support:7.23.0.Final" level="project" />
|
<orderEntry type="library" name="Maven: org.kie.soup:kie-soup-maven-support:7.28.0.Final" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
|
|
@ -14,6 +14,9 @@
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="Maven: org.kie:kie-internal:7.23.0.Final" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.kie:kie-api:7.23.0.Final" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.kie.soup:kie-soup-maven-support:7.23.0.Final" level="project" />
|
||||||
<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.boot:spring-boot-starter-data-elasticsearch:2.1.0.RELEASE" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.1.0.RELEASE" level="project" />
|
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.1.0.RELEASE" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.1.0.RELEASE" level="project" />
|
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.1.0.RELEASE" level="project" />
|
||||||
|
|
@ -92,8 +95,8 @@
|
||||||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||||
<orderEntry type="library" name="Maven: com.google.guava:guava:13.0.1" level="project" />
|
<orderEntry type="library" name="Maven: com.google.guava:guava:13.0.1" level="project" />
|
||||||
<orderEntry type="library" name="Maven: commons-io:commons-io:2.1" level="project" />
|
<orderEntry type="library" name="Maven: commons-io:commons-io:2.1" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.kie:kie-internal:7.23.0.Final" level="project" />
|
<orderEntry type="library" name="Maven: org.kie:kie-internal:7.28.0.Final" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.kie:kie-api:7.23.0.Final" level="project" />
|
<orderEntry type="library" name="Maven: org.kie:kie-api:7.28.0.Final" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.kie.soup:kie-soup-maven-support:7.23.0.Final" level="project" />
|
<orderEntry type="library" name="Maven: org.kie.soup:kie-soup-maven-support:7.28.0.Final" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
|
|
@ -94,7 +94,10 @@
|
||||||
<groupId>org.apache.camel</groupId>
|
<groupId>org.apache.camel</groupId>
|
||||||
<artifactId>camel-quartz2</artifactId>
|
<artifactId>camel-quartz2</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.camel</groupId>
|
||||||
|
<artifactId>camel-quartz2</artifactId>
|
||||||
|
</dependency>
|
||||||
<!-- Test -->
|
<!-- Test -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,14 @@ package org.chtijbug.drools.proxy;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
// CHECKSTYLE:OFF
|
// CHECKSTYLE:OFF
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
@Configuration
|
||||||
public class DroolsBusinessProxyServer {
|
public class DroolsBusinessProxyServer {
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,19 +2,14 @@ package org.chtijbug.drools.proxy.camel;
|
||||||
|
|
||||||
import org.apache.camel.builder.RouteBuilder;
|
import org.apache.camel.builder.RouteBuilder;
|
||||||
import org.apache.camel.model.rest.RestBindingMode;
|
import org.apache.camel.model.rest.RestBindingMode;
|
||||||
import org.chtijbug.drools.proxy.service.KieServiceCommon;
|
|
||||||
import org.kie.server.api.model.KieServerInfo;
|
import org.kie.server.api.model.KieServerInfo;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class AdminRouter extends RouteBuilder {
|
public class AdminRouter extends RouteBuilder {
|
||||||
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
KieServiceCommon kieServiceCommon;
|
|
||||||
@Value("${server.port}")
|
@Value("${server.port}")
|
||||||
private int serverPort;
|
private int serverPort;
|
||||||
@Value("${camel.component.servlet.mapping.context-path}")
|
@Value("${camel.component.servlet.mapping.context-path}")
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
package org.chtijbug.drools.proxy.camel;
|
||||||
|
|
||||||
|
import org.apache.camel.builder.RouteBuilder;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class AliveTimeStampRouter extends RouteBuilder {
|
||||||
|
@Override
|
||||||
|
public void configure() throws Exception {
|
||||||
|
from("quartz2://myGroup/myTimeStampTimer?cron=0/5+*+*+?+*+*").to("bean:kieService?method=setTimeStamp()");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -36,10 +36,10 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.annotation.PreDestroy;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.ws.rs.core.Context;
|
import javax.ws.rs.core.Context;
|
||||||
import javax.ws.rs.core.HttpHeaders;
|
import javax.ws.rs.core.HttpHeaders;
|
||||||
|
|
@ -67,6 +67,11 @@ public class KieServiceCommon {
|
||||||
@Value("${server.port}")
|
@Value("${server.port}")
|
||||||
private int serverPort;
|
private int serverPort;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationContext appContext;
|
||||||
|
|
||||||
|
private String hostName= "localhost";
|
||||||
|
|
||||||
private Map<String, DroolsRouter> routes = new HashMap<>();
|
private Map<String, DroolsRouter> routes = new HashMap<>();
|
||||||
|
|
||||||
public KieServiceCommon() {
|
public KieServiceCommon() {
|
||||||
|
|
@ -103,37 +108,48 @@ public class KieServiceCommon {
|
||||||
|
|
||||||
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);
|
|
||||||
if (itIsMes.size() == 0) {
|
|
||||||
ServiceResponse<KieServerInfo> result = server.getInfo();
|
|
||||||
String version = result.getResult().getVersion();
|
|
||||||
String hostName = "localhost";
|
|
||||||
try {
|
try {
|
||||||
InetAddress inetAddress = InetAddress.getLocalHost();
|
InetAddress inetAddress = InetAddress.getLocalHost();
|
||||||
hostName = inetAddress.getHostName();
|
hostName = inetAddress.getHostName();
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
logger.info("initCamelBusinessRoutes.getLocalHost", e);
|
logger.info("initCamelBusinessRoutes.getLocalHost", e);
|
||||||
}
|
}
|
||||||
RuntimePersist runtimePersist = new RuntimePersist(serverName, version, "http://" + hostName + ":" + serverPort,
|
List<RuntimePersist> itIsMes = runtimeRepository.findByServerName(serverName);
|
||||||
|
ServiceResponse<KieServerInfo> result = server.getInfo();
|
||||||
|
String version = result.getResult().getVersion();
|
||||||
|
String isSwarm=System.getProperty("org.kie.server.swarm");
|
||||||
|
if (itIsMes.size() == 0) {
|
||||||
|
|
||||||
|
RuntimePersist runtimePersist = new RuntimePersist(serverName, version, hostName ,
|
||||||
String.valueOf(serverPort), sftpPort,
|
String.valueOf(serverPort), sftpPort,
|
||||||
hostName, RuntimePersist.STATUS.UP.toString());
|
hostName, RuntimePersist.STATUS.UP.toString());
|
||||||
runtimeRepository.save(runtimePersist);
|
if ("1".equals(isSwarm)) {
|
||||||
|
runtimePersist.setServerUrl("http://" + serverName + ":" + serverPort);
|
||||||
}else {
|
}else {
|
||||||
RuntimePersist runtimePersist =itIsMes.get(0);
|
runtimePersist.setServerUrl("http://" + hostName + ":" + serverPort);
|
||||||
runtimePersist.setStatus(RuntimePersist.STATUS.UP.toString());
|
|
||||||
try {
|
|
||||||
/**
|
|
||||||
* HostName may have changed by reboot so retake it and save it
|
|
||||||
*/
|
|
||||||
InetAddress inetAddress = InetAddress.getLocalHost();
|
|
||||||
String hostName = inetAddress.getHostName();
|
|
||||||
runtimePersist.setHostname("http://" + hostName + ":" + serverPort);
|
|
||||||
runtimePersist.setSftpHost(hostName);
|
|
||||||
runtimePersist.setSftpPort(sftpPort);
|
|
||||||
} catch (UnknownHostException e) {
|
|
||||||
logger.info("initCamelBusinessRoutes.getLocalHost", e);
|
|
||||||
}
|
}
|
||||||
runtimeRepository.save(runtimePersist);
|
runtimeRepository.save(runtimePersist);
|
||||||
|
} else {
|
||||||
|
List<RuntimePersist> byServerNameAndHostname = runtimeRepository.findByServerNameAndHostname(serverName, hostName);
|
||||||
|
if (byServerNameAndHostname.size() == 0) {
|
||||||
|
RuntimePersist runtimePersist = new RuntimePersist(serverName, version, hostName ,
|
||||||
|
String.valueOf(serverPort), sftpPort,
|
||||||
|
hostName, RuntimePersist.STATUS.UP.toString());
|
||||||
|
if ("1".equals(isSwarm)) {
|
||||||
|
runtimePersist.setServerUrl("http://" + serverName + ":" + serverPort);
|
||||||
|
}else {
|
||||||
|
runtimePersist.setServerUrl("http://" + hostName + ":" + serverPort);
|
||||||
|
}
|
||||||
|
runtimePersist.setSftpHost(hostName);
|
||||||
|
runtimePersist.setSftpPort(sftpPort);
|
||||||
|
|
||||||
|
runtimeRepository.save(runtimePersist);
|
||||||
|
}else{
|
||||||
|
RuntimePersist runtimePersist =byServerNameAndHostname.get(0);
|
||||||
|
runtimePersist.setStatus(RuntimePersist.STATUS.UP.toString());
|
||||||
|
runtimeRepository.save(runtimePersist);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
@ -151,18 +167,29 @@ public class KieServiceCommon {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.info("initCamelBusinessRoutes", e);
|
logger.info("initCamelBusinessRoutes", e);
|
||||||
}
|
}
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||||
}
|
public void run() {
|
||||||
@PreDestroy
|
|
||||||
public void stopRuntime(){
|
|
||||||
String serverName = KieServiceCommon.getKieServerID();
|
String serverName = KieServiceCommon.getKieServerID();
|
||||||
List<RuntimePersist> itIsMes = runtimeRepository.findByServerName(serverName);
|
List<RuntimePersist> itIsMes = runtimeRepository.findByServerNameAndHostname(serverName,hostName);
|
||||||
if (itIsMes.size() == 1) {
|
if (itIsMes.size() == 1) {
|
||||||
RuntimePersist runtimePersist = itIsMes.get(0);
|
RuntimePersist runtimePersist = itIsMes.get(0);
|
||||||
runtimePersist.setStatus(RuntimePersist.STATUS.DOWN.toString());
|
runtimePersist.setStatus(RuntimePersist.STATUS.DOWN.toString());
|
||||||
|
runtimeRepository.delete(runtimePersist);
|
||||||
|
}
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setTimeStamp(){
|
||||||
|
String serverName = KieServiceCommon.getKieServerID();
|
||||||
|
List<RuntimePersist> itIsMes = runtimeRepository.findByServerNameAndHostname(serverName,hostName);
|
||||||
|
if (itIsMes.size() == 1) {
|
||||||
|
RuntimePersist runtimePersist = itIsMes.get(0);
|
||||||
|
runtimePersist.setTimeStamp(new Date());
|
||||||
runtimeRepository.save(runtimePersist);
|
runtimeRepository.save(runtimePersist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteCamelBusinessRoute(String containerId) throws Exception {
|
public void deleteCamelBusinessRoute(String containerId) throws Exception {
|
||||||
if (routes.containsKey(containerId)) {
|
if (routes.containsKey(containerId)) {
|
||||||
DroolsRouter routeToDelete = routes.get(containerId);
|
DroolsRouter routeToDelete = routes.get(containerId);
|
||||||
|
|
|
||||||
|
|
@ -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/30+*+*+?+*+*").to("bean:updateService?method=updateConfig()");
|
from("quartz2://myGroup/myTimerName?cron=0/10+*+*+?+*+*").to("bean:updateService?method=updateConfig()");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,9 +49,13 @@ public class UpdateService {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
runtimes.clear();
|
runtimes.clear();
|
||||||
List<RuntimePersist> runtimePersists = runtimeRepository.findAll();
|
List<RuntimePersist> runtimePersists = runtimeRepository.findAll();
|
||||||
|
Map<String, String> urlMap = new HashMap<>();
|
||||||
for (RuntimePersist runtimePersist : runtimePersists) {
|
for (RuntimePersist runtimePersist : runtimePersists) {
|
||||||
|
if (urlMap.containsKey(runtimePersist.getServerName()) == false) {
|
||||||
|
urlMap.put(runtimePersist.getServerName(), runtimePersist.getServerUrl());
|
||||||
runtimes.put(runtimePersist.getServerName(), runtimePersist.duplicate());
|
runtimes.put(runtimePersist.getServerName(), runtimePersist.duplicate());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
List<ProjectPersist> projectPersists = projectRepository.findAll();
|
List<ProjectPersist> projectPersists = projectRepository.findAll();
|
||||||
List<String> projectOk = new ArrayList<>();
|
List<String> projectOk = new ArrayList<>();
|
||||||
for (ProjectPersist projectPersist : projectPersists) {
|
for (ProjectPersist projectPersist : projectPersists) {
|
||||||
|
|
@ -95,6 +99,14 @@ public class UpdateService {
|
||||||
projects.clear();
|
projects.clear();
|
||||||
List<MappingProperties> paths = new ArrayList<>();
|
List<MappingProperties> paths = new ArrayList<>();
|
||||||
Collection<ProjectPersist> projectPersists = projectRepository.findAll();
|
Collection<ProjectPersist> projectPersists = projectRepository.findAll();
|
||||||
|
Map<String, String> urlMap = new HashMap<>();
|
||||||
|
List<RuntimePersist> runtimePersists = runtimeRepository.findAll();
|
||||||
|
for (RuntimePersist runtimePersist : runtimePersists) {
|
||||||
|
if (urlMap.containsKey(runtimePersist.getServerName()) == false) {
|
||||||
|
urlMap.put(runtimePersist.getServerName(), runtimePersist.getServerUrl());
|
||||||
|
runtimes.put(runtimePersist.getServerName(), runtimePersist.duplicate());
|
||||||
|
}
|
||||||
|
}
|
||||||
for (ProjectPersist projectPersist : projectPersists) {
|
for (ProjectPersist projectPersist : projectPersists) {
|
||||||
if (projectPersist.getServerNames().size() > 0) {
|
if (projectPersist.getServerNames().size() > 0) {
|
||||||
projects.put(projectPersist.getContainerID(), projectPersist.duplicate());
|
projects.put(projectPersist.getContainerID(), projectPersist.duplicate());
|
||||||
|
|
@ -103,7 +115,7 @@ public class UpdateService {
|
||||||
for (String serverName : projectPersist.getServerNames()) {
|
for (String serverName : projectPersist.getServerNames()) {
|
||||||
RuntimePersist runtimePersist = runtimes.get(serverName);
|
RuntimePersist runtimePersist = runtimes.get(serverName);
|
||||||
if (runtimePersist!= null) {
|
if (runtimePersist!= null) {
|
||||||
String hostName = runtimePersist.getHostname() + "/api/" + projectPersist.getContainerID();
|
String hostName = runtimePersist.getServerUrl() + "/api/" + projectPersist.getContainerID();
|
||||||
mappingProperties2.getDestinations().add(hostName);
|
mappingProperties2.getDestinations().add(hostName);
|
||||||
if (servList==null){
|
if (servList==null){
|
||||||
servList=serverName;
|
servList=serverName;
|
||||||
|
|
@ -120,7 +132,7 @@ public class UpdateService {
|
||||||
mappingProperties2.setStripPath(true);
|
mappingProperties2.setStripPath(true);
|
||||||
if ( mappingProperties2.getDestinations().size()>0) {
|
if ( mappingProperties2.getDestinations().size()>0) {
|
||||||
paths.add(mappingProperties2);
|
paths.add(mappingProperties2);
|
||||||
logger.info("Project "+projectPersist.getContainerID()+" defined on servers - "+servList);
|
logger.info("Project "+projectPersist.getContainerID()+" defined on servers - "+mappingProperties2.getDestinations().toString());
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
logger.error("Project "+projectPersist.getContainerID()+" defined on non existing server");
|
logger.error("Project "+projectPersist.getContainerID()+" defined on non existing server");
|
||||||
|
|
@ -136,16 +148,6 @@ public class UpdateService {
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void initConfig() {
|
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();
|
generateMappings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.mongodb.core.index.Indexed;
|
import org.springframework.data.mongodb.core.index.Indexed;
|
||||||
import org.springframework.data.mongodb.core.mapping.Document;
|
import org.springframework.data.mongodb.core.mapping.Document;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
public class RuntimePersist {
|
public class RuntimePersist {
|
||||||
public enum STATUS {
|
public enum STATUS {
|
||||||
|
|
@ -18,9 +20,11 @@ public class RuntimePersist {
|
||||||
private String serverName;
|
private String serverName;
|
||||||
|
|
||||||
private String version;
|
private String version;
|
||||||
|
@Indexed
|
||||||
private String hostname;
|
private String hostname;
|
||||||
|
|
||||||
|
private String serverUrl;
|
||||||
|
|
||||||
private String serverPort;
|
private String serverPort;
|
||||||
|
|
||||||
private String sftpHost;
|
private String sftpHost;
|
||||||
|
|
@ -29,6 +33,11 @@ public class RuntimePersist {
|
||||||
|
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
|
private Date creationDate;
|
||||||
|
|
||||||
|
private Date timeStamp;
|
||||||
|
|
||||||
|
|
||||||
public RuntimePersist(String serverName, String version, String hostname,String serverPort,String sftpPort,String sftpHost,String status) {
|
public RuntimePersist(String serverName, String version, String hostname,String serverPort,String sftpPort,String sftpHost,String status) {
|
||||||
this.serverName = serverName;
|
this.serverName = serverName;
|
||||||
this.version = version;
|
this.version = version;
|
||||||
|
|
@ -37,10 +46,19 @@ public class RuntimePersist {
|
||||||
this.sftpPort = sftpPort;
|
this.sftpPort = sftpPort;
|
||||||
this.sftpHost = sftpHost;
|
this.sftpHost = sftpHost;
|
||||||
this.status=status;
|
this.status=status;
|
||||||
|
this.creationDate = new Date();
|
||||||
|
}
|
||||||
|
|
||||||
|
public RuntimePersist(String serverName) {
|
||||||
|
this.serverName = serverName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RuntimePersist() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public RuntimePersist duplicate(){
|
public RuntimePersist duplicate(){
|
||||||
RuntimePersist duplicate = new RuntimePersist(serverName,version,hostname,serverPort,sftpPort,sftpHost,status);
|
RuntimePersist duplicate = new RuntimePersist(serverName,version,hostname,serverPort,sftpPort,sftpHost,status);
|
||||||
|
duplicate.setServerUrl(this.serverUrl);
|
||||||
return duplicate;
|
return duplicate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -107,4 +125,24 @@ public class RuntimePersist {
|
||||||
public void setStatus(String status) {
|
public void setStatus(String status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getServerUrl() {
|
||||||
|
return serverUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setServerUrl(String serverUrl) {
|
||||||
|
this.serverUrl = serverUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreationDate() {
|
||||||
|
return creationDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getTimeStamp() {
|
||||||
|
return timeStamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimeStamp(Date timeStamp) {
|
||||||
|
this.timeStamp = timeStamp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,4 +10,5 @@ import java.util.List;
|
||||||
public interface RuntimeRepository extends MongoRepository<RuntimePersist, String> {
|
public interface RuntimeRepository extends MongoRepository<RuntimePersist, String> {
|
||||||
|
|
||||||
public List<RuntimePersist> findByServerName(String serverName);
|
public List<RuntimePersist> findByServerName(String serverName);
|
||||||
|
public List<RuntimePersist> findByServerNameAndHostname(String serverName,String hostname);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
pom.xml
2
pom.xml
|
|
@ -20,7 +20,7 @@
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<jbpm.version>7.27.0.Final</jbpm.version>
|
<jbpm.version>7.28.0.Final</jbpm.version>
|
||||||
<node.version>v10.16.3</node.version>
|
<node.version>v10.16.3</node.version>
|
||||||
<npm.version>6.11.3</npm.version>
|
<npm.version>6.11.3</npm.version>
|
||||||
<frontend-maven-plugin.version>1.8.0</frontend-maven-plugin.version>
|
<frontend-maven-plugin.version>1.8.0</frontend-maven-plugin.version>
|
||||||
|
|
|
||||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue