d209c09ce7b4df93ae36387685c2765dd9f26717
[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 /**
24  * Class to hold statistical data for xacmlPdp component.
25  *
26  */
27 public class XacmlPdpStatisticsManager {
28
29     private static long totalPolicyTypesCount;
30     private static long totalPoliciesCount;
31     private static long errorsCount;
32     private static long permitDecisionsCount;
33     private static long denyDecisionsCount;
34     private static long indeterminantDecisionsCount;
35     private static long notApplicableDecisionsCount;
36
37     private XacmlPdpStatisticsManager() {
38         throw new IllegalStateException("Instantiation of the class is not allowed");
39     }
40
41     /**
42      * Method to set the xacml pdp total policy types count. This
43      * doesn't really increment, it depends on the applications
44      * that are loaded. Which can be dynamic.
45      *
46      * @return the total
47      */
48     public static long setTotalPolicyTypesCount(long newCount) {
49         totalPolicyTypesCount = newCount;
50         return totalPolicyTypesCount;
51     }
52
53     /**
54      * Method to update the xacml pdp total policies count.
55      *
56      * @return the total
57      */
58     public static long updateTotalPoliciesCount() {
59         return ++totalPoliciesCount;
60     }
61
62     /**
63      * Method to update the number of error decisions.
64      *
65      * @return the errorDecisionsCount
66      */
67     public static long updateErrorCount() {
68         return ++errorsCount;
69     }
70
71     /**
72      * Method to update the number of permit decisions.
73      *
74      * @return the permitDecisionsCount
75      */
76     public static long updatePermitDecisionsCount() {
77         return ++permitDecisionsCount;
78     }
79
80     /**
81      * Method to update the number of deny decisions.
82      *
83      * @return the denyDecisionsCount
84      */
85     public static long updateDenyDecisionsCount() {
86         return ++denyDecisionsCount;
87     }
88
89     /**
90      * Method to update the number of indeterminant decisions.
91      *
92      * @return the indeterminantDecisionsCount
93      */
94     public static long updateIndeterminantDecisionsCount() {
95         return ++indeterminantDecisionsCount;
96     }
97
98     /**
99      * Method to update the number of not applicable decisions.
100      *
101      * @return the notApplicableDecisionsCount
102      */
103     public static long updateNotApplicableDecisionsCount() {
104         return ++notApplicableDecisionsCount;
105     }
106
107     /**
108      * Returns the current value of totalPolicyTypesCount.
109
110      * @return the totalPolicyTypesCount
111      */
112     public static long getTotalPolicyTypesCount() {
113         return totalPolicyTypesCount;
114     }
115
116     /**
117      * Returns the current value of totalPoliciesCount.
118
119      * @return the totalPoliciesCount
120      */
121     public static long getTotalPoliciesCount() {
122         return totalPoliciesCount;
123     }
124
125     /**
126      * Returns the current value of errorDecisionsCount.
127
128      * @return the permitDecisionsCount
129      */
130     public static long getErrorCount() {
131         return errorsCount;
132     }
133
134     /**
135      * Returns the current value of permitDecisionsCount.
136
137      * @return the permitDecisionsCount
138      */
139     public static long getPermitDecisionsCount() {
140         return permitDecisionsCount;
141     }
142
143     /**
144      * Returns the current value of denyDecisionsCount.
145
146      * @return the denyDecisionsCount
147      */
148     public static long getDenyDecisionsCount() {
149         return denyDecisionsCount;
150     }
151
152     /**
153      * Returns the current value of indeterminantDecisionsCount.
154
155      * @return the indeterminantDecisionsCount
156      */
157     public static long getIndeterminantDecisionsCount() {
158         return indeterminantDecisionsCount;
159     }
160
161     /**
162      * Returns the current value of notApplicableDecisionsCount.
163
164      * @return the notApplicableDecisionsCount
165      */
166     public static long getNotApplicableDecisionsCount() {
167         return notApplicableDecisionsCount;
168     }
169
170     /**
171      * Reset all the statistics counts to 0.
172      */
173     public static void resetAllStatistics() {
174         totalPolicyTypesCount = 0L;
175         totalPoliciesCount = 0L;
176         errorsCount = 0L;
177         permitDecisionsCount = 0L;
178         denyDecisionsCount = 0L;
179         indeterminantDecisionsCount = 0L;
180         notApplicableDecisionsCount = 0L;
181     }
182 }