GN-76 added healthurl to servicedistribution
diff --git a/servicesDistributionDevLocal.json b/servicesDistributionDevLocal.json index de1ae98..d7ff796 100644 --- a/servicesDistributionDevLocal.json +++ b/servicesDistributionDevLocal.json
@@ -43,6 +43,17 @@ }, { "active": "true", + "name": "authNauth.openK", + "protocol": "http", + "host": "localhost", + "urlPath": "/portal/rest/beservice", + "healthUrlPath": "/portal/rest/beservice", + "portApp": "8080", + "portHealth": "8080", + "description": "Auth&Auth-Modul" + }, + { + "active": "true", "name": "mics-central-service", "protocol": "http", "host": "localhost",
diff --git a/servicesDistributionDevServer.json b/servicesDistributionDevServer.json index 8563df2..6f6b2b4 100644 --- a/servicesDistributionDevServer.json +++ b/servicesDistributionDevServer.json
@@ -43,6 +43,17 @@ }, { "active": "true", + "name": "authNauth.openK", + "protocol": "http", + "host": "172.18.22.160", + "urlPath": "/portal/rest/beservice", + "healthUrlPath": "/portal/rest/beservice", + "portApp": "8080", + "portHealth": "8080", + "description": "Auth&Auth-Modul" + }, + { + "active": "true", "name": "mics-central-service", "protocol": "http", "host": "172.18.22.160",
diff --git a/src/main/java/org/eclipse/openk/api/ServiceDistributionCluster.java b/src/main/java/org/eclipse/openk/api/ServiceDistributionCluster.java index a4a3ddb..5c5bc8b 100644 --- a/src/main/java/org/eclipse/openk/api/ServiceDistributionCluster.java +++ b/src/main/java/org/eclipse/openk/api/ServiceDistributionCluster.java
@@ -31,6 +31,8 @@ @NotEmpty private String urlPath; + private String healthUrlPath; + @NotEmpty private String protocol; @@ -85,6 +87,14 @@ this.urlPath = urlPath; } + public String getHealthUrlPath() { + return healthUrlPath; + } + + public void setHealthUrlPath(String healthUrlPath) { + this.healthUrlPath = healthUrlPath; + } + @JsonProperty public String getProtocol() { return protocol;
diff --git a/src/main/java/org/eclipse/openk/core/controller/BackendController.java b/src/main/java/org/eclipse/openk/core/controller/BackendController.java index c44c66f..5b55040 100644 --- a/src/main/java/org/eclipse/openk/core/controller/BackendController.java +++ b/src/main/java/org/eclipse/openk/core/controller/BackendController.java
@@ -50,9 +50,16 @@ ServiceDistributionCluster.ServiceDistribution dist = findDistribution(clustername, servicename); RestServiceWrapper w = new RestServiceWrapper(false); - return w.performGetRequest(dist.getProtocol() + "://" + dist.getHost() + ":" - + dist.getPortHealth() + "/" - + Globals.HEALTH_CHECK_ADD_PATH); + StringBuilder url = new StringBuilder(); + url.append(dist.getProtocol() + "://" + dist.getHost() + ":" + + dist.getPortHealth()); + + if( dist.getHealthUrlPath() != null ) { + url.append(dist.getUrlPath()); + } + url.append("/" + Globals.HEALTH_CHECK_ADD_PATH ); + + return w.performGetRequest(url.toString()); } private ServiceDistributionCluster.ServiceDistribution findDistribution(String clustername,
diff --git a/src/test/java/org/eclipse/openk/api/ServiceDistributionClusterTest.java b/src/test/java/org/eclipse/openk/api/ServiceDistributionClusterTest.java index d488d59..21341a1 100644 --- a/src/test/java/org/eclipse/openk/api/ServiceDistributionClusterTest.java +++ b/src/test/java/org/eclipse/openk/api/ServiceDistributionClusterTest.java
@@ -24,7 +24,7 @@ public class ServiceDistributionClusterTest { private ServiceDistributionCluster.ServiceDistribution createDistribution( - boolean active, String name, String host, String urlPath, String protocol, + boolean active, String name, String host, String urlPath, String healthUrlPath, String protocol, Integer portApp, Integer portHealth, String description) { ServiceDistributionCluster.ServiceDistribution sd = new ServiceDistributionCluster.ServiceDistribution(); @@ -32,6 +32,9 @@ sd.setName(name); sd.setHost(host); sd.setUrlPath(urlPath); + if( healthUrlPath != null) { + sd.setHealthUrlPath(healthUrlPath); + } sd.setProtocol(protocol); sd.setPortApp(portApp); sd.setPortHealth(portHealth); @@ -43,10 +46,11 @@ @Test public void testPojo() throws IOException { List<ServiceDistributionCluster.ServiceDistribution> distList = new ArrayList<>(); - distList.add(createDistribution(true, "Hugo", "1.2.3.4", "19/eleven", "httpx", + distList.add(createDistribution(true, "Hugo", "1.2.3.4", "19/eleven", + "healthy","httpx", 1000, 2000, "Hugo ist toll")); distList.add(createDistribution(false, "Bruno Haferkamp", "2.3.4.5", "seven/of/nine", "httpxy", - 10, null, "Bruno ist noch toller")); + null,10, null, "Bruno ist noch toller")); ServiceDistributionCluster.ServiceDistribution[] arr = new ServiceDistributionCluster.ServiceDistribution[distList.size()]; ServiceDistributionCluster cluster = new ServiceDistributionCluster();
diff --git a/src/test/resources/servicesDistributionTest.json b/src/test/resources/servicesDistributionTest.json index d17b741..f91ddc5 100644 --- a/src/test/resources/servicesDistributionTest.json +++ b/src/test/resources/servicesDistributionTest.json
@@ -10,6 +10,7 @@ "protocol": "http", "host": "172.18.22.160", "urlPath": "/authNAuth", + "healthUrlPath": "/portal/rest/beservice", "portApp": "9002", "portHealth": "9003", "description": "Authentication Service"
diff --git a/src/test/resources/testServiceDistributions.json b/src/test/resources/testServiceDistributions.json index bee259c..8049751 100644 --- a/src/test/resources/testServiceDistributions.json +++ b/src/test/resources/testServiceDistributions.json
@@ -10,6 +10,7 @@ "protocol": "http", "host": "172.18.22.160", "urlPath": "/authNAuth", + "healthUrlPath": "/portal/rest/beservice", "portApp": "9002", "portHealth": "9003", "description": "Authentication Service"
diff --git a/src/test/resources/testServiceDistributionsTwo_OneIsInactive.json b/src/test/resources/testServiceDistributionsTwo_OneIsInactive.json index afce6a9..0343c6c 100644 --- a/src/test/resources/testServiceDistributionsTwo_OneIsInactive.json +++ b/src/test/resources/testServiceDistributionsTwo_OneIsInactive.json
@@ -37,6 +37,7 @@ "protocol": "http", "host": "172.18.22.160", "urlPath": "/authNAuth", + "healthUrlPath": "/portal/rest/beservice", "portApp": "9002", "portHealth": "9003", "description": "Authentication Service"