diff options
Diffstat (limited to 'models-sim/policy-models-sim-pdp')
8 files changed, 55 insertions, 51 deletions
diff --git a/models-sim/policy-models-sim-pdp/pom.xml b/models-sim/policy-models-sim-pdp/pom.xml index cf89b12eb..326a76a30 100644 --- a/models-sim/policy-models-sim-pdp/pom.xml +++ b/models-sim/policy-models-sim-pdp/pom.xml @@ -1,17 +1,38 @@ -<?xml version="1.0"?> -<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.onap.policy.models.sim</groupId> - <artifactId>policy-models-sim</artifactId> - <version>3.0.0-SNAPSHOT</version> - </parent> - <artifactId>policy-models-sim-pdp</artifactId> - <name>policy-models-sim-pdp</name> +<!-- + ============LICENSE_START======================================================= + Copyright (C) 2019 Bell Canada. All rights reserved. + Modifications Copyright (C) 2023 Nordix Foundation. + ================================================================================ + 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 -<description>A module that implements a simulator for PDP.</description> - <dependencies> + 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. + + SPDX-License-Identifier: Apache-2.0 + ============LICENSE_END========================================================= +--> + +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.policy.models.sim</groupId> + <artifactId>policy-models-sim</artifactId> + <version>3.0.1-SNAPSHOT</version> + </parent> + <artifactId>policy-models-sim-pdp</artifactId> + <name>policy-models-sim-pdp</name> + + <description>A module that implements a simulator for PDP.</description> + <dependencies> <dependency> <groupId>org.onap.policy.models</groupId> <artifactId>policy-models-pdp</artifactId> @@ -37,23 +58,6 @@ <artifactId>common-parameters</artifactId> <version>${policy.common.version}</version> </dependency> - - <!--test dependencies --> - <dependency> - <groupId>org.assertj</groupId> - <artifactId>assertj-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> </dependencies> <build> <resources> diff --git a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorActivator.java b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorActivator.java index 1bc2ff72d..31d5b4120 100644 --- a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorActivator.java +++ b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorActivator.java @@ -52,8 +52,8 @@ public class PdpSimulatorActivator { private static final Logger LOGGER = LoggerFactory.getLogger(PdpSimulatorActivator.class); private final PdpSimulatorParameterGroup pdpSimulatorParameterGroup; - private List<TopicSink> topicSinks; // topics to which pdp sends pdp status - private List<TopicSource> topicSources; // topics to which pdp listens to for messages from pap. + private final List<TopicSink> topicSinks; // topics to which pdp sends pdp status + private final List<TopicSource> topicSources; // topics to which pdp listens to for messages from pap. private static final String[] MSG_TYPE_NAMES = { "messageName" }; /* @@ -70,7 +70,7 @@ public class PdpSimulatorActivator { /** * Used to manage the services. */ - private ServiceManager manager; + private final ServiceManager manager; @Getter diff --git a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorMain.java b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorMain.java index 1441ba37f..88d1b2686 100644 --- a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorMain.java +++ b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorMain.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2021 Nordix Foundation. + * Copyright (C) 2019-2021, 2023 Nordix Foundation. * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -132,7 +132,7 @@ public class PdpSimulatorMain { activator.terminate(); } } catch (final PdpSimulatorException e) { - LOGGER.warn("error occured during shut down of the pdp simulator service", e); + LOGGER.warn("error occurred during shut down of the pdp simulator service", e); } } } diff --git a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/comm/PdpStatusPublisher.java b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/comm/PdpStatusPublisher.java index 6be59b100..69b25dddd 100644 --- a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/comm/PdpStatusPublisher.java +++ b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/comm/PdpStatusPublisher.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019, 2023 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -41,10 +41,10 @@ public class PdpStatusPublisher extends TimerTask { private static final Logger LOGGER = LoggerFactory.getLogger(PdpStatusPublisher.class); - private TopicSinkClient topicSinkClient; - private Timer timer; + private final TopicSinkClient topicSinkClient; + private final Timer timer; @Getter - private long interval; + private final long interval; /** * Constructor for instantiating PdpStatusPublisher. diff --git a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpMessageHandler.java b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpMessageHandler.java index ae028dd32..ad1a32d7b 100644 --- a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpMessageHandler.java +++ b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpMessageHandler.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2021 Nordix Foundation. + * Copyright (C) 2019-2021, 2023 Nordix Foundation. * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -101,8 +101,8 @@ public class PdpMessageHandler { * * @return PdpResponseDetails */ - public PdpResponseDetails createPdpResonseDetails(final String requestId, final PdpResponseStatus status, - final String responseMessage) { + public PdpResponseDetails createPdpResponseDetails(final String requestId, final PdpResponseStatus status, + final String responseMessage) { final var pdpResponseDetails = new PdpResponseDetails(); pdpResponseDetails.setResponseTo(requestId); pdpResponseDetails.setResponseStatus(status); diff --git a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpStateChangeMessageHandler.java b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpStateChangeMessageHandler.java index 4f9804f7e..23df912e2 100644 --- a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpStateChangeMessageHandler.java +++ b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpStateChangeMessageHandler.java @@ -81,16 +81,16 @@ public class PdpStateChangeMessageHandler { final PdpStatus pdpStatusContext, final PdpMessageHandler pdpMessageHandler) { PdpResponseDetails pdpResponseDetails = null; if (pdpStatusContext.getState().equals(PdpState.ACTIVE)) { - pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpStateChangeMsg.getRequestId(), + pdpResponseDetails = pdpMessageHandler.createPdpResponseDetails(pdpStateChangeMsg.getRequestId(), PdpResponseStatus.SUCCESS, "Pdp already in active state"); } else { final List<ToscaPolicy> policies = Registry.get(PdpSimulatorConstants.REG_PDP_TOSCA_POLICY_LIST); if (policies.isEmpty()) { pdpStatusContext.setState(PdpState.ACTIVE); - pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpStateChangeMsg.getRequestId(), + pdpResponseDetails = pdpMessageHandler.createPdpResponseDetails(pdpStateChangeMsg.getRequestId(), PdpResponseStatus.SUCCESS, "State changed to active. No policies found."); } else { - pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpStateChangeMsg.getRequestId(), + pdpResponseDetails = pdpMessageHandler.createPdpResponseDetails(pdpStateChangeMsg.getRequestId(), PdpResponseStatus.SUCCESS, "Pdp started. State changed to active."); pdpStatusContext.setState(PdpState.ACTIVE); } @@ -110,10 +110,10 @@ public class PdpStateChangeMessageHandler { final PdpStatus pdpStatusContext, final PdpMessageHandler pdpMessageHandler) { PdpResponseDetails pdpResponseDetails = null; if (pdpStatusContext.getState().equals(PdpState.PASSIVE)) { - pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpStateChangeMsg.getRequestId(), + pdpResponseDetails = pdpMessageHandler.createPdpResponseDetails(pdpStateChangeMsg.getRequestId(), PdpResponseStatus.SUCCESS, "Pdp already in passive state"); } else { - pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpStateChangeMsg.getRequestId(), + pdpResponseDetails = pdpMessageHandler.createPdpResponseDetails(pdpStateChangeMsg.getRequestId(), PdpResponseStatus.SUCCESS, "Pdp state changed from Active to Passive."); pdpStatusContext.setState(PdpState.PASSIVE); } diff --git a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpUpdateMessageHandler.java b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpUpdateMessageHandler.java index a90f74fba..60f7c1461 100644 --- a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpUpdateMessageHandler.java +++ b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpUpdateMessageHandler.java @@ -56,7 +56,7 @@ public class PdpUpdateMessageHandler { final var pdpStatusPublisher = Registry.get(PdpSimulatorConstants.REG_PDP_STATUS_PUBLISHER, PdpStatusPublisher.class); if (checkIfAlreadyHandled(pdpUpdateMsg, pdpStatusContext)) { - pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpUpdateMsg.getRequestId(), + pdpResponseDetails = pdpMessageHandler.createPdpResponseDetails(pdpUpdateMsg.getRequestId(), PdpResponseStatus.SUCCESS, "Pdp already updated"); } else { if (null != pdpUpdateMsg.getPdpHeartbeatIntervalMs() && pdpUpdateMsg.getPdpHeartbeatIntervalMs() > 0 @@ -74,12 +74,12 @@ public class PdpUpdateMessageHandler { .collect(Collectors.toList())); if (pdpStatusContext.getState().equals(PdpState.ACTIVE) && !pdpUpdateMsg.getPoliciesToBeDeployed().isEmpty()) { - pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpUpdateMsg.getRequestId(), + pdpResponseDetails = pdpMessageHandler.createPdpResponseDetails(pdpUpdateMsg.getRequestId(), PdpResponseStatus.SUCCESS, "Pdp engine started and policies are running."); } Registry.registerOrReplace(PdpSimulatorConstants.REG_PDP_TOSCA_POLICY_LIST, policies); if (null == pdpResponseDetails) { - pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpUpdateMsg.getRequestId(), + pdpResponseDetails = pdpMessageHandler.createPdpResponseDetails(pdpUpdateMsg.getRequestId(), PdpResponseStatus.SUCCESS, "Pdp update successful."); } } diff --git a/models-sim/policy-models-sim-pdp/src/main/package/docker/Dockerfile b/models-sim/policy-models-sim-pdp/src/main/package/docker/Dockerfile index d1a68ae30..d13fe8e35 100644 --- a/models-sim/policy-models-sim-pdp/src/main/package/docker/Dockerfile +++ b/models-sim/policy-models-sim-pdp/src/main/package/docker/Dockerfile @@ -23,7 +23,7 @@ # Docker file to build an image that runs the PDP simulator on Java 8 in alpine # -FROM onap/policy-jre-alpine:3.0.0-SNAPSHOT +FROM onap/policy-jre-alpine:3.0.1-SNAPSHOT LABEL maintainer="Policy Team" |