Refactor xacml-pdp to remove various statics
[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 update the xacml pdp total policies count.
57      *
58      * @return the total
59      */
60     public long updateTotalPoliciesCount() {
61         return ++totalPoliciesCount;
62     }
63
64     /**
65      * Method to update the number of error decisions.
66      *
67      * @return the errorDecisionsCount
68      */
69     public long updateErrorCount() {
70         return ++errorsCount;
71     }
72
73     /**
74      * Method to update the number of permit decisions.
75      *
76      * @return the permitDecisionsCount
77      */
78     public long updatePermitDecisionsCount() {
79         return ++permitDecisionsCount;
80     }
81
82     /**
83      * Method to update the number of deny decisions.
84      *
85      * @return the denyDecisionsCount
86      */
87     public long updateDenyDecisionsCount() {
88         return ++denyDecisionsCount;
89     }
90
91     /**
92      * Method to update the number of indeterminant decisions.
93      *
94      * @return the indeterminantDecisionsCount
95      */
96     public long updateIndeterminantDecisionsCount() {
97         return ++indeterminantDecisionsCount;
98     }
99
100     /**
101      * Method to update the number of not applicable decisions.
102      *
103      * @return the notApplicableDecisionsCount
104      */
105     public long updateNotApplicableDecisionsCount() {
106         return ++notApplicableDecisionsCount;
107     }
108
109     /**
110      * Returns the current value of totalPolicyTypesCount.
111
112      * @return the totalPolicyTypesCount
113      */
114     public long getTotalPolicyTypesCount() {
115         return totalPolicyTypesCount;
116     }
117
118     /**
119      * Returns the current value of totalPoliciesCount.
120
121      * @return the totalPoliciesCount
122      */
123     public long getTotalPoliciesCount() {
124         return totalPoliciesCount;
125     }
126
127     /**
128      * Returns the current value of errorDecisionsCount.
129
130      * @return the permitDecisionsCount
131      */
132     public long getErrorCount() {
133         return errorsCount;
134     }
135
136     /**
137      * Returns the current value of permitDecisionsCount.
138
139      * @return the permitDecisionsCount
140      */
141     public long getPermitDecisionsCount() {
142         return permitDecisionsCount;
143     }
144
145     /**
146      * Returns the current value of denyDecisionsCount.
147
148      * @return the denyDecisionsCount
149      */
150     public long getDenyDecisionsCount() {
151         return denyDecisionsCount;
152     }
153
154     /**
155      * Returns the current value of indeterminantDecisionsCount.
156
157      * @return the indeterminantDecisionsCount
158      */
159     public long getIndeterminantDecisionsCount() {
160         return indeterminantDecisionsCount;
161     }
162
163     /**
164      * Returns the current value of notApplicableDecisionsCount.
165
166      * @return the notApplicableDecisionsCount
167      */
168     public long getNotApplicableDecisionsCount() {
169         return notApplicableDecisionsCount;
170     }
171
172     /**
173      * Reset all the statistics counts to 0.
174      */
175     public void resetAllStatistics() {
176         totalPolicyTypesCount = 0L;
177         totalPoliciesCount = 0L;
178         errorsCount = 0L;
179         permitDecisionsCount = 0L;
180         denyDecisionsCount = 0L;
181         indeterminantDecisionsCount = 0L;
182         notApplicableDecisionsCount = 0L;
183     }
184 }