Add changes to basic structure of api component
[policy/api.git] / main / src / main / java / org / onap / policy / api / main / rest / ApiStatisticsManager.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP Policy API 
4  * ================================================================================ 
5  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  * SPDX-License-Identifier: Apache-2.0
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.policy.api.main.rest;
24
25 /**
26  * Class to hold statistical data for API access.
27  */
28 public class ApiStatisticsManager {
29    
30     private static long totalApiCallCount;
31     private static long apiCallSuccessCount;
32     private static long apiCallFailureCount;
33     private static long totalPolicyGetCount;
34     private static long totalPolicyPostCount;
35     private static long totalTemplateGetCount;
36     private static long totalTemplatePostCount;
37     private static long policyGetSuccessCount;
38     private static long policyGetFailureCount;
39     private static long policyPostSuccessCount;
40     private static long policyPostFailureCount;
41     private static long templateGetSuccessCount;
42     private static long templateGetFailureCount;
43     private static long templatePostSuccessCount;
44     private static long templatePostFailureCount;
45    
46     private ApiStatisticsManager() {
47         throw new IllegalStateException("Instantiation of the class is not allowed");
48     }
49     
50     /**
51      * Method to update the total api call count.
52      * 
53      * @return the updated value of totalApiCallCount
54      */
55     public static long updateTotalApiCallCount() {
56         return ++totalApiCallCount;
57     }
58     
59     /**
60      * Method to update the successful api call count.
61      * 
62      * @return the updated value of apiCallSuccessCount
63      */
64     public static long updateApiCallSuccessCount() {
65         return ++apiCallSuccessCount;
66     }
67     
68     /**
69      * Method to update the failed api call count.
70      * 
71      * @return the updated value of apiCallFailureCount
72      */
73     public static long updateApiCallFailureCount() {
74         return ++apiCallFailureCount;
75     }
76     
77     /**
78      * Method to update the total policy GET count.
79      * 
80      * @return the updated value of totalPolicyGetCount
81      */
82     public static long updateTotalPolicyGetCount() {
83         return ++totalPolicyGetCount;
84     }
85     
86     /**
87      * Method to update the total policy POST count.
88      * 
89      * @return the updated value of totalPolicyPostCount
90      */
91     public static long updateTotalPolicyPostCount() {
92         return ++totalPolicyPostCount;
93     }
94     
95     /**
96      * Method to update the total template GET count.
97      * 
98      * @return the updated value of totalTemplateGetCount
99      */
100     public static long updateTotalTemplateGetCount() {
101         return ++totalTemplateGetCount;
102     }
103     
104     /**
105      * Method to update the total template POST count.
106      * 
107      * @return the updated value of totalTemplatePostCount
108      */
109     public static long updateTotalTemplatePostCount() {
110         return ++totalTemplatePostCount;
111     }
112     
113     /**
114      * Method to update successful policy GET count.
115      * 
116      * @return the updated value of policyGetSuccessCount
117      */
118     public static long updatePolicyGetSuccessCount() {
119         return ++policyGetSuccessCount;
120     }
121     
122     /**
123      * Method to update failed policy GET count.
124      * 
125      * @return the updated value of policyGetFailureCount
126      */
127     public static long updatePolicyGetFailureCount() {
128         return ++policyGetFailureCount;
129     }
130     
131     /**
132      * Method to update successful policy POST count.
133      * 
134      * @return the updated value of policyPostSuccessCount
135      */
136     public static long updatePolicyPostSuccessCount() {
137         return ++policyPostSuccessCount;
138     }
139     
140     /**
141      * Method to update failed policy POST count.
142      * 
143      * @return the updated value of policyPostFailureCount
144      */
145     public static long updatePolicyPostFailureCount() {
146         return ++policyPostFailureCount;
147     }
148     
149     /**
150      * Method to update successful template GET count.
151      * 
152      * @return the updated value of templateGetSuccessCount
153      */
154     public static long updateTemplateGetSuccessCount() {
155         return ++templateGetSuccessCount;
156     }
157     
158     /**
159      * Method to update failed template GET count.
160      * 
161      * @return the updated value of templateGetFailureCount
162      */
163     public static long updateTemplateGetFailureCount() {
164         return ++templateGetFailureCount;
165     }
166     
167     /**
168      * Method to update successful template POST count.
169      * 
170      * @return the updated value of templatePostSuccessCount
171      */
172     public static long updateTemplatePostSuccessCount() {
173         return ++templatePostSuccessCount;
174     }
175     
176     /**
177      * Method to update failed template POST count.
178      * 
179      * @return the updated value of templatePostFailureCount
180      */
181     public static long updateTemplatePostFailureCount() {
182         return ++templatePostFailureCount;
183     }
184     
185     /**
186      * Returns the current value of totalApiCallCount.
187      * 
188      * @return the totalApiCallCount
189      */
190     public static long getTotalApiCallCount() {
191         return totalApiCallCount;
192     }
193    
194     /**
195      * Returns the current value of apiCallSuccessCount.
196      * 
197      * @return the apiCallSuccessCount
198      */
199     public static long getApiCallSuccessCount() {
200         return apiCallSuccessCount;
201     }
202     
203     /**
204      * Returns the current value of apiCallFailureCount.
205      * 
206      * @return the apiCallFailureCount
207      */
208     public static long getApiCallFailureCount() {
209         return apiCallFailureCount;
210     } 
211     
212     /**
213      * Returns the current value of totalPolicyGetCount.
214      * 
215      * @return the totalPolicyGetCount
216      */
217     public static long getTotalPolicyGetCount() {
218         return totalPolicyGetCount;
219     }
220     
221     /**
222      * Returns the current value of totalPolicyPostCount.
223      * 
224      * @return the totalPolicyPostCount
225      */
226     public static long getTotalPolicyPostCount() {
227         return totalPolicyPostCount;
228     } 
229     
230     /**
231      * Returns the current value of totalTemplateGetCount.
232      * 
233      * @return the totalTemplateGetCount
234      */
235     public static long getTotalTemplateGetCount() {
236         return totalTemplateGetCount;
237     }
238     
239     /**
240      * Returns the current value of totalTemplatePostCount.
241      * 
242      * @return the totalTemplatePostCount
243      */
244     public static long getTotalTemplatePostCount() {
245         return totalTemplatePostCount;
246     }
247     
248     /**
249      * Returns the current value of policyGetSuccessCount.
250      * 
251      * @return the policyGetSuccessCount
252      */
253     public static long getPolicyGetSuccessCount() {
254         return policyGetSuccessCount;
255     }
256     
257     /**
258      * Returns the current value of policyGetFailureCount.
259      * 
260      * @return the policyGetFailureCount 
261      */
262     public static long getPolicyGetFailureCount() {
263         return policyGetFailureCount;
264     }
265     
266     /**
267      * Returns the current value of policyPostSuccessCount.
268      * 
269      * @return the policyPostSuccessCount
270      */
271     public static long getPolicyPostSuccessCount() {
272         return policyPostSuccessCount;
273     }
274     
275     /**
276      * Returns the current value of policyPostFailureCount.
277      * 
278      * @return the policyPostFailureCount
279      */
280     public static long getPolicyPostFailureCount() {
281         return policyPostFailureCount;
282     }
283     
284     /**
285      * Returns the current value of templateGetSuccessCount.
286      * 
287      * @return the templateGetSuccessCount
288      */
289     public static long getTemplateGetSuccessCount() {
290         return templateGetSuccessCount;
291     }
292     
293     /**
294      * Returns the current value of templateGetFailureCount.
295      * 
296      * @return the templateGetFailureCount
297      */
298     public static long getTemplateGetFailureCount() {
299         return templateGetFailureCount;
300     }
301     
302     /**
303      * Returns the current value of templatePostSuccessCount.
304      * 
305      * @return the templatePostSuccessCount
306      */
307     public static long getTemplatePostSuccessCount() {
308         return templatePostSuccessCount;
309     }
310     
311     /**
312      * Returns the current value of templatePostFailureCount.
313      * 
314      * @return the templatePostFailureCount
315      */
316     public static long getTemplatePostFailureCount() {
317         return templatePostFailureCount;
318     }
319     
320     /**
321      * Reset all the statistics counts to 0.
322      */
323     public static void resetAllStatistics() {
324         totalApiCallCount = 0L;
325         apiCallSuccessCount = 0L;
326         apiCallFailureCount = 0L;
327         totalPolicyGetCount = 0L;
328         totalPolicyPostCount = 0L;
329         totalTemplateGetCount = 0L;
330         totalTemplatePostCount = 0L;
331         policyGetSuccessCount = 0L;
332         policyGetFailureCount = 0L;
333         policyPostSuccessCount = 0L;
334         policyPostFailureCount = 0L;
335         templateGetSuccessCount = 0L;
336         templateGetFailureCount = 0L;
337         templatePostSuccessCount = 0L;
338         templatePostFailureCount = 0L;
339     }
340 }