summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/inbounds/health-api
diff options
context:
space:
mode:
authorSingal, Kapil (ks220y) <ks220y@att.com>2019-11-22 18:06:08 -0500
committerKAPIL SINGAL <ks220y@att.com>2019-11-26 21:32:38 +0000
commit341db21b2ac0a14a1ed2b8bf7930914dda054bfe (patch)
tree113bba965b06cfe3a8af3a0a527d1a41c9faf0f9 /ms/blueprintsprocessor/modules/inbounds/health-api
parentd274e5fc552cf9ae25500f504f0434981cf3accf (diff)
Formatting Code base with ktlint
No Business logic change, just the code format. Competible with IntelliJ: https://github.com/pinterest/ktlint#option-3 To format run: mvn process-sources -P format Issue-ID: CCSDK-1947 Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com> Change-Id: Ic9e9209fb7023d77f434693ad5a01229f8d09331
Diffstat (limited to 'ms/blueprintsprocessor/modules/inbounds/health-api')
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/CombinedHealth.kt16
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/CombinedMetrics.kt16
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedHealthService.kt23
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedMetricsService.kt28
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckApplicationTests.kt18
5 files changed, 59 insertions, 42 deletions
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/CombinedHealth.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/CombinedHealth.kt
index 54c85a0fc..531a275fa 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/CombinedHealth.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/CombinedHealth.kt
@@ -35,18 +35,20 @@ import org.springframework.web.bind.annotation.RestController
*/
@RestController
@RequestMapping("/api/v1/combinedHealth")
-@Api(value = "/api/v1/combinedHealth",
- description = "gather all HealthCheckResponses for HealthChecks known to the runtime")
+@Api(
+ value = "/api/v1/combinedHealth",
+ description = "gather all HealthCheckResponses for HealthChecks known to the runtime"
+)
open class CombinedHealth(private val combinedHealthService: CombinedHealthService) {
- @RequestMapping(path = [""],
- method = [RequestMethod.GET],
- produces = [MediaType.APPLICATION_JSON_VALUE])
+ @RequestMapping(
+ path = [""],
+ method = [RequestMethod.GET],
+ produces = [MediaType.APPLICATION_JSON_VALUE]
+ )
@ResponseBody
@ApiOperation(value = "Health Check", hidden = true)
fun getSystemHealthCheckResponse(): ResponseEntity<List<ApplicationHealth?>> {
return ResponseEntity.ok().body(combinedHealthService.getCombinedHealthCheck())
-
}
}
-
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/CombinedMetrics.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/CombinedMetrics.kt
index 785def524..d2f02028c 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/CombinedMetrics.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/CombinedMetrics.kt
@@ -35,18 +35,20 @@ import org.springframework.web.bind.annotation.RestController
*/
@RestController
@RequestMapping("/api/v1/combinedMetrics")
-@Api(value = "/api/v1/combinedMetrics",
- description = "gather all Metrics info from BluePrint and CDSListener")
+@Api(
+ value = "/api/v1/combinedMetrics",
+ description = "gather all Metrics info from BluePrint and CDSListener"
+)
open class CombinedMetrics(private val combinedMetricsService: CombinedMetricsService) {
- @RequestMapping(path = [""],
- method = [RequestMethod.GET],
- produces = [MediaType.APPLICATION_JSON_VALUE])
+ @RequestMapping(
+ path = [""],
+ method = [RequestMethod.GET],
+ produces = [MediaType.APPLICATION_JSON_VALUE]
+ )
@ResponseBody
@ApiOperation(value = " Metrics Check", hidden = true)
fun getMetricsHealthCheckResponse(): ResponseEntity<MetricsInfo?> {
return ResponseEntity.ok().body(combinedMetricsService.metricsInfo)
-
}
-
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedHealthService.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedHealthService.kt
index 786048ce4..f4c3e93bf 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedHealthService.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedHealthService.kt
@@ -22,7 +22,6 @@ import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.WebClientEnpointR
import org.springframework.boot.actuate.health.Status
import org.springframework.stereotype.Service
-
/**
*Service for combined health (BluePrintProcessor and CDSListener)
*
@@ -30,13 +29,15 @@ import org.springframework.stereotype.Service
* @version 1.0
*/
@Service
-open class CombinedHealthService(private val endPointExecution: EndPointExecution
- , private val healthCheckProperties: HealthCheckProperties) {
+open class CombinedHealthService(
+ private val endPointExecution: EndPointExecution,
+ private val healthCheckProperties: HealthCheckProperties
+) {
private fun setupServiceEndpoint(): List<ServiceEndpoint> {
return listOf(
- ServiceEndpoint("BluePrintProcessor Health Check ", healthCheckProperties.getBluePrintBaseURL() + "actuator/health")
- , ServiceEndpoint("CDSListener Health Check", healthCheckProperties.getCDSListenerBaseURL() + "actuator/health")
+ ServiceEndpoint("BluePrintProcessor Health Check ", healthCheckProperties.getBluePrintBaseURL() + "actuator/health"),
+ ServiceEndpoint("CDSListener Health Check", healthCheckProperties.getCDSListenerBaseURL() + "actuator/health")
)
}
@@ -45,14 +46,18 @@ open class CombinedHealthService(private val endPointExecution: EndPointExecutio
for (serviceEndpoint in setupServiceEndpoint().parallelStream()) {
val result: WebClientEnpointResponse? = endPointExecution?.retrieveWebClientResponse(serviceEndpoint)
if (result?.response != null &&
- result.response!!.status?.equals(200)!!) {
+ result.response!!.status?.equals(200)!!
+ ) {
listOfResponse.add(endPointExecution?.getHealthFromWebClientEnpointResponse(result))
} else {
- listOfResponse.add(ApplicationHealth(Status.DOWN,
- hashMapOf(serviceEndpoint.serviceLink to serviceEndpoint.serviceLink)))
+ listOfResponse.add(
+ ApplicationHealth(
+ Status.DOWN,
+ hashMapOf(serviceEndpoint.serviceLink to serviceEndpoint.serviceLink)
+ )
+ )
}
}
return listOfResponse
}
-
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedMetricsService.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedMetricsService.kt
index a23c9925b..0a2e7ae24 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedMetricsService.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedMetricsService.kt
@@ -16,7 +16,12 @@
package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service
import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.configuration.HealthCheckProperties
-import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.*
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ActuatorCheckResponse
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthCheckStatus
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.Metrics
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.MetricsInfo
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.MetricsResponse
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ServiceEndpoint
import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.utils.ObjectMappingUtils
import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
import org.springframework.stereotype.Service
@@ -28,14 +33,16 @@ import org.springframework.stereotype.Service
* @version 1.0
*/
@Service
-open class CombinedMetricsService(private val endPointExecution: EndPointExecution
- , private val healthCheckProperties: HealthCheckProperties
- , private val objectMappingUtils: ObjectMappingUtils<Metrics>) {
+open class CombinedMetricsService(
+ private val endPointExecution: EndPointExecution,
+ private val healthCheckProperties: HealthCheckProperties,
+ private val objectMappingUtils: ObjectMappingUtils<Metrics>
+) {
private fun setupServiceEndpoint(): List<ServiceEndpoint> {
return listOf(
- ServiceEndpoint("BluePrintProcessor metrics", healthCheckProperties.getBluePrintBaseURL() + "/actuator/metrics")
- , ServiceEndpoint("CDS Listener metrics", healthCheckProperties.getCDSListenerBaseURL() + "/actuator/metrics")
+ ServiceEndpoint("BluePrintProcessor metrics", healthCheckProperties.getBluePrintBaseURL() + "/actuator/metrics"),
+ ServiceEndpoint("CDS Listener metrics", healthCheckProperties.getCDSListenerBaseURL() + "/actuator/metrics")
)
}
@@ -46,7 +53,8 @@ open class CombinedMetricsService(private val endPointExecution: EndPointExecuti
val webClientResponse = endPointExecution?.retrieveWebClientResponse(serviceEndpoint)
var actuatorsHealthResponse: ActuatorCheckResponse? = null
actuatorsHealthResponse = if (webClientResponse?.response != null &&
- webClientResponse.response!!.status?.equals(200)!!) {
+ webClientResponse.response!!.status?.equals(200)!!
+ ) {
var body = gettingCustomizedBody(serviceEndpoint, webClientResponse.response!!)
ActuatorCheckResponse(serviceEndpoint.serviceName, body)
} else {
@@ -57,7 +65,10 @@ open class CombinedMetricsService(private val endPointExecution: EndPointExecuti
return MetricsInfo(containerHealthChecks)
}
- private fun gettingCustomizedBody(serviceEndpoint: ServiceEndpoint?, webClientResponse: BlueprintWebClientService.WebClientResponse<String>): Any {
+ private fun gettingCustomizedBody(
+ serviceEndpoint: ServiceEndpoint?,
+ webClientResponse: BlueprintWebClientService.WebClientResponse<String>
+ ): Any {
var body: Any
val metrics: Metrics = objectMappingUtils.getObjectFromBody(webClientResponse.body, Metrics::class.java)
val mapOfMetricsInfo = HashMap<String, String>()
@@ -69,4 +80,3 @@ open class CombinedMetricsService(private val endPointExecution: EndPointExecuti
return body
}
}
-
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckApplicationTests.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckApplicationTests.kt
index b1d629da7..5a1999ec1 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckApplicationTests.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckApplicationTests.kt
@@ -16,7 +16,6 @@
package org.onap.ccsdk.cds.blueprintsprocessor.healthapi
-
import org.junit.Test
import org.junit.runner.RunWith
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintCoreConfiguration
@@ -40,8 +39,10 @@ import org.springframework.test.web.reactive.server.WebTestClient
*/
@RunWith(SpringRunner::class)
@WebFluxTest
-@ContextConfiguration(classes = [BluePrintRuntimeService::class, BluePrintCoreConfiguration::class,
- BluePrintCatalogService::class, SecurityProperties::class, ComponentScriptExecutor::class])
+@ContextConfiguration(
+ classes = [BluePrintRuntimeService::class, BluePrintCoreConfiguration::class,
+ BluePrintCatalogService::class, SecurityProperties::class, ComponentScriptExecutor::class]
+)
@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"])
@TestPropertySource(locations = ["classpath:application-test.properties"])
class HealthCheckApplicationTests {
@@ -52,17 +53,14 @@ class HealthCheckApplicationTests {
@Test
fun testHealthApiUp() {
webTestClient.get().uri("/api/v1/combinedHealth")
- .exchange()
- .expectStatus().is2xxSuccessful
-
+ .exchange()
+ .expectStatus().is2xxSuccessful
}
@Test
fun testMetricsApiUp() {
webTestClient.get().uri("/api/v1/combinedMetrics")
- .exchange()
- .expectStatus().is2xxSuccessful
+ .exchange()
+ .expectStatus().is2xxSuccessful
}
-
-
}