aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/main/java/org/onap/policy/pap/main/rest
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/main/java/org/onap/policy/pap/main/rest')
-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
6 files changed, 1 insertions, 457 deletions
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);
- }
-
}