[SEBA-37] Added 11 Statistics counters for Accounting Server operations
Change-Id: I7dda193129e5dffe62907775aaf8dfdc5b3f1bf1
diff --git a/api/src/main/java/org/opencord/aaa/AaaConfig.java b/api/src/main/java/org/opencord/aaa/AaaConfig.java
index 3072ff5..2c4aa7b 100644
--- a/api/src/main/java/org/opencord/aaa/AaaConfig.java
+++ b/api/src/main/java/org/opencord/aaa/AaaConfig.java
@@ -85,7 +85,6 @@
// Packet Customizer Default value
protected static final String DEFAULT_PACKET_CUSTOMIZER = "default";
-
/**
* Gets the value of a string property, protecting for an empty
* JSON object.
diff --git a/api/src/main/java/org/opencord/aaa/AaaStatistics.java b/api/src/main/java/org/opencord/aaa/AaaStatistics.java
new file mode 100644
index 0000000..9764427
--- /dev/null
+++ b/api/src/main/java/org/opencord/aaa/AaaStatistics.java
@@ -0,0 +1,156 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.opencord.aaa;
+
+import java.util.concurrent.atomic.AtomicLong;
+
+public class AaaStatistics {
+ //Number of access accept packets sent to the server
+ private AtomicLong acceptResponsesRx = new AtomicLong();
+ //Number of access reject packets sent to the server
+ private AtomicLong rejectResponsesRx = new AtomicLong();
+ //Number of access challenge packets sent to the server
+ private AtomicLong challengeResponsesRx = new AtomicLong();
+ //Number of access request packets sent to the server
+ private AtomicLong accessRequestsTx = new AtomicLong();
+ //Number of access request packets pending a response from the server
+ private AtomicLong pendingRequests = new AtomicLong();
+ //Number of packets of an unknown RADIUS type received from the accounting server
+ private AtomicLong unknownTypeRx = new AtomicLong();
+ //Number of access response packets received from the server with an invalid validator
+ private AtomicLong invalidValidatorsRx = new AtomicLong();
+ //Number of dropped packets received from the accounting server
+ private AtomicLong droppedResponsesRx = new AtomicLong();
+ //Number of malformed access response packets received from the server
+ private AtomicLong malformedResponsesRx = new AtomicLong();
+ //Number of packets received from an unknown server
+ private AtomicLong unknownServerRx = new AtomicLong();
+ //Roundtrip packet time to the accounting server
+ private AtomicLong requestRttMilis = new AtomicLong();
+ //Number of access request packets retransmitted to the server
+ private AtomicLong requestReTx = new AtomicLong();
+ //Number of sessions expired
+ private AtomicLong numberOfSessionsExpired = new AtomicLong();
+
+ public Long getRequestReTx() {
+ return requestReTx.get();
+ }
+
+ public void setRequestRttMilis(AtomicLong requestRttMilis) {
+ this.requestRttMilis = requestRttMilis;
+ }
+
+ public Long getUnknownServerRx() {
+ return unknownServerRx.get();
+ }
+
+ public Long getRequestRttMilis() {
+ return requestRttMilis.get();
+ }
+
+ public Long getMalformedResponsesRx() {
+ return malformedResponsesRx.get();
+ }
+
+ public Long getDroppedResponsesRx() {
+ return droppedResponsesRx.get();
+ }
+
+ public Long getInvalidValidatorsRx() {
+ return invalidValidatorsRx.get();
+ }
+
+ public Long getAcceptResponsesRx() {
+ return acceptResponsesRx.get();
+ }
+
+ public Long getRejectResponsesRx() {
+ return rejectResponsesRx.get();
+ }
+
+ public Long getChallengeResponsesRx() {
+ return challengeResponsesRx.get();
+ }
+
+ public Long getAccessRequestsTx() {
+ return accessRequestsTx.get();
+ }
+
+ public Long getPendingRequests() {
+ return pendingRequests.get();
+ }
+
+ public Long getUnknownTypeRx() {
+ return unknownTypeRx.get();
+ }
+
+ public void increaseAcceptResponsesRx() {
+ acceptResponsesRx.incrementAndGet();
+ }
+
+ public void increaseRejectResponsesRx() {
+ rejectResponsesRx.incrementAndGet();
+ }
+
+ public void increaseChallengeResponsesRx() {
+ challengeResponsesRx.incrementAndGet();
+ }
+
+ public void increaseAccessRequestsTx() {
+ accessRequestsTx.incrementAndGet();
+ }
+
+ public void increaseRequestReTx() {
+ requestReTx.incrementAndGet();
+ }
+
+ public void increaseOrDecreasePendingRequests(boolean isIncrement) {
+ if (isIncrement) {
+ pendingRequests.incrementAndGet();
+ } else {
+ pendingRequests.decrementAndGet();
+ }
+ }
+
+ public void increaseUnknownTypeRx() {
+ unknownTypeRx.incrementAndGet();
+ }
+
+ public void increaseMalformedResponsesRx() {
+ malformedResponsesRx.incrementAndGet();
+ }
+
+ public void increaseInvalidValidatorsRx() {
+ invalidValidatorsRx.incrementAndGet();
+ }
+
+ public void incrementUnknownServerRx() {
+ unknownServerRx.incrementAndGet();
+ }
+
+ public void incrementNumberOfSessionsExpired() {
+ numberOfSessionsExpired.incrementAndGet();
+ }
+
+ public void countDroppedResponsesRx() {
+ long numberOfDroppedPackets = invalidValidatorsRx.get();
+ numberOfDroppedPackets += unknownTypeRx.get();
+ numberOfDroppedPackets += malformedResponsesRx.get();
+ numberOfDroppedPackets += numberOfSessionsExpired.get();
+ this.droppedResponsesRx = new AtomicLong(numberOfDroppedPackets);
+ }
+}
diff --git a/api/src/main/java/org/opencord/aaa/AuthenticationStatisticsDelegate.java b/api/src/main/java/org/opencord/aaa/AuthenticationStatisticsDelegate.java
new file mode 100644
index 0000000..b82e82f
--- /dev/null
+++ b/api/src/main/java/org/opencord/aaa/AuthenticationStatisticsDelegate.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.opencord.aaa;
+
+import org.onosproject.store.StoreDelegate;
+
+
+/**
+ * Delegate for Authentication Statistics.
+ */
+
+public interface AuthenticationStatisticsDelegate extends StoreDelegate<AuthenticationStatisticsEvent> {
+}
diff --git a/api/src/main/java/org/opencord/aaa/AuthenticationStatisticsEvent.java b/api/src/main/java/org/opencord/aaa/AuthenticationStatisticsEvent.java
new file mode 100644
index 0000000..11c00e3
--- /dev/null
+++ b/api/src/main/java/org/opencord/aaa/AuthenticationStatisticsEvent.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.opencord.aaa;
+import org.onosproject.event.AbstractEvent;
+/**
+ * Event indicating the Accounting Data of AAA.
+ */
+public class AuthenticationStatisticsEvent extends
+ AbstractEvent<AuthenticationStatisticsEvent.Type, AaaStatistics> {
+/**
+ * Accounting data.
+ * AuthenticationMetrixEvent event type.
+ */
+ public enum Type {
+ /**
+ * signifies that the Authentication Metrix Event stats has been updated.
+ */
+ STATS_UPDATE
+ }
+ public AuthenticationStatisticsEvent(Type type, AaaStatistics stats) {
+ super(type, stats);
+ }
+}
diff --git a/api/src/main/java/org/opencord/aaa/AuthenticationStatisticsEventListener.java b/api/src/main/java/org/opencord/aaa/AuthenticationStatisticsEventListener.java
new file mode 100644
index 0000000..5cef070
--- /dev/null
+++ b/api/src/main/java/org/opencord/aaa/AuthenticationStatisticsEventListener.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.opencord.aaa;
+
+import org.onosproject.event.EventListener;
+
+/**
+ * Listener for accounting events.
+ */
+public interface AuthenticationStatisticsEventListener extends
+ EventListener<AuthenticationStatisticsEvent> {
+}
\ No newline at end of file
diff --git a/api/src/main/java/org/opencord/aaa/AuthenticationStatisticsService.java b/api/src/main/java/org/opencord/aaa/AuthenticationStatisticsService.java
new file mode 100644
index 0000000..bdb9f2d
--- /dev/null
+++ b/api/src/main/java/org/opencord/aaa/AuthenticationStatisticsService.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.opencord.aaa;
+
+import org.onosproject.event.ListenerService;
+
+/**
+ * Service for interacting with accounting module.
+ */
+
+public interface AuthenticationStatisticsService extends
+ ListenerService<AuthenticationStatisticsEvent, AuthenticationStatisticsEventListener> {
+
+ /**
+ * Returns AaaStatistics object.
+ *
+ * @return AaaStatistics
+ */
+ public AaaStatistics getAaaStats();
+
+ /**
+ * Returns AuthenticationStatisticsDelegate object.
+ *
+ * @return AuthenticationStatisticsDelegate
+ */
+ public AuthenticationStatisticsDelegate getStatsDelegate();
+
+ /**
+ * Handle the roundTrip time of Radius Packet.
+ *
+ * @param identifier identifier of incoming radius packet
+ */
+ public void handleRoundtripTime(byte identifier);
+
+ /**
+ * Calculate average roundTrip time of multiple Packets.
+ */
+ public void calculatePacketRoundtripTime();
+
+ /**
+ * Put the identifier value to map.
+ *
+ * @param identifier identifier of incoming radius packet
+ */
+ public void putOutgoingIdentifierToMap(byte identifier);
+}