2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2018 Ericsson. All rights reserved.
4 * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.distribution.reception.statistics;
24 import io.prometheus.client.Counter;
27 * Class to hold statistical data for distribution component.
29 * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
31 public class DistributionStatisticsManager {
33 private static final Counter TOTAL_DISTRIBUTION_RECEIVED_COUNT = Counter.build()
34 .name("total_distribution_received_count")
35 .help("Total number of distribution received.").register();
36 private static final Counter DISTRIBUTION_SUCCESS_COUNT = Counter.build()
37 .name("distribution_success_count")
38 .help("Total number of distribution successfully processed.").register();
40 private static final Counter DISTRIBUTION_FAILURE_COUNT = Counter.build()
41 .name("distribution_failure_count")
42 .help("Total number of distribution failures.").register();
44 private static final Counter TOTAL_DOWNLOAD_RECEIVED_COUNT = Counter.build()
45 .name("total_download_received_count")
46 .help("Total number of download received.").register();
48 private static final Counter DOWNLOAD_SUCCESS_COUNT = Counter.build()
49 .name("download_success_count")
50 .help("Total number of download successfully processed.").register();
52 private static final Counter DOWNLOAD_FAILURE_COUNT = Counter.build()
53 .name("download_failure_count")
54 .help("Total number of download failures.").register();
56 private DistributionStatisticsManager() {
57 throw new IllegalStateException("Instantiation of the class is not allowed");
61 * Method to update the total distribution count.
64 public static void updateTotalDistributionCount() {
65 TOTAL_DISTRIBUTION_RECEIVED_COUNT.inc();
69 * Method to update the distribution success count.
72 public static void updateDistributionSuccessCount() {
73 DISTRIBUTION_SUCCESS_COUNT.inc();
77 * Method to update the distribution failure count.
80 public static void updateDistributionFailureCount() {
81 DISTRIBUTION_FAILURE_COUNT.inc();
85 * Method to update the total download count.
88 public static void updateTotalDownloadCount() {
89 TOTAL_DOWNLOAD_RECEIVED_COUNT.inc();
93 * Method to update the download success count.
96 public static void updateDownloadSuccessCount() {
97 DOWNLOAD_SUCCESS_COUNT.inc();
101 * Method to update the download failure count.
104 public static void updateDownloadFailureCount() {
105 DOWNLOAD_FAILURE_COUNT.inc();
109 * Returns the current value of totalDistributionCount.
111 * @return the totalDistributionCount
113 public static long getTotalDistributionCount() {
114 return (long) TOTAL_DISTRIBUTION_RECEIVED_COUNT.get();
118 * Returns the current value of distributionSuccessCount.
120 * @return the distributionSuccessCount
122 public static long getDistributionSuccessCount() {
123 return (long) DISTRIBUTION_SUCCESS_COUNT.get();
127 * Returns the current value of distributionFailureCount.
129 * @return the distributionFailureCount
131 public static long getDistributionFailureCount() {
132 return (long) DISTRIBUTION_FAILURE_COUNT.get();
136 * Returns the current value of totalDownloadCount.
138 * @return the totalDownloadCount
140 public static long getTotalDownloadCount() {
141 return (long) TOTAL_DOWNLOAD_RECEIVED_COUNT.get();
145 * Returns the current value of downloadSuccessCount.
147 * @return the downloadSuccessCount
149 public static long getDownloadSuccessCount() {
150 return (long) DOWNLOAD_SUCCESS_COUNT.get();
154 * Returns the current value of downloadFailureCount.
156 * @return the downloadFailureCount
158 public static long getDownloadFailureCount() {
159 return (long) DOWNLOAD_FAILURE_COUNT.get();
163 * Reset all the statistics counts to 0.
165 public static void resetAllStatistics() {
166 TOTAL_DISTRIBUTION_RECEIVED_COUNT.clear();
167 DISTRIBUTION_SUCCESS_COUNT.clear();
168 DISTRIBUTION_FAILURE_COUNT.clear();
169 TOTAL_DOWNLOAD_RECEIVED_COUNT.clear();
170 DOWNLOAD_SUCCESS_COUNT.clear();
171 DOWNLOAD_FAILURE_COUNT.clear();