PDPX Healthcheck/Statistic RESTful API entry point
[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 totalPoliciesCount;
30     private static long permitDecisionsCount;
31     private static long denyDecisionsCount;
32     private static long indeterminantDecisionsCount;
33     private static long notApplicableDecisionsCount;
34
35     private XacmlPdpStatisticsManager() {
36         throw new IllegalStateException("Instantiation of the class is not allowed");
37     }
38
39     /**
40      * Method to update the xacml pdp total policies count.
41      *
42      * @return the total
43      */
44     public static long updateTotalPoliciesCount() {
45         return ++totalPoliciesCount;
46     }
47
48     /**
49      * Method to update the number of permit decisions.
50      *
51      * @return the permitDecisionsCount
52      */
53     public static long updatePermitDecisionsCount() {
54         return ++permitDecisionsCount;
55     }
56
57     /**
58      * Method to update the number of deny decisions.
59      *
60      * @return the denyDecisionsCount
61      */
62     public static long updateDenyDecisionsCount() {
63         return ++denyDecisionsCount;
64     }
65
66     /**
67      * Method to update the number of indeterminant decisions.
68      *
69      * @return the indeterminantDecisionsCount
70      */
71     public static long updateIndeterminantDecisionsCount() {
72         return ++indeterminantDecisionsCount;
73     }
74
75     /**
76      * Method to update the number of not applicable decisions.
77      *
78      * @return the notApplicableDecisionsCount
79      */
80     public static long updateNotApplicableDecisionsCount() {
81         return ++notApplicableDecisionsCount;
82     }
83
84     /**
85      * Returns the current value of totalPoliciesCount.
86
87      * @return the totalPoliciesCount
88      */
89     public static long getTotalPoliciesCount() {
90         return totalPoliciesCount;
91     }
92
93     /**
94      * Returns the current value of permitDecisionsCount.
95
96      * @return the permitDecisionsCount
97      */
98     public static long getPermitDecisionsCount() {
99         return permitDecisionsCount;
100     }
101
102     /**
103      * Returns the current value of denyDecisionsCount.
104
105      * @return the denyDecisionsCount
106      */
107     public static long getDenyDecisionsCount() {
108         return denyDecisionsCount;
109     }
110
111     /**
112      * Returns the current value of indeterminantDecisionsCount.
113
114      * @return the indeterminantDecisionsCount
115      */
116     public static long getIndeterminantDecisionsCount() {
117         return indeterminantDecisionsCount;
118     }
119
120     /**
121      * Returns the current value of notApplicableDecisionsCount.
122
123      * @return the notApplicableDecisionsCount
124      */
125     public static long getNotApplicableDecisionsCount() {
126         return notApplicableDecisionsCount;
127     }
128
129     /**
130      * Reset all the statistics counts to 0.
131      */
132     public static void resetAllStatistics() {
133         totalPoliciesCount = 0L;
134         permitDecisionsCount = 0L;
135         denyDecisionsCount = 0L;
136         indeterminantDecisionsCount = 0L;
137         notApplicableDecisionsCount = 0L;
138     }
139 }