Set all cross references of policy/pap
[policy/pap.git] / main / src / main / java / org / onap / policy / pap / main / rest / PapStatisticsManager.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2019 Nordix Foundation.
4  *  Modifications Copyright (C) 2019 AT&T Intellectual Property.
5  * ================================================================================
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * SPDX-License-Identifier: Apache-2.0
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.pap.main.rest;
23
24 import java.util.concurrent.atomic.AtomicLong;
25
26 /**
27  * Class to hold statistical data for pap component.
28  *
29  * @author Ram Krishna Verma (ram.krishna.verma@est.tech)
30  */
31 public class PapStatisticsManager {
32
33     private final AtomicLong totalPdpCount = new AtomicLong(0);
34     private final AtomicLong totalPdpGroupCount = new AtomicLong(0);
35     private final AtomicLong totalPolicyDeployCount = new AtomicLong(0);
36     private final AtomicLong policyDeploySuccessCount = new AtomicLong(0);
37     private final AtomicLong policyDeployFailureCount = new AtomicLong(0);
38     private final AtomicLong totalPolicyDownloadCount = new AtomicLong(0);
39     private final AtomicLong policyDownloadSuccessCount = new AtomicLong(0);
40     private final AtomicLong policyDownloadFailureCount = new AtomicLong(0);
41
42     /**
43      * Constructs the object.
44      */
45     public PapStatisticsManager() {
46         super();
47     }
48
49     /**
50      * Method to update the total pdp count.
51      *
52      * @return the updated value of totalPdpCount
53      */
54     public long updateTotalPdpCount() {
55         return totalPdpCount.incrementAndGet();
56     }
57
58     /**
59      * Method to update the total pdp group count.
60      *
61      * @return the updated value of totalPdpGroupCount
62      */
63     public long updateTotalPdpGroupCount() {
64         return totalPdpGroupCount.incrementAndGet();
65     }
66
67     /**
68      * Method to update the total policy deploy count.
69      *
70      * @return the updated value of totalPolicyDeployCount
71      */
72     public long updateTotalPolicyDeployCount() {
73         return totalPolicyDeployCount.incrementAndGet();
74     }
75
76     /**
77      * Method to update the policy deploy success count.
78      *
79      * @return the updated value of policyDeploySuccessCount
80      */
81     public long updatePolicyDeploySuccessCount() {
82         return policyDeploySuccessCount.incrementAndGet();
83     }
84
85     /**
86      * Method to update the policy deploy failure count.
87      *
88      * @return the updated value of policyDeployFailureCount
89      */
90     public long updatePolicyDeployFailureCount() {
91         return policyDeployFailureCount.incrementAndGet();
92     }
93
94     /**
95      * Method to update the total policy download count.
96      *
97      * @return the updated value of totalPolicyDownloadCount
98      */
99     public long updateTotalPolicyDownloadCount() {
100         return totalPolicyDownloadCount.incrementAndGet();
101     }
102
103     /**
104      * Method to update the policy download success count.
105      *
106      * @return the updated value of policyDownloadSuccessCount
107      */
108     public long updatePolicyDownloadSuccessCount() {
109         return policyDownloadSuccessCount.incrementAndGet();
110     }
111
112     /**
113      * Method to update the policy download failure count.
114      *
115      * @return the updated value of policyDownloadFailureCount
116      */
117     public long updatePolicyDownloadFailureCount() {
118         return policyDownloadFailureCount.incrementAndGet();
119     }
120
121     /**
122      * Reset all the statistics counts to 0.
123      */
124     public void resetAllStatistics() {
125         totalPdpCount.set(0L);
126         totalPdpGroupCount.set(0L);
127         totalPolicyDeployCount.set(0L);
128         policyDeploySuccessCount.set(0L);
129         policyDeployFailureCount.set(0L);
130         totalPolicyDownloadCount.set(0L);
131         policyDownloadSuccessCount.set(0L);
132         policyDownloadFailureCount.set(0L);
133     }
134
135     public long getTotalPdpCount() {
136         return totalPdpCount.get();
137     }
138
139     public long getTotalPdpGroupCount() {
140         return totalPdpGroupCount.get();
141     }
142
143     public long getTotalPolicyDeployCount() {
144         return totalPolicyDeployCount.get();
145     }
146
147     public long getPolicyDeploySuccessCount() {
148         return policyDeploySuccessCount.get();
149     }
150
151     public long getPolicyDeployFailureCount() {
152         return policyDeployFailureCount.get();
153     }
154
155     public long getTotalPolicyDownloadCount() {
156         return totalPolicyDownloadCount.get();
157     }
158
159     public long getPolicyDownloadSuccessCount() {
160         return policyDownloadSuccessCount.get();
161     }
162
163     public long getPolicyDownloadFailureCount() {
164         return policyDownloadFailureCount.get();
165     }
166 }