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