MQTT stats changes to support instances of 5GHzL and 5GHzU where appropriate

This commit is contained in:
Mike Hansen
2020-05-25 16:30:04 -04:00
parent d140a0462e
commit 774c29557b

View File

@@ -463,7 +463,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
int radioChannel24G = 1;
int radioChannel5LG = 44;
int radioChannel5HG = 108;
int radioChannel5HG = 149;
ApElementConfiguration apElementConfiguration = (ApElementConfiguration) equipmentConfig.getDetails();
@@ -628,7 +628,6 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
LOG.error("Exception when processing populateApSsidMetrics", e);
}
if (!metricRecordList.isEmpty()) {
equipmentMetricsCollectorInterface.publishMetrics(metricRecordList);
}
@@ -839,9 +838,29 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
ClientMetrics cMetrics = new ClientMetrics();
clientMetrics.add(cMetrics);
cMetrics.setRadioType(
(clReport.getBand() == RadioBandType.BAND2G) ? RadioType.is2dot4GHz : RadioType.is5GHz);
RadioType radioType = RadioType.UNSUPPORTED;
switch (clReport.getBand()) {
case BAND2G:
radioType = RadioType.is2dot4GHz;
break;
case BAND5G:
radioType = RadioType.is5GHz;
break;
case BAND5GL:
radioType = RadioType.is5GHzL;
break;
case BAND5GU:
radioType = RadioType.is5GHzU;
break;
}
cMetrics.setRadioType(radioType);
if (cl.getMacAddress() != null)
cMetrics.setDeviceMacAddress(new MacAddress(cl.getMacAddress()));
else {
LOG.debug(
"No mac address for Client {}, cannot set device mac address for client in ApClientMetrics report.",
cl);
}
if (cl.hasStats()) {
if (cl.getStats().hasRssi()) {
@@ -850,8 +869,13 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
// we'll report each device as having a single (very long)
// session
if (cl.getMacAddress() != null)
cMetrics.setSessionId(cMetrics.getDeviceMacAddress().getAddressAsLong());
else {
LOG.debug(
"No mac address for Client {}, cannot set session id based on mac address for client in ApClientMetrics report.",
cl);
}
// populate Rx stats
if (cl.getStats().hasRxBytes()) {
cMetrics.setRxBytes(cl.getStats().getRxBytes());
@@ -904,11 +928,21 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
}
}
if (clReport.getBand() == RadioBandType.BAND2G) {
switch (clReport.getBand()) {
case BAND2G:
apClientMetrics.setClientMetrics2g(clientMetrics.toArray(new ClientMetrics[0]));
} else {
break;
case BAND5G:
apClientMetrics.setClientMetrics5g(clientMetrics.toArray(new ClientMetrics[0]));
break;
case BAND5GL:
apClientMetrics.setClientMetrics5g(clientMetrics.toArray(new ClientMetrics[0]));
break;
case BAND5GU:
apClientMetrics.setClientMetrics5g(clientMetrics.toArray(new ClientMetrics[0]));
break;
}
LOG.debug("APClientMetrics Report {}", apClientMetrics.toPrettyString());
}
@@ -927,9 +961,14 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
// Need Radios to get BSSID value
OpensyncAPRadioState radio2g = null;
OpensyncAPRadioState radio5g = null;
OpensyncAPRadioState radio5GHz = null;
OpensyncAPRadioState radio5GHzL = null;
OpensyncAPRadioState radio5GHzU = null;
OpensyncAPVIFState vif2g = null;
OpensyncAPVIFState vif5g = null;
OpensyncAPVIFState vif5GHz = null;
OpensyncAPVIFState vif5GHzL = null;
OpensyncAPVIFState vif5GHzU = null;
synchronized (opensyncNodeMap) {
OpensyncNode node = opensyncNodeMap.get(apId);
@@ -938,17 +977,21 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
return;
}
radio2g = node.getRadioForBand(RadioType.is2dot4GHz.toString());
radio5g = node.getRadioForBand(RadioType.is5GHz.toString());
radio5GHz = node.getRadioForBand(RadioType.is5GHz.toString());
radio5GHzL = node.getRadioForBand(RadioType.is5GHzL.toString());
radio5GHzU = node.getRadioForBand(RadioType.is5GHzU.toString());
if (radio2g == null || radio5g == null) {
if (radio2g == null && radio5GHzL == null && radio5GHzU == null && radio5GHz == null) {
LOG.debug("No Radio Data present for AP SSID report");
return;
}
vif2g = node.getVIFForChannel(radio2g.getChannel());
vif5g = node.getVIFForChannel(radio5g.getChannel());
vif5GHz = node.getVIFForChannel(radio5GHz.getChannel());
vif5GHzL = node.getVIFForChannel(radio5GHzL.getChannel());
vif5GHzU = node.getVIFForChannel(radio5GHzU.getChannel());
if (vif2g == null || vif5g == null) {
if (vif2g == null && vif5GHzL == null && vif5GHzU == null && vif5GHz == null) {
LOG.debug("No Wifi SSID Data present for AP SSID report");
return;
}
@@ -957,22 +1000,24 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
SingleMetricRecord smr = new SingleMetricRecord(customerId, equipmentId);
ApSsidMetrics apSsidMetrics = new ApSsidMetrics();
List<SsidStatistics> ssidStatsList2pt4GHz = new ArrayList<>();
List<SsidStatistics> ssidStatsList5GHzL = new ArrayList<>();
List<SsidStatistics> ssidStatsList5GHzU = new ArrayList<>();
List<SsidStatistics> ssidStatsList5GHz = new ArrayList<>();
if (vif2g != null)
apSsidMetrics.getSsidStats().put(RadioType.is2dot4GHz, ssidStatsList2pt4GHz);
if (vif5GHz != null)
apSsidMetrics.getSsidStats().put(RadioType.is5GHz, ssidStatsList5GHz);
if (vif5GHzL != null)
apSsidMetrics.getSsidStats().put(RadioType.is5GHzL, ssidStatsList5GHzL);
if (vif5GHzU != null)
apSsidMetrics.getSsidStats().put(RadioType.is5GHzU, ssidStatsList5GHzU);
smr.setData(apSsidMetrics);
metricRecordList.add(smr);
for (ClientReport clientReport : report.getClientsList()) {
int channel = clientReport.getChannel();
if (channel != radio5g.getChannel() && channel != radio2g.getChannel()) {
LOG.debug("Client channel {} not present on 5g {} or 2g {} radio", channel, radio5g.getChannel(),
radio2g.getChannel());
continue; // we will discard this report
}
// Always report the AP radio for that SSID if we are sending a
// report
// The '0' values will be overwritten, if applicable, from the
@@ -980,31 +1025,56 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
String encryption = null;
SsidStatistics ssidStat = new SsidStatistics();
if (clientReport.getBand() == RadioBandType.BAND2G) {
if (radio2g.getMac() != null)
ssidStat.setBssid(new MacAddress(radio2g.getMac()));
else {
LOG.debug("No mac address for radio {}, cannot set Bssid in ApSsidMetrics report.", clientReport);
}
ssidStat.setSsid(vif2g.getSsid());
ssidStat.setNumClient(vif2g.getAssociatedClients().size());
encryption = vif2g.getSecurity().get("encryption");
} else {
ssidStat.setBssid(new MacAddress(radio5g.getMac()));
ssidStat.setSsid(vif5g.getSsid());
ssidStat.setNumClient(vif5g.getAssociatedClients().size());
encryption = vif5g.getSecurity().get("encryption");
} else if (clientReport.getBand() == RadioBandType.BAND5G) {
if (radio5GHz.getMac() != null)
ssidStat.setBssid(new MacAddress(radio5GHz.getMac()));
else {
LOG.debug("No mac address for radio {}, cannot set Bssid in ApSsidMetrics report.", clientReport);
}
ssidStat.setSsid(vif5GHz.getSsid());
ssidStat.setNumClient(vif5GHz.getAssociatedClients().size());
encryption = vif5GHz.getSecurity().get("encryption");
} else if (clientReport.getBand() == RadioBandType.BAND5GL) {
if (radio5GHzL.getMac() != null)
ssidStat.setBssid(new MacAddress(radio5GHzL.getMac()));
else {
LOG.debug("No mac address for radio {}, cannot set Bssid in ApSsidMetrics report.", clientReport);
}
ssidStat.setSsid(vif5GHzL.getSsid());
ssidStat.setNumClient(vif5GHzL.getAssociatedClients().size());
encryption = vif5GHzL.getSecurity().get("encryption");
} else if (clientReport.getBand() == RadioBandType.BAND5GU) {
if (radio5GHzU.getMac() != null)
ssidStat.setBssid(new MacAddress(radio5GHzU.getMac()));
else {
LOG.debug("No mac address for radio {}, cannot set Bssid in ApSsidMetrics report.", clientReport);
}
ssidStat.setSsid(vif5GHzU.getSsid());
ssidStat.setNumClient(vif5GHzU.getAssociatedClients().size());
encryption = vif5GHzU.getSecurity().get("encryption");
}
SecurityType securityType = SecurityType.UNSUPPORTED;
if (encryption != null) {
if (encryption.endsWith("PSK")) {
securityType = securityType.PSK;
securityType = SecurityType.PSK;
} else if (encryption.equals("RADIUS")) {
securityType = securityType.RADIUS;
securityType = SecurityType.RADIUS;
} else if (encryption.equals("OPEN")) {
securityType = securityType.OPEN;
securityType = SecurityType.OPEN;
}
}
long txBytes = 0;
long rxBytes = 0;
long txBytes = 0L;
long rxBytes = 0L;
int txErrors = 0;
int rxRetries = 0;
int lastRssi = 0;
@@ -1013,12 +1083,6 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
if (client.hasSsid() && client.hasStats()) {
if (!client.getSsid().equals(vif2g.getSsid()) && !client.getSsid().equals(vif5g.getSsid())) {
LOG.debug("Client SSID {} does not match SSIDs on Radio 2G {} or Radio 5G {} ",
client.getSsid(), vif2g.getSsid(), vif5g.getSsid());
continue;
}
txBytes += client.getStats().getTxBytes();
rxBytes += client.getStats().getRxBytes();
txErrors += client.getStats().getTxErrors();
@@ -1041,25 +1105,49 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
if (clientReport.getBand() == RadioBandType.BAND2G) {
ssidStatsList2pt4GHz.add(ssidStat);
} else {
} else if (clientReport.getBand() == RadioBandType.BAND5G) {
ssidStatsList5GHz.add(ssidStat);
}
} else if (clientReport.getBand() == RadioBandType.BAND5GL) {
ssidStatsList5GHzL.add(ssidStat);
} else if (clientReport.getBand() == RadioBandType.BAND5GU) {
ssidStatsList5GHzU.add(ssidStat);
}
if (apSsidMetrics.getSsidStatsCount(RadioType.is2dot4GHz) == 0) {
}
if (apSsidMetrics.getSsidStatsCount(RadioType.is2dot4GHz) == 0 && vif2g != null) {
SsidStatistics ssidStat = new SsidStatistics();
if (radio2g.getMac() != null)
ssidStat.setBssid(new MacAddress(radio2g.getMac()));
ssidStat.setSsid(vif2g.getSsid());
ssidStat.setNumClient(vif2g.getAssociatedClients().size());
ssidStatsList2pt4GHz.add(ssidStat);
}
if (apSsidMetrics.getSsidStatsCount(RadioType.is5GHz) == 0) {
if (apSsidMetrics.getSsidStatsCount(RadioType.is5GHz) == 0 && vif5GHz != null) {
SsidStatistics ssidStat = new SsidStatistics();
ssidStat.setBssid(new MacAddress(radio5g.getMac()));
ssidStat.setSsid(vif5g.getSsid());
ssidStat.setNumClient(vif5g.getAssociatedClients().size());
ssidStatsList5GHz.add(ssidStat);
if (radio5GHz.getMac() != null)
ssidStat.setBssid(new MacAddress(radio5GHz.getMac()));
ssidStat.setSsid(vif5GHz.getSsid());
ssidStat.setNumClient(vif5GHz.getAssociatedClients().size());
ssidStatsList5GHzL.add(ssidStat);
}
if (apSsidMetrics.getSsidStatsCount(RadioType.is5GHzL) == 0 && vif5GHzL != null) {
SsidStatistics ssidStat = new SsidStatistics();
if (radio5GHzL.getMac() != null)
ssidStat.setBssid(new MacAddress(radio5GHzL.getMac()));
ssidStat.setSsid(vif5GHzL.getSsid());
ssidStat.setNumClient(vif5GHzL.getAssociatedClients().size());
ssidStatsList5GHzL.add(ssidStat);
}
if (apSsidMetrics.getSsidStatsCount(RadioType.is5GHzU) == 0 && vif5GHzU != null) {
SsidStatistics ssidStat = new SsidStatistics();
if (radio5GHzU.getMac() != null)
ssidStat.setBssid(new MacAddress(radio5GHzU.getMac()));
ssidStat.setSsid(vif5GHzU.getSsid());
ssidStat.setNumClient(vif5GHzU.getAssociatedClients().size());
ssidStatsList5GHzU.add(ssidStat);
}
LOG.debug("Created ApSsidMetrics Report {}", apSsidMetrics.toPrettyString());
@@ -1070,7 +1158,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
RadioBandType band, long timestamp, Client client, SecurityType securityType) {
boolean found = false;
List<com.telecominfraproject.wlan.client.models.Client> clientRecords = clientServiceInterface.get(customerId, Collections.singleton(new MacAddress(client.getMacAddress())));
List<com.telecominfraproject.wlan.client.models.Client> clientRecords = clientServiceInterface.get(customerId,
Collections.singleton(new MacAddress(client.getMacAddress())));
if (!clientRecords.isEmpty()) {
com.telecominfraproject.wlan.client.models.Client record = clientRecords.get(0);
LOG.debug("Found Client {}", record.toPrettyString());
@@ -1089,8 +1178,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
clientRecord.setDetails(cid);
try {
LOG.debug("Created Client {}",
clientServiceInterface.create(clientRecord).toPrettyString());
LOG.debug("Created Client {}", clientServiceInterface.create(clientRecord).toPrettyString());
} catch (Exception e) {
LOG.error("Unabled to create client for {}", client.getMacAddress(), e);
}
@@ -1098,7 +1186,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
try {
ClientSession clientSession = clientServiceInterface.getSessionOrNull(customerId, equipmentId, new MacAddress(client.getMacAddress()));
ClientSession clientSession = clientServiceInterface.getSessionOrNull(customerId, equipmentId,
new MacAddress(client.getMacAddress()));
if (clientSession == null) {
LOG.debug("No session found for Client {}, creating new one.", client.getMacAddress());
clientSession = new ClientSession();
@@ -1108,7 +1197,21 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
ClientSessionDetails clientSessionDetails = new ClientSessionDetails();
clientSession.setDetails(clientSessionDetails);
RadioType radioType = band == RadioBandType.BAND2G ? RadioType.is2dot4GHz : RadioType.is5GHz;
RadioType radioType = RadioType.UNSUPPORTED;
switch (band) {
case BAND2G:
radioType = RadioType.is2dot4GHz;
break;
case BAND5G:
radioType = RadioType.is5GHz;
break;
case BAND5GL:
radioType = RadioType.is5GHzL;
break;
case BAND5GU:
radioType = RadioType.is5GHzU;
break;
}
clientSessionDetails.setRadioType(radioType);
clientSessionDetails.setSessionId(clientSession.getMacAddress().getAddressAsLong());
clientSessionDetails.setSsid(client.getSsid());
@@ -1159,8 +1262,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
if (client.hasStats()) {
if (metricDetails == null) {
LOG.debug("No metric details for client {} session {}, creating",
clientSession.getMacAddress(), clientSessionDetails.getSessionId());
LOG.debug("No metric details for client {} session {}, creating", clientSession.getMacAddress(),
clientSessionDetails.getSessionId());
metricDetails = new ClientSessionMetricDetails();
}
metricDetails.setRssi(client.getStats().getRssi());
@@ -1184,8 +1287,9 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
}
//TODO: We support bulk updates for sessions, which is more efficient way of updating many sessions at once.
//Need to rewrite this to make use of bulk operation.
// TODO: We support bulk updates for sessions, which is more efficient way of
// updating many sessions at once.
// Need to rewrite this to make use of bulk operation.
ClientSession session = clientServiceInterface.updateSession(clientSession);
if (session != null)