2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 * SPDX-License-Identifier: Apache-2.0
20 * ============LICENSE_END=========================================================
23 package org.onap.policy.api.main.rest;
26 * Class to hold statistical data for API access.
28 public class ApiStatisticsManager {
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;
46 private ApiStatisticsManager() {
47 throw new IllegalStateException("Instantiation of the class is not allowed");
51 * Method to update the total api call count.
53 * @return the updated value of totalApiCallCount
55 public static long updateTotalApiCallCount() {
56 return ++totalApiCallCount;
60 * Method to update the successful api call count.
62 * @return the updated value of apiCallSuccessCount
64 public static long updateApiCallSuccessCount() {
65 return ++apiCallSuccessCount;
69 * Method to update the failed api call count.
71 * @return the updated value of apiCallFailureCount
73 public static long updateApiCallFailureCount() {
74 return ++apiCallFailureCount;
78 * Method to update the total policy GET count.
80 * @return the updated value of totalPolicyGetCount
82 public static long updateTotalPolicyGetCount() {
83 return ++totalPolicyGetCount;
87 * Method to update the total policy POST count.
89 * @return the updated value of totalPolicyPostCount
91 public static long updateTotalPolicyPostCount() {
92 return ++totalPolicyPostCount;
96 * Method to update the total template GET count.
98 * @return the updated value of totalTemplateGetCount
100 public static long updateTotalTemplateGetCount() {
101 return ++totalTemplateGetCount;
105 * Method to update the total template POST count.
107 * @return the updated value of totalTemplatePostCount
109 public static long updateTotalTemplatePostCount() {
110 return ++totalTemplatePostCount;
114 * Method to update successful policy GET count.
116 * @return the updated value of policyGetSuccessCount
118 public static long updatePolicyGetSuccessCount() {
119 return ++policyGetSuccessCount;
123 * Method to update failed policy GET count.
125 * @return the updated value of policyGetFailureCount
127 public static long updatePolicyGetFailureCount() {
128 return ++policyGetFailureCount;
132 * Method to update successful policy POST count.
134 * @return the updated value of policyPostSuccessCount
136 public static long updatePolicyPostSuccessCount() {
137 return ++policyPostSuccessCount;
141 * Method to update failed policy POST count.
143 * @return the updated value of policyPostFailureCount
145 public static long updatePolicyPostFailureCount() {
146 return ++policyPostFailureCount;
150 * Method to update successful template GET count.
152 * @return the updated value of templateGetSuccessCount
154 public static long updateTemplateGetSuccessCount() {
155 return ++templateGetSuccessCount;
159 * Method to update failed template GET count.
161 * @return the updated value of templateGetFailureCount
163 public static long updateTemplateGetFailureCount() {
164 return ++templateGetFailureCount;
168 * Method to update successful template POST count.
170 * @return the updated value of templatePostSuccessCount
172 public static long updateTemplatePostSuccessCount() {
173 return ++templatePostSuccessCount;
177 * Method to update failed template POST count.
179 * @return the updated value of templatePostFailureCount
181 public static long updateTemplatePostFailureCount() {
182 return ++templatePostFailureCount;
186 * Returns the current value of totalApiCallCount.
188 * @return the totalApiCallCount
190 public static long getTotalApiCallCount() {
191 return totalApiCallCount;
195 * Returns the current value of apiCallSuccessCount.
197 * @return the apiCallSuccessCount
199 public static long getApiCallSuccessCount() {
200 return apiCallSuccessCount;
204 * Returns the current value of apiCallFailureCount.
206 * @return the apiCallFailureCount
208 public static long getApiCallFailureCount() {
209 return apiCallFailureCount;
213 * Returns the current value of totalPolicyGetCount.
215 * @return the totalPolicyGetCount
217 public static long getTotalPolicyGetCount() {
218 return totalPolicyGetCount;
222 * Returns the current value of totalPolicyPostCount.
224 * @return the totalPolicyPostCount
226 public static long getTotalPolicyPostCount() {
227 return totalPolicyPostCount;
231 * Returns the current value of totalTemplateGetCount.
233 * @return the totalTemplateGetCount
235 public static long getTotalTemplateGetCount() {
236 return totalTemplateGetCount;
240 * Returns the current value of totalTemplatePostCount.
242 * @return the totalTemplatePostCount
244 public static long getTotalTemplatePostCount() {
245 return totalTemplatePostCount;
249 * Returns the current value of policyGetSuccessCount.
251 * @return the policyGetSuccessCount
253 public static long getPolicyGetSuccessCount() {
254 return policyGetSuccessCount;
258 * Returns the current value of policyGetFailureCount.
260 * @return the policyGetFailureCount
262 public static long getPolicyGetFailureCount() {
263 return policyGetFailureCount;
267 * Returns the current value of policyPostSuccessCount.
269 * @return the policyPostSuccessCount
271 public static long getPolicyPostSuccessCount() {
272 return policyPostSuccessCount;
276 * Returns the current value of policyPostFailureCount.
278 * @return the policyPostFailureCount
280 public static long getPolicyPostFailureCount() {
281 return policyPostFailureCount;
285 * Returns the current value of templateGetSuccessCount.
287 * @return the templateGetSuccessCount
289 public static long getTemplateGetSuccessCount() {
290 return templateGetSuccessCount;
294 * Returns the current value of templateGetFailureCount.
296 * @return the templateGetFailureCount
298 public static long getTemplateGetFailureCount() {
299 return templateGetFailureCount;
303 * Returns the current value of templatePostSuccessCount.
305 * @return the templatePostSuccessCount
307 public static long getTemplatePostSuccessCount() {
308 return templatePostSuccessCount;
312 * Returns the current value of templatePostFailureCount.
314 * @return the templatePostFailureCount
316 public static long getTemplatePostFailureCount() {
317 return templatePostFailureCount;
321 * Reset all the statistics counts to 0.
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;