summaryrefslogtreecommitdiffstats
path: root/dcae-analytics/dcae-analytics-web/src/main
diff options
context:
space:
mode:
authorKai <lukai@chinamobile.com>2021-03-29 11:48:10 +0800
committerRemigiusz Janeczek <remigiusz.janeczek@nokia.com>2021-05-12 17:11:08 +0200
commit9bb841d5faa995c2170057f93cd65303fba7979c (patch)
treeb3fe5deaa60844546984d74adb82b9217a6f4705 /dcae-analytics/dcae-analytics-web/src/main
parent6302edb304f69068b108a69001d69bc6213b6a6a (diff)
Fix mongodb errors on application startup1.3.0-tca-gen2
Revert Dockerfile refactor due to permissions issues Issue-ID: DCAEGEN2-2747 Issue-ID: DCAEGEN2-2590 Signed-off-by: Kai Lu <lukai@chinamobile.com> Change-Id: I84075575cc75090876416cb13e0ac197a8e0f6e3 Signed-off-by: Remigiusz Janeczek <remigiusz.janeczek@nokia.com>
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.java28
-rw-r--r--dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/DmaapPollerConfig.java6
-rw-r--r--dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/DmaapRetryConfig.java3
-rw-r--r--dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/MessageStoreConfig.java5
-rw-r--r--dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrSubscriberPollingAdvice.java18
5 files changed, 31 insertions, 29 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 1fe9e51..705a724 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
@@ -1,6 +1,8 @@
/*
* ================================================================================
* Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2021 China Mobile Property. All rights reserved.
+ * Copyright (c) 2021 Nokia 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.
@@ -19,10 +21,6 @@
package org.onap.dcae.analytics.web.config;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-import java.util.Map;
-
import org.onap.dcae.analytics.model.AnalyticsHttpConstants;
import org.onap.dcae.analytics.model.AnalyticsProfile;
import org.onap.dcae.analytics.model.DmaapMrConstants;
@@ -44,16 +42,20 @@ import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.dsl.IntegrationFlow;
import org.springframework.integration.dsl.IntegrationFlows;
-import org.springframework.integration.dsl.channel.MessageChannels;
+import org.springframework.integration.dsl.MessageChannels;
import org.springframework.integration.endpoint.MethodInvokingMessageSource;
+import org.springframework.integration.handler.GenericHandler;
import org.springframework.integration.handler.advice.RequestHandlerRetryAdvice;
import org.springframework.integration.http.dsl.Http;
import org.springframework.integration.scheduling.PollerMetadata;
import org.springframework.integration.store.BasicMessageGroupStore;
import org.springframework.integration.store.MessageGroupQueue;
import org.springframework.integration.support.MessageBuilder;
+import org.springframework.messaging.MessageHeaders;
import org.springframework.web.client.RestTemplate;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
/**
* @author Rajiv Singla
*/
@@ -139,21 +141,23 @@ public class DmaapMrConfig {
final RestTemplate mrPublisherRestTemplate,
final DirectChannel mrPublisherInputChannel,
final RequestHandlerRetryAdvice requestHandlerRetryAdvice) {
-
return IntegrationFlows.from(mrPublisherInputChannel)
.handle(Http.outboundGateway(mrPublisherPreferences.getRequestURL(), mrPublisherRestTemplate)
.mappedRequestHeaders(DMAAP_MAPPED_REQUEST_HEADERS)
.httpMethod(HttpMethod.POST)
.extractPayload(true)
.expectedResponseType(String.class), c -> c.advice(requestHandlerRetryAdvice))
- // add end timestamp
- .handle((String p, Map<String, Object> headers) ->
- MessageBuilder.withPayload(p).copyHeaders(headers)
- .setHeader(AnalyticsHttpConstants.REQUEST_END_TS_HEADER_KEY,
- AnalyticsWebUtils.CREATION_TIMESTAMP_SUPPLIER.get()).build()
- )
+ .handle(new GenericHandler<String>() {
+ @Override
+ public Object handle(String payload, MessageHeaders headers) {
+ return MessageBuilder.withPayload(payload).copyHeaders(headers)
+ .setHeader(AnalyticsHttpConstants.REQUEST_END_TS_HEADER_KEY,
+ AnalyticsWebUtils.CREATION_TIMESTAMP_SUPPLIER.get()).build();
+ }
+ })
.channel(DmaapMrConstants.DMAAP_MR_PUBLISHER_OUTPUT_CHANNEL)
.get();
}
}
+
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/DmaapPollerConfig.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/DmaapPollerConfig.java
index ab85d5f..9fec649 100644
--- a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/DmaapPollerConfig.java
+++ b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/DmaapPollerConfig.java
@@ -1,6 +1,7 @@
/*
* ================================================================================
* Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2021 China Mobile 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.
@@ -19,8 +20,6 @@
package org.onap.dcae.analytics.web.config;
-import java.util.concurrent.TimeUnit;
-
import org.onap.dcae.analytics.model.AnalyticsProfile;
import org.onap.dcae.analytics.web.dmaap.MrSubscriberPollingAdvice;
import org.onap.dcae.analytics.web.dmaap.MrSubscriberPollingPreferences;
@@ -56,7 +55,7 @@ public class DmaapPollerConfig {
final MrSubscriberPollingPreferences pollingPreferences = mrSubscriberPreferences.getPollingPreferences();
final int minInterval = pollingPreferences.getMinPollingInterval();
final DynamicPeriodicTrigger dynamicPeriodicTrigger =
- new DynamicPeriodicTrigger(minInterval, TimeUnit.MILLISECONDS);
+ new DynamicPeriodicTrigger(minInterval);
dynamicPeriodicTrigger.setFixedRate(true);
return dynamicPeriodicTrigger;
}
@@ -77,3 +76,4 @@ public class DmaapPollerConfig {
}
}
+
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/DmaapRetryConfig.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/DmaapRetryConfig.java
index 48f0144..319be8b 100644
--- a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/DmaapRetryConfig.java
+++ b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/DmaapRetryConfig.java
@@ -1,6 +1,7 @@
/*
* ================================================================================
* Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2021 China Mobile 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.
@@ -31,7 +32,7 @@ import org.springframework.context.annotation.Profile;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.dsl.IntegrationFlow;
import org.springframework.integration.dsl.IntegrationFlows;
-import org.springframework.integration.dsl.channel.MessageChannels;
+import org.springframework.integration.dsl.MessageChannels;
import org.springframework.integration.handler.LoggingHandler;
import org.springframework.integration.handler.advice.ErrorMessageSendingRecoverer;
import org.springframework.integration.handler.advice.RequestHandlerRetryAdvice;
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/MessageStoreConfig.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/MessageStoreConfig.java
index aa1c502..c645b6c 100644
--- a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/MessageStoreConfig.java
+++ b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/MessageStoreConfig.java
@@ -1,6 +1,7 @@
/*
* ================================================================================
* Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2021 Nokia 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.
@@ -23,7 +24,7 @@ import org.onap.dcae.analytics.model.AnalyticsProfile;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
-import org.springframework.data.mongodb.MongoDbFactory;
+import org.springframework.data.mongodb.MongoDatabaseFactory;
import org.springframework.integration.mongodb.store.MongoDbChannelMessageStore;
import org.springframework.integration.store.BasicMessageGroupStore;
import org.springframework.integration.store.SimpleMessageStore;
@@ -43,7 +44,7 @@ public class MessageStoreConfig {
@Bean
@Profile(AnalyticsProfile.MONGO_PROFILE_NAME)
- public BasicMessageGroupStore mongoMessageGroupStore(final MongoDbFactory mongoDbFactory) {
+ public BasicMessageGroupStore mongoMessageGroupStore(final MongoDatabaseFactory mongoDbFactory) {
final MongoDbChannelMessageStore store = new MongoDbChannelMessageStore(mongoDbFactory);
store.setPriorityEnabled(true);
return store;
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 2ebb38d..6572a25 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
@@ -1,6 +1,8 @@
/*
* ================================================================================
* Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2021 China Mobile Property. All rights reserved.
+ * Copyright (c) 2021 Nokia 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.
@@ -19,6 +21,7 @@
package org.onap.dcae.analytics.web.dmaap;
+import java.time.Duration;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
@@ -84,8 +87,7 @@ public class MrSubscriberPollingAdvice extends AbstractRequestHandlerAdvice {
@Override
@SuppressWarnings("unchecked")
- protected Object doInvoke(final ExecutionCallback callback, final Object target, final Message<?> message)
- throws Exception {
+ protected Object doInvoke(final ExecutionCallback callback, final Object target, final Message<?> message) {
// execute call back
Object result = callback.execute();
@@ -98,14 +100,7 @@ public class MrSubscriberPollingAdvice extends AbstractRequestHandlerAdvice {
final MessageBuilder<String> resultMessageBuilder = (MessageBuilder<String>) result;
final String payload = resultMessageBuilder.getPayload();
final Map<String, Object> headers = resultMessageBuilder.getHeaders();
- final Object httpStatusCode = headers.get(AnalyticsHttpConstants.HTTP_STATUS_CODE_HEADER_KEY);
-
- // get http status code
- if (httpStatusCode == null) {
- return result;
- }
- final HttpStatus httpStatus = HttpStatus.resolve(Integer.parseInt(httpStatusCode.toString()));
-
+ final HttpStatus httpStatus = (HttpStatus) headers.get(AnalyticsHttpConstants.HTTP_STATUS_CODE_HEADER_KEY);
// if status code is present and successful apply polling adjustments
if (httpStatus != null && httpStatus.is2xxSuccessful()) {
@@ -119,7 +114,7 @@ public class MrSubscriberPollingAdvice extends AbstractRequestHandlerAdvice {
"Next Polling Interval will be: {}", debugLogSpec, requestId, transactionId,
String.valueOf(areMessagesPresent), nextPollingInterval.toString());
- trigger.setPeriod(nextPollingInterval.get());
+ trigger.setDuration(Duration.ofMillis(nextPollingInterval.get()));
// if no messages were found in dmaap poll - terminate further processing
if (!areMessagesPresent) {
@@ -148,3 +143,4 @@ public class MrSubscriberPollingAdvice extends AbstractRequestHandlerAdvice {
}
}
}
+