mirror of
https://github.com/Telecominfraproject/wlan-cloud-rrm.git
synced 2025-10-29 01:32:21 +00:00
Follow-up on stats aggregation (#96)
* fix some comments from Jerrey Signed-off-by: zhiqiand <zhiqian@fb.com> * fix some comments Signed-off-by: zhiqiand <zhiqian@fb.com> Signed-off-by: zhiqiand <zhiqian@fb.com>
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
|
||||
package com.facebook.openwifirrm.modules;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -271,7 +270,7 @@ public class Modeler implements Runnable {
|
||||
State stateModel = gson.fromJson(state, State.class);
|
||||
dataModel.latestStates.computeIfAbsent(
|
||||
device.serialNumber,
|
||||
k -> Collections.synchronizedList(new LinkedList<>())
|
||||
k -> new LinkedList<>()
|
||||
).add(stateModel);
|
||||
logger.debug(
|
||||
"Device {}: added initial state from uCentralGw",
|
||||
@@ -307,10 +306,11 @@ public class Modeler implements Runnable {
|
||||
List<State> latestStatesList = dataModel.latestStates
|
||||
.computeIfAbsent(
|
||||
record.serialNumber,
|
||||
k -> Collections
|
||||
.synchronizedList(new LinkedList<>())
|
||||
k -> new LinkedList<>()
|
||||
);
|
||||
if (latestStatesList.size() >= params.stateBufferSize) {
|
||||
while (
|
||||
latestStatesList.size() >= params.stateBufferSize
|
||||
) {
|
||||
latestStatesList.remove(0);
|
||||
}
|
||||
latestStatesList.add(stateModel);
|
||||
|
||||
@@ -169,48 +169,28 @@ public class AggregatedState {
|
||||
this.radio = new Radio(radioInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(bssid, station, radio);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
AggregatedState other = (AggregatedState) obj;
|
||||
|
||||
return bssid == other.bssid && station == other.station &&
|
||||
connected == other.connected && inactive == other.inactive && rssi
|
||||
.equals(other.rssi) &&
|
||||
rxBytes == other.rxBytes && rxBytes == other.rxPackets &&
|
||||
Objects.equals(rxRate, other.rxRate) &&
|
||||
txBytes == other.txBytes && txDuration == other.txDuration &&
|
||||
txFailed == other.txFailed && txPackets == other.txPackets &&
|
||||
Objects.equals(txRate, other.txRate) &&
|
||||
txRetries == other.txRetries && ackSignal == other.ackSignal &&
|
||||
ackSignalAvg == other.ackSignalAvg &&
|
||||
Objects.equals(radio, other.radio);
|
||||
/**
|
||||
* Check whether the passed-in AggregatedState and this one match for aggregation.
|
||||
* If the two match in bssid, station and radio. Then they could be aggregated.
|
||||
*
|
||||
* @param state the reference AggregatedState with which to check with.
|
||||
* @return boolean return true if the two matches for aggregation.
|
||||
*/
|
||||
public boolean matchesForAggregation(AggregatedState state) {
|
||||
return bssid == state.bssid && station == state.station &&
|
||||
Objects.equals(radio, state.radio);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an AggregatedState to this AggregatedState. Succeed only when the two
|
||||
* matches in hashCode.
|
||||
* match for aggregation.
|
||||
*
|
||||
* @param state input AggregatedState
|
||||
* @return boolean true if the two matches in bssid, station, channel,
|
||||
* @return boolean true if the two match in bssid, station, channel,
|
||||
* channel_width and tx_power
|
||||
*/
|
||||
public boolean add(AggregatedState state) {
|
||||
if (hashCode() == state.hashCode()) {
|
||||
if (matchesForAggregation(state)) {
|
||||
this.rssi.addAll(state.rssi);
|
||||
this.rxRate.add(state.rxRate);
|
||||
this.txRate.add(state.txRate);
|
||||
|
||||
Reference in New Issue
Block a user