Health Check RestService added
diff --git a/src/main/java/de/pta/mics/home/common/BackendConfig.java b/src/main/java/de/pta/mics/home/common/BackendConfig.java index 03437c8..0d4530a 100644 --- a/src/main/java/de/pta/mics/home/common/BackendConfig.java +++ b/src/main/java/de/pta/mics/home/common/BackendConfig.java
@@ -9,6 +9,7 @@ // properties of the configfile private String micsCentralURL; private String micsDistributionCluster; + private String micsHealthStateExtraPath; private static BackendConfig instance; @@ -37,6 +38,10 @@ return micsDistributionCluster; } + public String getMicsHealthStateExtraPath() { + return micsHealthStateExtraPath; + } + public static String getConfigFileName() { return configFileName; }
diff --git a/src/main/java/de/pta/mics/home/controller/CentralProxy.java b/src/main/java/de/pta/mics/home/controller/CentralProxy.java index 01e8b1d..8eb038f 100644 --- a/src/main/java/de/pta/mics/home/controller/CentralProxy.java +++ b/src/main/java/de/pta/mics/home/controller/CentralProxy.java
@@ -14,4 +14,9 @@ RestServiceWrapper w = new RestServiceWrapper( url, false ); return w.performGetRequest(url + "/serviceDistribution/" + clusterName ); } + + public String getHealthState( String healthStateExtraPath, String protocol, String host, String port ) throws HttpStatusException { + RestServiceWrapper w = new RestServiceWrapper( url, false ); + return w.performGetRequest(protocol + "://" + host + ":" + port + "/" + healthStateExtraPath ); + } }
diff --git a/src/main/java/de/pta/mics/home/rest/BackendRestService.java b/src/main/java/de/pta/mics/home/rest/BackendRestService.java index fbd7989..e35e5c4 100644 --- a/src/main/java/de/pta/mics/home/rest/BackendRestService.java +++ b/src/main/java/de/pta/mics/home/rest/BackendRestService.java
@@ -37,6 +37,21 @@ } } + @GET + @Path("/healthState/{protocol}/{host}/{port}") + @Produces("application/json") + public Response getHealthState( @PathParam("protocol") String protocol, @PathParam("host") String host , @PathParam("port") String port ) { + try { + BackendConfig bc = BackendConfig.getInstance(); + CentralProxy central = new CentralProxy(bc.getMicsCentralURL()); + return ResponseBuilderWrapper.INSTANCE.buildOKResponse( + central.getHealthState(bc.getMicsHealthStateExtraPath(), protocol, host, port)); + } + catch (Exception e) { + return responseFromException(e); + } + } + private Response responseFromException(Exception e) { int errcode;
diff --git a/src/main/resources/backendConfigCustom.json b/src/main/resources/backendConfigCustom.json index 3205e0c..dbcd9c7 100644 --- a/src/main/resources/backendConfigCustom.json +++ b/src/main/resources/backendConfigCustom.json
@@ -1,4 +1,5 @@ { "micsDistributionCluster" : "elogbook.openK", - "micsCentralURL" : "http://localhost:9500/mics/central/serviceDistribution" + "micsCentralURL" : "http://localhost:9500/mics/central/serviceDistribution", + "micsHealthStateExtraPath" : "healthcheck?pretty=true" }
diff --git a/src/main/resources/backendConfigDevLocal.json b/src/main/resources/backendConfigDevLocal.json index 79f7aea..5d4e7f1 100644 --- a/src/main/resources/backendConfigDevLocal.json +++ b/src/main/resources/backendConfigDevLocal.json
@@ -1,4 +1,5 @@ { "micsDistributionCluster" : "elogbook.openK", - "micsCentralURL" : "http://localhost:9010/mics/central" + "micsCentralURL" : "http://localhost:9010/mics/central", + "micsHealthStateExtraPath" : "healthcheck?pretty=true" }
diff --git a/src/main/resources/backendConfigDevServer.json b/src/main/resources/backendConfigDevServer.json index d147326..1fb9d1f 100644 --- a/src/main/resources/backendConfigDevServer.json +++ b/src/main/resources/backendConfigDevServer.json
@@ -1,5 +1,5 @@ { "micsDistributionCluster" : "elogbook.openK", - "micsCentralURL" : "http://localhost:9500/mics/central" - + "micsCentralURL" : "http://localhost:9500/mics/central", + "micsHealthStateExtraPath" : "healthcheck?pretty=true" }
diff --git a/src/main/resources/backendConfigProduction.json b/src/main/resources/backendConfigProduction.json index 0b8e5bf..e5d07ac 100644 --- a/src/main/resources/backendConfigProduction.json +++ b/src/main/resources/backendConfigProduction.json
@@ -1,4 +1,5 @@ { "micsDistributionCluster" : "elogbook.openK", - "micsCentralURL" : "http://localhost:9500/mics/central" + "micsCentralURL" : "http://localhost:9500/mics/central", + "micsHealthStateExtraPath" : "healthcheck?pretty=true" } \ No newline at end of file