From 9bb841d5faa995c2170057f93cd65303fba7979c Mon Sep 17 00:00:00 2001 From: Kai Date: Mon, 29 Mar 2021 11:48:10 +0800 Subject: Fix mongodb errors on application startup Revert Dockerfile refactor due to permissions issues Issue-ID: DCAEGEN2-2747 Issue-ID: DCAEGEN2-2590 Signed-off-by: Kai Lu Change-Id: I84075575cc75090876416cb13e0ac197a8e0f6e3 Signed-off-by: Remigiusz Janeczek --- dcae-analytics/dcae-analytics-model/pom.xml | 15 --- dcae-analytics/dcae-analytics-tca-core/pom.xml | 24 ++--- dcae-analytics/dcae-analytics-tca-model/pom.xml | 10 -- dcae-analytics/dcae-analytics-tca-web/Dockerfile | 28 +++--- dcae-analytics/dcae-analytics-tca-web/pom.xml | 102 ++++++++----------- .../dcae/analytics/tca/web/config/TcaMrConfig.java | 15 ++- .../tca/web/integration/TcaAlertTransformer.java | 4 +- .../integration/TcaPublisherResponseHandler.java | 5 +- .../TcaPublisherResponseHandlerTest.java | 12 ++- dcae-analytics/dcae-analytics-web/pom.xml | 26 +---- .../dcae/analytics/web/config/DmaapMrConfig.java | 28 +++--- .../analytics/web/config/DmaapPollerConfig.java | 6 +- .../analytics/web/config/DmaapRetryConfig.java | 3 +- .../analytics/web/config/MessageStoreConfig.java | 5 +- .../web/dmaap/MrSubscriberPollingAdvice.java | 18 ++-- dcae-analytics/pom.xml | 110 +++------------------ 16 files changed, 138 insertions(+), 273 deletions(-) diff --git a/dcae-analytics/dcae-analytics-model/pom.xml b/dcae-analytics/dcae-analytics-model/pom.xml index 96f235d..ff8382d 100644 --- a/dcae-analytics/dcae-analytics-model/pom.xml +++ b/dcae-analytics/dcae-analytics-model/pom.xml @@ -97,21 +97,6 @@ dmaap-client ${sdk.version} - - io.projectreactor.netty - reactor-netty - 0.9.12.RELEASE - - - io.netty - netty-handler - 4.1.54.Final - - - io.netty - netty-handler-proxy - 4.1.54.Final - org.springframework spring-beans diff --git a/dcae-analytics/dcae-analytics-tca-core/pom.xml b/dcae-analytics/dcae-analytics-tca-core/pom.xml index 81a97f1..f7393ac 100644 --- a/dcae-analytics/dcae-analytics-tca-core/pom.xml +++ b/dcae-analytics/dcae-analytics-tca-core/pom.xml @@ -72,27 +72,17 @@ ${project.groupId} dcae-analytics-test - - io.netty - netty-handler - 4.1.54.Final - - - io.netty - netty-handler-proxy - 4.1.54.Final - - - - org.springframework - spring-context - 5.0.11.RELEASE - - + + + org.springframework + spring-context + 5.0.11.RELEASE + + diff --git a/dcae-analytics/dcae-analytics-tca-model/pom.xml b/dcae-analytics/dcae-analytics-tca-model/pom.xml index 0510883..076125d 100644 --- a/dcae-analytics/dcae-analytics-tca-model/pom.xml +++ b/dcae-analytics/dcae-analytics-tca-model/pom.xml @@ -63,16 +63,6 @@ ${project.groupId} dcae-analytics-test - - io.netty - netty-handler - 4.1.54.Final - - - io.netty - netty-handler-proxy - 4.1.54.Final - diff --git a/dcae-analytics/dcae-analytics-tca-web/Dockerfile b/dcae-analytics/dcae-analytics-tca-web/Dockerfile index 2791e03..a2c59c4 100644 --- a/dcae-analytics/dcae-analytics-tca-web/Dockerfile +++ b/dcae-analytics/dcae-analytics-tca-web/Dockerfile @@ -9,23 +9,23 @@ ARG DOCKER_ARTIFACT_DIR ARG user=tca-gen2 ARG group=tca-gen2 -WORKDIR ${DOCKER_ARTIFACT_DIR} -#Copy dependencies and executable jar -COPY ${PROJECT_BUILD_DIR_NAME}/${FINAL_JAR} . - USER root -#Symlink to overcome Docker limitation to put ARG inside ENTRYPOINT -RUN mkdir -p /var/log/ONAP/dcaegen2/analytics/tca-gen2 && \ - addgroup $group && adduser --system --disabled-password --no-create-home --ingroup $group $user && \ - chmod g+rwx /opt; \ - chmod u+rw /var/log/ONAP/dcaegen2/analytics/tca-gen2 && \ - chown -R $user /opt && \ - chown -R $user /var/log/ONAP/dcaegen2/analytics/tca-gen2 && \ - ln -s ${FINAL_JAR} tca-gen2.jar && \ - chown $user ${FINAL_JAR} tca-gen2.jar +RUN mkdir -p /var/log/ONAP/dcaegen2/analytics/tca-gen2 +#Add a new user and group to allow container to be run as non-root +RUN addgroup $group && adduser --system --disabled-password --no-create-home --ingroup $group $user && \ + chmod 775 /opt && \ + chmod 775 /var/log/ONAP/dcaegen2/analytics/tca-gen2 && \ + chown -R $user:$group /opt && \ + chown -R $user:$group /var/log/ONAP/dcaegen2/analytics/tca-gen2 + +#Copy dependencies and executable jar +WORKDIR ${DOCKER_ARTIFACT_DIR} +COPY ${PROJECT_BUILD_DIR_NAME}/${FINAL_JAR} . +#Overcome Docker limitation to put ARG inside ENTRYPOINT +RUN ln -s ${FINAL_JAR} tca-gen2.jar EXPOSE 8100 -USER $user +USER $user:$group ENTRYPOINT ["java", "-Dspring.profiles.active=configBindingService,dmaap,mongo", "-jar", "tca-gen2.jar"] diff --git a/dcae-analytics/dcae-analytics-tca-web/pom.xml b/dcae-analytics/dcae-analytics-tca-web/pom.xml index 86d332f..7c81f4f 100644 --- a/dcae-analytics/dcae-analytics-tca-web/pom.xml +++ b/dcae-analytics/dcae-analytics-tca-web/pom.xml @@ -3,6 +3,7 @@ ~ ================================================================================ ~ Copyright (c) 2018-2020 AT&T Intellectual Property. All rights reserved. ~ Copyright (c) 2021 Samsung Electronics. All rights reserved. + ~ Copyright (c) 2021 Nokia Intellectual Property. All rights reserved. ~ ================================================================================ ~ Modifications Copyright (C) 2019 IBM ~ ================================================================================ @@ -43,7 +44,7 @@ ${project.parent.basedir} onap/${project.groupId}.${project.artifactId} - yyyyMMdd'T'HHmmss + yyyyMMdd'T'HHmmss @@ -69,7 +70,6 @@ undertow-core - io.micrometer @@ -106,6 +106,10 @@ io.springfox springfox-swagger2 + + org.springframework.plugin + spring-plugin-core + io.springfox springfox-swagger-ui @@ -117,33 +121,13 @@ dcae-analytics-test - - io.undertow - undertow-core - - io.netty - netty-handler - 4.1.54.Final - - - io.netty - netty-handler-proxy - 4.1.54.Final + io.undertow + undertow-core - - - - org.springframework - spring-core - 5.1.12.RELEASE - - - - @@ -165,39 +149,39 @@ - com.spotify - dockerfile-maven-plugin - 1.4.10 - - ${project.basedir} - ${docker.repository}/${docker.image.name} - true - - target - ${dependency.dir.name} - /opt - ${project.build.finalName}.jar - - - - - build-image - install - - build - - - - tag-version - install - - tag - push - - - ${project.version} - - + com.spotify + dockerfile-maven-plugin + 1.4.10 + + ${project.basedir} + ${docker.repository}/${docker.image.name} + true + + target + ${dependency.dir.name} + /opt + ${project.build.finalName}.jar + + + + + build-image + install + + build + + + + tag-version + install + + tag + push + + + ${project.version} + + tag-version-ts install @@ -206,10 +190,10 @@ push - ${project.version}-${maven.build.timestamp}Z + ${project.version}-${maven.build.timestamp}Z - + diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/TcaMrConfig.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/TcaMrConfig.java index 3579d3e..ed8e7ea 100644 --- a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/TcaMrConfig.java +++ b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/TcaMrConfig.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. @@ -23,8 +25,6 @@ import static org.onap.dcae.analytics.model.AnalyticsHttpConstants.REQUEST_ID_HE import static org.onap.dcae.analytics.model.AnalyticsHttpConstants.REQUEST_TRANSACTION_ID_HEADER_KEY; import java.util.List; -import java.util.Map; - import org.onap.dcae.analytics.model.AnalyticsProfile; import org.onap.dcae.analytics.model.DmaapMrConstants; import org.onap.dcae.analytics.tca.web.TcaAppProperties; @@ -44,6 +44,7 @@ import org.springframework.integration.channel.NullChannel; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.dsl.IntegrationFlow; import org.springframework.integration.dsl.IntegrationFlows; +import org.springframework.integration.handler.GenericHandler; import org.springframework.messaging.MessageHeaders; /** @@ -82,11 +83,15 @@ public class TcaMrConfig { // get messages from dmaap subscriber channel return IntegrationFlows.from(mrSubscriberOutputChannel) // handle incoming message from dmaap - .handle((List cefMessages, Map headers) -> - tcaProcessingService.getTcaExecutionResults( + .handle(new GenericHandler>() { + @Override + public Object handle(List cefMessages, MessageHeaders headers) { + return tcaProcessingService.getTcaExecutionResults( headers.getOrDefault(REQUEST_ID_HEADER_KEY, headers.get(MessageHeaders.ID)).toString(), headers.getOrDefault(REQUEST_TRANSACTION_ID_HEADER_KEY, "").toString(), - tcaPolicyWrapper, cefMessages)) + tcaPolicyWrapper, cefMessages); + } + }) // transform tca execution results to alerts - if not alerts are detected terminate further processing .transform(tcaAlertTransformer, c -> c.requiresReply(false)) // post messages to dmaap publisher input channel diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/integration/TcaAlertTransformer.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/integration/TcaAlertTransformer.java index 9bade85..ff086ed 100644 --- a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/integration/TcaAlertTransformer.java +++ b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/integration/TcaAlertTransformer.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. @@ -71,7 +72,7 @@ public class TcaAlertTransformer extends AbstractTransformer { @Override @SuppressWarnings("unchecked") - protected Object doTransform(final Message message) throws Exception { + protected Object doTransform(final Message message) { final Object messagePayload = message.getPayload(); @@ -158,3 +159,4 @@ public class TcaAlertTransformer extends AbstractTransformer { Integer.toString(abatedExecutionContexts.size()), Integer.toString(tcaAlerts.size())); } } + diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/integration/TcaPublisherResponseHandler.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/integration/TcaPublisherResponseHandler.java index 7cd542c..024e4bf 100644 --- a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/integration/TcaPublisherResponseHandler.java +++ b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/integration/TcaPublisherResponseHandler.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. @@ -24,7 +25,6 @@ import static org.onap.dcae.analytics.model.AnalyticsHttpConstants.REQUEST_BEGIN import static org.onap.dcae.analytics.model.AnalyticsHttpConstants.REQUEST_END_TS_HEADER_KEY; import java.util.Date; -import java.util.Map; import org.onap.dcae.analytics.model.ecomplogger.AnalyticsErrorType; import org.onap.dcae.analytics.tca.core.util.TcaUtils; @@ -60,7 +60,7 @@ public class TcaPublisherResponseHandler implements GenericHandler { } @Override - public Object handle(final String payload, final Map headers) { + public Object handle(final String payload, MessageHeaders headers) { final MessageHeaders messageHeaders = new MessageHeaders(headers); final String requestId = AnalyticsHttpUtils.getRequestId(messageHeaders); @@ -99,3 +99,4 @@ public class TcaPublisherResponseHandler implements GenericHandler { } } + diff --git a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/integration/TcaPublisherResponseHandlerTest.java b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/integration/TcaPublisherResponseHandlerTest.java index 66043aa..2637a39 100644 --- a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/integration/TcaPublisherResponseHandlerTest.java +++ b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/integration/TcaPublisherResponseHandlerTest.java @@ -1,6 +1,7 @@ /* * ================================================================================ * Copyright (c) 2019 IBM 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. @@ -26,17 +27,19 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.onap.dcae.analytics.tca.web.TcaAppProperties; import org.onap.dcae.analytics.tca.web.TcaAppProperties.Tca; +import org.springframework.messaging.MessageHeaders; public class TcaPublisherResponseHandlerTest { - static Map headers; + static MessageHeaders messageHeaders; @BeforeAll static void initialize() { - headers = new HashMap<>(); + Map headers = new HashMap<>(); headers.put("X-ECOMP-RequestID", "TestRequestID"); headers.put("X-ECOMP-TransactionID", "TestTransactionID"); headers.put("X-ECOMP-FromAppID", "TestFromAppID"); + messageHeaders = new MessageHeaders(headers); } @@ -49,7 +52,7 @@ public class TcaPublisherResponseHandlerTest { Mockito.when(tcaAppProperties.getTca().getEnableEcompLogging()).thenReturn(true); TcaPublisherResponseHandler responseHandler = new TcaPublisherResponseHandler(tcaAppProperties); - responseHandler.handle("testpayload", headers); + responseHandler.handle("testpayload", messageHeaders); } @@ -62,8 +65,9 @@ public class TcaPublisherResponseHandlerTest { Mockito.when(tcaAppProperties.getTca().getEnableEcompLogging()).thenReturn(false); TcaPublisherResponseHandler responseHandler = new TcaPublisherResponseHandler(tcaAppProperties); - responseHandler.handle("testpayload", headers); + responseHandler.handle("testpayload", messageHeaders); } } + diff --git a/dcae-analytics/dcae-analytics-web/pom.xml b/dcae-analytics/dcae-analytics-web/pom.xml index 4d7efb7..856a8ed 100644 --- a/dcae-analytics/dcae-analytics-web/pom.xml +++ b/dcae-analytics/dcae-analytics-web/pom.xml @@ -3,6 +3,7 @@ ~ ================================================================================ ~ Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved. ~ Copyright (c) 2021 Samsung Electronics. 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. @@ -104,7 +105,10 @@ org.springframework.integration spring-integration-mongodb - + + org.springframework.boot + spring-boot-starter-data-mongodb + @@ -145,27 +149,7 @@ io.undertow undertow-core - - io.netty - netty-handler - 4.1.54.Final - - - io.netty - netty-handler-proxy - 4.1.54.Final - - - - - - org.springframework - spring-core - 5.0.11.RELEASE - - - 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 headers) -> - MessageBuilder.withPayload(p).copyHeaders(headers) - .setHeader(AnalyticsHttpConstants.REQUEST_END_TS_HEADER_KEY, - AnalyticsWebUtils.CREATION_TIMESTAMP_SUPPLIER.get()).build() - ) + .handle(new GenericHandler() { + @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 resultMessageBuilder = (MessageBuilder) result; final String payload = resultMessageBuilder.getPayload(); final Map 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 { } } } + diff --git a/dcae-analytics/pom.xml b/dcae-analytics/pom.xml index 4f8fc42..d3d924f 100644 --- a/dcae-analytics/pom.xml +++ b/dcae-analytics/pom.xml @@ -3,6 +3,7 @@ ~ ================================================================================ ~ Copyright (c) 2018-2020 AT&T Intellectual Property. All rights reserved. ~ Copyright (c) 2021 Samsung Electronics. 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. @@ -56,9 +57,8 @@ 1.0.1-SNAPSHOT - 2.0.9.RELEASE + 2.4.4 Finchley.RC2 - 5.0.11.RELEASE 1.4 3.0.0 3.0.2 @@ -109,9 +109,7 @@ content/repositories/snapshots/ content/repositories/releases/ nexus3.onap.org:10003 - 2.11.0 - 2.2.2.Final - 5.2.7.RELEASE + 2.10.5 @@ -270,40 +269,6 @@ org.springframework.boot spring-boot-dependencies ${spring.boot.version} - - - org.springframework - spring-web - - - org.springframework.boot - spring-boot-starter-test - - - org.mockito - mockito-core - - - io.undertow - undertow-core - - - org.springframework - spring-webflux - - - com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.core - jackson-core - - - com.fasterxml.jackson.dataformat - jackson-dataformat-smile - - pom import @@ -315,46 +280,6 @@ pom import - - org.springframework - spring-webflux - ${spring-webflux.version} - - - org.springframework - spring-web - ${spring.version} - - - org.springframework.boot - spring-boot-starter-test - 2.2.0.RELEASE - - - org.mockito - mockito-core - 2.23.4 - - - io.undertow - undertow-core - ${undertow.version} - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - com.fasterxml.jackson.core - jackson-core - ${jackson.version} - - - com.fasterxml.jackson.dataformat - jackson-dataformat-smile - ${jackson.version} - @@ -445,8 +370,7 @@ ${maven-surefire-plugin.version} ${skip.unit.tests} - -Xmx2048m -Djava.awt.headless=true - -XX:+UseConcMarkSweepGC + -Xmx2048m -Djava.awt.headless=true -XX:+UseConcMarkSweepGC -XX:OnOutOfMemoryError="kill -9 %p" -XX:+HeapDumpOnOutOfMemoryError ${surefireArgLine} ${surefire.redirectTestOutputToFile} @@ -553,7 +477,7 @@ validate validate - true + true ${checkstyle.file.name} ${checkstyle.suppression.file.name} UTF-8 @@ -686,12 +610,6 @@ - - - - -- cgit 1.2.3-korg