2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2020 Bell Canada.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
20 * SPDX-License-Identifier: Apache-2.0
21 * ============LICENSE_END=========================================================
24 package org.onap.policy.api.main.rest;
29 * Class to hold statistical data for API access.
31 * @author Chenfei Gao (cgao@research.att.com)
33 public class ApiStatisticsManager {
36 private static long totalApiCallCount;
39 private static long apiCallSuccessCount;
42 private static long apiCallFailureCount;
45 private static long totalPolicyGetCount;
48 private static long totalPolicyPostCount;
51 private static long totalPolicyDeleteCount;
54 private static long totalPolicyTypeGetCount;
57 private static long totalPolicyTypePostCount;
60 private static long totalPolicyTypeDeleteCount;
63 private static long policyGetSuccessCount;
66 private static long policyGetFailureCount;
69 private static long policyPostSuccessCount;
72 private static long policyPostFailureCount;
75 private static long policyDeleteSuccessCount;
78 private static long policyDeleteFailureCount;
81 private static long policyTypeGetSuccessCount;
84 private static long policyTypeGetFailureCount;
87 private static long policyTypePostSuccessCount;
90 private static long policyTypePostFailureCount;
93 private static long policyTypeDeleteSuccessCount;
96 private static long policyTypeDeleteFailureCount;
98 private ApiStatisticsManager() {
99 throw new IllegalStateException("Instantiation of the class is not allowed");
103 * Method to update the total api call count.
105 * @return the updated value of totalApiCallCount
107 public static long updateTotalApiCallCount() {
108 return ++totalApiCallCount;
112 * Method to update the successful api call count.
114 * @return the updated value of apiCallSuccessCount
116 public static long updateApiCallSuccessCount() {
117 return ++apiCallSuccessCount;
121 * Method to update the failed api call count.
123 * @return the updated value of apiCallFailureCount
125 public static long updateApiCallFailureCount() {
126 return ++apiCallFailureCount;
130 * Method to update the total policy GET count.
132 * @return the updated value of totalPolicyGetCount
134 public static long updateTotalPolicyGetCount() {
135 return ++totalPolicyGetCount;
139 * Method to update the total policy POST count.
141 * @return the updated value of totalPolicyPostCount
143 public static long updateTotalPolicyPostCount() {
144 return ++totalPolicyPostCount;
148 * Method to update the total policy DELETE count.
150 * @return the updated value of totalPolicyDeleteCount
152 public static long updateTotalPolicyDeleteCount() {
153 return ++totalPolicyDeleteCount;
157 * Method to update the total policyType GET count.
159 * @return the updated value of totalPolicyTypeGetCount
161 public static long updateTotalPolicyTypeGetCount() {
162 return ++totalPolicyTypeGetCount;
166 * Method to update the total policyType POST count.
168 * @return the updated value of totalPolicyTypePostCount
170 public static long updateTotalPolicyTypePostCount() {
171 return ++totalPolicyTypePostCount;
175 * Method to update the total policyType DELETE count.
177 * @return the updated value of totalPolicyTypeDeleteCount
179 public static long updateTotalPolicyTypeDeleteCount() {
180 return ++totalPolicyTypeDeleteCount;
184 * Method to update successful policy GET count.
186 * @return the updated value of policyGetSuccessCount
188 public static long updatePolicyGetSuccessCount() {
189 return ++policyGetSuccessCount;
193 * Method to update failed policy GET count.
195 * @return the updated value of policyGetFailureCount
197 public static long updatePolicyGetFailureCount() {
198 return ++policyGetFailureCount;
202 * Method to update successful policy POST count.
204 * @return the updated value of policyPostSuccessCount
206 public static long updatePolicyPostSuccessCount() {
207 return ++policyPostSuccessCount;
211 * Method to update failed policy POST count.
213 * @return the updated value of policyPostFailureCount
215 public static long updatePolicyPostFailureCount() {
216 return ++policyPostFailureCount;
220 * Method to update successful policy DELETE count.
222 * @return the updated value of policyDeleteSuccessCount
224 public static long updatePolicyDeleteSuccessCount() {
225 return ++policyDeleteSuccessCount;
229 * Method to update failed policy DELETE count.
231 * @return the updated value of policyDeleteFailureCount
233 public static long updatePolicyDeleteFailureCount() {
234 return ++policyDeleteFailureCount;
238 * Method to update successful policyType GET count.
240 * @return the updated value of policyTypeGetSuccessCount
242 public static long updatePolicyTypeGetSuccessCount() {
243 return ++policyTypeGetSuccessCount;
247 * Method to update failed policyType GET count.
249 * @return the updated value of policyTypeGetFailureCount
251 public static long updatePolicyTypeGetFailureCount() {
252 return ++policyTypeGetFailureCount;
256 * Method to update successful policyType POST count.
258 * @return the updated value of policyTypePostSuccessCount
260 public static long updatePolicyTypePostSuccessCount() {
261 return ++policyTypePostSuccessCount;
265 * Method to update failed policyType POST count.
267 * @return the updated value of policyTypePostFailureCount
269 public static long updatePolicyTypePostFailureCount() {
270 return ++policyTypePostFailureCount;
274 * Method to update successful policyType DELETE count.
276 * @return the updated value of policyTypeDeleteSuccessCount
278 public static long updatePolicyTypeDeleteSuccessCount() {
279 return ++policyTypeDeleteSuccessCount;
283 * Method to update failed policyType DELETE count.
285 * @return the updated value of policyTypePostFailureCount
287 public static long updatePolicyTypeDeleteFailureCount() {
288 return ++policyTypeDeleteFailureCount;
292 * Reset all the statistics counts to 0.
294 public static void resetAllStatistics() {
295 totalApiCallCount = 0L;
296 apiCallSuccessCount = 0L;
297 apiCallFailureCount = 0L;
298 totalPolicyGetCount = 0L;
299 totalPolicyPostCount = 0L;
300 totalPolicyDeleteCount = 0L;
301 totalPolicyTypeGetCount = 0L;
302 totalPolicyTypePostCount = 0L;
303 totalPolicyTypeDeleteCount = 0L;
304 policyGetSuccessCount = 0L;
305 policyGetFailureCount = 0L;
306 policyPostSuccessCount = 0L;
307 policyPostFailureCount = 0L;
308 policyDeleteSuccessCount = 0L;
309 policyDeleteFailureCount = 0L;
310 policyTypeGetSuccessCount = 0L;
311 policyTypeGetFailureCount = 0L;
312 policyTypePostSuccessCount = 0L;
313 policyTypePostFailureCount = 0L;
314 policyTypeDeleteSuccessCount = 0L;
315 policyTypeDeleteFailureCount = 0L;