blob: 921de5f621f52f0e0c4bdaf0fdf9a517e1b6a531 [file] [log] [blame]
kartikey dubeye1545422019-05-22 12:53:45 +00001/*
2 * Copyright 2018-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.opencord.aaa;
18
Vijaykumar Kushwahaa54ce552019-06-18 09:37:42 +000019import java.util.LinkedList;
kartikey dubeye1545422019-05-22 12:53:45 +000020import java.util.concurrent.atomic.AtomicLong;
21
22public class AaaStatistics {
Vijaykumar Kushwahaa54ce552019-06-18 09:37:42 +000023 // Number of access accept packets sent to the server
kartikey dubeye1545422019-05-22 12:53:45 +000024 private AtomicLong acceptResponsesRx = new AtomicLong();
Vijaykumar Kushwahaa54ce552019-06-18 09:37:42 +000025 // Number of access reject packets sent to the server
kartikey dubeye1545422019-05-22 12:53:45 +000026 private AtomicLong rejectResponsesRx = new AtomicLong();
Vijaykumar Kushwahaa54ce552019-06-18 09:37:42 +000027 // Number of access challenge packets sent to the server
kartikey dubeye1545422019-05-22 12:53:45 +000028 private AtomicLong challengeResponsesRx = new AtomicLong();
Vijaykumar Kushwahaa54ce552019-06-18 09:37:42 +000029 // Number of access request packets sent to the server
kartikey dubeye1545422019-05-22 12:53:45 +000030 private AtomicLong accessRequestsTx = new AtomicLong();
Vijaykumar Kushwahaa54ce552019-06-18 09:37:42 +000031 // Number of access request packets pending a response from the server
kartikey dubeye1545422019-05-22 12:53:45 +000032 private AtomicLong pendingRequests = new AtomicLong();
Vijaykumar Kushwahaa54ce552019-06-18 09:37:42 +000033 // Number of packets of an unknown RADIUS type received from the accounting
34 // server
kartikey dubeye1545422019-05-22 12:53:45 +000035 private AtomicLong unknownTypeRx = new AtomicLong();
Vijaykumar Kushwahaa54ce552019-06-18 09:37:42 +000036 // Number of access response packets received from the server with an invalid
37 // validator
kartikey dubeye1545422019-05-22 12:53:45 +000038 private AtomicLong invalidValidatorsRx = new AtomicLong();
Vijaykumar Kushwahaa54ce552019-06-18 09:37:42 +000039 // Number of dropped packets received from the accounting server
kartikey dubeye1545422019-05-22 12:53:45 +000040 private AtomicLong droppedResponsesRx = new AtomicLong();
Vijaykumar Kushwahaa54ce552019-06-18 09:37:42 +000041 // Number of malformed access response packets received from the server
kartikey dubeye1545422019-05-22 12:53:45 +000042 private AtomicLong malformedResponsesRx = new AtomicLong();
Vijaykumar Kushwahaa54ce552019-06-18 09:37:42 +000043 // Number of packets received from an unknown server
kartikey dubeye1545422019-05-22 12:53:45 +000044 private AtomicLong unknownServerRx = new AtomicLong();
Vijaykumar Kushwahaa54ce552019-06-18 09:37:42 +000045 // Roundtrip packet time to the accounting server
kartikey dubeye1545422019-05-22 12:53:45 +000046 private AtomicLong requestRttMilis = new AtomicLong();
Vijaykumar Kushwahaa54ce552019-06-18 09:37:42 +000047 // Number of access request packets retransmitted to the server
kartikey dubeye1545422019-05-22 12:53:45 +000048 private AtomicLong requestReTx = new AtomicLong();
Vijaykumar Kushwahaa54ce552019-06-18 09:37:42 +000049 // Number of sessions expired
kartikey dubeye1545422019-05-22 12:53:45 +000050 private AtomicLong numberOfSessionsExpired = new AtomicLong();
51
Vijaykumar Kushwahaa54ce552019-06-18 09:37:42 +000052 private LinkedList<Long> packetRoundTripTimeList = new LinkedList<Long>();
53
54 public LinkedList<Long> getPacketRoundTripTimeList() {
55 return packetRoundTripTimeList;
56 }
57
58 public int getPacketRoundTripTimeListSize() {
59 return packetRoundTripTimeList.size();
60 }
61
62 public void clearPacketRoundTripTimeList() {
63 packetRoundTripTimeList.clear();
64 }
65
66 public void getPacketRoundTripTimeListRemoveFirst() {
67 packetRoundTripTimeList.removeFirst();
68 }
69
70 public void getPacketRoundTripTimeListAdd(long time) {
71 packetRoundTripTimeList.add(time);
72 }
73
kartikey dubeye1545422019-05-22 12:53:45 +000074 public Long getRequestReTx() {
75 return requestReTx.get();
76 }
77
78 public void setRequestRttMilis(AtomicLong requestRttMilis) {
79 this.requestRttMilis = requestRttMilis;
80 }
81
82 public Long getUnknownServerRx() {
83 return unknownServerRx.get();
84 }
85
86 public Long getRequestRttMilis() {
87 return requestRttMilis.get();
88 }
89
90 public Long getMalformedResponsesRx() {
91 return malformedResponsesRx.get();
92 }
93
94 public Long getDroppedResponsesRx() {
95 return droppedResponsesRx.get();
96 }
97
98 public Long getInvalidValidatorsRx() {
99 return invalidValidatorsRx.get();
100 }
101
102 public Long getAcceptResponsesRx() {
103 return acceptResponsesRx.get();
104 }
105
106 public Long getRejectResponsesRx() {
107 return rejectResponsesRx.get();
108 }
109
110 public Long getChallengeResponsesRx() {
111 return challengeResponsesRx.get();
112 }
113
114 public Long getAccessRequestsTx() {
115 return accessRequestsTx.get();
116 }
117
118 public Long getPendingRequests() {
119 return pendingRequests.get();
120 }
121
122 public Long getUnknownTypeRx() {
123 return unknownTypeRx.get();
124 }
125
126 public void increaseAcceptResponsesRx() {
127 acceptResponsesRx.incrementAndGet();
128 }
129
130 public void increaseRejectResponsesRx() {
131 rejectResponsesRx.incrementAndGet();
132 }
133
134 public void increaseChallengeResponsesRx() {
135 challengeResponsesRx.incrementAndGet();
136 }
137
138 public void increaseAccessRequestsTx() {
139 accessRequestsTx.incrementAndGet();
140 }
141
142 public void increaseRequestReTx() {
143 requestReTx.incrementAndGet();
144 }
145
146 public void increaseOrDecreasePendingRequests(boolean isIncrement) {
147 if (isIncrement) {
148 pendingRequests.incrementAndGet();
149 } else {
150 pendingRequests.decrementAndGet();
151 }
152 }
153
154 public void increaseUnknownTypeRx() {
155 unknownTypeRx.incrementAndGet();
156 }
157
158 public void increaseMalformedResponsesRx() {
159 malformedResponsesRx.incrementAndGet();
160 }
161
162 public void increaseInvalidValidatorsRx() {
163 invalidValidatorsRx.incrementAndGet();
164 }
165
166 public void incrementUnknownServerRx() {
167 unknownServerRx.incrementAndGet();
168 }
169
170 public void incrementNumberOfSessionsExpired() {
171 numberOfSessionsExpired.incrementAndGet();
172 }
173
174 public void countDroppedResponsesRx() {
175 long numberOfDroppedPackets = invalidValidatorsRx.get();
176 numberOfDroppedPackets += unknownTypeRx.get();
177 numberOfDroppedPackets += malformedResponsesRx.get();
178 numberOfDroppedPackets += numberOfSessionsExpired.get();
179 this.droppedResponsesRx = new AtomicLong(numberOfDroppedPackets);
180 }
Vijaykumar Kushwahaa54ce552019-06-18 09:37:42 +0000181
182 public void resetAllCounters() {
183 clearPacketRoundTripTimeList();
184
185 accessRequestsTx.set(0);
186 acceptResponsesRx.set(0);
187 challengeResponsesRx.set(0);
188 droppedResponsesRx.set(0);
189 invalidValidatorsRx.set(0);
190 malformedResponsesRx.set(0);
191 pendingRequests.set(0);
192 rejectResponsesRx.set(0);
193 requestReTx.set(0);
194 requestRttMilis.set(0);
195 unknownServerRx.set(0);
196 unknownTypeRx.set(0);
197 }
kartikey dubeye1545422019-05-22 12:53:45 +0000198}