aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuresh Charan <suresh.charan@bell.ca>2023-03-29 14:38:40 -0400
committerSuresh Charan <suresh.charan@bell.ca>2023-08-08 15:53:54 -0400
commiteb4cf2ad5d004cbfda90a752d10fbc6e91ef8fb4 (patch)
treec047ac129e41c7806dfe490dcb0f40a78e65d45e
parentf26cf8bef56574106ec30a7fcfbf2f6652097425 (diff)
Removed db-based statistics feature
Statistics code cleanup Issue-ID: POLICY-4109 Change-Id: I543080e1ed3ce9c4f16d01df8f13219cba0a9c8c Signed-off-by: Suresh Charan <suresh.charan@bell.ca>
-rw-r--r--main/pom.xml7
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/PapConstants.java3
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java56
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/parameters/PapParameterGroup.java3
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/parameters/PdpModifyRequestMapParams.java3
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/repository/PdpStatisticsRepository.java84
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PapStatisticsManager.java166
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployProvider.java5
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/StatisticsReport.java46
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/StatisticsRestControllerV1.java143
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/stub/StatisticsRestControllerV1Stub.java88
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/stub/StubUtils.java10
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/service/PdpStatisticsService.java275
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java8
-rw-r--r--main/src/main/resources/application.yaml1
-rw-r--r--main/src/main/resources/openapi/openapi.yaml732
-rw-r--r--main/src/test/java/org/onap/policy/pap/contract/PapContractTest.java10
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java165
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/ProviderSuper.java5
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPapStatisticsManager.java95
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployProvider.java23
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestStatisticsReport.java47
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestStatisticsRestControllerV1.java103
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndBase.java20
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/e2e/StatisticsTest.java199
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/service/PdpStatisticsServiceTest.java193
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/startstop/TestPapActivator.java5
-rw-r--r--main/src/test/resources/application-test-e2e.yaml1
-rw-r--r--main/src/test/resources/application-test.yaml1
-rw-r--r--main/src/test/resources/parameters/MinimumParameters.json1
-rw-r--r--main/src/test/resources/parameters/PapConfigParameters.json1
-rw-r--r--main/src/test/resources/parameters/PapConfigParametersStd.json1
-rw-r--r--packages/policy-pap-tarball/src/main/resources/etc/papParameters.yaml1
-rw-r--r--postman/pap-api-collection.json232
34 files changed, 18 insertions, 2715 deletions
diff --git a/main/pom.xml b/main/pom.xml
index fe395995..636fce34 100644
--- a/main/pom.xml
+++ b/main/pom.xml
@@ -2,7 +2,7 @@
============LICENSE_START=======================================================
Copyright (C) 2019,2023 Nordix Foundation.
Modifications Copyright (C) 2019-2020 AT&T Intellectual Property.
- Modifications Copyright (C) 2020-2022 Bell Canada.
+ Modifications Copyright (C) 2020-2023 Bell Canada.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -170,8 +170,6 @@
<generateSupportingFiles>false</generateSupportingFiles>
<importMappings>
HealthCheckReport=org.onap.policy.common.endpoints.report.HealthCheckReport,
- StatisticsReport=org.onap.policy.pap.main.rest.StatisticsReport,
- PdpStatistics=org.onap.policy.models.pdp.concepts.PdpStatistics,
Pdps=org.onap.policy.models.pdp.concepts.Pdps,
PdpState=org.onap.policy.models.pdp.enums.PdpState,
PdpGroupUpdateResponse=org.onap.policy.models.pap.concepts.PdpGroupUpdateResponse,
@@ -184,9 +182,6 @@
PolicyAudit=org.onap.policy.models.pap.concepts.PolicyAudit,
PolicyStatus=org.onap.policy.models.pap.concepts.PolicyStatus
</importMappings>
- <typeMappings>
- PdpStatistics=org.onap.policy.models.pdp.concepts.PdpStatistics
- </typeMappings>
<configOptions>
<sourceFolder>src/gen/java</sourceFolder>
<dateLibrary>java11</dateLibrary>
diff --git a/main/src/main/java/org/onap/policy/pap/main/PapConstants.java b/main/src/main/java/org/onap/policy/pap/main/PapConstants.java
index 98859f10..58a484ff 100644
--- a/main/src/main/java/org/onap/policy/pap/main/PapConstants.java
+++ b/main/src/main/java/org/onap/policy/pap/main/PapConstants.java
@@ -3,7 +3,7 @@
* ONAP PAP
* ================================================================================
* Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2022-2023 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -31,7 +31,6 @@ public final class PapConstants {
// Registry keys
public static final String REG_PAP_ACTIVATOR = "object:activator/pap";
- public static final String REG_STATISTICS_MANAGER = "object:manager/statistics";
public static final String REG_PDP_MODIFY_LOCK = "lock:pdp";
public static final String REG_PDP_MODIFY_MAP = "object:pdp/modify/map";
public static final String REG_METER_REGISTRY = "object:meter/registry";
diff --git a/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java b/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java
index dc4a030b..696a6942 100644
--- a/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java
+++ b/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java
@@ -38,7 +38,6 @@ import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
-import org.onap.policy.models.pdp.concepts.PdpStatistics;
import org.onap.policy.models.pdp.concepts.PdpStatus;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.pdp.enums.PdpState;
@@ -48,7 +47,6 @@ import org.onap.policy.pap.main.PolicyPapException;
import org.onap.policy.pap.main.parameters.PapParameterGroup;
import org.onap.policy.pap.main.parameters.PdpParameters;
import org.onap.policy.pap.main.service.PdpGroupService;
-import org.onap.policy.pap.main.service.PdpStatisticsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -66,12 +64,8 @@ public class PdpStatusMessageHandler extends PdpMessageGenerator {
private final PdpParameters params;
- private final boolean savePdpStatistics;
-
private final PdpGroupService pdpGroupService;
- private final PdpStatisticsService pdpStatisticsService;
-
/**
* List to store policies present in db.
*/
@@ -92,15 +86,11 @@ public class PdpStatusMessageHandler extends PdpMessageGenerator {
*
* @param parameterGroup the parameterGroup
* @param pdpGroupService the pdpGroupService
- * @param pdpStatisticsService the pdpStatisticsService
*/
- public PdpStatusMessageHandler(PapParameterGroup parameterGroup, PdpGroupService pdpGroupService,
- PdpStatisticsService pdpStatisticsService) {
+ public PdpStatusMessageHandler(PapParameterGroup parameterGroup, PdpGroupService pdpGroupService) {
super(true);
this.params = parameterGroup.getPdpParameters();
- this.savePdpStatistics = parameterGroup.isSavePdpStatisticsInDb();
this.pdpGroupService = pdpGroupService;
- this.pdpStatisticsService = pdpStatisticsService;
}
/**
@@ -294,12 +284,6 @@ public class PdpStatusMessageHandler extends PdpMessageGenerator {
} else if (validatePdpDetails(message, pdpGroup, pdpSubGroup, pdpInstance)) {
LOGGER.debug("PdpInstance details are correct. Saving current state in DB - {}", pdpInstance);
updatePdpHealthStatus(message, pdpSubGroup, pdpInstance, pdpGroup);
-
- if (savePdpStatistics) {
- processPdpStatistics(message, pdpSubGroup, pdpInstance, pdpGroup);
- } else {
- LOGGER.debug("Not processing PdpStatistics - {}", message.getStatistics());
- }
} else {
LOGGER.debug("PdpInstance details are not correct. Sending PdpUpdate message - {}", pdpInstance);
LOGGER.debug("Policy list in DB - {}. Policy list in heartbeat - {}", pdpSubGroup.getPolicies(),
@@ -309,17 +293,6 @@ public class PdpStatusMessageHandler extends PdpMessageGenerator {
}
}
- private void processPdpStatistics(final PdpStatus message, final PdpSubGroup pdpSubGroup, final Pdp pdpInstance,
- final PdpGroup pdpGroup) {
- if (validatePdpStatisticsDetails(message, pdpInstance, pdpGroup, pdpSubGroup)) {
- LOGGER.debug("PdpStatistics details are correct. Saving current statistics in DB - {}",
- message.getStatistics());
- createPdpStatistics(message.getStatistics());
- } else {
- LOGGER.debug("PdpStatistics details are not correct - {}", message.getStatistics());
- }
- }
-
private void processPdpTermination(final PdpSubGroup pdpSubGroup, final Pdp pdpInstance, final PdpGroup pdpGroup) {
pdpSubGroup.getPdpInstances().remove(pdpInstance);
pdpSubGroup.setCurrentInstanceCount(pdpSubGroup.getCurrentInstanceCount() - 1);
@@ -343,28 +316,6 @@ public class PdpStatusMessageHandler extends PdpMessageGenerator {
.append(subGroup.getPolicies().containsAll(message.getPolicies()), true).build();
}
- private boolean validatePdpStatisticsDetails(final PdpStatus message, final Pdp pdpInstanceDetails,
- final PdpGroup pdpGroup, final PdpSubGroup pdpSubGroup) {
- if (message.getStatistics() != null) {
- return new EqualsBuilder()
- .append(message.getStatistics().getPdpInstanceId(), pdpInstanceDetails.getInstanceId())
- .append(message.getStatistics().getPdpGroupName(), pdpGroup.getName())
- .append(message.getStatistics().getPdpSubGroupName(), pdpSubGroup.getPdpType())
- .append(message.getStatistics().getPolicyDeployCount() < 0, false)
- .append(message.getStatistics().getPolicyDeployFailCount() < 0, false)
- .append(message.getStatistics().getPolicyDeploySuccessCount() < 0, false)
- .append(message.getStatistics().getPolicyUndeployCount() < 0, false)
- .append(message.getStatistics().getPolicyUndeployFailCount() < 0, false)
- .append(message.getStatistics().getPolicyUndeploySuccessCount() < 0, false)
- .append(message.getStatistics().getPolicyExecutedCount() < 0, false)
- .append(message.getStatistics().getPolicyExecutedFailCount() < 0, false)
- .append(message.getStatistics().getPolicyExecutedSuccessCount() < 0, false).build();
- } else {
- LOGGER.debug("PdpStatistics is null");
- return false;
- }
- }
-
private void updatePdpHealthStatus(final PdpStatus message, final PdpSubGroup pdpSubgroup, final Pdp pdpInstance,
final PdpGroup pdpGroup) {
pdpInstance.setHealthy(message.getHealthy());
@@ -375,11 +326,6 @@ public class PdpStatusMessageHandler extends PdpMessageGenerator {
LOGGER.debug("Updated Pdp in DB - {}", pdpInstance);
}
- private void createPdpStatistics(final PdpStatistics pdpStatistics) {
- pdpStatisticsService.createPdpStatistics(Arrays.asList(pdpStatistics));
- LOGGER.debug("Created PdpStatistics in DB - {}", pdpStatistics);
- }
-
private void sendPdpMessage(final String pdpGroupName, final PdpSubGroup subGroup, final String pdpInstanceId,
final PdpState pdpState) {
final List<ToscaPolicy> polsToBeDeployed = new LinkedList<>(policiesToBeDeployed.values());
diff --git a/main/src/main/java/org/onap/policy/pap/main/parameters/PapParameterGroup.java b/main/src/main/java/org/onap/policy/pap/main/parameters/PapParameterGroup.java
index 6165d422..8bee9786 100644
--- a/main/src/main/java/org/onap/policy/pap/main/parameters/PapParameterGroup.java
+++ b/main/src/main/java/org/onap/policy/pap/main/parameters/PapParameterGroup.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
* Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property.
- * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021-2023 Bell Canada. 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.
@@ -50,7 +50,6 @@ public class PapParameterGroup extends ParameterGroupImpl {
@Valid
@ParameterGroupConstraint
private PdpParameters pdpParameters;
- private boolean savePdpStatisticsInDb;
@Valid
@ParameterGroupConstraint
private TopicParameterGroup topicParameterGroup;
diff --git a/main/src/main/java/org/onap/policy/pap/main/parameters/PdpModifyRequestMapParams.java b/main/src/main/java/org/onap/policy/pap/main/parameters/PdpModifyRequestMapParams.java
index bca00e87..026ec0fb 100644
--- a/main/src/main/java/org/onap/policy/pap/main/parameters/PdpModifyRequestMapParams.java
+++ b/main/src/main/java/org/onap/policy/pap/main/parameters/PdpModifyRequestMapParams.java
@@ -3,7 +3,7 @@
* ONAP PAP
* ================================================================================
* Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021-2023 Bell Canada. 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.
@@ -43,7 +43,6 @@ public class PdpModifyRequestMapParams {
private PdpParameters params;
private TimerManager updateTimers;
private TimerManager stateChangeTimers;
- private boolean savePdpStatistics;
/**
* Validates the parameters.
diff --git a/main/src/main/java/org/onap/policy/pap/main/repository/PdpStatisticsRepository.java b/main/src/main/java/org/onap/policy/pap/main/repository/PdpStatisticsRepository.java
deleted file mode 100644
index f2dfeebd..00000000
--- a/main/src/main/java/org/onap/policy/pap/main/repository/PdpStatisticsRepository.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2022 Bell Canada. 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.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.pap.main.repository;
-
-import java.util.Date;
-import java.util.List;
-import org.onap.policy.models.pdp.persistence.concepts.JpaPdpStatistics;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.stereotype.Repository;
-
-@Repository
-public interface PdpStatisticsRepository extends JpaRepository<JpaPdpStatistics, Long> {
-
- List<JpaPdpStatistics> findByTimeStampBetween(Date startTime, Date endTime, Pageable topRecordsSize);
-
- List<JpaPdpStatistics> findByTimeStampGreaterThanEqual(Date startTime, Pageable topRecordsSize);
-
- List<JpaPdpStatistics> findByTimeStampLessThanEqual(Date endTime, Pageable topRecordsSize);
-
- List<JpaPdpStatistics> findByPdpGroupName(String pdpGroup, Pageable topRecordsSize);
-
- List<JpaPdpStatistics> findByPdpGroupNameAndTimeStampBetween(String pdpGroup, Date startTime, Date endTime,
- Pageable topRecordsSize);
-
- List<JpaPdpStatistics> findByPdpGroupNameAndTimeStampGreaterThanEqual(String pdpGroup, Date startTime,
- Pageable topRecordsSize);
-
- List<JpaPdpStatistics> findByPdpGroupNameAndTimeStampLessThanEqual(String pdpGroup, Date endTime,
- Pageable topRecordsSize);
-
- List<JpaPdpStatistics> findByPdpGroupNameAndPdpSubGroupName(String pdpGroup, String pdpSubGroup,
- Pageable topRecordsSize);
-
- List<JpaPdpStatistics> findByPdpGroupNameAndPdpSubGroupNameAndTimeStampBetween(String pdpGroup, String pdpSubGroup,
- Date startTime, Date endTime, Pageable topRecordsSize);
-
- List<JpaPdpStatistics> findByPdpGroupNameAndPdpSubGroupNameAndTimeStampGreaterThanEqual(String pdpGroup,
- String pdpSubGroup, Date startTime, Pageable topRecordsSize);
-
- List<JpaPdpStatistics> findByPdpGroupNameAndPdpSubGroupNameAndTimeStampLessThanEqual(String pdpGroup,
- String pdpSubGroup, Date endTime, Pageable topRecordsSize);
-
- List<JpaPdpStatistics> findByPdpGroupNameAndPdpSubGroupNameAndName(String pdpGroup, String pdpSubGroup,
- String pdp, Pageable topRecordsSize);
-
- List<JpaPdpStatistics> findByPdpGroupNameAndPdpSubGroupNameAndNameAndTimeStampGreaterThanEqual(String pdpGroup,
- String pdpSubGroup, String pdp, Date startTime, Pageable topRecordsSize);
-
- List<JpaPdpStatistics> findByPdpGroupNameAndPdpSubGroupNameAndNameAndTimeStampLessThanEqual(String pdpGroup,
- String pdpSubGroup, String pdp, Date endTime, Pageable topRecordsSize);
-
- List<JpaPdpStatistics> findByPdpGroupNameAndPdpSubGroupNameAndNameAndTimeStampBetween(String pdpGroup,
- String pdpSubGroup, String pdp, Date startTime, Date endTime, Pageable topRecordsSize);
-
- List<JpaPdpStatistics> findByName(String pdp, Pageable topRecordsSize);
-
- List<JpaPdpStatistics> findByNameAndTimeStampGreaterThanEqual(String pdp, Date startTime,
- Pageable topRecordsSize);
-
- List<JpaPdpStatistics> findByNameAndTimeStampLessThanEqual(String pdp, Date startTime, Pageable topRecordsSize);
-
- List<JpaPdpStatistics> findByNameAndTimeStampBetween(String pdp, Date startTime, Date endTime,
- Pageable topRecordsSize);
-
-}
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PapStatisticsManager.java b/main/src/main/java/org/onap/policy/pap/main/rest/PapStatisticsManager.java
deleted file mode 100644
index daa1a9c4..00000000
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PapStatisticsManager.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property.
- * ================================================================================
- * 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.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.pap.main.rest;
-
-import java.util.concurrent.atomic.AtomicLong;
-
-/**
- * Class to hold statistical data for pap component.
- *
- * @author Ram Krishna Verma (ram.krishna.verma@est.tech)
- */
-public class PapStatisticsManager {
-
- private final AtomicLong totalPdpCount = new AtomicLong(0);
- private final AtomicLong totalPdpGroupCount = new AtomicLong(0);
- private final AtomicLong totalPolicyDeployCount = new AtomicLong(0);
- private final AtomicLong policyDeploySuccessCount = new AtomicLong(0);
- private final AtomicLong policyDeployFailureCount = new AtomicLong(0);
- private final AtomicLong totalPolicyDownloadCount = new AtomicLong(0);
- private final AtomicLong policyDownloadSuccessCount = new AtomicLong(0);
- private final AtomicLong policyDownloadFailureCount = new AtomicLong(0);
-
- /**
- * Constructs the object.
- */
- public PapStatisticsManager() {
- super();
- }
-
- /**
- * Method to update the total pdp count.
- *
- * @return the updated value of totalPdpCount
- */
- public long updateTotalPdpCount() {
- return totalPdpCount.incrementAndGet();
- }
-
- /**
- * Method to update the total pdp group count.
- *
- * @return the updated value of totalPdpGroupCount
- */
- public long updateTotalPdpGroupCount() {
- return totalPdpGroupCount.incrementAndGet();
- }
-
- /**
- * Method to update the total policy deploy count.
- *
- * @return the updated value of totalPolicyDeployCount
- */
- public long updateTotalPolicyDeployCount() {
- return totalPolicyDeployCount.incrementAndGet();
- }
-
- /**
- * Method to update the policy deploy success count.
- *
- * @return the updated value of policyDeploySuccessCount
- */
- public long updatePolicyDeploySuccessCount() {
- return policyDeploySuccessCount.incrementAndGet();
- }
-
- /**
- * Method to update the policy deploy failure count.
- *
- * @return the updated value of policyDeployFailureCount
- */
- public long updatePolicyDeployFailureCount() {
- return policyDeployFailureCount.incrementAndGet();
- }
-
- /**
- * Method to update the total policy download count.
- *
- * @return the updated value of totalPolicyDownloadCount
- */
- public long updateTotalPolicyDownloadCount() {
- return totalPolicyDownloadCount.incrementAndGet();
- }
-
- /**
- * Method to update the policy download success count.
- *
- * @return the updated value of policyDownloadSuccessCount
- */
- public long updatePolicyDownloadSuccessCount() {
- return policyDownloadSuccessCount.incrementAndGet();
- }
-
- /**
- * Method to update the policy download failure count.
- *
- * @return the updated value of policyDownloadFailureCount
- */
- public long updatePolicyDownloadFailureCount() {
- return policyDownloadFailureCount.incrementAndGet();
- }
-
- /**
- * Reset all the statistics counts to 0.
- */
- public void resetAllStatistics() {
- totalPdpCount.set(0L);
- totalPdpGroupCount.set(0L);
- totalPolicyDeployCount.set(0L);
- policyDeploySuccessCount.set(0L);
- policyDeployFailureCount.set(0L);
- totalPolicyDownloadCount.set(0L);
- policyDownloadSuccessCount.set(0L);
- policyDownloadFailureCount.set(0L);
- }
-
- public long getTotalPdpCount() {
- return totalPdpCount.get();
- }
-
- public long getTotalPdpGroupCount() {
- return totalPdpGroupCount.get();
- }
-
- public long getTotalPolicyDeployCount() {
- return totalPolicyDeployCount.get();
- }
-
- public long getPolicyDeploySuccessCount() {
- return policyDeploySuccessCount.get();
- }
-
- public long getPolicyDeployFailureCount() {
- return policyDeployFailureCount.get();
- }
-
- public long getTotalPolicyDownloadCount() {
- return totalPolicyDownloadCount.get();
- }
-
- public long getPolicyDownloadSuccessCount() {
- return policyDownloadSuccessCount.get();
- }
-
- public long getPolicyDownloadFailureCount() {
- return policyDownloadFailureCount.get();
- }
-}
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployProvider.java b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployProvider.java
index 2963fe62..7a3e3395 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployProvider.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployProvider.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2019, 2022 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020-2021 Nordix Foundation.
- * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021, 2023 Bell Canada. 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,7 +56,6 @@ import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.pap.main.PapConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
@@ -429,8 +428,6 @@ public class PdpGroupDeployProvider extends ProviderBase {
ToscaConceptIdentifier desiredIdent = policy.getIdentifier();
ToscaConceptIdentifier desiredType = policy.getTypeIdentifier();
- PapStatisticsManager mgr = Registry.get(PapConstants.REG_STATISTICS_MANAGER, PapStatisticsManager.class);
- mgr.updateTotalPolicyDeployCount();
return (group, subgroup) -> {
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/StatisticsReport.java b/main/src/main/java/org/onap/policy/pap/main/rest/StatisticsReport.java
deleted file mode 100644
index e84d9684..00000000
--- a/main/src/main/java/org/onap/policy/pap/main/rest/StatisticsReport.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 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
- *
- * 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=========================================================
- */
-
-package org.onap.policy.pap.main.rest;
-
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * Class to represent statistics report of pap component.
- *
- * @author Ram Krishna Verma (ram.krishna.verma@est.tech)
- */
-@Getter
-@Setter
-@ToString
-public class StatisticsReport {
-
- private int code;
- private long totalPdpCount;
- private long totalPdpGroupCount;
- private long totalPolicyDeployCount;
- private long policyDeploySuccessCount;
- private long policyDeployFailureCount;
- private long totalPolicyDownloadCount;
- private long policyDownloadSuccessCount;
- private long policyDownloadFailureCount;
-}
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/StatisticsRestControllerV1.java b/main/src/main/java/org/onap/policy/pap/main/rest/StatisticsRestControllerV1.java
deleted file mode 100644
index 2af6e731..00000000
--- a/main/src/main/java/org/onap/policy/pap/main/rest/StatisticsRestControllerV1.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019-2023 Nordix Foundation.
- * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property.
- * Modifications Copyright (C) 2021-2022 Bell Canada. 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.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.pap.main.rest;
-
-import java.time.Instant;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import lombok.RequiredArgsConstructor;
-import org.onap.policy.models.pdp.concepts.PdpStatistics;
-import org.onap.policy.pap.main.service.PdpStatisticsService;
-import org.springframework.context.annotation.Profile;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * Class to provide REST endpoints for PAP component statistics.
- *
- * @author Ram Krishna Verma (ram.krishna.verma@est.tech)
- */
-@RestController
-@RequiredArgsConstructor
-@Profile("default")
-public class StatisticsRestControllerV1 extends PapRestControllerV1
- implements StatisticsRestControllerV1Api {
-
- private final PdpStatisticsService pdpStatisticsService;
-
- /**
- * get statistics of PAP.
- *
- *
- * @return a response
- */
- @Override
- public ResponseEntity<StatisticsReport> statistics(UUID requestId) {
- return addLoggingHeaders(addVersionControlHeaders(ResponseEntity.ok()), requestId)
- .body(pdpStatisticsService.fetchCurrentStatistics());
- }
-
- /**
- * get all statistics of PDP groups.
- *
- * @return a response
- */
- @Override
- public ResponseEntity<Map<String, Map<String, List<PdpStatistics>>>> pdpStatistics(
- UUID requestId,
- Integer recordCount,
- Long startTime,
- Long endTime) {
- return addLoggingHeaders(addVersionControlHeaders(ResponseEntity.ok()), requestId).body(pdpStatisticsService
- .fetchDatabaseStatistics(recordCount.intValue(), convertEpochtoInstant(startTime),
- convertEpochtoInstant(endTime)));
- }
-
-
- /**
- * get all statistics of a PDP group.
- *
- * @param groupName name of the PDP group
- * @return a response
- */
- @Override
- public ResponseEntity<Map<String, Map<String, List<PdpStatistics>>>> pdpGroupStatistics(
- String groupName,
- UUID requestId,
- Integer recordCount,
- Long startTime,
- Long endTime) {
- return addLoggingHeaders(addVersionControlHeaders(ResponseEntity.ok()), requestId)
- .body(pdpStatisticsService.fetchDatabaseStatistics(groupName, recordCount.intValue(),
- convertEpochtoInstant(startTime), convertEpochtoInstant(endTime)));
- }
-
- /**
- * get all statistics of sub PDP group.
- *
- * @param groupName name of the PDP group
- * @param subType type of the sub PDP group
- * @return a response
- */
- @Override
- public ResponseEntity<Map<String, Map<String, List<PdpStatistics>>>> pdpSubGroupStatistics(
- String groupName,
- String subType,
- UUID requestId,
- Integer recordCount,
- Long startTime,
- Long endTime) {
- return addLoggingHeaders(addVersionControlHeaders(ResponseEntity.ok()), requestId)
- .body(pdpStatisticsService.fetchDatabaseStatistics(groupName, subType, recordCount.intValue(),
- convertEpochtoInstant(startTime), convertEpochtoInstant(endTime)));
- }
-
- /**
- * get all statistics of one PDP.
- *
- * @param groupName name of the PDP group
- * @param subType type of the sub PDP group
- * @param pdpName the name of the PDP
- * @param recordCount the count of the query response, optional, default return all statistics stored
- * @return a response
- */
- @Override
- public ResponseEntity<Map<String, Map<String, List<PdpStatistics>>>> pdpInstanceStatistics(
- String groupName,
- String subType,
- String pdpName,
- UUID requestId,
- Integer recordCount,
- Long startTime,
- Long endTime) {
- return addLoggingHeaders(addVersionControlHeaders(ResponseEntity.ok()), requestId)
- .body(pdpStatisticsService.fetchDatabaseStatistics(groupName, subType, pdpName, recordCount.intValue(),
- convertEpochtoInstant(startTime), convertEpochtoInstant(endTime)));
- }
-
- private Instant convertEpochtoInstant(Long epochSecond) {
- return (epochSecond == null ? null : Instant.ofEpochSecond(epochSecond));
- }
-
-}
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/stub/StatisticsRestControllerV1Stub.java b/main/src/main/java/org/onap/policy/pap/main/rest/stub/StatisticsRestControllerV1Stub.java
deleted file mode 100644
index 663f1acc..00000000
--- a/main/src/main/java/org/onap/policy/pap/main/rest/stub/StatisticsRestControllerV1Stub.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * 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
- *
- * 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=========================================================
- */
-
-package org.onap.policy.pap.main.rest.stub;
-
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import javax.validation.Valid;
-import lombok.RequiredArgsConstructor;
-import org.onap.policy.models.pdp.concepts.PdpStatistics;
-import org.onap.policy.pap.main.rest.PapRestControllerV1;
-import org.onap.policy.pap.main.rest.StatisticsReport;
-import org.onap.policy.pap.main.rest.StatisticsRestControllerV1Api;
-import org.springframework.context.annotation.Profile;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.RestController;
-
-@RestController
-@RequiredArgsConstructor
-@Profile("stub")
-public class StatisticsRestControllerV1Stub extends PapRestControllerV1
- implements StatisticsRestControllerV1Api {
-
- private final StubUtils stubUtils;
-
- @Override
- public ResponseEntity<Map<String, Map<String, List<PdpStatistics>>>> pdpGroupStatistics(
- String group,
- UUID requestId,
- @Valid Integer recordCount,
- @Valid Long startTime,
- @Valid Long endTime) {
- return stubUtils.getStubbedResponseStatistics();
- }
-
- @Override
- public ResponseEntity<Map<String, Map<String, List<PdpStatistics>>>> pdpInstanceStatistics(
- String group,
- String type,
- String pdp,
- UUID requestId,
- @Valid Integer recordCount,
- @Valid Long startTime,
- @Valid Long endTime) {
- return stubUtils.getStubbedResponseStatistics();
- }
-
- @Override
- public ResponseEntity<Map<String, Map<String, List<PdpStatistics>>>> pdpStatistics(
- UUID requestId, @Valid Integer recordCount, @Valid Long startTime, @Valid Long endTime) {
- return stubUtils.getStubbedResponseStatistics();
- }
-
- @Override
- public ResponseEntity<Map<String, Map<String, List<PdpStatistics>>>> pdpSubGroupStatistics(
- String group,
- String type,
- UUID requestId,
- @Valid Integer recordCount,
- @Valid Long startTime,
- @Valid Long endTime) {
- return stubUtils.getStubbedResponseStatistics();
- }
-
- @Override
- public ResponseEntity<StatisticsReport> statistics(UUID requestId) {
- return stubUtils.getStubbedResponse(StatisticsReport.class);
- }
-
-}
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/stub/StubUtils.java b/main/src/main/java/org/onap/policy/pap/main/rest/stub/StubUtils.java
index 1f4f10f3..8eb4aba3 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/stub/StubUtils.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/stub/StubUtils.java
@@ -30,7 +30,6 @@ import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
-import org.onap.policy.models.pdp.concepts.PdpStatistics;
import org.onap.policy.pap.main.rest.PapRestControllerV1;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -104,13 +103,4 @@ class StubUtils {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
- ResponseEntity<Map<String, Map<String, List<PdpStatistics>>>> getStubbedResponseStatistics() {
- var accept = request.getHeader(ACCEPT);
- if (accept != null && accept.contains(APPLICATION_JSON)) {
- Map<String, Map<String, List<PdpStatistics>>> map = new HashMap<>();
- return new ResponseEntity<>(map, HttpStatus.OK);
- }
- return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
- }
-
}
diff --git a/main/src/main/java/org/onap/policy/pap/main/service/PdpStatisticsService.java b/main/src/main/java/org/onap/policy/pap/main/service/PdpStatisticsService.java
deleted file mode 100644
index eba34f30..00000000
--- a/main/src/main/java/org/onap/policy/pap/main/service/PdpStatisticsService.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2022 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
- *
- * 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=========================================================
- */
-
-package org.onap.policy.pap.main.service;
-
-import java.time.Instant;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-import javax.ws.rs.core.Response;
-import lombok.NonNull;
-import lombok.RequiredArgsConstructor;
-import org.onap.policy.common.parameters.BeanValidationResult;
-import org.onap.policy.common.utils.services.Registry;
-import org.onap.policy.models.base.PfModelRuntimeException;
-import org.onap.policy.models.pdp.concepts.PdpStatistics;
-import org.onap.policy.models.pdp.persistence.concepts.JpaPdpStatistics;
-import org.onap.policy.pap.main.PapConstants;
-import org.onap.policy.pap.main.repository.PdpStatisticsRepository;
-import org.onap.policy.pap.main.rest.PapStatisticsManager;
-import org.onap.policy.pap.main.rest.StatisticsReport;
-import org.onap.policy.pap.main.startstop.PapActivator;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.domain.Sort;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-@Service
-@Transactional
-@RequiredArgsConstructor
-public class PdpStatisticsService {
-
- private static final String TIMESTAMP = "timeStamp";
- private static final int DEFAULT_RECORD_COUNT = 10;
- private static final int MAX_RECORD_COUNT = 100;
-
- private final PdpStatisticsRepository pdpStatisticsRepository;
-
- /**
- * Returns the current statistics of pap component.
- *
- * @return Report containing statistics of pap component
- */
- public StatisticsReport fetchCurrentStatistics() {
- final var report = new StatisticsReport();
- report.setCode(Registry.get(PapConstants.REG_PAP_ACTIVATOR, PapActivator.class).isAlive() ? 200 : 500);
-
- PapStatisticsManager mgr = Registry.get(PapConstants.REG_STATISTICS_MANAGER, PapStatisticsManager.class);
- report.setTotalPdpCount(mgr.getTotalPdpCount());
- report.setTotalPdpGroupCount(mgr.getTotalPdpGroupCount());
- report.setTotalPolicyDownloadCount(mgr.getTotalPolicyDownloadCount());
- report.setPolicyDownloadSuccessCount(mgr.getPolicyDownloadSuccessCount());
- report.setPolicyDownloadFailureCount(mgr.getPolicyDownloadFailureCount());
- report.setTotalPolicyDeployCount(mgr.getTotalPolicyDeployCount());
- report.setPolicyDeploySuccessCount(mgr.getPolicyDeploySuccessCount());
- report.setPolicyDeployFailureCount(mgr.getPolicyDeployFailureCount());
-
- return report;
- }
-
- /**
- * Creates PDP statistics.
- *
- * @param pdpStatisticsList a specification of the PDP statistics to create
- * @return the PDP statistics created
- */
- public List<PdpStatistics> createPdpStatistics(@NonNull final List<PdpStatistics> pdpStatisticsList) {
- for (PdpStatistics pdpStatistics : pdpStatisticsList) {
- var jpaPdpStatistics = new JpaPdpStatistics();
- jpaPdpStatistics.fromAuthorative(pdpStatistics);
- BeanValidationResult validationResult = jpaPdpStatistics.validate("pdp statistics");
- if (!validationResult.isValid()) {
- throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult());
- }
- pdpStatisticsRepository.saveAndFlush(jpaPdpStatistics);
- pdpStatistics.setGeneratedId(jpaPdpStatistics.getGeneratedId());
- }
-
- // Return the created PDP statistics
- List<PdpStatistics> pdpStatistics = new ArrayList<>(pdpStatisticsList.size());
-
- for (PdpStatistics pdpStatisticsItem : pdpStatisticsList) {
- @SuppressWarnings("deprecation")
- var jpaPdpStatistics = pdpStatisticsRepository.getById(pdpStatisticsItem.getGeneratedId());
- pdpStatistics.add(jpaPdpStatistics.toAuthorative());
- }
- return pdpStatistics;
- }
-
- /**
- * Fetch PdpStatistics from db.
- *
- * @param pdpGroup the name of the group
- * @param pdpSubGroup the name of the subgroup
- * @param pdp the pdp instance id
- * @param recordCount the number of records to return
- * @param startTime start time of the records to be returned
- * @param endTime end time of the records to be returned
- * @return pdpStatistics grouped by pdpGroup
- */
- public Map<String, Map<String, List<PdpStatistics>>> fetchDatabaseStatistics(@NonNull String pdpGroup,
- @NonNull String pdpSubGroup, @NonNull String pdp, int recordCount, Instant startTime, Instant endTime) {
-
- Pageable recordSize = getRecordSize(recordCount);
- if (startTime != null && endTime != null) {
- return generatePdpStatistics(asPdpStatisticsList(pdpStatisticsRepository
- .findByPdpGroupNameAndPdpSubGroupNameAndNameAndTimeStampBetween(pdpGroup, pdpSubGroup, pdp,
- convertInstantToDate(startTime), convertInstantToDate(endTime), recordSize)));
- } else if (startTime == null && endTime == null) {
- return generatePdpStatistics(
- asPdpStatisticsList(pdpStatisticsRepository.findByPdpGroupNameAndPdpSubGroupNameAndName(pdpGroup,
- pdpSubGroup, pdp, recordSize)));
- } else if (startTime != null) {
- return generatePdpStatistics(asPdpStatisticsList(
- pdpStatisticsRepository.findByPdpGroupNameAndPdpSubGroupNameAndNameAndTimeStampGreaterThanEqual(
- pdpGroup, pdpSubGroup, pdp, convertInstantToDate(startTime), recordSize)));
- } else {
- return generatePdpStatistics(asPdpStatisticsList(
- pdpStatisticsRepository.findByPdpGroupNameAndPdpSubGroupNameAndNameAndTimeStampLessThanEqual(
- pdpGroup, pdpSubGroup, pdp, convertInstantToDate(endTime), recordSize)));
- }
- }
-
- /**
- * Fetch PdpStatistics from db.
- *
- * @param pdpGroup the name of the group
- * @param pdpSubGroup the name of the subgroup
- * @param recordCount the number of records to return
- * @param startTime start time of the records to be returned
- * @param endTime end time of the records to be returned
- * @return pdpStatistics grouped by pdpGroup
- */
- public Map<String, Map<String, List<PdpStatistics>>> fetchDatabaseStatistics(@NonNull String pdpGroup,
- @NonNull String pdpSubGroup, int recordCount, Instant startTime, Instant endTime) {
-
- Pageable recordSize = getRecordSize(recordCount);
- if (startTime != null && endTime != null) {
- return generatePdpStatistics(asPdpStatisticsList(
- pdpStatisticsRepository.findByPdpGroupNameAndPdpSubGroupNameAndTimeStampBetween(pdpGroup, pdpSubGroup,
- convertInstantToDate(startTime), convertInstantToDate(endTime), recordSize)));
- } else if (startTime == null && endTime == null) {
- return generatePdpStatistics(asPdpStatisticsList(pdpStatisticsRepository
- .findByPdpGroupNameAndPdpSubGroupName(pdpGroup, pdpSubGroup, recordSize)));
- } else if (startTime != null) {
- return generatePdpStatistics(asPdpStatisticsList(
- pdpStatisticsRepository.findByPdpGroupNameAndPdpSubGroupNameAndTimeStampGreaterThanEqual(pdpGroup,
- pdpSubGroup, convertInstantToDate(startTime), recordSize)));
- } else {
- return generatePdpStatistics(asPdpStatisticsList(
- pdpStatisticsRepository.findByPdpGroupNameAndPdpSubGroupNameAndTimeStampLessThanEqual(pdpGroup,
- pdpSubGroup, convertInstantToDate(endTime), recordSize)));
- }
- }
-
- /**
- * Fetch PdpStatistics from db.
- *
- * @param pdpGroup the name of the group
- * @param recordCount the number of records to return
- * @param startTime start time of the records to be returned
- * @param endTime end time of the records to be returned
- * @return pdpStatistics grouped by pdpGroup
- */
- public Map<String, Map<String, List<PdpStatistics>>> fetchDatabaseStatistics(@NonNull String pdpGroup,
- int recordCount, Instant startTime, Instant endTime) {
-
- Pageable recordSize = getRecordSize(recordCount);
- if (startTime != null && endTime != null) {
- return generatePdpStatistics(
- asPdpStatisticsList(pdpStatisticsRepository.findByPdpGroupNameAndTimeStampBetween(pdpGroup,
- convertInstantToDate(startTime), convertInstantToDate(endTime), recordSize)));
- } else if (startTime == null && endTime == null) {
- return generatePdpStatistics(
- asPdpStatisticsList(pdpStatisticsRepository.findByPdpGroupName(pdpGroup, recordSize)));
- } else if (startTime != null) {
- return generatePdpStatistics(
- asPdpStatisticsList(pdpStatisticsRepository.findByPdpGroupNameAndTimeStampGreaterThanEqual(pdpGroup,
- convertInstantToDate(startTime), recordSize)));
- } else {
- return generatePdpStatistics(
- asPdpStatisticsList(pdpStatisticsRepository.findByPdpGroupNameAndTimeStampLessThanEqual(pdpGroup,
- convertInstantToDate(endTime), recordSize)));
- }
- }
-
- /**
- * Fetch PdpStatistics from db.
- *
- * @param recordCount the number of records to return
- * @param startTime start time of the records to be returned
- * @param endTime end time of the records to be returned
- * @return pdpStatistics grouped by pdpGroup
- */
- public Map<String, Map<String, List<PdpStatistics>>> fetchDatabaseStatistics(int recordCount, Instant startTime,
- Instant endTime) {
-
- Pageable recordSize = getRecordSize(recordCount);
- if (startTime != null && endTime != null) {
- return generatePdpStatistics(asPdpStatisticsList(pdpStatisticsRepository.findByTimeStampBetween(
- convertInstantToDate(startTime), convertInstantToDate(endTime), recordSize)));
- } else if (startTime == null && endTime == null) {
- return generatePdpStatistics(
- asPdpStatisticsList(pdpStatisticsRepository.findAll(recordSize).toList()));
- } else if (startTime != null) {
- return generatePdpStatistics(asPdpStatisticsList(pdpStatisticsRepository
- .findByTimeStampGreaterThanEqual(convertInstantToDate(startTime), recordSize)));
- } else {
- return generatePdpStatistics(asPdpStatisticsList(pdpStatisticsRepository
- .findByTimeStampLessThanEqual(convertInstantToDate(endTime), recordSize)));
- }
- }
-
- private Pageable getRecordSize(int recordCount) {
- if (recordCount < 1) {
- recordCount = DEFAULT_RECORD_COUNT;
- } else if (recordCount > MAX_RECORD_COUNT) {
- recordCount = MAX_RECORD_COUNT;
- }
- return PageRequest.of(0, recordCount, Sort.by(TIMESTAMP).descending());
- }
-
- /**
- * generate the statistics of pap component by group/subgroup.
- *
- */
- private Map<String, Map<String, List<PdpStatistics>>> generatePdpStatistics(List<PdpStatistics> pdpStatisticsList) {
- Map<String, Map<String, List<PdpStatistics>>> groupMap = new HashMap<>();
- if (pdpStatisticsList != null) {
- pdpStatisticsList.stream().forEach(s -> {
- String curGroup = s.getPdpGroupName();
- String curSubGroup = s.getPdpSubGroupName();
- groupMap.computeIfAbsent(curGroup, curGroupMap -> new HashMap<>())
- .computeIfAbsent(curSubGroup, curSubGroupList -> new ArrayList<>()).add(s);
- });
- }
- return groupMap;
- }
-
- /**
- * Convert JPA PDP statistics list to an PDP statistics list.
- *
- * @param jpaPdpStatisticsList the list to convert
- * @return the PDP statistics list
- */
- private List<PdpStatistics> asPdpStatisticsList(List<JpaPdpStatistics> jpaPdpStatisticsList) {
- return jpaPdpStatisticsList.stream().map(JpaPdpStatistics::toAuthorative).collect(Collectors.toList());
- }
-
- private Date convertInstantToDate(Instant instant) {
- return (instant == null ? null : Date.from(instant));
- }
-}
diff --git a/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java b/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java
index 825208a4..4d90d7e1 100644
--- a/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java
+++ b/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019, 2022-2023 Nordix Foundation.
* Modifications Copyright (C) 2019-2021 AT&T Intellectual Property.
- * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021-2023 Bell Canada. 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.
@@ -50,7 +50,6 @@ import org.onap.policy.pap.main.comm.TimerManager;
import org.onap.policy.pap.main.notification.PolicyNotifier;
import org.onap.policy.pap.main.parameters.PapParameterGroup;
import org.onap.policy.pap.main.parameters.PdpModifyRequestMapParams;
-import org.onap.policy.pap.main.rest.PapStatisticsManager;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.context.event.ContextRefreshedEvent;
@@ -172,10 +171,6 @@ public class PapActivator extends ServiceManagerContainer {
TopicEndpointManager.getManager()::start,
TopicEndpointManager.getManager()::shutdown);
- addAction("PAP statistics",
- () -> Registry.register(PapConstants.REG_STATISTICS_MANAGER, new PapStatisticsManager()),
- () -> Registry.unregister(PapConstants.REG_STATISTICS_MANAGER));
-
addAction("PAP Activator",
() -> Registry.register(PapConstants.REG_PAP_ACTIVATOR, this),
() -> Registry.unregister(PapConstants.REG_PAP_ACTIVATOR));
@@ -224,7 +219,6 @@ public class PapActivator extends ServiceManagerContainer {
.responseDispatcher(responseReqIdDispatcher)
.stateChangeTimers(pdpStChgTimers.get())
.updateTimers(pdpUpdTimers.get())
- .savePdpStatistics(papParameterGroup.isSavePdpStatisticsInDb())
.build());
requestMap.set(pdpModifyRequestMap);
Registry.register(PapConstants.REG_PDP_MODIFY_MAP, requestMap.get());
diff --git a/main/src/main/resources/application.yaml b/main/src/main/resources/application.yaml
index 9703715d..4a7083a0 100644
--- a/main/src/main/resources/application.yaml
+++ b/main/src/main/resources/application.yaml
@@ -40,7 +40,6 @@ pap:
stateChangeParameters:
maxRetryCount: 1
maxWaitMs: 30000
- savePdpStatisticsInDb: true
topicParameterGroup:
topicSources:
- topic: ${pap.topic.pdp-pap.name}
diff --git a/main/src/main/resources/openapi/openapi.yaml b/main/src/main/resources/openapi/openapi.yaml
index 281d2cc3..9a88c801 100644
--- a/main/src/main/resources/openapi/openapi.yaml
+++ b/main/src/main/resources/openapi/openapi.yaml
@@ -1,5 +1,6 @@
# ============LICENSE_START=======================================================
# Copyright (C) 2022-2023 Nordix Foundation
+# Modifications Copyright (C) 2023 Bell Canada. 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.
@@ -52,7 +53,6 @@ tags:
- name: PolicyAuditControllerV1
- name: PolicyComponentsHealthCheckControllerV1
- name: PolicyStatusControllerV1
- - name: StatisticsRestControllerV1
paths:
/healthcheck:
get:
@@ -63,7 +63,7 @@ paths:
operationId: healthcheck
responses:
200:
- description: OK, serialised instance of
+ description: OK, serialized instance of
[HealthCheckReport](https://github.com/onap/policy-common/blob/master/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/report/HealthCheckReport.java)
headers:
X-LatestVersion:
@@ -2990,729 +2990,7 @@ paths:
- basicAuth: []
x-interface info:
api-version: 1.0.0
- last-mod-release: Dublin
- /pdps/statistics:
- get:
- tags:
- - StatisticsRestControllerV1
- summary: Fetch statistics for all PDP Groups and subgroups in the system
- description: >-
- Returns for all PDP Groups and subgroups statistics of the Policy
- Administration component
- operationId: pdpStatistics
- parameters:
- - name: X-ONAP-RequestID
- in: header
- description: RequestID for http transaction
- required: false
- schema:
- type: string
- format: uuid
- - name: recordCount
- in: query
- description: Record Count
- required: false
- style: form
- schema:
- type: integer
- format: int32
- default: 10
- - name: startTime
- in: query
- description: Start time in epoch timestamp
- required: false
- style: form
- schema:
- type: integer
- format: int64
- - name: endTime
- in: query
- description: End time in epoch timestamp
- required: false
- style: form
- schema:
- type: integer
- format: int64
- responses:
- 200:
- description: OK, a map for each PDP group keyed by PDP group name that contains another
- map keyed by PDP subgroup name that contains the statistics for each PDP in the PDP
- subgroup as a list of instances of
- [PdpStatistics](https://github.com/onap/policy-models/blob/master/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatistics.java)
- content:
- application/json:
- schema:
- type: string
- additionalProperties:
- type: string
- additionalProperties:
- type: array
- items:
- $ref: '#/components/schemas/PdpStatistics'
- application/yaml:
- schema:
- type: string
- additionalProperties:
- type: string
- additionalProperties:
- type: array
- items:
- $ref: '#/components/schemas/PdpStatistics'
- 401:
- description: Authentication Error
- headers:
- X-LatestVersion:
- description: Used only to communicate an API's latest version
- required: true
- schema:
- type: string
- X-PatchVersion:
- description: >-
- Used only to communicate a PATCH version in a response for
- troubleshooting purposes only, and will not be provided by the
- client on request
- required: true
- schema:
- type: string
- X-MinorVersion:
- description: >-
- Used to request or communicate a MINOR version back from the
- client to the server, and from the server back to the client
- required: true
- schema:
- type: string
- X-ONAP-RequestID:
- description: Used to track REST transactions for logging purpose
- required: true
- schema:
- type: string
- format: uuid
- 403:
- description: Authorization Error
- headers:
- X-LatestVersion:
- description: Used only to communicate an API's latest version
- required: true
- schema:
- type: string
- X-PatchVersion:
- description: >-
- Used only to communicate a PATCH version in a response for
- troubleshooting purposes only, and will not be provided by the
- client on request
- required: true
- schema:
- type: string
- X-MinorVersion:
- description: >-
- Used to request or communicate a MINOR version back from the
- client to the server, and from the server back to the client
- required: true
- schema:
- type: string
- X-ONAP-RequestID:
- description: Used to track REST transactions for logging purpose
- required: true
- schema:
- type: string
- format: uuid
- 404:
- description: Not Found
- 500:
- description: Internal Server Error
- headers:
- X-LatestVersion:
- description: Used only to communicate an API's latest version
- required: true
- schema:
- type: string
- X-PatchVersion:
- description: >-
- Used only to communicate a PATCH version in a response for
- troubleshooting purposes only, and will not be provided by the
- client on request
- required: true
- schema:
- type: string
- X-MinorVersion:
- description: >-
- Used to request or communicate a MINOR version back from the
- client to the server, and from the server back to the client
- required: true
- schema:
- type: string
- X-ONAP-RequestID:
- description: Used to track REST transactions for logging purpose
- required: true
- schema:
- type: string
- format: uuid
- security:
- - basicAuth: []
- x-interface info:
- api-version: 1.0.0
last-mod-release: Dublin
- /pdps/statistics/{group}:
- get:
- tags:
- - StatisticsRestControllerV1
- summary: Fetch current statistics for given PDP Group
- description: >-
- Returns statistics for given PDP Group of the Policy Administration
- component
- operationId: pdpGroupStatistics
- parameters:
- - name: X-ONAP-RequestID
- in: header
- description: RequestID for http transaction
- required: false
- schema:
- type: string
- format: uuid
- - name: group
- in: path
- description: PDP Group Name
- required: true
- style: simple
- schema:
- type: string
- - name: recordCount
- in: query
- description: Record Count
- required: false
- style: form
- schema:
- type: integer
- format: int32
- default: 10
- - name: startTime
- in: query
- description: Start time in epoch timestamp
- required: false
- style: form
- schema:
- type: integer
- format: int64
- - name: endTime
- in: query
- description: End time in epoch timestamp
- required: false
- style: form
- schema:
- type: integer
- format: int64
- responses:
- 200:
- description: OK, a map for each PDP group keyed by PDP group name that contains another
- map keyed by PDP subgroup name that contains the statistics for each PDP in the PDP
- subgroup as a list of instances of
- [PdpStatistics](https://github.com/onap/policy-models/blob/master/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatistics.java)
- content:
- application/json:
- schema:
- type: string
- additionalProperties:
- type: string
- additionalProperties:
- type: array
- items:
- $ref: '#/components/schemas/PdpStatistics'
- application/yaml:
- schema:
- type: string
- additionalProperties:
- type: string
- additionalProperties:
- type: array
- items:
- $ref: '#/components/schemas/PdpStatistics'
- 401:
- description: Authentication Error
- headers:
- X-LatestVersion:
- description: Used only to communicate an API's latest version
- required: true
- schema:
- type: string
- X-PatchVersion:
- description: >-
- Used only to communicate a PATCH version in a response for
- troubleshooting purposes only, and will not be provided by the
- client on request
- required: true
- schema:
- type: string
- X-MinorVersion:
- description: >-
- Used to request or communicate a MINOR version back from the
- client to the server, and from the server back to the client
- required: true
- schema:
- type: string
- X-ONAP-RequestID:
- description: Used to track REST transactions for logging purpose
- required: true
- schema:
- type: string
- format: uuid
- 403:
- description: Authorization Error
- headers:
- X-LatestVersion:
- description: Used only to communicate an API's latest version
- required: true
- schema:
- type: string
- X-PatchVersion:
- description: >-
- Used only to communicate a PATCH version in a response for
- troubleshooting purposes only, and will not be provided by the
- client on request
- required: true
- schema:
- type: string
- X-MinorVersion:
- description: >-
- Used to request or communicate a MINOR version back from the
- client to the server, and from the server back to the client
- required: true
- schema:
- type: string
- X-ONAP-RequestID:
- description: Used to track REST transactions for logging purpose
- required: true
- schema:
- type: string
- format: uuid
- 404:
- description: Not Found
- 500:
- description: Internal Server Error
- headers:
- X-LatestVersion:
- description: Used only to communicate an API's latest version
- required: true
- schema:
- type: string
- X-PatchVersion:
- description: >-
- Used only to communicate a PATCH version in a response for
- troubleshooting purposes only, and will not be provided by the
- client on request
- required: true
- schema:
- type: string
- X-MinorVersion:
- description: >-
- Used to request or communicate a MINOR version back from the
- client to the server, and from the server back to the client
- required: true
- schema:
- type: string
- X-ONAP-RequestID:
- description: Used to track REST transactions for logging purpose
- required: true
- schema:
- type: string
- format: uuid
- security:
- - basicAuth: []
- x-interface info:
- api-version: 1.0.0
- last-mod-release: Dublin
- /pdps/statistics/{group}/{type}:
- get:
- tags:
- - StatisticsRestControllerV1
- summary: Fetch statistics for the specified subgroup
- description: >-
- Returns statistics for the specified subgroup of the Policy
- Administration component
- operationId: pdpSubGroupStatistics
- parameters:
- - name: X-ONAP-RequestID
- in: header
- description: RequestID for http transaction
- required: false
- schema:
- type: string
- format: uuid
- - name: group
- in: path
- description: PDP Group Name
- required: true
- style: simple
- schema:
- type: string
- - name: type
- in: path
- description: PDP SubGroup type
- required: true
- style: simple
- schema:
- type: string
- - name: recordCount
- in: query
- description: Record Count
- required: false
- style: form
- schema:
- type: integer
- format: int32
- default: 10
- - name: startTime
- in: query
- description: Start time in epoch timestamp
- required: false
- style: form
- schema:
- type: integer
- format: int64
- - name: endTime
- in: query
- description: End time in epoch timestamp
- required: false
- style: form
- schema:
- type: integer
- format: int64
- responses:
- 200:
- description: OK, a map for each PDP group keyed by PDP group name that contains another
- map keyed by PDP subgroup name that contains the statistics for each PDP in the PDP
- subgroup as a list of instances of
- [PdpStatistics](https://github.com/onap/policy-models/blob/master/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatistics.java)
- content:
- application/json:
- schema:
- type: string
- additionalProperties:
- type: string
- additionalProperties:
- type: array
- items:
- $ref: '#/components/schemas/PdpStatistics'
- application/yaml:
- schema:
- type: string
- additionalProperties:
- type: string
- additionalProperties:
- type: array
- items:
- $ref: '#/components/schemas/PdpStatistics'
- 401:
- description: Authentication Error
- headers:
- X-LatestVersion:
- description: Used only to communicate an API's latest version
- required: true
- schema:
- type: string
- X-PatchVersion:
- description: >-
- Used only to communicate a PATCH version in a response for
- troubleshooting purposes only, and will not be provided by the
- client on request
- required: true
- schema:
- type: string
- X-MinorVersion:
- description: >-
- Used to request or communicate a MINOR version back from the
- client to the server, and from the server back to the client
- required: true
- schema:
- type: string
- X-ONAP-RequestID:
- description: Used to track REST transactions for logging purpose
- required: true
- schema:
- type: string
- format: uuid
- 403:
- description: Authorization Error
- headers:
- X-LatestVersion:
- description: Used only to communicate an API's latest version
- required: true
- schema:
- type: string
- X-PatchVersion:
- description: >-
- Used only to communicate a PATCH version in a response for
- troubleshooting purposes only, and will not be provided by the
- client on request
- required: true
- schema:
- type: string
- X-MinorVersion:
- description: >-
- Used to request or communicate a MINOR version back from the
- client to the server, and from the server back to the client
- required: true
- schema:
- type: string
- X-ONAP-RequestID:
- description: Used to track REST transactions for logging purpose
- required: true
- schema:
- type: string
- format: uuid
- 404:
- description: Not Found
- 500:
- description: Internal Server Error
- headers:
- X-LatestVersion:
- description: Used only to communicate an API's latest version
- required: true
- schema:
- type: string
- X-PatchVersion:
- description: >-
- Used only to communicate a PATCH version in a response for
- troubleshooting purposes only, and will not be provided by the
- client on request
- required: true
- schema:
- type: string
- X-MinorVersion:
- description: >-
- Used to request or communicate a MINOR version back from the
- client to the server, and from the server back to the client
- required: true
- schema:
- type: string
- X-ONAP-RequestID:
- description: Used to track REST transactions for logging purpose
- required: true
- schema:
- type: string
- format: uuid
- security:
- - basicAuth: []
- x-interface info:
- api-version: 1.0.0
- last-mod-release: Dublin
- /pdps/statistics/{group}/{type}/{pdp}:
- get:
- tags:
- - StatisticsRestControllerV1
- summary: Fetch statistics for the specified pdp
- description: >-
- Returns statistics for the specified pdp of the Policy Administration
- component
- operationId: pdpInstanceStatistics
- parameters:
- - name: X-ONAP-RequestID
- in: header
- description: RequestID for http transaction
- required: false
- schema:
- type: string
- format: uuid
- - name: group
- in: path
- description: PDP Group Name
- required: true
- style: simple
- schema:
- type: string
- - name: type
- in: path
- description: PDP SubGroup type
- required: true
- style: simple
- schema:
- type: string
- - name: pdp
- in: path
- description: PDP Instance name
- required: true
- style: simple
- schema:
- type: string
- - name: recordCount
- in: query
- description: Record Count
- required: false
- style: form
- schema:
- type: integer
- format: int32
- default: 10
- - name: startTime
- in: query
- description: Start time in epoch timestamp
- required: false
- style: form
- schema:
- type: integer
- format: int64
- - name: endTime
- in: query
- description: End time in epoch timestamp
- required: false
- style: form
- schema:
- type: integer
- format: int64
- responses:
- 200:
- description: OK, a map for each PDP group keyed by PDP group name that contains another
- map keyed by PDP subgroup name that contains the statistics for each PDP in the PDP
- subgroup as a list of instances of
- [PdpStatistics](https://github.com/onap/policy-models/blob/master/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatistics.java)
- content:
- application/json:
- schema:
- type: string
- additionalProperties:
- type: string
- additionalProperties:
- type: array
- items:
- $ref: '#/components/schemas/PdpStatistics'
- application/yaml:
- schema:
- type: string
- additionalProperties:
- type: string
- additionalProperties:
- type: array
- items:
- $ref: '#/components/schemas/PdpStatistics'
- 401:
- description: Authentication Error
- headers:
- X-LatestVersion:
- description: Used only to communicate an API's latest version
- required: true
- schema:
- type: string
- X-PatchVersion:
- description: >-
- Used only to communicate a PATCH version in a response for
- troubleshooting purposes only, and will not be provided by the
- client on request
- required: true
- schema:
- type: string
- X-MinorVersion:
- description: >-
- Used to request or communicate a MINOR version back from the
- client to the server, and from the server back to the client
- required: true
- schema:
- type: string
- X-ONAP-RequestID:
- description: Used to track REST transactions for logging purpose
- required: true
- schema:
- type: string
- format: uuid
- 403:
- description: Authorization Error
- headers:
- X-LatestVersion:
- description: Used only to communicate an API's latest version
- required: true
- schema:
- type: string
- X-PatchVersion:
- description: >-
- Used only to communicate a PATCH version in a response for
- troubleshooting purposes only, and will not be provided by the
- client on request
- required: true
- schema:
- type: string
- X-MinorVersion:
- description: >-
- Used to request or communicate a MINOR version back from the
- client to the server, and from the server back to the client
- required: true
- schema:
- type: string
- X-ONAP-RequestID:
- description: Used to track REST transactions for logging purpose
- required: true
- schema:
- type: string
- format: uuid
- 404:
- description: Not Found
- 500:
- description: Internal Server Error
- headers:
- X-LatestVersion:
- description: Used only to communicate an API's latest version
- required: true
- schema:
- type: string
- X-PatchVersion:
- description: >-
- Used only to communicate a PATCH version in a response for
- troubleshooting purposes only, and will not be provided by the
- client on request
- required: true
- schema:
- type: string
- X-MinorVersion:
- description: >-
- Used to request or communicate a MINOR version back from the
- client to the server, and from the server back to the client
- required: true
- schema:
- type: string
- X-ONAP-RequestID:
- description: Used to track REST transactions for logging purpose
- required: true
- schema:
- type: string
- format: uuid
- security:
- - basicAuth: []
- x-interface info:
- api-version: 1.0.0
- last-mod-release: Dublin
- /statistics:
- get:
- tags:
- - StatisticsRestControllerV1
- summary: Fetch current statistics
- description: Returns current statistics of the Policy Administration component
- operationId: statistics
- parameters:
- - name: X-ONAP-RequestID
- in: header
- description: RequestID for http transaction
- required: false
- schema:
- type: string
- format: uuid
- responses:
- 200:
- description: OK, the statistics report in an instance of
- [StatisticsReport](https://github.com/onap/policy-api/blob/master/main/src/main/java/org/onap/policy/api/main/rest/provider/statistics/StatisticsReport.java)
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/StatisticsReport'
- application/yaml:
- schema:
- $ref: '#/components/schemas/StatisticsReport'
- 401:
- description: Authentication Error
- 403:
- description: Authorization Error
- 404:
- description: Not Found
- 500:
- description: Internal Server Error
- security:
- - basicAuth: []
components:
securitySchemes:
basicAuth:
@@ -3755,9 +3033,3 @@ components:
PolicyStatus:
title: PolicyStatus
type: object
- PdpStatistics:
- title: PdpStatistics
- type: object
- StatisticsReport:
- title: StatisticsReport
- type: object
diff --git a/main/src/test/java/org/onap/policy/pap/contract/PapContractTest.java b/main/src/test/java/org/onap/policy/pap/contract/PapContractTest.java
index f2440381..7b9698bb 100644
--- a/main/src/test/java/org/onap/policy/pap/contract/PapContractTest.java
+++ b/main/src/test/java/org/onap/policy/pap/contract/PapContractTest.java
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023 Bell Canada. 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.
@@ -39,15 +40,6 @@ public class PapContractTest extends CommonPapRestServer {
}
@Test
- public void testStubsStatistics() throws Exception {
- checkStubJsonGet("pdps/statistics");
- checkStubJsonGet("pdps/statistics/group");
- checkStubJsonGet("pdps/statistics/group/type");
- checkStubJsonGet("pdps/statistics/group/type/pdp");
- checkStubJsonGet("statistics");
- }
-
- @Test
public void testStubsPolicies() throws Exception {
checkStubJsonGet("policies/audit");
checkStubJsonGet("policies/audit/group");
diff --git a/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java b/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java
index 34c20410..20e34f62 100644
--- a/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2020-2021 AT&T Intellectual Property.
- * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021-2023 Bell Canada. 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,19 +26,16 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
-import java.text.ParseException;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import java.util.Map;
import java.util.stream.Collectors;
import org.junit.Test;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.pdp.concepts.PdpGroup;
-import org.onap.policy.models.pdp.concepts.PdpStatistics;
import org.onap.policy.models.pdp.concepts.PdpStatus;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
@@ -77,7 +74,6 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
addGroups("PdpGroups.json");
PapParameterGroup parameterGroup = new PapParameterGroup();
parameterGroup.setPdpParameters(new PdpParameters());
- parameterGroup.setSavePdpStatisticsInDb(true);
// Testing pdp registration success case
final PdpStatus status1 = new PdpStatus();
@@ -227,164 +223,16 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
policies.add(polA);
policies.add(polB);
final PapParameterGroup testGroup = new CommonTestData().getPapParameterGroup(1);
- testGroup.setSavePdpStatisticsInDb(true);
List<ToscaConceptIdentifier> polsUndep =
policies.stream().map(ToscaPolicy::getIdentifier).collect(Collectors.toList());
- PdpStatusMessageHandler handler = new PdpStatusMessageHandler(testGroup, pdpGroupService,
- pdpStatisticsService);
+ PdpStatusMessageHandler handler = new PdpStatusMessageHandler(testGroup, pdpGroupService);
PdpUpdate update10 =
handler.createPdpUpdateMessage(status3.getPdpGroup(), new PdpSubGroup(), "pdp_2", policies, polsUndep);
assertSame(update10.getPoliciesToBeDeployed(), policies);
assertSame(update10.getPoliciesToBeUndeployed(), polsUndep);
assertThat(update10.getPoliciesToBeDeployed()).isInstanceOf(List.class);
}
-
- @Test
- public void testPdpStatistics() throws CoderException, PfModelException, ParseException {
- addGroups("PdpGroups.json");
- PapParameterGroup parameterGroup = new PapParameterGroup();
- parameterGroup.setPdpParameters(new PdpParameters());
- parameterGroup.setSavePdpStatisticsInDb(true);
- timeStamp = Instant.parse("2021-02-12T17:48:01.029211400Z");
-
- // init default pdp group
- final PdpStatus status1 = new PdpStatus();
- status1.setName(PDP_NAME);
- status1.setState(PdpState.ACTIVE);
- status1.setPdpGroup(DEFAULT_GROUP);
- status1.setPdpType(APEX_TYPE);
- status1.setHealthy(PdpHealthStatus.HEALTHY);
- final List<ToscaConceptIdentifier> idents1 =
- Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
- status1.setPolicies(idents1);
- pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status1);
- verifyPdpGroup(DEFAULT_GROUP, 1);
-
- // init pdp instance
- final PdpStatus status2 = new PdpStatus();
- status2.setName(PDP_NAME);
- status2.setState(PdpState.ACTIVE);
- status2.setPdpGroup(DEFAULT_GROUP);
- status2.setPdpType(APEX_TYPE);
- status2.setHealthy(PdpHealthStatus.HEALTHY);
- status2.setPdpSubgroup(APEX_TYPE);
- final List<ToscaConceptIdentifier> idents2 =
- Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
- status2.setPolicies(idents2);
- pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status2);
-
- // Testing passing pdp statistics success case
- final PdpStatus status3 = new PdpStatus();
- status3.setName(PDP_NAME);
- status3.setState(PdpState.ACTIVE);
- status3.setPdpGroup(DEFAULT_GROUP);
- status3.setPdpType(APEX_TYPE);
- status3.setHealthy(PdpHealthStatus.HEALTHY);
- status3.setPdpSubgroup(APEX_TYPE);
- final List<ToscaConceptIdentifier> idents3 =
- Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
- status3.setPolicies(idents3);
-
- PdpStatistics pdpStatistics03 = new PdpStatistics();
- pdpStatistics03.setPdpInstanceId(PDP_NAME);
- pdpStatistics03.setPdpGroupName(DEFAULT_GROUP);
- pdpStatistics03.setPdpSubGroupName(APEX_TYPE);
- pdpStatistics03.setTimeStamp(timeStamp);
- status3.setStatistics(pdpStatistics03);
- pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status3);
- verifyPdpStatistics(PDP_NAME, DEFAULT_GROUP, APEX_TYPE, 1);
-
- // Testing pdp statistics failure having the pdpStatistics null in the heartbeat for already registered pdp
- final PdpStatus status4 = new PdpStatus();
- status4.setName(PDP_NAME);
- status4.setState(PdpState.ACTIVE);
- status4.setPdpGroup(DEFAULT_GROUP);
- status4.setPdpType(APEX_TYPE);
- status4.setHealthy(PdpHealthStatus.HEALTHY);
- status4.setPdpSubgroup(APEX_TYPE);
- final List<ToscaConceptIdentifier> idents4 =
- Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
- status4.setPolicies(idents4);
- status4.setStatistics(null);
- pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status4);
- verifyPdpStatistics(PDP_NAME, DEFAULT_GROUP, APEX_TYPE, 1);
-
- // Testing pdp statistics failure passing different pdpGroup, PdpSubGroup & pdpInstanceId
- final PdpStatus status5 = new PdpStatus();
- status5.setName(PDP_NAME);
- status5.setState(PdpState.ACTIVE);
- status5.setPdpGroup(DEFAULT_GROUP);
- status5.setPdpType(APEX_TYPE);
- status5.setHealthy(PdpHealthStatus.HEALTHY);
- status5.setPdpSubgroup(APEX_TYPE);
- final List<ToscaConceptIdentifier> idents5 =
- Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
- status5.setPolicies(idents5);
-
- PdpStatistics pdpStatistics05 = new PdpStatistics();
- pdpStatistics05.setPdpInstanceId("pdp_2");
- pdpStatistics05.setPdpGroupName("defaultGroup_1");
- pdpStatistics05.setPdpSubGroupName("apex_1");
- pdpStatistics03.setTimeStamp(timeStamp);
- status5.setStatistics(pdpStatistics05);
-
- pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status5);
- verifyPdpStatistics(PDP_NAME, DEFAULT_GROUP, APEX_TYPE, 1);
-
- // Test pdp statistics failure passing negative values
- final PdpStatus status6 = new PdpStatus();
- status6.setName(PDP_NAME);
- status6.setState(PdpState.ACTIVE);
- status6.setPdpGroup(DEFAULT_GROUP);
- status6.setPdpType(APEX_TYPE);
- status6.setHealthy(PdpHealthStatus.HEALTHY);
- status6.setPdpSubgroup(APEX_TYPE);
- final List<ToscaConceptIdentifier> idents6 =
- Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
- status5.setPolicies(idents6);
-
- PdpStatistics pdpStatistics06 = new PdpStatistics();
- pdpStatistics06.setPdpInstanceId(PDP_NAME);
- pdpStatistics06.setPdpGroupName(DEFAULT_GROUP);
- pdpStatistics06.setPdpSubGroupName(APEX_TYPE);
- pdpStatistics03.setTimeStamp(timeStamp);
-
- pdpStatistics06.setPolicyDeployCount(-1);
- pdpStatistics06.setPolicyDeployFailCount(-1);
- pdpStatistics06.setPolicyUndeployCount(-1);
- pdpStatistics06.setPolicyUndeployFailCount(-1);
- status5.setStatistics(pdpStatistics06);
-
- pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status5);
- verifyPdpStatistics(PDP_NAME, DEFAULT_GROUP, APEX_TYPE, 1);
-
- // Test pdp statistics save disabled case, sending valid pdp status but count should still remain 1
- parameterGroup = new PapParameterGroup();
- parameterGroup.setPdpParameters(new PdpParameters());
- parameterGroup.setSavePdpStatisticsInDb(false);
- timeStamp = Instant.parse("2021-02-12T17:48:05.029211400Z");
- final PdpStatus status7 = new PdpStatus();
- status7.setName(PDP_NAME);
- status7.setState(PdpState.ACTIVE);
- status7.setPdpGroup(DEFAULT_GROUP);
- status7.setPdpType(APEX_TYPE);
- status7.setHealthy(PdpHealthStatus.HEALTHY);
- status7.setPdpSubgroup(APEX_TYPE);
- final List<ToscaConceptIdentifier> idents7 =
- Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
- status7.setPolicies(idents7);
-
- PdpStatistics pdpStatistics07 = new PdpStatistics();
- pdpStatistics07.setPdpInstanceId(PDP_NAME);
- pdpStatistics07.setPdpGroupName(DEFAULT_GROUP);
- pdpStatistics07.setPdpSubGroupName(APEX_TYPE);
- pdpStatistics07.setTimeStamp(timeStamp);
- status7.setStatistics(pdpStatistics07);
- pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status7);
- verifyPdpStatistics(PDP_NAME, DEFAULT_GROUP, APEX_TYPE, 1);
-
- }
-
+
private void verifyPdpGroup(final String name, final int count) throws PfModelException {
final List<PdpGroup> fetchedGroups = fetchGroups(name);
for (final PdpSubGroup subGroup : fetchedGroups.get(0).getPdpSubgroups()) {
@@ -397,11 +245,4 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
}
}
}
-
- private void verifyPdpStatistics(final String pdpInstanceId, final String pdpGroupName,
- final String pdpSubGroupName, final int count) throws PfModelException {
- final Map<String, Map<String, List<PdpStatistics>>> fetchedPdpStatistics =
- fetchPdpStatistics(pdpInstanceId, pdpGroupName, pdpSubGroupName);
- assertEquals(count, fetchedPdpStatistics.size());
- }
}
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/ProviderSuper.java b/main/src/test/java/org/onap/policy/pap/main/rest/ProviderSuper.java
index 857309c8..60de563e 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/ProviderSuper.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/ProviderSuper.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021-2022 Nordix Foundation.
- * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2022-2023 Bell Canada. 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.
@@ -93,7 +93,6 @@ public class ProviderSuper {
protected Object lockit;
protected PdpModifyRequestMap reqmap;
protected ToscaPolicy policy1;
- protected PapStatisticsManager statsmanager;
protected MeterRegistry meterRegistry;
/**
@@ -110,7 +109,6 @@ public class ProviderSuper {
lockit = new Object();
policy1 = loadPolicy("policy.json");
- statsmanager = mock(PapStatisticsManager.class);
meterRegistry = mock(MeterRegistry.class);
@@ -123,7 +121,6 @@ public class ProviderSuper {
Registry.register(PapConstants.REG_PDP_MODIFY_LOCK, lockit);
Registry.register(PapConstants.REG_PDP_MODIFY_MAP, reqmap);
- Registry.register(PapConstants.REG_STATISTICS_MANAGER, statsmanager);
Registry.register(PapConstants.REG_METER_REGISTRY, meterRegistry);
}
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPapStatisticsManager.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPapStatisticsManager.java
deleted file mode 100644
index 5412ac94..00000000
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPapStatisticsManager.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 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.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.pap.main.rest;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.function.ToLongFunction;
-import org.junit.Test;
-
-public class TestPapStatisticsManager {
-
- @Test
- public void testTotalPdpCount() {
- verifyCount(PapStatisticsManager::getTotalPdpCount,
- PapStatisticsManager::updateTotalPdpCount);
- }
-
- @Test
- public void testTotalPdpGroupCount() {
- verifyCount(PapStatisticsManager::getTotalPdpGroupCount,
- PapStatisticsManager::updateTotalPdpGroupCount);
- }
-
- @Test
- public void testTotalPolicyDeployCount() {
- verifyCount(PapStatisticsManager::getTotalPolicyDeployCount,
- PapStatisticsManager::updateTotalPolicyDeployCount);
- }
-
- @Test
- public void testPolicyDeploySuccessCount() {
- verifyCount(PapStatisticsManager::getPolicyDeploySuccessCount,
- PapStatisticsManager::updatePolicyDeploySuccessCount);
- }
-
- @Test
- public void testPolicyDeployFailureCount() {
- verifyCount(PapStatisticsManager::getPolicyDeployFailureCount,
- PapStatisticsManager::updatePolicyDeployFailureCount);
- }
-
- @Test
- public void testTotalPolicyDownloadCount() {
- verifyCount(PapStatisticsManager::getTotalPolicyDownloadCount,
- PapStatisticsManager::updateTotalPolicyDownloadCount);
- }
-
- @Test
- public void testPolicyDownloadSuccessCount() {
- verifyCount(PapStatisticsManager::getPolicyDownloadSuccessCount,
- PapStatisticsManager::updatePolicyDownloadSuccessCount);
- }
-
- @Test
- public void testPolicyDownloadFailureCount() {
- verifyCount(PapStatisticsManager::getPolicyDownloadFailureCount,
- PapStatisticsManager::updatePolicyDownloadFailureCount);
- }
-
- private void verifyCount(ToLongFunction<PapStatisticsManager> getCount,
- ToLongFunction<PapStatisticsManager> updateCount) {
-
- PapStatisticsManager mgr = new PapStatisticsManager();
-
- assertEquals(0, getCount.applyAsLong(mgr));
- assertEquals(1, updateCount.applyAsLong(mgr));
- assertEquals(1, getCount.applyAsLong(mgr));
-
- assertEquals(2, updateCount.applyAsLong(mgr));
- assertEquals(2, getCount.applyAsLong(mgr));
-
- // now check reset
- mgr.resetAllStatistics();
-
- assertEquals(0, getCount.applyAsLong(mgr));
- }
-}
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployProvider.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployProvider.java
index 29c06f76..b828509b 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployProvider.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployProvider.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
- * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021-2023 Bell Canada. 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.
@@ -54,12 +54,10 @@ import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.pap.main.PapConstants;
public class TestPdpGroupDeployProvider extends ProviderSuper {
private static final String EXPECTED_EXCEPTION = "expected exception";
-
private static final String POLICY2_NAME = "policyB";
private static final String POLICY3_NAME = "policyC";
private static final String POLICY1_VERSION = "1.2.3";
@@ -568,25 +566,6 @@ public class TestPdpGroupDeployProvider extends ProviderSuper {
.hasMessage("policy not supported by any PDP group: policyA 1.2.3");
}
- /**
- * Tests PapStatisticsManager counts when policies are added to a subgroup.
- *
- * @throws Exception if an error occurs
- */
- @Test
- public void testDeployedPdpGroupCountStatistics() throws Exception {
- Registry.unregister(PapConstants.REG_STATISTICS_MANAGER);
- PapStatisticsManager mgr = new PapStatisticsManager();
- Registry.register(PapConstants.REG_STATISTICS_MANAGER, mgr);
-
- when(pdpGroupService.getFilteredPdpGroups(any())).thenReturn(loadGroups("deployPoliciesWildCard.json"));
- prov.deployPolicies(loadRequest("multiple_requests.json"), DEFAULT_USER);
- assertEquals(3, mgr.getTotalPolicyDeployCount());
-
- Registry.unregister(PapConstants.REG_STATISTICS_MANAGER);
- Registry.register(PapConstants.REG_STATISTICS_MANAGER, statsmanager);
- }
-
@Test
public void testMakeUpdater() throws Exception {
/*
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestStatisticsReport.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestStatisticsReport.java
deleted file mode 100644
index 60b95aab..00000000
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestStatisticsReport.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 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
- *
- * 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=========================================================
- */
-
-package org.onap.policy.pap.main.rest;
-
-import com.openpojo.reflection.filters.FilterClassName;
-import com.openpojo.validation.Validator;
-import com.openpojo.validation.ValidatorBuilder;
-import com.openpojo.validation.rule.impl.GetterMustExistRule;
-import com.openpojo.validation.rule.impl.SetterMustExistRule;
-import com.openpojo.validation.test.impl.GetterTester;
-import com.openpojo.validation.test.impl.SetterTester;
-import org.junit.Test;
-import org.onap.policy.common.utils.test.ToStringTester;
-
-/**
- * Class to perform unit testing of {@link StatisticsReport}.
- *
- * @author Ram Krishna Verma (ram.krishna.verma@est.tech)
- */
-public class TestStatisticsReport {
-
- @Test
- public void testStatisticsReport() {
- final Validator validator = ValidatorBuilder.create().with(new ToStringTester()).with(new SetterMustExistRule())
- .with(new GetterMustExistRule()).with(new SetterTester()).with(new GetterTester()).build();
- validator.validate(StatisticsReport.class.getPackage().getName(),
- new FilterClassName(StatisticsReport.class.getName()));
- }
-}
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestStatisticsRestControllerV1.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestStatisticsRestControllerV1.java
deleted file mode 100644
index 423c1d33..00000000
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestStatisticsRestControllerV1.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020, 2022 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property.
- * ================================================================================
- * 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.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.pap.main.rest;
-
-import static org.junit.Assert.assertEquals;
-
-import javax.ws.rs.client.Invocation;
-import org.junit.Test;
-import org.onap.policy.common.utils.services.Registry;
-import org.onap.policy.pap.main.PapConstants;
-import org.springframework.test.context.ActiveProfiles;
-
-/**
- * Class to perform unit test of {@link StatisticsRestControllerV1}.
- *
- * @author Ram Krishna Verma (ram.krishna.verma@est.tech)
- */
-@ActiveProfiles({ "test", "default" })
-public class TestStatisticsRestControllerV1 extends CommonPapRestServer {
-
- private static final String STATISTICS_ENDPOINT = "statistics";
- private static final String STATISTICS_DB_ENDPOINT = "pdps/statistics";
-
- @Test
- public void testSwagger() throws Exception {
- super.testSwagger(STATISTICS_ENDPOINT);
- super.testSwagger(STATISTICS_DB_ENDPOINT);
- super.testSwagger(STATISTICS_DB_ENDPOINT + "/{group}");
- super.testSwagger(STATISTICS_DB_ENDPOINT + "/{group}" + "/{type}");
- super.testSwagger(STATISTICS_DB_ENDPOINT + "/{group}" + "/{type}" + "/{pdp}");
- }
-
- @Test
- public void testPapStatistics_200() throws Exception {
- Invocation.Builder invocationBuilder = sendRequest(STATISTICS_ENDPOINT);
- StatisticsReport report = invocationBuilder.get(StatisticsReport.class);
- validateStatisticsReport(report, 0, 200);
- updateDistributionStatistics();
-
- invocationBuilder = sendRequest(STATISTICS_ENDPOINT);
- report = invocationBuilder.get(StatisticsReport.class);
- validateStatisticsReport(report, 1, 200);
-
- // verify it fails when no authorization info is included
- checkUnauthRequest(STATISTICS_ENDPOINT, req -> req.get());
- }
-
- @Test
- public void testPapStatistics_500() throws Exception {
-
- markActivatorDead();
-
- Registry.get(PapConstants.REG_STATISTICS_MANAGER, PapStatisticsManager.class).resetAllStatistics();
-
- Invocation.Builder invocationBuilder = sendRequest(STATISTICS_ENDPOINT);
- StatisticsReport report = invocationBuilder.get(StatisticsReport.class);
- validateStatisticsReport(report, 0, 500);
- }
-
- private void updateDistributionStatistics() {
- PapStatisticsManager mgr = Registry.get(PapConstants.REG_STATISTICS_MANAGER, PapStatisticsManager.class);
-
- mgr.updateTotalPdpCount();
- mgr.updateTotalPdpGroupCount();
- mgr.updateTotalPolicyDeployCount();
- mgr.updatePolicyDeploySuccessCount();
- mgr.updatePolicyDeployFailureCount();
- mgr.updateTotalPolicyDownloadCount();
- mgr.updatePolicyDownloadSuccessCount();
- mgr.updatePolicyDownloadFailureCount();
- }
-
- private void validateStatisticsReport(final StatisticsReport report, final int count, final int code) {
- assertEquals(code, report.getCode());
- assertEquals(count, report.getTotalPdpCount());
- assertEquals(count, report.getTotalPdpGroupCount());
- assertEquals(count, report.getTotalPolicyDeployCount());
- assertEquals(count, report.getPolicyDeploySuccessCount());
- assertEquals(count, report.getPolicyDeployFailureCount());
- assertEquals(count, report.getTotalPolicyDownloadCount());
- assertEquals(count, report.getPolicyDeploySuccessCount());
- assertEquals(count, report.getPolicyDeployFailureCount());
- }
-}
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndBase.java b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndBase.java
index fd74caa2..2b339f82 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndBase.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndBase.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019-2020, 2022 Nordix Foundation.
- * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021-2023 Bell Canada. 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.
@@ -28,7 +28,6 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
-import java.util.Map;
import java.util.Optional;
import lombok.Getter;
import org.junit.After;
@@ -43,14 +42,12 @@ import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpGroups;
import org.onap.policy.models.pdp.concepts.PdpPolicyStatus;
import org.onap.policy.models.pdp.concepts.PdpPolicyStatus.State;
-import org.onap.policy.models.pdp.concepts.PdpStatistics;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
import org.onap.policy.pap.main.PolicyPapRuntimeException;
import org.onap.policy.pap.main.repository.ToscaServiceTemplateRepository;
import org.onap.policy.pap.main.rest.CommonPapRestServer;
import org.onap.policy.pap.main.service.PdpGroupService;
-import org.onap.policy.pap.main.service.PdpStatisticsService;
import org.onap.policy.pap.main.service.PolicyStatusService;
import org.onap.policy.pap.main.service.ToscaServiceTemplateService;
import org.slf4j.Logger;
@@ -75,9 +72,6 @@ public abstract class End2EndBase extends CommonPapRestServer {
public PdpGroupService pdpGroupService;
@Autowired
- public PdpStatisticsService pdpStatisticsService;
-
- @Autowired
private ToscaServiceTemplateRepository serviceTemplateRepository;
@Autowired
@@ -187,18 +181,6 @@ public abstract class End2EndBase extends CommonPapRestServer {
}
/**
- * Fetch PDP statistics from the DB.
- *
- * @param instanceId name of the pdpStatistics
- * @param groupName name of the pdpGroup
- * @param subGroupName name of the pdpSubGroup
- */
- public Map<String, Map<String, List<PdpStatistics>>> fetchPdpStatistics(final String instanceId,
- final String groupName, final String subGroupName) {
- return pdpStatisticsService.fetchDatabaseStatistics(groupName, subGroupName, instanceId, 100, null, null);
- }
-
- /**
* Adds PdpPolicyStatus records to the DB.
*
* @param jsonFile name of the JSON file specifying the data to be loaded
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/StatisticsTest.java b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/StatisticsTest.java
deleted file mode 100644
index 876ea0fb..00000000
--- a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/StatisticsTest.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP PAP
- * ================================================================================
- * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020-2021 Nordix Foundation.
- * Modifications Copyright (C) 2021-2022 Bell Canada. 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.policy.pap.main.rest.e2e;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-
-import java.net.HttpURLConnection;
-import java.time.Instant;
-import java.util.List;
-import java.util.Map;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.core.GenericType;
-import javax.ws.rs.core.Response;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.policy.common.utils.services.Registry;
-import org.onap.policy.models.pdp.concepts.PdpStatistics;
-import org.onap.policy.pap.main.PapConstants;
-import org.onap.policy.pap.main.rest.PapStatisticsManager;
-import org.onap.policy.pap.main.rest.StatisticsReport;
-
-public class StatisticsTest extends End2EndBase {
- private static final String STATISTICS_ENDPOINT = "statistics";
- private static final String END_TIME_NAME = "endTime";
- private static final String START_TIME_NAME = "startTime";
- private static final long TIMESTAMP_SEC = 1562494272;
-
- private static PdpStatistics pdpStatisticsRecord;
-
- /**
- * Adds a record to the DB.
- */
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- End2EndBase.setUpBeforeClass();
-
- pdpStatisticsRecord = new PdpStatistics();
- pdpStatisticsRecord.setPdpGroupName("defaultGroup");
- pdpStatisticsRecord.setPdpSubGroupName("apex");
- pdpStatisticsRecord.setPdpInstanceId("pdp1");
- pdpStatisticsRecord.setTimeStamp(Instant.ofEpochSecond(TIMESTAMP_SEC));
- pdpStatisticsRecord.setPolicyDeployCount(1);
- pdpStatisticsRecord.setPolicyDeployFailCount(0);
- pdpStatisticsRecord.setPolicyDeploySuccessCount(1);
- pdpStatisticsRecord.setPolicyExecutedCount(1);
- pdpStatisticsRecord.setPolicyExecutedFailCount(0);
- pdpStatisticsRecord.setPolicyExecutedSuccessCount(1);
- }
-
- @Override
- @Before
- public void setUp() throws Exception {
- super.setUp();
- pdpStatisticsService.createPdpStatistics(List.of(pdpStatisticsRecord));
- }
-
- @Test
- public void test() throws Exception {
- Invocation.Builder invocationBuilder = sendRequest(STATISTICS_ENDPOINT);
- StatisticsReport report = invocationBuilder.get(StatisticsReport.class);
- assertEquals(HttpURLConnection.HTTP_OK, report.getCode());
-
- updateDistributionStatistics();
-
- invocationBuilder = sendRequest(STATISTICS_ENDPOINT);
- StatisticsReport report2 = invocationBuilder.get(StatisticsReport.class);
-
- assertEquals(HttpURLConnection.HTTP_OK, report.getCode());
- assertEquals(report.getTotalPdpCount() + 1, report2.getTotalPdpCount());
- assertEquals(report.getTotalPdpGroupCount() + 1, report2.getTotalPdpGroupCount());
- assertEquals(report.getTotalPolicyDeployCount() + 1, report2.getTotalPolicyDeployCount());
- assertEquals(report.getPolicyDeploySuccessCount() + 1, report2.getPolicyDeploySuccessCount());
- assertEquals(report.getPolicyDeployFailureCount() + 1, report2.getPolicyDeployFailureCount());
- assertEquals(report.getTotalPolicyDownloadCount() + 1, report2.getTotalPolicyDownloadCount());
- assertEquals(report.getPolicyDeploySuccessCount() + 1, report2.getPolicyDeploySuccessCount());
- assertEquals(report.getPolicyDeployFailureCount() + 1, report2.getPolicyDeployFailureCount());
- }
-
- @Test
- public void testDb() throws Exception {
- verifyResponse("pdps/statistics");
- }
-
- @Test
- public void testDbWithGroup() throws Exception {
- verifyResponse("pdps/statistics/defaultGroup");
-
- }
-
- @Test
- public void testDbWithSubGroup() throws Exception {
- verifyResponse("pdps/statistics/defaultGroup/apex");
- }
-
- @Test
- public void testDbWithPdp() throws Exception {
- verifyResponse("pdps/statistics/defaultGroup/apex/pdp1");
- }
-
- @Test
- public void testDbWithPdpLatest() throws Exception {
- verifyResponse("pdps/statistics/defaultGroup/apex/pdp1?recordCount=5");
- }
-
- private void updateDistributionStatistics() {
- PapStatisticsManager mgr = Registry.get(PapConstants.REG_STATISTICS_MANAGER, PapStatisticsManager.class);
-
- mgr.updateTotalPdpCount();
- mgr.updateTotalPdpGroupCount();
- mgr.updateTotalPolicyDeployCount();
- mgr.updatePolicyDeploySuccessCount();
- mgr.updatePolicyDeployFailureCount();
- mgr.updateTotalPolicyDownloadCount();
- mgr.updatePolicyDownloadSuccessCount();
- mgr.updatePolicyDownloadFailureCount();
- }
-
- private void verifyResponse(String endpoint) throws Exception {
- Invocation.Builder invocationBuilder = sendRequest(endpoint);
- verifyResponse(invocationBuilder.get());
-
- // repeat with "start", in range
- invocationBuilder = sendRequest(addTimeParam(endpoint, START_TIME_NAME, TIMESTAMP_SEC));
- verifyResponse(invocationBuilder.get());
-
- // repeat with "end", in range
- invocationBuilder = sendRequest(addTimeParam(endpoint, END_TIME_NAME, TIMESTAMP_SEC));
- verifyResponse(invocationBuilder.get());
-
- // repeat with "start" and "end", in range
- invocationBuilder = sendRequest(addTimeParam(endpoint, START_TIME_NAME, TIMESTAMP_SEC - 1)
- + "&" + END_TIME_NAME + "=" + TIMESTAMP_SEC + 1);
- verifyResponse(invocationBuilder.get());
-
- // repeat with "start", out of range
- invocationBuilder = sendRequest(addTimeParam(endpoint, START_TIME_NAME, TIMESTAMP_SEC + 1));
- verifyEmptyResponse(invocationBuilder.get());
-
- // repeat with "end", out of range
- invocationBuilder = sendRequest(addTimeParam(endpoint, END_TIME_NAME, TIMESTAMP_SEC - 1));
- verifyEmptyResponse(invocationBuilder.get());
- }
-
- private void verifyResponse(Response testResponse) {
- assertEquals(Response.Status.OK.getStatusCode(), testResponse.getStatus());
- Map<String, Map<String, List<PdpStatistics>>> map =
- testResponse.readEntity(new GenericType<Map<String, Map<String, List<PdpStatistics>>>>() {});
- Map<String, List<PdpStatistics>> subMap = map.get("defaultGroup");
- List<PdpStatistics> resRecord = subMap.get("apex");
- assertEquals("pdp1", resRecord.get(0).getPdpInstanceId());
- assertEquals("apex", resRecord.get(0).getPdpSubGroupName());
- assertEquals("defaultGroup", resRecord.get(0).getPdpGroupName());
- }
-
- private void verifyEmptyResponse(Response testResponse) {
- assertEquals(Response.Status.OK.getStatusCode(), testResponse.getStatus());
- Map<String, Map<String, List<PdpStatistics>>> map =
- testResponse.readEntity(new GenericType<Map<String, Map<String, List<PdpStatistics>>>>() {});
- assertThat(map).isEmpty();
- }
-
- /**
- * Adds a timestamp parameter to an endpoint string.
- * @param endpoint endpoint to which it should be added
- * @param paramName parameter name
- * @param timeSec time, in seconds
- * @return the new endpoint, with the added parameter
- */
- private String addTimeParam(String endpoint, String paramName, long timeSec) {
- StringBuilder builder = new StringBuilder(endpoint);
- builder.append(endpoint.contains("?") ? '&' : '?');
- builder.append(paramName);
- builder.append('=');
- builder.append(timeSec);
- return builder.toString();
- }
-}
diff --git a/main/src/test/java/org/onap/policy/pap/main/service/PdpStatisticsServiceTest.java b/main/src/test/java/org/onap/policy/pap/main/service/PdpStatisticsServiceTest.java
deleted file mode 100644
index 1d429ee8..00000000
--- a/main/src/test/java/org/onap/policy/pap/main/service/PdpStatisticsServiceTest.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2022 Bell Canada. All rights reserved.
- * Modifications Copyright (C) 2022 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
- *
- * 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=========================================================
- */
-
-package org.onap.policy.pap.main.service;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-import java.time.Instant;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.models.pdp.concepts.PdpStatistics;
-import org.onap.policy.pap.main.repository.PdpStatisticsRepository;
-import org.onap.policy.pap.main.rest.CommonPapRestServer;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ActiveProfiles;
-
-@ActiveProfiles("test")
-public class PdpStatisticsServiceTest extends CommonPapRestServer {
-
- private static final String NAME3 = "name3";
- private static final String NAME1 = "name1";
- private static final String LIST_IS_NULL = "pdpStatisticsList is marked .*ull but is null";
- private static final String GROUP0 = "group0";
- private static final String GROUP = "group";
- private static final String SUBGROUP = "subgroup";
- private static final Instant TIMESTAMP1 = Instant.ofEpochSecond(1078884319);
- private static final Instant TIMESTAMP2 = Instant.ofEpochSecond(1078884350);
- private static final Integer NUMBER_RECORDS = 10;
-
- @Autowired
- private PdpStatisticsService pdpStatisticsService;
-
- @Autowired
- private PdpStatisticsRepository pdpStatisticsRepository;
-
- private PdpStatistics pdpStatistics1;
- private PdpStatistics pdpStatistics2;
- private PdpStatistics pdpStatistics3;
- private PdpStatistics pdpStatistics4;
-
- /**
- * Setup before tests.
- *
- * @throws Exception the exception
- */
- @Override
- @Before
- public void setUp() throws Exception {
- super.setUp();
- pdpStatistics1 = generatePdpStatistics(NAME1, TIMESTAMP1, GROUP);
- pdpStatistics2 = generatePdpStatistics("name2", TIMESTAMP1, GROUP);
- pdpStatistics3 = generatePdpStatistics(NAME1, TIMESTAMP2, GROUP);
- pdpStatistics4 = generatePdpStatistics(NAME3, TIMESTAMP2, GROUP0);
- }
-
- /**
- * Teardown after tests.
- */
- @Override
- @After
- public void tearDown() {
- pdpStatisticsRepository.deleteAll();
- }
-
- @Test
- public void testCreatePdpStatisticsSuccess() {
- List<PdpStatistics> createList = List.of(pdpStatistics1, pdpStatistics3, pdpStatistics4, pdpStatistics2);
- List<PdpStatistics> createdPdpStatisticsList = pdpStatisticsService.createPdpStatistics(createList);
- // these should match AND be in the same order
- assertThat(createdPdpStatisticsList).isEqualTo(createList);
- }
-
- @Test
- public void testCreatePdpStatisticsFailure() {
-
- assertThatThrownBy(() -> pdpStatisticsService.createPdpStatistics(null)).hasMessageMatching(LIST_IS_NULL);
-
- PdpStatistics pdpStatisticsErr = new PdpStatistics();
- pdpStatisticsErr.setPdpInstanceId("NULL");
- pdpStatisticsErr.setPdpGroupName(GROUP);
- assertThatThrownBy(() -> pdpStatisticsService.createPdpStatistics(List.of(pdpStatisticsErr)))
- .hasMessageContaining("item \"name\" value \"NULL\" INVALID, is null");
- }
-
- @Test
- public void testFetchDatabaseStatistics() {
- List<PdpStatistics> createList = List.of(pdpStatistics1, pdpStatistics3, pdpStatistics4, pdpStatistics2);
- pdpStatisticsService.createPdpStatistics(createList);
-
- Map<String, Map<String, List<PdpStatistics>>> statistics;
-
- statistics = pdpStatisticsService.fetchDatabaseStatistics(NUMBER_RECORDS, null, null);
- assertGroupAndSubgroupSize(statistics, 2, GROUP0, 1);
- assertGroupAndSubgroupSize(statistics, 2, GROUP, 3);
-
- statistics = pdpStatisticsService.fetchDatabaseStatistics(NUMBER_RECORDS, TIMESTAMP2, TIMESTAMP2);
- assertGroupAndSubgroupSize(statistics, 2, GROUP0, 1);
- assertThat(statistics.get(GROUP0)).containsEntry(SUBGROUP, List.of(pdpStatistics4));
- assertGroupAndSubgroupSize(statistics, 2, GROUP, 1);
- assertThat(statistics.get(GROUP)).containsEntry(SUBGROUP, List.of(pdpStatistics3));
-
- statistics = pdpStatisticsService.fetchDatabaseStatistics(NUMBER_RECORDS, null, TIMESTAMP1);
- assertGroupAndSubgroupSize(statistics, 1, GROUP, 2);
-
- statistics = pdpStatisticsService.fetchDatabaseStatistics(NUMBER_RECORDS, TIMESTAMP2, null);
- assertThat(statistics).hasSize(2);
-
- statistics = pdpStatisticsService.fetchDatabaseStatistics(GROUP0, NUMBER_RECORDS, TIMESTAMP2, TIMESTAMP2);
- assertThat(statistics).hasSize(1);
- assertThat(statistics.get(GROUP0)).hasSize(1);
- assertThat(statistics.get(GROUP0)).containsEntry(SUBGROUP, List.of(pdpStatistics4));
-
- statistics = pdpStatisticsService.fetchDatabaseStatistics(GROUP, NUMBER_RECORDS, null, TIMESTAMP1);
- assertGroupAndSubgroupSize(statistics, 1, GROUP, 2);
-
- statistics = pdpStatisticsService.fetchDatabaseStatistics(GROUP, NUMBER_RECORDS, TIMESTAMP2, null);
- assertThat(statistics).hasSize(1);
-
- statistics = pdpStatisticsService.fetchDatabaseStatistics(GROUP, SUBGROUP, NUMBER_RECORDS, TIMESTAMP1,
- TIMESTAMP2);
- assertGroupAndSubgroupSize(statistics, 1, GROUP, 3);
-
- statistics = pdpStatisticsService.fetchDatabaseStatistics(GROUP, SUBGROUP, NUMBER_RECORDS, null, TIMESTAMP1);
- assertGroupAndSubgroupSize(statistics, 1, GROUP, 2);
-
- statistics = pdpStatisticsService.fetchDatabaseStatistics(GROUP, SUBGROUP, NUMBER_RECORDS, TIMESTAMP2, null);
- assertThat(statistics).hasSize(1);
- assertThat(statistics.get(GROUP)).containsEntry(SUBGROUP, List.of(pdpStatistics3));
-
- statistics = pdpStatisticsService.fetchDatabaseStatistics(GROUP, SUBGROUP, NAME1, NUMBER_RECORDS, TIMESTAMP1,
- TIMESTAMP2);
- assertGroupAndSubgroupSize(statistics, 1, GROUP, 2);
-
- statistics =
- pdpStatisticsService.fetchDatabaseStatistics(GROUP, SUBGROUP, NAME1, NUMBER_RECORDS, null, TIMESTAMP1);
- assertGroupAndSubgroupSize(statistics, 1, GROUP, 1);
-
- statistics =
- pdpStatisticsService.fetchDatabaseStatistics(GROUP0, SUBGROUP, NAME3, NUMBER_RECORDS, TIMESTAMP2, null);
- assertThat(statistics).hasSize(1);
- assertThat(statistics.get(GROUP0)).containsEntry(SUBGROUP, List.of(pdpStatistics4));
- }
-
- /**
- * Asserts if statistics list is the expected size and the subgroup list is also the expected size.
- */
- private void assertGroupAndSubgroupSize(Map<String, Map<String, List<PdpStatistics>>> statistics, int listSize,
- String group, int subGroupSize) {
- assertThat(statistics).hasSize(listSize);
- assertThat(statistics.get(group)).hasSize(1);
- assertThat(statistics.get(group).get(SUBGROUP)).hasSize(subGroupSize);
- }
-
- private PdpStatistics generatePdpStatistics(String pdpInstanceId, Instant date, String group) {
- PdpStatistics pdpStatistics11 = new PdpStatistics();
- pdpStatistics11.setPdpInstanceId(pdpInstanceId);
- pdpStatistics11.setTimeStamp(date);
- pdpStatistics11.setPdpGroupName(group);
- pdpStatistics11.setPdpSubGroupName(PdpStatisticsServiceTest.SUBGROUP);
- pdpStatistics11.setPolicyDeployCount(2);
- pdpStatistics11.setPolicyDeployFailCount(1);
- pdpStatistics11.setPolicyDeploySuccessCount(1);
- pdpStatistics11.setPolicyExecutedCount(2);
- pdpStatistics11.setPolicyExecutedFailCount(1);
- pdpStatistics11.setPolicyExecutedSuccessCount(1);
- pdpStatistics11.setEngineStats(new ArrayList<>());
-
- return pdpStatistics11;
- }
-}
diff --git a/main/src/test/java/org/onap/policy/pap/main/startstop/TestPapActivator.java b/main/src/test/java/org/onap/policy/pap/main/startstop/TestPapActivator.java
index 67921381..04ef2b66 100644
--- a/main/src/test/java/org/onap/policy/pap/main/startstop/TestPapActivator.java
+++ b/main/src/test/java/org/onap/policy/pap/main/startstop/TestPapActivator.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019, 2022 Nordix Foundation.
* Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property.
- * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021-2023 Bell Canada. 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.
@@ -48,7 +48,6 @@ import org.onap.policy.pap.main.comm.PdpModifyRequestMap;
import org.onap.policy.pap.main.notification.PolicyNotifier;
import org.onap.policy.pap.main.parameters.CommonTestData;
import org.onap.policy.pap.main.parameters.PapParameterGroup;
-import org.onap.policy.pap.main.rest.PapStatisticsManager;
/**
@@ -125,7 +124,6 @@ public class TestPapActivator {
// ensure items were added to the registry
assertNotNull(Registry.get(PapConstants.REG_PDP_MODIFY_LOCK, Object.class));
- assertNotNull(Registry.get(PapConstants.REG_STATISTICS_MANAGER, PapStatisticsManager.class));
assertNotNull(Registry.get(PapConstants.REG_PDP_MODIFY_MAP, PdpModifyRequestMap.class));
// repeat - should throw an exception
@@ -142,7 +140,6 @@ public class TestPapActivator {
// ensure items have been removed from the registry
assertNull(Registry.getOrDefault(PapConstants.REG_PDP_MODIFY_LOCK, Object.class, null));
- assertNull(Registry.getOrDefault(PapConstants.REG_STATISTICS_MANAGER, PapStatisticsManager.class, null));
assertNull(Registry.getOrDefault(PapConstants.REG_PDP_MODIFY_MAP, PdpModifyRequestMap.class, null));
// repeat - should throw an exception
diff --git a/main/src/test/resources/application-test-e2e.yaml b/main/src/test/resources/application-test-e2e.yaml
index 96ed124d..435eb569 100644
--- a/main/src/test/resources/application-test-e2e.yaml
+++ b/main/src/test/resources/application-test-e2e.yaml
@@ -41,7 +41,6 @@ pap:
maxWaitMs: 3000
heartBeatMs: 6000
maxMessageAgeMs: 20000
- savePdpStatisticsInDb: true
topicParameterGroup:
topicSources:
- topic: ${pap.topic.pdp-pap.name}
diff --git a/main/src/test/resources/application-test.yaml b/main/src/test/resources/application-test.yaml
index 7a2e9fc9..96ba60df 100644
--- a/main/src/test/resources/application-test.yaml
+++ b/main/src/test/resources/application-test.yaml
@@ -41,7 +41,6 @@ pap:
maxWaitMs: 3000
heartBeatMs: 6000
maxMessageAgeMs: 20000
- savePdpStatisticsInDb: true
topicParameterGroup:
topicSources:
- topic: ${pap.topic.pdp-pap.name}
diff --git a/main/src/test/resources/parameters/MinimumParameters.json b/main/src/test/resources/parameters/MinimumParameters.json
index 3c439d1f..80125305 100644
--- a/main/src/test/resources/parameters/MinimumParameters.json
+++ b/main/src/test/resources/parameters/MinimumParameters.json
@@ -26,7 +26,6 @@
"databasePassword": "P01icY",
"persistenceUnit": "PdpGroupTest"
},
- "savePdpStatisticsInDb": true,
"topicParameterGroup": {
"topicSources" : [{
"topic" : "POLICY-PDP-PAP",
diff --git a/main/src/test/resources/parameters/PapConfigParameters.json b/main/src/test/resources/parameters/PapConfigParameters.json
index bb1a7588..debdc47c 100644
--- a/main/src/test/resources/parameters/PapConfigParameters.json
+++ b/main/src/test/resources/parameters/PapConfigParameters.json
@@ -27,7 +27,6 @@
"databasePassword": "UDAxaWNZ",
"persistenceUnit": "ToscaConceptTest"
},
- "savePdpStatisticsInDb": true,
"topicParameterGroup": {
"topicSources" : [{
"topic" : "POLICY-PDP-PAP",
diff --git a/main/src/test/resources/parameters/PapConfigParametersStd.json b/main/src/test/resources/parameters/PapConfigParametersStd.json
index 9ba3f124..1b5b0eff 100644
--- a/main/src/test/resources/parameters/PapConfigParametersStd.json
+++ b/main/src/test/resources/parameters/PapConfigParametersStd.json
@@ -28,7 +28,6 @@
"databasePassword": "UDAxaWNZ",
"persistenceUnit": "ToscaConceptTest"
},
- "savePdpStatisticsInDb": true,
"topicParameterGroup": {
"topicSources" : [{
"topic" : "POLICY-PDP-PAP",
diff --git a/packages/policy-pap-tarball/src/main/resources/etc/papParameters.yaml b/packages/policy-pap-tarball/src/main/resources/etc/papParameters.yaml
index 06dd45f4..a1ed00e1 100644
--- a/packages/policy-pap-tarball/src/main/resources/etc/papParameters.yaml
+++ b/packages/policy-pap-tarball/src/main/resources/etc/papParameters.yaml
@@ -37,7 +37,6 @@ pap:
stateChangeParameters:
maxRetryCount: 1
maxWaitMs: 30000
- savePdpStatisticsInDb: false
topicParameterGroup:
topicSources:
- topic: POLICY-PDP-PAP
diff --git a/postman/pap-api-collection.json b/postman/pap-api-collection.json
index 483468c4..cdc38f56 100644
--- a/postman/pap-api-collection.json
+++ b/postman/pap-api-collection.json
@@ -2,7 +2,7 @@
"info": {
"_postman_id": "cf7db76a-e5a7-4c92-a3b7-7b97ffd006bf",
"name": "Policy Framework Administration API",
- "description": "This collection lists all the Administration API's supported by ONAP Policy Framework. These API's are used to perform administrative operations for managing policies, groups, statistics & health information for all registered PDP engines.",
+ "description": "This collection lists all the Administration API's supported by ONAP Policy Framework. These API's are used to perform administrative operations for managing policies, groups & health information for all registered PDP engines.",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
@@ -554,236 +554,6 @@
"response": []
},
{
- "name": "Fetch All PDPs Statistics",
- "protocolProfileBehavior": {
- "disableBodyPruning": true
- },
- "request": {
- "method": "GET",
- "header": [
- {
- "key": "Content-Type",
- "value": "application/json",
- "type": "text"
- },
- {
- "key": "Accept",
- "value": "application/json",
- "type": "text"
- }
- ],
- "body": {
- "mode": "raw",
- "raw": ""
- },
- "url": {
- "raw": "{{POLICY-PAP-URL}}/policy/pap/v1/pdps/statistics?recordCount=5",
- "host": [
- "{{POLICY-PAP-URL}}"
- ],
- "path": [
- "policy",
- "pap",
- "v1",
- "pdps",
- "statistics"
- ],
- "query": [
- {
- "key": "recordCount",
- "value": "5"
- },
- {
- "key": "startTime",
- "value": "1627219515",
- "disabled": true
- },
- {
- "key": "endTime",
- "value": "1627478715",
- "disabled": true
- }
- ]
- },
- "description": "This is an API to fetch current statistics information for the all registered PDP instances."
- },
- "response": []
- },
- {
- "name": "Fetch PdpGroup Statistics",
- "protocolProfileBehavior": {
- "disableBodyPruning": true
- },
- "request": {
- "method": "GET",
- "header": [
- {
- "key": "Content-Type",
- "type": "text",
- "value": "application/json"
- },
- {
- "key": "Accept",
- "type": "text",
- "value": "application/json"
- }
- ],
- "body": {
- "mode": "raw",
- "raw": ""
- },
- "url": {
- "raw": "{{POLICY-PAP-URL}}/policy/pap/v1/pdps/statistics/defaultGroup?recordCount=5",
- "host": [
- "{{POLICY-PAP-URL}}"
- ],
- "path": [
- "policy",
- "pap",
- "v1",
- "pdps",
- "statistics",
- "defaultGroup"
- ],
- "query": [
- {
- "key": "recordCount",
- "value": "5"
- },
- {
- "key": "startTime",
- "value": "1627219515",
- "disabled": true
- },
- {
- "key": "endTime",
- "value": "1627478715",
- "disabled": true
- }
- ]
- },
- "description": "This is an API to fetch current statistics information for the all registered PDP instances of the specified PdpGroup (example - \"defaultGroup\")."
- },
- "response": []
- },
- {
- "name": "Fetch PdpSubGroup Statistics",
- "protocolProfileBehavior": {
- "disableBodyPruning": true
- },
- "request": {
- "method": "GET",
- "header": [
- {
- "key": "Content-Type",
- "type": "text",
- "value": "application/json"
- },
- {
- "key": "Accept",
- "type": "text",
- "value": "application/json"
- }
- ],
- "body": {
- "mode": "raw",
- "raw": ""
- },
- "url": {
- "raw": "{{POLICY-PAP-URL}}/policy/pap/v1/pdps/statistics/defaultGroup/apex?recordCount=5",
- "host": [
- "{{POLICY-PAP-URL}}"
- ],
- "path": [
- "policy",
- "pap",
- "v1",
- "pdps",
- "statistics",
- "defaultGroup",
- "apex"
- ],
- "query": [
- {
- "key": "recordCount",
- "value": "5"
- },
- {
- "key": "startTime",
- "value": "1627219515",
- "disabled": true
- },
- {
- "key": "endTime",
- "value": "1627478715",
- "disabled": true
- }
- ]
- },
- "description": "This is an API to fetch current statistics information for the all registered PDP instances of the specified PdpGroup (example - \"defaultGroup\") & PdpSubgroup (example - \"apex\")."
- },
- "response": []
- },
- {
- "name": "Fetch PDP Statistics",
- "protocolProfileBehavior": {
- "disableBodyPruning": true
- },
- "request": {
- "method": "GET",
- "header": [
- {
- "key": "Content-Type",
- "type": "text",
- "value": "application/json"
- },
- {
- "key": "Accept",
- "type": "text",
- "value": "application/json"
- }
- ],
- "body": {
- "mode": "raw",
- "raw": ""
- },
- "url": {
- "raw": "{{POLICY-PAP-URL}}/policy/pap/v1/pdps/statistics/defaultGroup/apex/dev-policy-apex-pdp-0?recordCount=5",
- "host": [
- "{{POLICY-PAP-URL}}"
- ],
- "path": [
- "policy",
- "pap",
- "v1",
- "pdps",
- "statistics",
- "defaultGroup",
- "apex",
- "dev-policy-apex-pdp-0"
- ],
- "query": [
- {
- "key": "recordCount",
- "value": "5"
- },
- {
- "key": "startTime",
- "value": "1627219515",
- "disabled": true
- },
- {
- "key": "endTime",
- "value": "1627478715",
- "disabled": true
- }
- ]
- },
- "description": "This is an API to fetch current statistics information for the specified PDP instance (example - \"dev-policy-apex-pdp-0\") of the specified PdpGroup (example - \"defaultGroup\") & PdpSubgroup (example - \"apex\")."
- },
- "response": []
- },
- {
"name": "Fetch All Policy Audit Records",
"event": [
{