Update totalPoliciesCount statistic
[policy/xacml-pdp.git] / main / src / main / java / org / onap / policy / pdpx / main / rest / XacmlPdpStatisticsManager.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.pdpx.main.rest;
22
23 import lombok.Getter;
24 import lombok.Setter;
25
26 /**
27  * Class to hold statistical data for xacmlPdp component.
28  *
29  */
30 public class XacmlPdpStatisticsManager {
31     @Getter
32     @Setter
33     private static XacmlPdpStatisticsManager current = null;
34
35     private long totalPolicyTypesCount;
36     private long totalPoliciesCount;
37     private long errorsCount;
38     private long permitDecisionsCount;
39     private long denyDecisionsCount;
40     private long indeterminantDecisionsCount;
41     private long notApplicableDecisionsCount;
42
43     /**
44      * Method to set the xacml pdp total policy types count. This
45      * doesn't really increment, it depends on the applications
46      * that are loaded. Which can be dynamic.
47      *
48      * @return the total
49      */
50     public long setTotalPolicyTypesCount(long newCount) {
51         totalPolicyTypesCount = newCount;
52         return totalPolicyTypesCount;
53     }
54
55     /**
56      * Method to set the xacml pdp total policies count. This
57      * doesn't really increment, it depends on the applications
58      * that are loaded. Which can be dynamic.
59      *
60      * @return the total
61      */
62     public long setTotalPolicyCount(long newCount) {
63         totalPoliciesCount = newCount;
64         return totalPoliciesCount;
65     }
66
67     /**
68      * Method to update the number of error decisions.
69      *
70      * @return the errorDecisionsCount
71      */
72     public long updateErrorCount() {
73         return ++errorsCount;
74     }
75
76     /**
77      * Method to update the number of permit decisions.
78      *
79      * @return the permitDecisionsCount
80      */
81     public long updatePermitDecisionsCount() {
82         return ++permitDecisionsCount;
83     }
84
85     /**
86      * Method to update the number of deny decisions.
87      *
88      * @return the denyDecisionsCount
89      */
90     public long updateDenyDecisionsCount() {
91         return ++denyDecisionsCount;
92     }
93
94     /**
95      * Method to update the number of indeterminant decisions.
96      *
97      * @return the indeterminantDecisionsCount
98      */
99     public long updateIndeterminantDecisionsCount() {
100         return ++indeterminantDecisionsCount;
101     }
102
103     /**
104      * Method to update the number of not applicable decisions.
105      *
106      * @return the notApplicableDecisionsCount
107      */
108     public long updateNotApplicableDecisionsCount() {
109         return ++notApplicableDecisionsCount;
110     }
111
112     /**
113      * Returns the current value of totalPolicyTypesCount.
114
115      * @return the totalPolicyTypesCount
116      */
117     public long getTotalPolicyTypesCount() {
118         return totalPolicyTypesCount;
119     }
120
121     /**
122      * Returns the current value of totalPoliciesCount.
123
124      * @return the totalPoliciesCount
125      */
126     public long getTotalPoliciesCount() {
127         return totalPoliciesCount;
128     }
129
130     /**
131      * Returns the current value of errorDecisionsCount.
132
133      * @return the permitDecisionsCount
134      */
135     public long getErrorCount() {
136         return errorsCount;
137     }
138
139     /**
140      * Returns the current value of permitDecisionsCount.
141
142      * @return the permitDecisionsCount
143      */
144     public long getPermitDecisionsCount() {
145         return permitDecisionsCount;
146     }
147
148     /**
149      * Returns the current value of denyDecisionsCount.
150
151      * @return the denyDecisionsCount
152      */
153     public long getDenyDecisionsCount() {
154         return denyDecisionsCount;
155     }
156
157     /**
158      * Returns the current value of indeterminantDecisionsCount.
159
160      * @return the indeterminantDecisionsCount
161      */
162     public long getIndeterminantDecisionsCount() {
163         return indeterminantDecisionsCount;
164     }
165
166     /**
167      * Returns the current value of notApplicableDecisionsCount.
168
169      * @return the notApplicableDecisionsCount
170      */
171     public long getNotApplicableDecisionsCount() {
172         return notApplicableDecisionsCount;
173     }
174
175     /**
176      * Reset all the statistics counts to 0.
177      */
178     public void resetAllStatistics() {
179         totalPolicyTypesCount = 0L;
180         totalPoliciesCount = 0L;
181         errorsCount = 0L;
182         permitDecisionsCount = 0L;
183         denyDecisionsCount = 0L;
184         indeterminantDecisionsCount = 0L;
185         notApplicableDecisionsCount = 0L;
186     }
187 }