Some improved traces 32/3932/2
authorPatrikBuhr <patrik.buhr@est.tech>
Mon, 1 Jun 2020 08:54:35 +0000 (10:54 +0200)
committerPatrikBuhr <patrik.buhr@est.tech>
Tue, 2 Jun 2020 09:52:33 +0000 (11:52 +0200)
Change-Id: I422b504325eabfaa9374a320a89412c9780543a5
Issue-ID: NONRTRIC-195
Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
policy-agent/src/main/java/org/oransc/policyagent/clients/AsyncRestClient.java
policy-agent/src/main/java/org/oransc/policyagent/controllers/PolicyController.java
policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageHandler.java

index 4ba58c7..b292c51 100644 (file)
@@ -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);
         }
     }
 
index 49d7702..832bbe9 100644 (file)
@@ -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<Object> 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);
index c50a46f..19d1564 100644 (file)
@@ -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<ResponseEntity<String>> 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) {