From 175313c873ae4e23bad63e4a10d348cc0c6a1d7e Mon Sep 17 00:00:00 2001 From: PatrikBuhr Date: Mon, 1 Jun 2020 10:54:35 +0200 Subject: [PATCH] Some improved traces Change-Id: I422b504325eabfaa9374a320a89412c9780543a5 Issue-ID: NONRTRIC-195 Signed-off-by: PatrikBuhr --- .../main/java/org/oransc/policyagent/clients/AsyncRestClient.java | 2 +- .../java/org/oransc/policyagent/controllers/PolicyController.java | 3 +++ .../java/org/oransc/policyagent/dmaap/DmaapMessageHandler.java | 7 ++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/policy-agent/src/main/java/org/oransc/policyagent/clients/AsyncRestClient.java b/policy-agent/src/main/java/org/oransc/policyagent/clients/AsyncRestClient.java index 4ba58c7b..b292c519 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/clients/AsyncRestClient.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/clients/AsyncRestClient.java @@ -196,7 +196,7 @@ public class AsyncRestClient { logger.debug("{} HTTP error status = '{}', body '{}'", traceTag, exception.getStatusCode(), exception.getResponseBodyAsString()); } else { - logger.debug("{} HTTP error: {}", traceTag, t.getMessage()); + logger.debug("{} HTTP error", traceTag, t); } } diff --git a/policy-agent/src/main/java/org/oransc/policyagent/controllers/PolicyController.java b/policy-agent/src/main/java/org/oransc/policyagent/controllers/PolicyController.java index 49d77028..832bbe94 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/controllers/PolicyController.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/controllers/PolicyController.java @@ -269,6 +269,7 @@ public class PolicyController { RejectionException e = new RejectionException("Policy cannot change RIC, policyId: " + current.id() + // ", RIC name: " + current.ric().name() + // ", new name: " + policy.ric().name(), HttpStatus.CONFLICT); + logger.debug("Request rejected, {}", e); return Mono.error(e); } return Mono.just("OK"); @@ -276,6 +277,7 @@ public class PolicyController { private Mono checkSupportedType(Ric ric, PolicyType type) { if (!ric.isSupportingType(type.name())) { + logger.debug("Request rejected, type not supported, RIC: {}", ric); RejectionException e = new RejectionException( "Type: " + type.name() + " not supported by RIC: " + ric.name(), HttpStatus.NOT_FOUND); return Mono.error(e); @@ -287,6 +289,7 @@ public class PolicyController { if (ric.getState() == Ric.RicState.AVAILABLE) { return Mono.just("OK"); } else { + logger.debug("Request rejected RIC not IDLE, ric: {}", ric); RejectionException e = new RejectionException( "Ric is not operational, RIC name: " + ric.name() + ", state: " + ric.getState(), HttpStatus.LOCKED); return Mono.error(e); diff --git a/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageHandler.java b/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageHandler.java index c50a46fa..19d15648 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageHandler.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageHandler.java @@ -35,6 +35,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.web.reactive.function.client.WebClientException; import org.springframework.web.reactive.function.client.WebClientResponseException; import reactor.core.publisher.Mono; @@ -81,7 +82,7 @@ public class DmaapMessageHandler { private Mono> handleAgentCallError(Throwable t, String originalMessage, DmaapRequestMessage dmaapRequestMessage) { logger.debug("Agent call failed: {}", t.getMessage()); - HttpStatus status = HttpStatus.NOT_FOUND; + HttpStatus status = HttpStatus.INTERNAL_SERVER_ERROR; String errorMessage = t.getMessage(); if (t instanceof WebClientResponseException) { WebClientResponseException exception = (WebClientResponseException) t; @@ -90,7 +91,8 @@ public class DmaapMessageHandler { } else if (t instanceof ServiceException) { status = HttpStatus.BAD_REQUEST; errorMessage = prepareBadOperationErrorMessage(t, originalMessage); - + } else if (!(t instanceof WebClientException)) { + logger.warn("Unexpected exception ", t); } return sendDmaapResponse(errorMessage, dmaapRequestMessage, status) // .flatMap(notUsed -> Mono.empty()); @@ -119,7 +121,6 @@ public class DmaapMessageHandler { } else { return Mono.error(new ServiceException("Not implemented operation: " + operation)); } - } private String payload(DmaapRequestMessage message) { -- 2.16.6