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 8a7bed840c

View File

@@ -628,7 +628,6 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
LOG.error("Exception when processing populateApSsidMetrics", e); LOG.error("Exception when processing populateApSsidMetrics", e);
} }
if (!metricRecordList.isEmpty()) { if (!metricRecordList.isEmpty()) {
equipmentMetricsCollectorInterface.publishMetrics(metricRecordList); equipmentMetricsCollectorInterface.publishMetrics(metricRecordList);
} }
@@ -839,8 +838,22 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
ClientMetrics cMetrics = new ClientMetrics(); ClientMetrics cMetrics = new ClientMetrics();
clientMetrics.add(cMetrics); clientMetrics.add(cMetrics);
cMetrics.setRadioType( RadioType radioType = RadioType.UNSUPPORTED;
(clReport.getBand() == RadioBandType.BAND2G) ? RadioType.is2dot4GHz : RadioType.is5GHz); 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);
cMetrics.setDeviceMacAddress(new MacAddress(cl.getMacAddress())); cMetrics.setDeviceMacAddress(new MacAddress(cl.getMacAddress()));
if (cl.hasStats()) { if (cl.hasStats()) {
@@ -904,11 +917,21 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
} }
} }
if (clReport.getBand() == RadioBandType.BAND2G) { switch (clReport.getBand()) {
case BAND2G:
apClientMetrics.setClientMetrics2g(clientMetrics.toArray(new ClientMetrics[0])); apClientMetrics.setClientMetrics2g(clientMetrics.toArray(new ClientMetrics[0]));
} else { break;
case BAND5G:
apClientMetrics.setClientMetrics5g(clientMetrics.toArray(new ClientMetrics[0])); 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()); LOG.debug("APClientMetrics Report {}", apClientMetrics.toPrettyString());
} }
@@ -927,9 +950,14 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
// Need Radios to get BSSID value // Need Radios to get BSSID value
OpensyncAPRadioState radio2g = null; OpensyncAPRadioState radio2g = null;
OpensyncAPRadioState radio5g = null; OpensyncAPRadioState radio5GHz = null;
OpensyncAPRadioState radio5GHzL = null;
OpensyncAPRadioState radio5GHzU = null;
OpensyncAPVIFState vif2g = null; OpensyncAPVIFState vif2g = null;
OpensyncAPVIFState vif5g = null; OpensyncAPVIFState vif5GHz = null;
OpensyncAPVIFState vif5GHzL = null;
OpensyncAPVIFState vif5GHzU = null;
synchronized (opensyncNodeMap) { synchronized (opensyncNodeMap) {
OpensyncNode node = opensyncNodeMap.get(apId); OpensyncNode node = opensyncNodeMap.get(apId);
@@ -938,17 +966,21 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
return; return;
} }
radio2g = node.getRadioForBand(RadioType.is2dot4GHz.toString()); 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"); LOG.debug("No Radio Data present for AP SSID report");
return; return;
} }
vif2g = node.getVIFForChannel(radio2g.getChannel()); 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"); LOG.debug("No Wifi SSID Data present for AP SSID report");
return; return;
} }
@@ -957,22 +989,24 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
SingleMetricRecord smr = new SingleMetricRecord(customerId, equipmentId); SingleMetricRecord smr = new SingleMetricRecord(customerId, equipmentId);
ApSsidMetrics apSsidMetrics = new ApSsidMetrics(); ApSsidMetrics apSsidMetrics = new ApSsidMetrics();
List<SsidStatistics> ssidStatsList2pt4GHz = new ArrayList<>(); List<SsidStatistics> ssidStatsList2pt4GHz = new ArrayList<>();
List<SsidStatistics> ssidStatsList5GHzL = new ArrayList<>();
List<SsidStatistics> ssidStatsList5GHzU = new ArrayList<>();
List<SsidStatistics> ssidStatsList5GHz = new ArrayList<>(); List<SsidStatistics> ssidStatsList5GHz = new ArrayList<>();
if (vif2g != null)
apSsidMetrics.getSsidStats().put(RadioType.is2dot4GHz, ssidStatsList2pt4GHz); apSsidMetrics.getSsidStats().put(RadioType.is2dot4GHz, ssidStatsList2pt4GHz);
if (vif5GHz != null)
apSsidMetrics.getSsidStats().put(RadioType.is5GHz, ssidStatsList5GHz); 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); smr.setData(apSsidMetrics);
metricRecordList.add(smr); metricRecordList.add(smr);
for (ClientReport clientReport : report.getClientsList()) { 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 // Always report the AP radio for that SSID if we are sending a
// report // report
// The '0' values will be overwritten, if applicable, from the // The '0' values will be overwritten, if applicable, from the
@@ -984,27 +1018,36 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
ssidStat.setSsid(vif2g.getSsid()); ssidStat.setSsid(vif2g.getSsid());
ssidStat.setNumClient(vif2g.getAssociatedClients().size()); ssidStat.setNumClient(vif2g.getAssociatedClients().size());
encryption = vif2g.getSecurity().get("encryption"); encryption = vif2g.getSecurity().get("encryption");
} else { } else if (clientReport.getBand() == RadioBandType.BAND5G) {
ssidStat.setBssid(new MacAddress(radio5g.getMac())); ssidStat.setBssid(new MacAddress(radio5GHz.getMac()));
ssidStat.setSsid(vif5g.getSsid()); ssidStat.setSsid(vif5GHz.getSsid());
ssidStat.setNumClient(vif5g.getAssociatedClients().size()); ssidStat.setNumClient(vif5GHz.getAssociatedClients().size());
encryption = vif5g.getSecurity().get("encryption"); encryption = vif5GHz.getSecurity().get("encryption");
} else if (clientReport.getBand() == RadioBandType.BAND5GL) {
ssidStat.setBssid(new MacAddress(radio5GHzL.getMac()));
ssidStat.setSsid(vif5GHzL.getSsid());
ssidStat.setNumClient(vif5GHzL.getAssociatedClients().size());
encryption = vif5GHzL.getSecurity().get("encryption");
} else if (clientReport.getBand() == RadioBandType.BAND5GU) {
ssidStat.setBssid(new MacAddress(radio5GHzU.getMac()));
ssidStat.setSsid(vif5GHzU.getSsid());
ssidStat.setNumClient(vif5GHzU.getAssociatedClients().size());
encryption = vif5GHzU.getSecurity().get("encryption");
} }
SecurityType securityType = SecurityType.UNSUPPORTED; SecurityType securityType = SecurityType.UNSUPPORTED;
if (encryption != null) { if (encryption != null) {
if (encryption.endsWith("PSK")) { if (encryption.endsWith("PSK")) {
securityType = securityType.PSK; securityType = SecurityType.PSK;
} else if (encryption.equals("RADIUS")) { } else if (encryption.equals("RADIUS")) {
securityType = securityType.RADIUS; securityType = SecurityType.RADIUS;
} else if (encryption.equals("OPEN")) { } else if (encryption.equals("OPEN")) {
securityType = securityType.OPEN; securityType = SecurityType.OPEN;
} }
} }
long txBytes = 0; long txBytes = 0L;
long rxBytes = 0; long rxBytes = 0L;
int txErrors = 0; int txErrors = 0;
int rxRetries = 0; int rxRetries = 0;
int lastRssi = 0; int lastRssi = 0;
@@ -1013,12 +1056,6 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
if (client.hasSsid() && client.hasStats()) { 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(); txBytes += client.getStats().getTxBytes();
rxBytes += client.getStats().getRxBytes(); rxBytes += client.getStats().getRxBytes();
txErrors += client.getStats().getTxErrors(); txErrors += client.getStats().getTxErrors();
@@ -1041,12 +1078,18 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
if (clientReport.getBand() == RadioBandType.BAND2G) { if (clientReport.getBand() == RadioBandType.BAND2G) {
ssidStatsList2pt4GHz.add(ssidStat); ssidStatsList2pt4GHz.add(ssidStat);
} else { } else if (clientReport.getBand() == RadioBandType.BAND5G) {
ssidStatsList5GHz.add(ssidStat); 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(); SsidStatistics ssidStat = new SsidStatistics();
ssidStat.setBssid(new MacAddress(radio2g.getMac())); ssidStat.setBssid(new MacAddress(radio2g.getMac()));
ssidStat.setSsid(vif2g.getSsid()); ssidStat.setSsid(vif2g.getSsid());
@@ -1054,12 +1097,26 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
ssidStatsList2pt4GHz.add(ssidStat); ssidStatsList2pt4GHz.add(ssidStat);
} }
if (apSsidMetrics.getSsidStatsCount(RadioType.is5GHz) == 0) { if (apSsidMetrics.getSsidStatsCount(RadioType.is5GHz) == 0 && vif5GHz != null) {
SsidStatistics ssidStat = new SsidStatistics(); SsidStatistics ssidStat = new SsidStatistics();
ssidStat.setBssid(new MacAddress(radio5g.getMac())); ssidStat.setBssid(new MacAddress(radio5GHz.getMac()));
ssidStat.setSsid(vif5g.getSsid()); ssidStat.setSsid(vif5GHz.getSsid());
ssidStat.setNumClient(vif5g.getAssociatedClients().size()); ssidStat.setNumClient(vif5GHz.getAssociatedClients().size());
ssidStatsList5GHz.add(ssidStat); ssidStatsList5GHzL.add(ssidStat);
}
if (apSsidMetrics.getSsidStatsCount(RadioType.is5GHzL) == 0 && vif5GHzL != null) {
SsidStatistics ssidStat = new SsidStatistics();
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();
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()); LOG.debug("Created ApSsidMetrics Report {}", apSsidMetrics.toPrettyString());
@@ -1070,7 +1127,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
RadioBandType band, long timestamp, Client client, SecurityType securityType) { RadioBandType band, long timestamp, Client client, SecurityType securityType) {
boolean found = false; 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()) { if (!clientRecords.isEmpty()) {
com.telecominfraproject.wlan.client.models.Client record = clientRecords.get(0); com.telecominfraproject.wlan.client.models.Client record = clientRecords.get(0);
LOG.debug("Found Client {}", record.toPrettyString()); LOG.debug("Found Client {}", record.toPrettyString());
@@ -1089,8 +1147,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
clientRecord.setDetails(cid); clientRecord.setDetails(cid);
try { try {
LOG.debug("Created Client {}", LOG.debug("Created Client {}", clientServiceInterface.create(clientRecord).toPrettyString());
clientServiceInterface.create(clientRecord).toPrettyString());
} catch (Exception e) { } catch (Exception e) {
LOG.error("Unabled to create client for {}", client.getMacAddress(), e); LOG.error("Unabled to create client for {}", client.getMacAddress(), e);
} }
@@ -1098,7 +1155,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
try { try {
ClientSession clientSession = clientServiceInterface.getSessionOrNull(customerId, equipmentId, new MacAddress(client.getMacAddress())); ClientSession clientSession = clientServiceInterface.getSessionOrNull(customerId, equipmentId,
new MacAddress(client.getMacAddress()));
if (clientSession == null) { if (clientSession == null) {
LOG.debug("No session found for Client {}, creating new one.", client.getMacAddress()); LOG.debug("No session found for Client {}, creating new one.", client.getMacAddress());
clientSession = new ClientSession(); clientSession = new ClientSession();
@@ -1108,7 +1166,21 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
ClientSessionDetails clientSessionDetails = new ClientSessionDetails(); ClientSessionDetails clientSessionDetails = new ClientSessionDetails();
clientSession.setDetails(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.setRadioType(radioType);
clientSessionDetails.setSessionId(clientSession.getMacAddress().getAddressAsLong()); clientSessionDetails.setSessionId(clientSession.getMacAddress().getAddressAsLong());
clientSessionDetails.setSsid(client.getSsid()); clientSessionDetails.setSsid(client.getSsid());
@@ -1159,8 +1231,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
if (client.hasStats()) { if (client.hasStats()) {
if (metricDetails == null) { if (metricDetails == null) {
LOG.debug("No metric details for client {} session {}, creating", LOG.debug("No metric details for client {} session {}, creating", clientSession.getMacAddress(),
clientSession.getMacAddress(), clientSessionDetails.getSessionId()); clientSessionDetails.getSessionId());
metricDetails = new ClientSessionMetricDetails(); metricDetails = new ClientSessionMetricDetails();
} }
metricDetails.setRssi(client.getStats().getRssi()); metricDetails.setRssi(client.getStats().getRssi());
@@ -1184,8 +1256,9 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
} }
//TODO: We support bulk updates for sessions, which is more efficient way of updating many sessions at once. // TODO: We support bulk updates for sessions, which is more efficient way of
//Need to rewrite this to make use of bulk operation. // updating many sessions at once.
// Need to rewrite this to make use of bulk operation.
ClientSession session = clientServiceInterface.updateSession(clientSession); ClientSession session = clientServiceInterface.updateSession(clientSession);
if (session != null) if (session != null)