* ============LICENSE_START=======================================================
* ONAP Policy API
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020-2021 Bell Canada.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
package org.onap.policy.api.main.rest;
-import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
*
* @author Chenfei Gao (cgao@research.att.com)
*/
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class ApiStatisticsManager {
-
- @Getter
- private static long totalApiCallCount;
-
- @Getter
- private static long apiCallSuccessCount;
-
- @Getter
- private static long apiCallFailureCount;
-
- @Getter
- private static long totalPolicyGetCount;
-
- @Getter
- private static long totalPolicyPostCount;
-
- @Getter
- private static long totalPolicyDeleteCount;
-
- @Getter
- private static long totalPolicyTypeGetCount;
-
- @Getter
- private static long totalPolicyTypePostCount;
-
- @Getter
- private static long totalPolicyTypeDeleteCount;
-
- @Getter
- private static long policyGetSuccessCount;
-
+@Getter
+@NoArgsConstructor
+public class ApiStatisticsManager {
@Getter
- private static long policyGetFailureCount;
+ private static ApiStatisticsManager instance = new ApiStatisticsManager();
- @Getter
- private static long policyPostSuccessCount;
-
- @Getter
- private static long policyPostFailureCount;
-
- @Getter
- private static long policyDeleteSuccessCount;
-
- @Getter
- private static long policyDeleteFailureCount;
-
- @Getter
- private static long policyTypeGetSuccessCount;
-
- @Getter
- private static long policyTypeGetFailureCount;
-
- @Getter
- private static long policyTypePostSuccessCount;
-
- @Getter
- private static long policyTypePostFailureCount;
-
- @Getter
- private static long policyTypeDeleteSuccessCount;
-
- @Getter
- private static long policyTypeDeleteFailureCount;
+ private StatisticsReport report = new StatisticsReport();
+ private long totalPolicyDeleteCount;
+ private long totalPolicyTypeDeleteCount;
+ private long policyDeleteSuccessCount;
+ private long policyDeleteFailureCount;
+ private long policyTypeDeleteSuccessCount;
+ private long policyTypeDeleteFailureCount;
/**
* Method to update the total api call count.
*
* @return the updated value of totalApiCallCount
*/
- public static long updateTotalApiCallCount() {
- return ++totalApiCallCount;
+ public long updateTotalApiCallCount() {
+ return ++report.totalApiCallCount;
}
/**
*
* @return the updated value of apiCallSuccessCount
*/
- public static long updateApiCallSuccessCount() {
- return ++apiCallSuccessCount;
+ public long updateApiCallSuccessCount() {
+ return ++report.apiCallSuccessCount;
}
/**
*
* @return the updated value of apiCallFailureCount
*/
- public static long updateApiCallFailureCount() {
- return ++apiCallFailureCount;
+ public long updateApiCallFailureCount() {
+ return ++report.apiCallFailureCount;
}
/**
*
* @return the updated value of totalPolicyGetCount
*/
- public static long updateTotalPolicyGetCount() {
- return ++totalPolicyGetCount;
+ public long updateTotalPolicyGetCount() {
+ return ++report.totalPolicyGetCount;
}
/**
*
* @return the updated value of totalPolicyPostCount
*/
- public static long updateTotalPolicyPostCount() {
- return ++totalPolicyPostCount;
+ public long updateTotalPolicyPostCount() {
+ return ++report.totalPolicyPostCount;
}
/**
*
* @return the updated value of totalPolicyDeleteCount
*/
- public static long updateTotalPolicyDeleteCount() {
+ public long updateTotalPolicyDeleteCount() {
return ++totalPolicyDeleteCount;
}
*
* @return the updated value of totalPolicyTypeGetCount
*/
- public static long updateTotalPolicyTypeGetCount() {
- return ++totalPolicyTypeGetCount;
+ public long updateTotalPolicyTypeGetCount() {
+ return ++report.totalPolicyTypeGetCount;
}
/**
*
* @return the updated value of totalPolicyTypePostCount
*/
- public static long updateTotalPolicyTypePostCount() {
- return ++totalPolicyTypePostCount;
+ public long updateTotalPolicyTypePostCount() {
+ return ++report.totalPolicyTypePostCount;
}
/**
*
* @return the updated value of totalPolicyTypeDeleteCount
*/
- public static long updateTotalPolicyTypeDeleteCount() {
+ public long updateTotalPolicyTypeDeleteCount() {
return ++totalPolicyTypeDeleteCount;
}
*
* @return the updated value of policyGetSuccessCount
*/
- public static long updatePolicyGetSuccessCount() {
- return ++policyGetSuccessCount;
+ public long updatePolicyGetSuccessCount() {
+ return ++report.policyGetSuccessCount;
}
/**
*
* @return the updated value of policyGetFailureCount
*/
- public static long updatePolicyGetFailureCount() {
- return ++policyGetFailureCount;
+ public long updatePolicyGetFailureCount() {
+ return ++report.policyGetFailureCount;
}
/**
*
* @return the updated value of policyPostSuccessCount
*/
- public static long updatePolicyPostSuccessCount() {
- return ++policyPostSuccessCount;
+ public long updatePolicyPostSuccessCount() {
+ return ++report.policyPostSuccessCount;
}
/**
*
* @return the updated value of policyPostFailureCount
*/
- public static long updatePolicyPostFailureCount() {
- return ++policyPostFailureCount;
+ public long updatePolicyPostFailureCount() {
+ return ++report.policyPostFailureCount;
}
/**
*
* @return the updated value of policyDeleteSuccessCount
*/
- public static long updatePolicyDeleteSuccessCount() {
+ public long updatePolicyDeleteSuccessCount() {
return ++policyDeleteSuccessCount;
}
*
* @return the updated value of policyDeleteFailureCount
*/
- public static long updatePolicyDeleteFailureCount() {
+ public long updatePolicyDeleteFailureCount() {
return ++policyDeleteFailureCount;
}
*
* @return the updated value of policyTypeGetSuccessCount
*/
- public static long updatePolicyTypeGetSuccessCount() {
- return ++policyTypeGetSuccessCount;
+ public long updatePolicyTypeGetSuccessCount() {
+ return ++report.policyTypeGetSuccessCount;
}
/**
*
* @return the updated value of policyTypeGetFailureCount
*/
- public static long updatePolicyTypeGetFailureCount() {
- return ++policyTypeGetFailureCount;
+ public long updatePolicyTypeGetFailureCount() {
+ return ++report.policyTypeGetFailureCount;
}
/**
*
* @return the updated value of policyTypePostSuccessCount
*/
- public static long updatePolicyTypePostSuccessCount() {
- return ++policyTypePostSuccessCount;
+ public long updatePolicyTypePostSuccessCount() {
+ return ++report.policyTypePostSuccessCount;
}
/**
*
* @return the updated value of policyTypePostFailureCount
*/
- public static long updatePolicyTypePostFailureCount() {
- return ++policyTypePostFailureCount;
+ public long updatePolicyTypePostFailureCount() {
+ return ++report.policyTypePostFailureCount;
}
/**
*
* @return the updated value of policyTypeDeleteSuccessCount
*/
- public static long updatePolicyTypeDeleteSuccessCount() {
+ public long updatePolicyTypeDeleteSuccessCount() {
return ++policyTypeDeleteSuccessCount;
}
*
* @return the updated value of policyTypePostFailureCount
*/
- public static long updatePolicyTypeDeleteFailureCount() {
+ public long updatePolicyTypeDeleteFailureCount() {
return ++policyTypeDeleteFailureCount;
}
/**
- * Reset all the statistics counts to 0.
+ * Resets the statistics.
*/
- public static void resetAllStatistics() {
- totalApiCallCount = 0L;
- apiCallSuccessCount = 0L;
- apiCallFailureCount = 0L;
- totalPolicyGetCount = 0L;
- totalPolicyPostCount = 0L;
- totalPolicyDeleteCount = 0L;
- totalPolicyTypeGetCount = 0L;
- totalPolicyTypePostCount = 0L;
- totalPolicyTypeDeleteCount = 0L;
- policyGetSuccessCount = 0L;
- policyGetFailureCount = 0L;
- policyPostSuccessCount = 0L;
- policyPostFailureCount = 0L;
- policyDeleteSuccessCount = 0L;
- policyDeleteFailureCount = 0L;
- policyTypeGetSuccessCount = 0L;
- policyTypeGetFailureCount = 0L;
- policyTypePostSuccessCount = 0L;
- policyTypePostFailureCount = 0L;
- policyTypeDeleteSuccessCount = 0L;
- policyTypeDeleteFailureCount = 0L;
-
+ protected static void resetAllStatistics() {
+ instance = new ApiStatisticsManager();
}
-
}