summaryrefslogtreecommitdiffstats
path: root/dcae-analytics/dcae-analytics-web/src/main
diff options
context:
space:
mode:
authorKai <lukai@chinamobile.com>2020-02-22 15:54:23 +0800
committerLUKAI <lukai@chinamobile.com>2020-02-25 03:17:03 +0000
commit8ff4faad57fceb3c62ad04da0cf9b6bae5f6bc4f (patch)
tree320ade2d13390ca5ff6537c06a554eb95b362e6a /dcae-analytics/dcae-analytics-web/src/main
parentef75d53326ad27f4bfe21e341e43a4c916ea9fbc (diff)
fix debug log1.0.0
Issue-ID: DCAEGEN2-2077 Signed-off-by: Kai Lu <lukai@chinamobile.com> Change-Id: Ice1b21ae478a6311f6202cac48ba10dc1b859bc3
Diffstat (limited to 'dcae-analytics/dcae-analytics-web/src/main')
-rw-r--r--dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/DmaapMrConfig.java2
-rw-r--r--dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrMessageSplitter.java48
-rw-r--r--dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrSubscriberPollingAdvice.java20
-rw-r--r--dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrTriggerMessageProvider.java13
-rw-r--r--dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/exception/AnalyticsParsingException.java33
-rw-r--r--dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/spring/ConfigBindingServiceEnvironmentPostProcessor.java2
6 files changed, 50 insertions, 68 deletions
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/DmaapMrConfig.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/DmaapMrConfig.java
index 97fdcc5..1fe9e51 100644
--- a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/DmaapMrConfig.java
+++ b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/DmaapMrConfig.java
@@ -63,7 +63,7 @@ import org.springframework.web.client.RestTemplate;
public class DmaapMrConfig {
private static final String[] DMAAP_MAPPED_REQUEST_HEADERS =
- DmaapMrConstants.DMAAP_MAPPED_HEADERS.toArray(new String[DmaapMrConstants.DMAAP_MAPPED_HEADERS.size()]);
+ DmaapMrConstants.getDmaapmappedHeaders().toArray(new String[DmaapMrConstants.getDmaapmappedHeaders().size()]);
@Bean(name = DmaapMrConstants.DMAAP_MR_SUBSCRIBER_OUTPUT_CHANNEL_NAME)
public QueueChannel mrSubscriberOutputChannel(final BasicMessageGroupStore basicMessageGroupStore) {
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrMessageSplitter.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrMessageSplitter.java
index fe8f7ed..0396005 100644
--- a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrMessageSplitter.java
+++ b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrMessageSplitter.java
@@ -24,11 +24,9 @@ import static org.apache.commons.text.StringEscapeUtils.unescapeJson;
import static org.onap.dcae.analytics.model.AnalyticsHttpConstants.REQUEST_ID_HEADER_KEY;
import static org.onap.dcae.analytics.model.AnalyticsModelConstants.ANALYTICS_REQUEST_ID_DELIMITER;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
import java.io.IOException;
import java.util.Collections;
+import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.IntStream;
@@ -36,15 +34,22 @@ import java.util.stream.IntStream;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import org.onap.dcae.analytics.model.AnalyticsHttpConstants;
import org.onap.dcae.analytics.model.DmaapMrConstants;
-import org.onap.dcae.analytics.web.exception.AnalyticsParsingException;
+import org.onap.dcae.analytics.tca.core.exception.AnalyticsParsingException;
+import org.onap.dcae.analytics.tca.core.util.LogSpec;
import org.onap.dcae.analytics.web.util.AnalyticsHttpUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.onap.dcae.utils.eelf.logger.api.log.EELFLogFactory;
+import org.onap.dcae.utils.eelf.logger.api.log.EELFLogger;
+import org.onap.dcae.utils.eelf.logger.api.spec.AuditLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.ErrorLogSpec;
import org.springframework.integration.splitter.AbstractMessageSplitter;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
/**
* DMaaP MR message splitter split the incoming messages into batch of given batch size
*
@@ -52,7 +57,7 @@ import org.springframework.messaging.Message;
*/
public class MrMessageSplitter extends AbstractMessageSplitter {
- private static final Logger logger = LoggerFactory.getLogger(MrMessageSplitter.class);
+ private static final EELFLogger eelfLogger = EELFLogFactory.getLogger(MrMessageSplitter.class);
private final ObjectMapper objectMapper;
private final Integer batchSize;
@@ -66,18 +71,23 @@ public class MrMessageSplitter extends AbstractMessageSplitter {
@Override
protected Object splitMessage(final Message<?> message) {
- final List<String> dmaapMessages = convertJsonToStringMessages(String.class.cast(message.getPayload()).trim());
-
final String requestId = AnalyticsHttpUtils.getRequestId(message.getHeaders());
+ final List<String> dmaapMessages = convertJsonToStringMessages(requestId, String.class.cast(message.getPayload()).trim());
+
final String transactionId = AnalyticsHttpUtils.getTransactionId(message.getHeaders());
- logger.info("Request Id: {}, Transaction Id: {}, Received new messages from DMaaP MR. Count: {}",
- requestId, transactionId, dmaapMessages.size());
+ final Date requestBeginTimestamp = AnalyticsHttpUtils.getTimestampFromHeaders(message.getHeaders(),
+ AnalyticsHttpConstants.REQUEST_BEGIN_TS_HEADER_KEY);
+ final AuditLogSpec auditLogSpec = LogSpec.createAuditLogSpec(requestId, requestBeginTimestamp);
- final List<List<String>> messagePartitions = partition(dmaapMessages, batchSize);
+ eelfLogger.auditLog().info("Request Id: {}, Transaction Id: {}, dmaapMessages: {},"
+ + " Received new messages from DMaaP MR. Count: {}",
+ auditLogSpec, requestId, transactionId, dmaapMessages.toString(), String.valueOf(dmaapMessages.size()));
- logger.debug("Request Id: {}, Transaction Id: {}, Max allowed messages per batch: {}. " +
- "No of batches created: {}", requestId, transactionId, batchSize, messagePartitions.size());
+ final List<List<String>> messagePartitions = partition(dmaapMessages, batchSize);
+ eelfLogger.auditLog().info("Request Id: {}, Transaction Id: {}, Max allowed messages per batch: {}. " +
+ "No of batches created: {}",
+ auditLogSpec, requestId, transactionId, String.valueOf(batchSize), String.valueOf(messagePartitions.size()));
// append batch id to request id header
return messagePartitions.isEmpty() ? null : IntStream.range(0, messagePartitions.size())
@@ -100,7 +110,7 @@ public class MrMessageSplitter extends AbstractMessageSplitter {
*
* @return List containing DMaaP MR Messages
*/
- private List<String> convertJsonToStringMessages(@Nullable final String messagesJsonString) {
+ private List<String> convertJsonToStringMessages(String requestId, @Nullable final String messagesJsonString) {
final LinkedList<String> messages = new LinkedList<>();
@@ -128,9 +138,11 @@ public class MrMessageSplitter extends AbstractMessageSplitter {
}
} catch (IOException e) {
- final String errorMessage = String.format("Unable to convert subscriber Json String to Messages. " +
+ ErrorLogSpec errorLogSpec = LogSpec.createErrorLogSpec(requestId);
+ eelfLogger.errorLog().error("Unable to convert subscriber Json String to Messages. " +
+ "Subscriber Response String: {}, Json Error: {}", errorLogSpec, messagesJsonString, e.toString());
+ String errorMessage = String.format("Unable to convert subscriber Json String to Messages. " +
"Subscriber Response String: %s, Json Error: %s", messagesJsonString, e);
- logger.error(errorMessage, e);
throw new AnalyticsParsingException(errorMessage, e);
}
@@ -183,6 +195,4 @@ public class MrMessageSplitter extends AbstractMessageSplitter {
}
return result;
}
-
-
}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrSubscriberPollingAdvice.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrSubscriberPollingAdvice.java
index 33115c5..2ebb38d 100644
--- a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrSubscriberPollingAdvice.java
+++ b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrSubscriberPollingAdvice.java
@@ -24,9 +24,11 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.onap.dcae.analytics.model.AnalyticsHttpConstants;
import org.onap.dcae.analytics.model.DmaapMrConstants;
+import org.onap.dcae.analytics.tca.core.util.LogSpec;
import org.onap.dcae.analytics.web.util.AnalyticsHttpUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.onap.dcae.utils.eelf.logger.api.log.EELFLogFactory;
+import org.onap.dcae.utils.eelf.logger.api.log.EELFLogger;
+import org.onap.dcae.utils.eelf.logger.api.spec.DebugLogSpec;
import org.springframework.http.HttpStatus;
import org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice;
import org.springframework.integration.support.MessageBuilder;
@@ -48,7 +50,7 @@ import org.springframework.messaging.Message;
*/
public class MrSubscriberPollingAdvice extends AbstractRequestHandlerAdvice {
- private static final Logger log = LoggerFactory.getLogger(MrSubscriberPollingAdvice.class);
+ private static final EELFLogger eelfLogger = EELFLogFactory.getLogger(MrSubscriberPollingAdvice.class);
private final DynamicPeriodicTrigger trigger;
private final int minPollingInterval;
@@ -112,17 +114,17 @@ public class MrSubscriberPollingAdvice extends AbstractRequestHandlerAdvice {
final String requestId = AnalyticsHttpUtils.getRequestId(message.getHeaders());
final String transactionId = AnalyticsHttpUtils.getTransactionId(message.getHeaders());
-
- log.debug("Request Id: {}, Transaction Id: {}, Messages Present: {}, " +
- "Next Polling Interval will be: {}", requestId, transactionId,
- areMessagesPresent, nextPollingInterval);
+ final DebugLogSpec debugLogSpec = LogSpec.createDebugLogSpec(requestId);
+ eelfLogger.debugLog().debug("Request Id: {}, Transaction Id: {}, Messages Present: {}, " +
+ "Next Polling Interval will be: {}", debugLogSpec, requestId, transactionId,
+ String.valueOf(areMessagesPresent), nextPollingInterval.toString());
trigger.setPeriod(nextPollingInterval.get());
// if no messages were found in dmaap poll - terminate further processing
if (!areMessagesPresent) {
- log.info("Request Id: {}, Transaction Id: {}, No new messages found in DMaaP MR Response. " +
- "No further processing required", requestId, transactionId);
+ eelfLogger.debugLog().debug("Request Id: {}, Transaction Id: {}, No new messages found in DMaaP MR Response. " +
+ "No further processing required", debugLogSpec, requestId, transactionId);
return null;
}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrTriggerMessageProvider.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrTriggerMessageProvider.java
index 183957d..b537170 100644
--- a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrTriggerMessageProvider.java
+++ b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrTriggerMessageProvider.java
@@ -26,10 +26,12 @@ import java.util.function.Supplier;
import org.onap.dcae.analytics.model.AnalyticsHttpConstants;
import org.onap.dcae.analytics.model.util.supplier.UnboundedSupplier;
+import org.onap.dcae.analytics.tca.core.util.LogSpec;
import org.onap.dcae.analytics.web.util.AnalyticsWebUtils;
import org.onap.dcae.analytics.web.util.function.MrSubscriberURLFunction;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.onap.dcae.utils.eelf.logger.api.log.EELFLogFactory;
+import org.onap.dcae.utils.eelf.logger.api.log.EELFLogger;
+import org.onap.dcae.utils.eelf.logger.api.spec.DebugLogSpec;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
@@ -40,7 +42,7 @@ import org.springframework.messaging.Message;
*/
public class MrTriggerMessageProvider {
- private static final Logger logger = LoggerFactory.getLogger(MrTriggerMessageProvider.class);
+ private static final EELFLogger logger = EELFLogFactory.getLogger(MrTriggerMessageProvider.class);
public static final String TRIGGER_METHOD_NAME = "getTriggerMessage";
@@ -60,8 +62,9 @@ public class MrTriggerMessageProvider {
final String requestId = AnalyticsWebUtils.REQUEST_ID_SUPPLIER.get();
final String transactionId = AnalyticsWebUtils.RANDOM_ID_SUPPLIER.get();
final String beginTimestamp = AnalyticsWebUtils.CREATION_TIMESTAMP_SUPPLIER.get();
- logger.debug("Request Id: {}. Transaction Id: {}. Begin TS: {}. Starting new DMaaP MR Subscriber poll.",
- requestId, transactionId, beginTimestamp);
+ final DebugLogSpec debugLogSpec = LogSpec.createDebugLogSpec(requestId);
+ logger.debugLog().debug("Request Id: {}. Transaction Id: {}. Begin TS: {}. Starting new DMaaP MR Subscriber poll.",
+ debugLogSpec, requestId, transactionId, beginTimestamp);
return MessageBuilder
.withPayload(subscriberUrlSupplier.get().toString())
.setHeader(AnalyticsHttpConstants.REQUEST_ID_HEADER_KEY, requestId)
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/exception/AnalyticsParsingException.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/exception/AnalyticsParsingException.java
deleted file mode 100644
index 1af40f2..0000000
--- a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/exception/AnalyticsParsingException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * ================================================================================
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- *
- */
-
-package org.onap.dcae.analytics.web.exception;
-
-/**
- * @author Rajiv Singla
- */
-public class AnalyticsParsingException extends RuntimeException {
-
- private static final long serialVersionUID = 1L;
-
- public AnalyticsParsingException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
-}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/spring/ConfigBindingServiceEnvironmentPostProcessor.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/spring/ConfigBindingServiceEnvironmentPostProcessor.java
index d643de2..31c01b0 100644
--- a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/spring/ConfigBindingServiceEnvironmentPostProcessor.java
+++ b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/spring/ConfigBindingServiceEnvironmentPostProcessor.java
@@ -240,7 +240,7 @@ public class ConfigBindingServiceEnvironmentPostProcessor implements Environment
// remove config service key prefix on spring reserved property key prefixes
final Set<String> springKeyPrefixes =
- ConfigBindingServiceConstants.SPRING_RESERVED_PROPERTIES_KEY_PREFIXES;
+ ConfigBindingServiceConstants.getSpringReservedPropertiesKeyPrefixes();
final Set<String> springKeys = springKeyPrefixes.stream()
.map(springKeyPrefix -> configServicePropertiesKey + "." + springKeyPrefix)
.collect(Collectors.toSet());