Retrieve Radio State information on initial AP connect

This commit is contained in:
Mike Hansen
2020-06-23 17:46:31 -04:00
parent 2be3559547
commit 82332611ce
6 changed files with 911 additions and 772 deletions

View File

@@ -9,6 +9,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.function.Consumer;
import javax.annotation.PostConstruct;
@@ -39,7 +40,6 @@ import com.telecominfraproject.wlan.core.model.equipment.RadioType;
import com.telecominfraproject.wlan.customer.models.Customer;
import com.telecominfraproject.wlan.customer.service.CustomerServiceInterface;
import com.telecominfraproject.wlan.datastore.exceptions.DsConcurrentModificationException;
import com.telecominfraproject.wlan.datastore.exceptions.DsEntityNotFoundException;
import com.telecominfraproject.wlan.equipment.EquipmentServiceInterface;
import com.telecominfraproject.wlan.equipment.models.ApElementConfiguration;
import com.telecominfraproject.wlan.equipment.models.Equipment;
@@ -48,7 +48,6 @@ import com.telecominfraproject.wlan.firmware.FirmwareServiceInterface;
import com.telecominfraproject.wlan.firmware.models.CustomerFirmwareTrackRecord;
import com.telecominfraproject.wlan.firmware.models.CustomerFirmwareTrackSettings;
import com.telecominfraproject.wlan.firmware.models.CustomerFirmwareTrackSettings.TrackFlag;
import com.telecominfraproject.wlan.firmware.models.FirmwareVersion;
import com.telecominfraproject.wlan.location.models.Location;
import com.telecominfraproject.wlan.location.service.LocationServiceInterface;
import com.telecominfraproject.wlan.opensync.external.integration.controller.OpensyncCloudGatewayController;
@@ -115,10 +114,6 @@ import sts.OpensyncStats.Neighbor;
import sts.OpensyncStats.Neighbor.NeighborBss;
import sts.OpensyncStats.RadioBandType;
import sts.OpensyncStats.Report;
import sts.OpensyncStats.RssiPeer;
import sts.OpensyncStats.RssiPeer.RssiSample;
import sts.OpensyncStats.RssiPeer.RssiSource;
import sts.OpensyncStats.RssiReport;
import sts.OpensyncStats.Survey;
import sts.OpensyncStats.Survey.SurveySample;
import sts.OpensyncStats.SurveyType;
@@ -129,7 +124,7 @@ import wc.stats.IpDnsTelemetry.WCStatsReport;
@Component
public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegrationInterface {
private static final Logger LOG = LoggerFactory.getLogger(OpensyncExternalIntegrationCloud.class);
private static Logger LOG = LoggerFactory.getLogger(OpensyncExternalIntegrationCloud.class);
@Autowired
private AlarmServiceInterface alarmServiceInterface;
@@ -197,6 +192,41 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
return ce;
}
private RadioType opensyncFreqBandToRadioType(String osFreqBand) {
switch (osFreqBand) {
case "2.4G":
return RadioType.is2dot4GHz;
case "5G":
return RadioType.is5GHz;
case "5GL":
return RadioType.is5GHzL;
case "5GU":
return RadioType.is5GHzU;
default:
return RadioType.UNSUPPORTED;
}
}
private String radioTypeToOpensyncFrequencyBand(RadioType radioType) {
switch (radioType) {
case is2dot4GHz:
return "2.4G";
case is5GHz:
return "5G";
case is5GHzL:
return "5GL";
case is5GHzU:
return "5GU";
default:
return null;
}
}
@Override
public void apConnected(String apId, ConnectNodeInfo connectNodeInfo) {
@@ -208,9 +238,10 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
CustomerFirmwareTrackRecord custFwTrackRecord = firmwareServiceInterface
.getCustomerFirmwareTrackRecord(autoProvisionedCustomerId);
if (custFwTrackRecord != null) {
trackSettings = custFwTrackRecord.getSettings();
trackSettings = CustomerFirmwareTrackSettings.combine(custFwTrackRecord.getSettings(), trackSettings);
}
// determine if AP requires FW upgrade before cloud connection/provision
// determine if AP requires FW upgrade before cloud
// connection/provision
if (trackSettings.getAutoUpgradeDeprecatedOnBind().equals(TrackFlag.ALWAYS)
|| trackSettings.getAutoUpgradeUnknownOnBind().equals(TrackFlag.ALWAYS)) {
@@ -232,90 +263,69 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
try {
if (ce == null) {
Customer customer = customerServiceInterface.getOrNull(autoProvisionedCustomerId);
if (customer == null) {
customer = new Customer();
customer.setName("DefaultCustomer");
customer.setEmail("DefaulCustomer@DefaultEmail.com");
customer = customerServiceInterface.create(customer);
}
ce = new Equipment();
ce.setEquipmentType(EquipmentType.AP);
ce.setCustomerId(customer.getId());
ce.setInventoryId(apId);
ce.setSerial(connectNodeInfo.serialNumber);
ce.setDetails(ApElementConfiguration.createWithDefaults());
ce.setName(apId);
ce.setLocationId(autoProvisionedLocationId);
ce = equipmentServiceInterface.create(ce);
ce.setCustomerId(autoProvisionedCustomerId);
ce.setName(apId);
ce.setLocationId(autoProvisionedLocationId);
ApElementConfiguration apElementConfig = (ApElementConfiguration) ce.getDetails();
apElementConfig.setEquipmentModel(connectNodeInfo.model);
apElementConfig.getAdvancedRadioMap().get(RadioType.is2dot4GHz)
.setAutoChannelSelection(StateSetting.disabled);
apElementConfig.getAdvancedRadioMap().get(RadioType.is5GHzL)
.setAutoChannelSelection(StateSetting.disabled);
apElementConfig.getAdvancedRadioMap().get(RadioType.is5GHzU)
.setAutoChannelSelection(StateSetting.disabled);
apElementConfig.getRadioMap().get(RadioType.is2dot4GHz).setAutoChannelSelection(false);
apElementConfig.getRadioMap().get(RadioType.is5GHzL).setAutoChannelSelection(false);
apElementConfig.getRadioMap().get(RadioType.is5GHzU).setAutoChannelSelection(false);
for (RadioType key : apElementConfig.getRadioMap().keySet()) {
String ovsdbKey = radioTypeToOpensyncFrequencyBand(key);
if (connectNodeInfo.wifiRadioStates.containsKey(ovsdbKey)) {
apElementConfig.getAdvancedRadioMap().get(key)
.setAutoChannelSelection(StateSetting.disabled);
apElementConfig.getRadioMap().get(key).setAutoChannelSelection(false);
} else {
apElementConfig.getAdvancedRadioMap().remove(key);
apElementConfig.getRadioMap().remove(key);
}
}
ce.setDetails(apElementConfig);
ce = equipmentServiceInterface.update(ce);
Profile ssidProfile = new Profile();
ssidProfile.setCustomerId(ce.getCustomerId());
ssidProfile.setName("DefaultSsidApConnected");
SsidConfiguration ssidConfig = SsidConfiguration.createWithDefaults();
ssidConfig.setSsid("DefaultSsidApConnected");
ssidConfig.setSecureMode(SecureMode.wpa2PSK);
ssidConfig.setKeyStr("12345678");
Set<RadioType> appliedRadios = new HashSet<>();
appliedRadios.addAll(((ApElementConfiguration) ce.getDetails()).getRadioMap().keySet());
ssidConfig.setAppliedRadios(appliedRadios);
ssidProfile.setDetails(ssidConfig);
ssidProfile = profileServiceInterface.create(ssidProfile);
Profile apProfile = new Profile();
apProfile.setCustomerId(ce.getCustomerId());
apProfile.setName("DefaultApProfile");
apProfile.setDetails(ApNetworkConfiguration.createWithDefaults());
apProfile = profileServiceInterface.create(apProfile);
Profile ssidProfile = new Profile();
ssidProfile.setCustomerId(ce.getCustomerId());
ssidProfile.setName("DefaultSsid-2g");
SsidConfiguration ssidConfig = SsidConfiguration.createWithDefaults();
ssidConfig.setSsid("DefaultSsid-2g");
ssidConfig.setSecureMode(SecureMode.wpa2PSK);
ssidConfig.setKeyStr("12345678");
Set<RadioType> appliedRadios = new HashSet<>();
appliedRadios.add(RadioType.is2dot4GHz);
// ssidConfig.getRadioBasedConfigs().get(RadioType.is2dot4GHz).setEnable80211r(true);
ssidConfig.setAppliedRadios(appliedRadios);
ssidProfile.setDetails(ssidConfig);
ssidProfile = profileServiceInterface.create(ssidProfile);
Profile ssidProfile5g = new Profile();
ssidProfile5g.setCustomerId(ce.getCustomerId());
ssidProfile5g.setName("DefaultSsid-5g");
SsidConfiguration ssidConfig5g = SsidConfiguration.createWithDefaults();
ssidConfig5g.setSecureMode(SecureMode.wpa2PSK);
ssidConfig5g.setSsid("DefaultSsid-5g");
ssidConfig5g.setKeyStr("12345678");
Set<RadioType> appliedRadios5g = new HashSet<>();
appliedRadios5g.add(RadioType.is5GHzL);
appliedRadios5g.add(RadioType.is5GHzU);
ssidConfig5g.setAppliedRadios(appliedRadios5g);
// ssidConfig5g.getRadioBasedConfigs().get(RadioType.is5GHzL).setEnable80211r(true);
// ssidConfig5g.getRadioBasedConfigs().get(RadioType.is5GHzU).setEnable80211r(true);
ssidProfile5g.setDetails(ssidConfig5g);
ssidProfile5g = profileServiceInterface.create(ssidProfile5g);
Set<Long> childProfileIds = new HashSet<>();
childProfileIds.add(ssidProfile.getId());
childProfileIds.add(ssidProfile5g.getId());
apProfile.setChildProfileIds(childProfileIds);
apProfile = profileServiceInterface.create(apProfile);
apProfile = profileServiceInterface.update(apProfile);
ce.setProfileId(apProfile.getId());
ce = equipmentServiceInterface.update(ce);
Customer customer = customerServiceInterface.getOrNull(ce.getCustomerId());
if (customer == null) {
customer = new Customer();
customer.setId(autoProvisionedCustomerId);
customerServiceInterface.create(customer);
ce.setCustomerId(customer.getId());
equipmentServiceInterface.update(ce);
}
}
EquipmentRoutingRecord equipmentRoutingRecord = gatewayController
@@ -405,7 +415,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
} catch (UnknownHostException e) {
// do nothing here
}
if (connectNodeInfo.macAddress != null && MacAddress.valueOf(connectNodeInfo.macAddress) != null) {
if ((connectNodeInfo.macAddress != null) && (MacAddress.valueOf(connectNodeInfo.macAddress) != null)) {
protocolStatusData.setReportedMacAddr(MacAddress.valueOf(connectNodeInfo.macAddress));
}
protocolStatusData.setReportedSku(connectNodeInfo.skuNumber);
@@ -633,7 +643,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
int customerId = extractCustomerIdFromTopic(topic);
long equipmentId = extractEquipmentIdFromTopic(topic);
if (equipmentId <= 0 || customerId <= 0) {
if ((equipmentId <= 0) || (customerId <= 0)) {
LOG.warn("Cannot determine equipment ids from topic {} - customerId {} equipmentId {}", topic, customerId,
equipmentId);
return;
@@ -647,13 +657,12 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
populateApNodeMetrics(metricRecordList, report, customerId, equipmentId);
populateNeighbourScanReports(metricRecordList, report, customerId, equipmentId);
try {
// TODO: depends on survey
// populateChannelInfoReports(metricRecordList, report, customerId,
// equipmentId);
populateChannelInfoReports(metricRecordList, report, customerId, equipmentId);
populateApSsidMetrics(metricRecordList, report, customerId, equipmentId, extractApIdFromTopic(topic));
// handleRssiMetrics(metricRecordList, report, customerId,
// equipmentId);
/*
* TODO: add when available handleRssiMetrics(metricRecordList,
* report, customerId, equipmentId);
*/
} catch (Exception e) {
LOG.error("Exception when processing populateApSsidMetrics", e);
}
@@ -664,31 +673,32 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
}
private void handleRssiMetrics(List<ServiceMetric> metricRecordList, Report report, int customerId,
long equipmentId) {
LOG.debug("handleRssiMetrics for Customer {} Equipment {}", customerId, equipmentId);
for (RssiReport rssiReport : report.getRssiReportList()) {
for (RssiPeer peer : rssiReport.getPeerListList()) {
if (peer.getRssiSource().equals(RssiSource.CLIENT)) {
int rssi = 0;
for (RssiSample sample : peer.getRssiListList()) {
rssi += getNegativeSignedIntFromUnsigned(sample.getRssi());
LOG.debug("RSSI Sample: unsignedValue {} signedValue {}", sample.getRssi(),
getNegativeSignedIntFromUnsigned(sample.getRssi()));
}
rssi = rssi / peer.getRssiListCount();
LOG.debug("RssiReport::RssiPeer::Band {} RssiPeer MAC {} RssiSamples Avg {} RxPpdus {} TxPpdus {}",
rssiReport.getBand(), peer.getMacAddress(), rssi, peer.getRxPpdus(), peer.getTxPpdus());
}
}
}
}
/*
* TODO: when available handle RSSI metric processing private void
* handleRssiMetrics(List<ServiceMetric> metricRecordList, Report report,
* int customerId, long equipmentId) {
* LOG.debug("handleRssiMetrics for Customer {} Equipment {}", customerId,
* equipmentId);
*
* for (RssiReport rssiReport : report.getRssiReportList()) {
*
* for (RssiPeer peer : rssiReport.getPeerListList()) { if
* (peer.getRssiSource().equals(RssiSource.CLIENT)) { int rssi = 0;
*
* for (RssiSample sample : peer.getRssiListList()) { rssi +=
* getNegativeSignedIntFromUnsigned(sample.getRssi());
* LOG.debug("RSSI Sample: unsignedValue {} signedValue {}",
* sample.getRssi(), getNegativeSignedIntFromUnsigned(sample.getRssi())); }
*
* rssi = rssi / peer.getRssiListCount();
*
* LOG.
* debug("RssiReport::RssiPeer::Band {} RssiPeer MAC {} RssiSamples Avg {} RxPpdus {} TxPpdus {}"
* , rssiReport.getBand(), peer.getMacAddress(), rssi, peer.getRxPpdus(),
* peer.getTxPpdus()); } }
*
* } }
*/
private void populateApNodeMetrics(List<ServiceMetric> metricRecordList, Report report, int customerId,
long equipmentId) {
@@ -890,7 +900,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
ClientMetrics cMetrics = new ClientMetrics();
smr.setDetails(cMetrics);
Integer periodLengthSec = 60; // matches what's configured by
Integer periodLengthSec = 60; // matches what's configured
// by
// OvsdbDao.configureStats(OvsdbClient)
cMetrics.setPeriodLengthSec(periodLengthSec);
@@ -934,7 +945,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
}
if (cl.getStats().hasTxRate()) {
cMetrics.setAverageTxRate(Double.valueOf(cl.getStats().getTxRate() / 1000));
cMetrics.setAverageTxRate(cl.getStats().getTxRate() / 1000);
}
if (cl.getStats().hasTxRate() && cl.getStats().hasRxRate()) {
@@ -1010,7 +1021,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
nr.setMacAddress(new MacAddress(nBss.getBssid()));
nr.setNetworkType(NetworkType.AP);
nr.setPacketType(NeighborScanPacketType.BEACON);
nr.setPrivacy((nBss.getSsid() == null || nBss.getSsid().isEmpty()) ? true : false);
nr.setPrivacy(((nBss.getSsid() == null) || nBss.getSsid().isEmpty()) ? true : false);
// nr.setRate(rate);
// we can only get Rssi as an unsigned int from opensync, so
// some shifting
@@ -1120,8 +1131,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
metricDetails.setTxDataFrames((int) ((int) client.getStats().getTxFrames() - client.getStats().getTxRetries()));
metricDetails.setRxDataFrames((int) ((int) client.getStats().getRxFrames() - client.getStats().getRxRetries()));
// values reported in Kbps, convert to Mbps
metricDetails.setRxMbps(Float.valueOf((float) (client.getStats().getRxRate() / 1000)));
metricDetails.setTxMbps(Float.valueOf((float) (client.getStats().getTxRate() / 1000)));
metricDetails.setRxMbps((float) (client.getStats().getRxRate() / 1000));
metricDetails.setTxMbps((float) (client.getStats().getTxRate() / 1000));
metricDetails.setRxRateKbps((long) client.getStats().getRxRate());
metricDetails.setTxRateKbps((long) client.getStats().getTxRate());
return metricDetails;
@@ -1187,7 +1198,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
for (Client client : clientReport.getClientListList()) {
if (client.hasSsid() && client.getSsid() != null && !client.getSsid().equals("")) {
if (client.hasSsid() && (client.getSsid() != null) && !client.getSsid().equals("")) {
ssid = client.getSsid();
}
@@ -1319,15 +1330,18 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
// ChannelInfo entries per surveyed channel
Map<Integer, List<SurveySample>> sampleByChannelMap = new HashMap<>();
survey.getSurveyListList().stream().forEach(s -> {
List<SurveySample> surveySampleList;
if (sampleByChannelMap.get(s.getChannel()) == null) {
surveySampleList = new ArrayList<>();
} else {
surveySampleList = sampleByChannelMap.get(s.getChannel());
survey.getSurveyListList().stream().forEach(new Consumer<SurveySample>() {
@Override
public void accept(SurveySample s) {
List<SurveySample> surveySampleList;
if (sampleByChannelMap.get(s.getChannel()) == null) {
surveySampleList = new ArrayList<>();
} else {
surveySampleList = sampleByChannelMap.get(s.getChannel());
}
surveySampleList.add(s);
sampleByChannelMap.put(s.getChannel(), surveySampleList);
}
surveySampleList.add(s);
sampleByChannelMap.put(s.getChannel(), surveySampleList);
});
for (List<SurveySample> surveySampleList : sampleByChannelMap.values()) {
@@ -1383,9 +1397,9 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
channelInfo.setWifiUtilization(totalWifi);
channelInfo.setBandwidth(((ApElementConfiguration) equipmentServiceInterface.get(equipmentId).getDetails())
.getRadioMap().get(radioType).getChannelBandwidth());
channelInfo.setNoiseFloor(Integer.valueOf(-84)); // TODO: when this
// becomes available
// add
channelInfo.setNoiseFloor(-84); // TODO: when this
// becomes available
// add
return channelInfo;
}
@@ -1396,7 +1410,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
int customerId = extractCustomerIdFromTopic(topic);
long equipmentId = extractEquipmentIdFromTopic(topic);
if (equipmentId <= 0 || customerId <= 0) {
if ((equipmentId <= 0) || (customerId <= 0)) {
LOG.warn("Cannot determine equipment ids from topic {} - customerId {} equipmentId {}", topic, customerId,
equipmentId);
return;
@@ -1420,7 +1434,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
int customerId = extractCustomerIdFromTopic(topic);
long equipmentId = extractEquipmentIdFromTopic(topic);
if (equipmentId <= 0 || customerId <= 0) {
if ((equipmentId <= 0) || (customerId <= 0)) {
LOG.warn("Cannot determine equipment ids from topic {} - customerId {} equipmentId {}", topic, customerId,
equipmentId);
return;
@@ -1453,13 +1467,13 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
return;
}
if (vifStateTables == null || vifStateTables.isEmpty() || apId == null) {
if ((vifStateTables == null) || vifStateTables.isEmpty() || (apId == null)) {
return;
}
for (OpensyncAPVIFState vifState : vifStateTables) {
if (vifState.getMac() != null && vifState.getSsid() != null && vifState.getChannel() > 0) {
if ((vifState.getMac() != null) && (vifState.getSsid() != null) && (vifState.getChannel() > 0)) {
String bssid = vifState.getMac();
String ssid = vifState.getSsid();
@@ -1550,7 +1564,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
int customerId = ovsdbSession.getCustomerId();
long equipmentId = ovsdbSession.getEquipmentId();
if (customerId < 0 || equipmentId < 0) {
if ((customerId < 0) || (equipmentId < 0)) {
LOG.debug("wifiRadioStatusDbTableUpdate::Cannot get valid CustomerId {} or EquipmentId {} for AP {}",
customerId, equipmentId, apId);
return;
@@ -1704,14 +1718,10 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
return;
}
if (inetStateTables == null || inetStateTables.isEmpty() || apId == null) {
if ((inetStateTables == null) || inetStateTables.isEmpty() || (apId == null)) {
return;
}
for (OpensyncAPInetState inetState : inetStateTables) {
// TODO: implement me
}
}
@Override
@@ -1738,7 +1748,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
return;
}
if (wifiAssociatedClients == null || wifiAssociatedClients.isEmpty() || apId == null) {
if ((wifiAssociatedClients == null) || wifiAssociatedClients.isEmpty() || (apId == null)) {
return;
}
@@ -1757,7 +1767,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
int customerId = ovsdbSession.getCustomerId();
long equipmentId = ovsdbSession.getEquipmentId();
if (customerId < 0 || equipmentId < 0) {
if ((customerId < 0) || (equipmentId < 0)) {
LOG.debug("awlanNodeDbTableUpdate::Cannot get valid CustomerId {} or EquipmentId {} for AP {}", customerId,
equipmentId, apId);
return;

View File

@@ -10,6 +10,7 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import javax.servlet.http.HttpServletRequest;
@@ -122,62 +123,66 @@ public class OpensyncCloudGatewayController {
return ret;
}
commands.stream().forEach(command -> {
LOG.debug("sendCommands - processing {}", command);
commands.stream().forEach(new Consumer<CEGWBaseCommand>() {
@Override
public void accept(CEGWBaseCommand command) {
LOG.debug("sendCommands - processing {}", command);
String inventoryId = command.getInventoryId();
String inventoryId = command.getInventoryId();
if (com.telecominfraproject.wlan.core.model.json.BaseJsonModel.hasUnsupportedValue(command)) {
LOG.error("[{}] Failed to deliver command {}, command contains unsupported value", inventoryId,
command);
ret.add(new EquipmentCommandResponse(CEGWCommandResultCode.UnsupportedCommand,
"Unsupported value in command for " + inventoryId, command, registeredGateway.getHostname(),
registeredGateway.getPort()));
return;
}
OvsdbSession session = ovsdbSessionMapInterface.getSession(inventoryId);
if (session == null) {
LOG.warn("[{}] Failed to deliver command {}, equipment session not found", inventoryId, command);
ret.add(new EquipmentCommandResponse(CEGWCommandResultCode.NoRouteToCE,
"No session found for " + inventoryId, command, registeredGateway.getHostname(),
registeredGateway.getPort()));
return;
}
switch (command.getCommandType()) {
case ConfigChangeNotification:
ret.add(sendConfigChangeNotification(session, (CEGWConfigChangeNotification) command));
break;
case CloseSessionRequest:
ret.add(closeSession(session, (CEGWCloseSessionRequest) command));
break;
case CheckRouting:
ret.add(checkEquipmentRouting(session, (CEGWRouteCheck) command));
break;
case BlinkRequest:
ret.add(processBlinkRequest(session, (CEGWBlinkRequest) command));
break;
case StartDebugEngine:
ret.add(processChangeRedirector(session, (CEGWStartDebugEngine) command));
break;
case FirmwareDownloadRequest:
ret.add(processFirmwareDownload(session, (CEGWFirmwareDownloadRequest) command));
break;
case FirmwareFlashRequest:
ret.add(processFirmwareFlash(session, (CEGWFirmwareFlashRequest) command));
break;
case RadioReset:
ret.add(processRadioReset(session, (CEGWRadioResetRequest) command));
break;
default:
LOG.warn("[{}] Failed to deliver command {}, unsupported command type", inventoryId, command);
ret.add(new EquipmentCommandResponse(
CEGWCommandResultCode.UnsupportedCommand, "Invalid command type ("
+ command.getCommandType() + ") for equipment (" + inventoryId + ")",
command, registeredGateway.getHostname(), registeredGateway.getPort()));
}
if (com.telecominfraproject.wlan.core.model.json.BaseJsonModel.hasUnsupportedValue(command)) {
LOG.error("[{}] Failed to deliver command {}, command contains unsupported value", inventoryId,
command);
ret.add(new EquipmentCommandResponse(CEGWCommandResultCode.UnsupportedCommand,
"Unsupported value in command for " + inventoryId, command, registeredGateway.getHostname(),
registeredGateway.getPort()));
return;
}
OvsdbSession session = ovsdbSessionMapInterface.getSession(inventoryId);
if (session == null) {
LOG.warn("[{}] Failed to deliver command {}, equipment session not found", inventoryId, command);
ret.add(new EquipmentCommandResponse(CEGWCommandResultCode.NoRouteToCE,
"No session found for " + inventoryId, command, registeredGateway.getHostname(),
registeredGateway.getPort()));
return;
}
switch (command.getCommandType()) {
case ConfigChangeNotification:
ret.add(sendConfigChangeNotification(session, (CEGWConfigChangeNotification) command));
break;
case CloseSessionRequest:
ret.add(closeSession(session, (CEGWCloseSessionRequest) command));
break;
case CheckRouting:
ret.add(checkEquipmentRouting(session, (CEGWRouteCheck) command));
break;
case BlinkRequest:
ret.add(processBlinkRequest(session, (CEGWBlinkRequest) command));
break;
case StartDebugEngine:
ret.add(processChangeRedirector(session, (CEGWStartDebugEngine) command));
break;
case FirmwareDownloadRequest:
ret.add(processFirmwareDownload(session, (CEGWFirmwareDownloadRequest) command));
break;
case FirmwareFlashRequest:
ret.add(processFirmwareFlash(session, (CEGWFirmwareFlashRequest) command));
break;
case RadioReset:
ret.add(processRadioReset(session, (CEGWRadioResetRequest) command));
break;
default:
LOG.warn("[{}] Failed to deliver command {}, unsupported command type", inventoryId, command);
ret.add(new EquipmentCommandResponse(CEGWCommandResultCode.UnsupportedCommand,
"Invalid command type (" + command.getCommandType() + ") for equipment (" + inventoryId + ")",
command, registeredGateway.getHostname(), registeredGateway.getPort()));
}
});
return ret;
@@ -352,9 +357,9 @@ public class OpensyncCloudGatewayController {
try {
EquipmentGatewayRecord result = this.eqRoutingSvc.registerGateway(gwRecord);
this.registeredGwId = result.getId();
this.registeredGateway = result;
EquipmentGatewayRecord result = eqRoutingSvc.registerGateway(gwRecord);
registeredGwId = result.getId();
registeredGateway = result;
LOG.info("Successfully registered (name={}, id={}) with Routing Service", result.getHostname(),
registeredGwId);
registeredWithRoutingService = true;
@@ -383,20 +388,20 @@ public class OpensyncCloudGatewayController {
try {
eqRoutingSvc.deleteGateway(registeredGwId);
LOG.info("Deregistered Customer Equipment Gateway (name={},id={}) with Routing Service",
getGatewayName(), this.registeredGwId);
this.registeredGwId = -1;
this.registeredGateway = null;
getGatewayName(), registeredGwId);
registeredGwId = -1;
registeredGateway = null;
} catch (Exception e) {
// failed
LOG.error("Failed to deregister Customer Equipment Gateway (name={},id={}) with Routing Service: {}",
getGatewayName(), this.registeredGwId, e.getLocalizedMessage());
getGatewayName(), registeredGwId, e.getLocalizedMessage());
}
registeredWithRoutingService = false;
}
}
public long getRegisteredGwId() {
return this.registeredGwId;
return registeredGwId;
}
/**
@@ -418,7 +423,7 @@ public class OpensyncCloudGatewayController {
EquipmentRoutingRecord routingRecord = new EquipmentRoutingRecord();
routingRecord.setCustomerId(customerId);
routingRecord.setEquipmentId(equipmentId);
routingRecord.setGatewayId(this.registeredGwId);
routingRecord.setGatewayId(registeredGwId);
try {
routingRecord = eqRoutingSvc.create(routingRecord);
@@ -456,7 +461,7 @@ public class OpensyncCloudGatewayController {
@Scheduled(initialDelay = 5 * 60 * 1000, fixedRate = 5 * 60 * 1000)
public void updateActiveCustomer() {
try {
Map<Integer, Long> activeMap = this.getActiveCustomerMapForUpdate();
Map<Integer, Long> activeMap = getActiveCustomerMapForUpdate();
if (null != activeMap) {
LOG.info("Updating active customer records, total record size {}", activeMap.size());
// this.eqRoutingSvc.updateActiveCustomer(activeMap,
@@ -482,11 +487,11 @@ public class OpensyncCloudGatewayController {
* @param customerId
*/
public void updateActiveCustomer(int customerId) {
this.activeCustomerReadLock.lock();
activeCustomerReadLock.lock();
try {
this.activeCustomerMap.merge(customerId, System.currentTimeMillis(), latestTimestamp);
activeCustomerMap.merge(customerId, System.currentTimeMillis(), latestTimestamp);
} finally {
this.activeCustomerReadLock.unlock();
activeCustomerReadLock.unlock();
}
}
@@ -496,17 +501,17 @@ public class OpensyncCloudGatewayController {
* @return null if no records.
*/
protected Map<Integer, Long> getActiveCustomerMapForUpdate() {
this.activeCustomerWriteLock.lock();
activeCustomerWriteLock.lock();
try {
Map<Integer, Long> map = null;
if (!this.activeCustomerMap.isEmpty()) {
map = this.activeCustomerMap;
this.activeCustomerMap = new ConcurrentHashMap<>();
if (!activeCustomerMap.isEmpty()) {
map = activeCustomerMap;
activeCustomerMap = new ConcurrentHashMap<>();
}
return map;
} finally {
this.activeCustomerWriteLock.unlock();
activeCustomerWriteLock.unlock();
}
}
}

View File

@@ -3,8 +3,9 @@ package com.telecominfraproject.wlan.opensync.external.integration.models;
import java.util.HashMap;
import java.util.Map;
public class ConnectNodeInfo implements Cloneable{
public Map<String,String> mqttSettings;
public class ConnectNodeInfo implements Cloneable {
public Map<String, String> mqttSettings;
public Map<String, Map<String,String>> wifiRadioStates;
public String redirectorAddr;
public String managerAddr;
public String skuNumber;
@@ -15,29 +16,35 @@ public class ConnectNodeInfo implements Cloneable{
public String firmwareVersion;
public String revision;
public String model;
public String ifName;
public String ifType;
public String country;
@Override
public ConnectNodeInfo clone() {
try {
ConnectNodeInfo ret = (ConnectNodeInfo)super.clone();
if (this.mqttSettings!=null) {
ConnectNodeInfo ret = (ConnectNodeInfo) super.clone();
if (this.mqttSettings != null) {
ret.mqttSettings = new HashMap<>(this.mqttSettings);
}
if (this.wifiRadioStates != null) {
ret.wifiRadioStates = new HashMap<>(this.wifiRadioStates);
}
return ret;
}catch(CloneNotSupportedException e) {
} catch (CloneNotSupportedException e) {
throw new IllegalStateException("Cannot clone ", e);
}
}
}
@Override
public String toString() {
return String.format(
"ConnectNodeInfo [mqttSettings=%s, redirectorAddr=%s, managerAddr=%s, skuNumber=%s, serialNumber=%s, "
+ "macAddress=%s, ipV4Address=%s, platformVersion=%s, firmwareVersion=%s, revision=%s, model=%s]",
+ "macAddress=%s, ipV4Address=%s, platformVersion=%s, firmwareVersion=%s, revision=%s, model=%s ifName=%s ifType=%s, wifiRadioStates=%s]",
mqttSettings, redirectorAddr, managerAddr, skuNumber, serialNumber, macAddress, ipV4Address,
platformVersion, firmwareVersion, revision, model);
platformVersion, firmwareVersion, revision, model, ifName, ifType, wifiRadioStates);
}
}
}

View File

@@ -38,196 +38,221 @@ import wc.stats.IpDnsTelemetry.WCStatsReport;
@Component
public class OpensyncMqttClient implements ApplicationListener<ContextClosedEvent> {
private static final Logger LOG = LoggerFactory.getLogger(OpensyncMqttClient.class);
private static final Logger LOG = LoggerFactory.getLogger(OpensyncMqttClient.class);
private static final Logger MQTT_LOG = LoggerFactory.getLogger("MQTT_DATA");
private static final Logger MQTT_LOG = LoggerFactory.getLogger("MQTT_DATA");
public static Charset utf8 = Charset.forName("UTF-8");
public static Charset utf8 = Charset.forName("UTF-8");
@Autowired
private OpensyncExternalIntegrationInterface extIntegrationInterface;
@Autowired
private OpensyncExternalIntegrationInterface extIntegrationInterface;
//
// See https://github.com/fusesource/mqtt-client for the docs
//
//
// See https://github.com/fusesource/mqtt-client for the docs
//
private boolean keepReconnecting = true;
private Thread mqttClientThread;
private boolean keepReconnecting = true;
private Thread mqttClientThread;
public OpensyncMqttClient(@Autowired io.netty.handler.ssl.SslContext sslContext,
@Value("${connectus.mqttBroker.address:testportal.123wlan.com}") String mqttBrokerAddress,
@Value("${connectus.mqttBroker.listenPort:1883}") int mqttBrokerListenPort,
@Value("${connectus.mqttBroker.user:admin}") String username,
@Value("${connectus.mqttBroker.password:admin}") String password,
@Value("${mqtt.javax.net.ssl.keyStore:/opt/tip-wlan/certs/client_keystore.jks}") String jdkKeyStoreLocation,
@Value("${mqtt.javax.net.ssl.keyStorePassword:mypassword}") String jdkKeyStorePassword,
@Value("${mqtt.javax.net.ssl.trustStore:/opt/tip-wlan/certs/truststore.jks}") String jdkTrustStoreLocation,
@Value("${mqtt.javax.net.ssl.trustStorePassword:mypassword}") String jdkTrustStorePassword) {
public OpensyncMqttClient(@Autowired io.netty.handler.ssl.SslContext sslContext,
@Value("${connectus.mqttBroker.address:testportal.123wlan.com}") String mqttBrokerAddress,
@Value("${connectus.mqttBroker.listenPort:1883}") int mqttBrokerListenPort,
@Value("${connectus.mqttBroker.user:admin}") String username,
@Value("${connectus.mqttBroker.password:admin}") String password,
@Value("${mqtt.javax.net.ssl.keyStore:/opt/tip-wlan/certs/client_keystore.jks}") String jdkKeyStoreLocation,
@Value("${mqtt.javax.net.ssl.keyStorePassword:mypassword}") String jdkKeyStorePassword,
@Value("${mqtt.javax.net.ssl.trustStore:/opt/tip-wlan/certs/truststore.jks}") String jdkTrustStoreLocation,
@Value("${mqtt.javax.net.ssl.trustStorePassword:mypassword}") String jdkTrustStorePassword) {
if (System.getProperty("javax.net.ssl.keyStore") == null) {
System.setProperty("javax.net.ssl.keyStore", jdkKeyStoreLocation);
}
if (System.getProperty("javax.net.ssl.keyStore") == null) {
System.setProperty("javax.net.ssl.keyStore", jdkKeyStoreLocation);
}
if (System.getProperty("javax.net.ssl.keyStorePassword") == null) {
System.setProperty("javax.net.ssl.keyStorePassword", jdkKeyStorePassword);
}
if (System.getProperty("javax.net.ssl.keyStorePassword") == null) {
System.setProperty("javax.net.ssl.keyStorePassword", jdkKeyStorePassword);
}
if (System.getProperty("javax.net.ssl.trustStore") == null) {
System.setProperty("javax.net.ssl.trustStore", jdkTrustStoreLocation);
}
if (System.getProperty("javax.net.ssl.trustStore") == null) {
System.setProperty("javax.net.ssl.trustStore", jdkTrustStoreLocation);
}
if (System.getProperty("javax.net.ssl.trustStorePassword") == null) {
System.setProperty("javax.net.ssl.trustStorePassword", jdkTrustStorePassword);
}
if (System.getProperty("javax.net.ssl.trustStorePassword") == null) {
System.setProperty("javax.net.ssl.trustStorePassword", jdkTrustStorePassword);
}
Runnable mqttClientRunnable = () -> {
while (keepReconnecting) {
BlockingConnection connection = null;
try {
Thread.sleep(5000);
Runnable mqttClientRunnable = new Runnable() {
@Override
public void run() {
while (keepReconnecting) {
BlockingConnection connection = null;
try {
Thread.sleep(5000);
// Create a new MQTT connection to the broker.
/*
* Using SSL connections If you want to connect over SSL/TLS instead of TCP, use
* an "ssl://" or "tls://" URI prefix instead of "tcp://" for the host field.
* Supported protocol values are:
*
* ssl:// - Use the JVM default version of the SSL algorithm. sslv*:// - Use a
* specific SSL version where * is a version supported by your JVM. Example:
* sslv3 tls:// - Use the JVM default version of the TLS algorithm. tlsv*:// -
* Use a specific TLS version where * is a version supported by your JVM.
* Example: tlsv1.1 The client will use the default JVM SSLContext which is
* configured via JVM system properties unless you configure the MQTT instance
* using the setSslContext method.
*
* SSL connections perform blocking operations against internal thread pool
* unless you call the setBlockingExecutor method to configure that executor
* they will use instead.
*
*/
// Create a new MQTT connection to the broker.
/*
* Using SSL connections If you want to connect over
* SSL/TLS instead of TCP, use an "ssl://" or "tls://"
* URI prefix instead of "tcp://" for the host field.
* Supported protocol values are:
*
* ssl:// - Use the JVM default version of the SSL
* algorithm. sslv*:// - Use a specific SSL version
* where * is a version supported by your JVM. Example:
* sslv3 tls:// - Use the JVM default version of the TLS
* algorithm. tlsv*:// - Use a specific TLS version
* where * is a version supported by your JVM. Example:
* tlsv1.1 The client will use the default JVM
* SSLContext which is configured via JVM system
* properties unless you configure the MQTT instance
* using the setSslContext method.
*
* SSL connections perform blocking operations against
* internal thread pool unless you call the
* setBlockingExecutor method to configure that executor
* they will use instead.
*
*/
MQTT mqtt = new MQTT();
// mqtt.setHost("tcp://192.168.0.137:61616");
mqtt.setHost("tls://" + mqttBrokerAddress + ":" + mqttBrokerListenPort);
LOG.info("Connecting to MQTT broker at {}", mqtt.getHost());
mqtt.setClientId("opensync_mqtt");
mqtt.setUserName(username);
mqtt.setPassword(password);
// Note: the following does not work with the serverContext, it has to be the
// clientContext
// mqtt.setSslContext(((JdkSslContext) sslContext).context());
// For now we'll rely on regular SSLContext from the JDK
MQTT mqtt = new MQTT();
// mqtt.setHost("tcp://192.168.0.137:61616");
mqtt.setHost("tls://" + mqttBrokerAddress + ":" + mqttBrokerListenPort);
LOG.info("Connecting to MQTT broker at {}", mqtt.getHost());
mqtt.setClientId("opensync_mqtt");
mqtt.setUserName(username);
mqtt.setPassword(password);
// Note: the following does not work with the
// serverContext,
// it has to be the
// clientContext
// mqtt.setSslContext(((JdkSslContext)
// sslContext).context());
// For now we'll rely on regular SSLContext from the JDK
// TODO: revisit this blocking connection, change it to futureConnection
connection = mqtt.blockingConnection();
connection.connect();
LOG.info("Connected to MQTT broker at {}", mqtt.getHost());
// TODO: revisit this blocking connection, change it to
// futureConnection
connection = mqtt.blockingConnection();
connection.connect();
LOG.info("Connected to MQTT broker at {}", mqtt.getHost());
// Subscribe to topics:
//
// new Topic("mqtt/example/publish", QoS.AT_LEAST_ONCE),
// new Topic("#", QoS.AT_LEAST_ONCE),
// new Topic("test/#", QoS.EXACTLY_ONCE),
// new Topic("foo/+/bar", QoS.AT_LEAST_ONCE)
Topic[] topics = { new Topic("#", QoS.AT_LEAST_ONCE), };
// Subscribe to topics:
//
// new Topic("mqtt/example/publish", QoS.AT_LEAST_ONCE),
// new Topic("#", QoS.AT_LEAST_ONCE),
// new Topic("test/#", QoS.EXACTLY_ONCE),
// new Topic("foo/+/bar", QoS.AT_LEAST_ONCE)
Topic[] topics = { new Topic("#", QoS.AT_LEAST_ONCE), };
connection.subscribe(topics);
LOG.info("Subscribed to mqtt topics {}", Arrays.asList(topics));
connection.subscribe(topics);
LOG.info("Subscribed to mqtt topics {}", Arrays.asList(topics));
// prepare a JSONPrinter to format protobuf messages as json
List<Descriptors.Descriptor> protobufDescriptors = new ArrayList<>();
protobufDescriptors.addAll(OpensyncStats.getDescriptor().getMessageTypes());
protobufDescriptors.addAll(IpDnsTelemetry.getDescriptor().getMessageTypes());
protobufDescriptors.addAll(NetworkMetadata.getDescriptor().getMessageTypes());
TypeRegistry oldRegistry = TypeRegistry.newBuilder().add(protobufDescriptors).build();
JsonFormat.Printer jsonPrinter = JsonFormat.printer().includingDefaultValueFields()
.omittingInsignificantWhitespace().usingTypeRegistry(oldRegistry);
// prepare a JSONPrinter to format protobuf messages as
// json
List<Descriptors.Descriptor> protobufDescriptors = new ArrayList<>();
protobufDescriptors.addAll(OpensyncStats.getDescriptor().getMessageTypes());
protobufDescriptors.addAll(IpDnsTelemetry.getDescriptor().getMessageTypes());
protobufDescriptors.addAll(NetworkMetadata.getDescriptor().getMessageTypes());
TypeRegistry oldRegistry = TypeRegistry.newBuilder().add(protobufDescriptors).build();
JsonFormat.Printer jsonPrinter = JsonFormat.printer().includingDefaultValueFields()
.omittingInsignificantWhitespace().usingTypeRegistry(oldRegistry);
// main loop - receive messages
while (true) {
Message mqttMsg = connection.receive(5, TimeUnit.SECONDS);
// main loop - receive messages
while (true) {
Message mqttMsg = connection.receive(5, TimeUnit.SECONDS);
if (mqttMsg == null) {
continue;
}
if (mqttMsg == null) {
continue;
}
byte payload[] = mqttMsg.getPayload();
// we acknowledge right after receive because:
// a. none of the stats messages are so important that we cannot skip one
// b. if there's some kind of problem with the message (decoding or processing)
// - we want to move on as quickly as possible and not let it get stuck in the
// queue
mqttMsg.ack();
byte payload[] = mqttMsg.getPayload();
// we acknowledge right after receive because:
// a. none of the stats messages are so important
// that
// we cannot skip one
// b. if there's some kind of problem with the
// message
// (decoding or processing)
// - we want to move on as quickly as possible and
// not
// let it get stuck in the
// queue
mqttMsg.ack();
LOG.trace("received message on topic {} size {}", mqttMsg.getTopic(), payload.length);
LOG.trace("received message on topic {} size {}", mqttMsg.getTopic(), payload.length);
if (payload[0] == 0x78) {
// looks like zlib-compressed data, let's decompress it before deserializing
payload = ZlibUtil.decompress(payload);
}
if (payload[0] == 0x78) {
// looks like zlib-compressed data, let's
// decompress
// it before deserializing
payload = ZlibUtil.decompress(payload);
}
// attempt to parse the message as protobuf
MessageOrBuilder encodedMsg = null;
try {
// attempt to parse the message as protobuf
MessageOrBuilder encodedMsg = null;
try {
encodedMsg = Report.parseFrom(payload);
MQTT_LOG.info("topic = {} Report = {}", mqttMsg.getTopic(), jsonPrinter.print(encodedMsg));
extIntegrationInterface.processMqttMessage(mqttMsg.getTopic(), (Report) encodedMsg);
encodedMsg = Report.parseFrom(payload);
MQTT_LOG.info("topic = {} Report = {}", mqttMsg.getTopic(),
jsonPrinter.print(encodedMsg));
extIntegrationInterface.processMqttMessage(mqttMsg.getTopic(), (Report) encodedMsg);
} catch (Exception e) {
try {
// not a plume_stats report, attempt to deserialize as network_metadata
encodedMsg = FlowReport.parseFrom(payload);
MQTT_LOG.info("topic = {} FlowReport = {}", mqttMsg.getTopic(),
jsonPrinter.print(encodedMsg));
extIntegrationInterface.processMqttMessage(mqttMsg.getTopic(), (FlowReport) encodedMsg);
} catch (Exception e1) {
} catch (Exception e) {
try {
// not a plume_stats report, attempt to
// deserialize as network_metadata
encodedMsg = FlowReport.parseFrom(payload);
MQTT_LOG.info("topic = {} FlowReport = {}", mqttMsg.getTopic(),
jsonPrinter.print(encodedMsg));
extIntegrationInterface.processMqttMessage(mqttMsg.getTopic(),
(FlowReport) encodedMsg);
} catch (Exception e1) {
try {
// not a plume_stats report and not network_metadata report, attempt to
// deserialize as WCStatsReport
encodedMsg = WCStatsReport.parseFrom(payload);
MQTT_LOG.info("topic = {} IpDnsTelemetry = {}", mqttMsg.getTopic(),
jsonPrinter.print(encodedMsg));
extIntegrationInterface.processMqttMessage(mqttMsg.getTopic(),
(WCStatsReport) encodedMsg);
} catch (Exception e2) {
String msgStr = new String(mqttMsg.getPayload(), utf8);
MQTT_LOG.info("topic = {} message = {}", mqttMsg.getTopic(), msgStr);
}
}
}
try {
// not a plume_stats report and not
// network_metadata report, attempt to
// deserialize as WCStatsReport
encodedMsg = WCStatsReport.parseFrom(payload);
MQTT_LOG.info("topic = {} IpDnsTelemetry = {}", mqttMsg.getTopic(),
jsonPrinter.print(encodedMsg));
extIntegrationInterface.processMqttMessage(mqttMsg.getTopic(),
(WCStatsReport) encodedMsg);
} catch (Exception e2) {
String msgStr = new String(mqttMsg.getPayload(), utf8);
MQTT_LOG.info("topic = {} message = {}", mqttMsg.getTopic(), msgStr);
}
}
}
}
}
} catch (Exception e) {
LOG.error("Exception in MQTT receiver", e);
} finally {
try {
if (connection != null) {
connection.disconnect();
}
} catch (Exception e1) {
// do nothing
}
}
}
} catch (Exception e) {
LOG.error("Exception in MQTT receiver", e);
} finally {
try {
if (connection != null) {
connection.disconnect();
}
} catch (Exception e1) {
// do nothing
}
}
}
};
}
};
mqttClientThread = new Thread(mqttClientRunnable, "mqttClientThread");
mqttClientThread.setDaemon(true);
mqttClientThread.start();
mqttClientThread = new Thread(mqttClientRunnable, "mqttClientThread");
mqttClientThread.setDaemon(true);
mqttClientThread.start();
}
}
@Override
public void onApplicationEvent(ContextClosedEvent event) {
LOG.debug("Processing ContextClosedEvent event");
keepReconnecting = false;
@Override
public void onApplicationEvent(ContextClosedEvent event) {
LOG.debug("Processing ContextClosedEvent event");
keepReconnecting = false;
if (mqttClientThread != null) {
mqttClientThread.interrupt();
}
}
if (mqttClientThread != null) {
mqttClientThread.interrupt();
}
}
}

View File

@@ -97,7 +97,7 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface {
// with the serialNumber and using it as a key (equivalent
// of KDC unique qrCode)
String key = clientCn + "_" + connectNodeInfo.serialNumber;
ConnectusOvsdbClient.this.ovsdbSessionMapInterface.newSession(key, ovsdbClient);
ovsdbSessionMapInterface.newSession(key, ovsdbClient);
extIntegrationInterface.apConnected(key, connectNodeInfo);
// push configuration to AP
@@ -105,8 +105,7 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface {
monitorOvsdbStateTables(ovsdbClient, key);
LOG.info("ovsdbClient connected from {} on port {} key {} ", remoteHost, localPort, key);
LOG.info("ovsdbClient connectedClients = {}",
ConnectusOvsdbClient.this.ovsdbSessionMapInterface.getNumSessions());
LOG.info("ovsdbClient connectedClients = {}", ovsdbSessionMapInterface.getNumSessions());
} catch (Exception e) {
LOG.error("ovsdbClient error", e);
@@ -139,7 +138,7 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface {
// so we are doing a reverse lookup here, and then if we find
// the key we will
// remove the entry from the connectedClients.
String key = ConnectusOvsdbClient.this.ovsdbSessionMapInterface.lookupClientId(ovsdbClient);
String key = ovsdbSessionMapInterface.lookupClientId(ovsdbClient);
if (key != null) {
try {
@@ -155,7 +154,7 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface {
}
try {
extIntegrationInterface.apDisconnected(key);
ConnectusOvsdbClient.this.ovsdbSessionMapInterface.removeSession(key);
ovsdbSessionMapInterface.removeSession(key);
} catch (Exception e) {
LOG.debug("Unable to process ap disconnect. {}", e.getMessage());
} finally {
@@ -165,8 +164,7 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface {
LOG.info("ovsdbClient disconnected from {} on port {} clientCn {} key {} ", remoteHost, localPort,
clientCn, key);
LOG.info("ovsdbClient connectedClients = {}",
ConnectusOvsdbClient.this.ovsdbSessionMapInterface.getNumSessions());
LOG.info("ovsdbClient connectedClients = {}", ovsdbSessionMapInterface.getNumSessions());
}
};
@@ -182,8 +180,8 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface {
LOG.debug("Starting Client connect");
connectNodeInfo = ovsdbDao.updateConnectNodeInfoOnConnect(ovsdbClient, clientCn, connectNodeInfo);
String apId = clientCn + "_" + connectNodeInfo.serialNumber;
OpensyncAPConfig opensyncAPConfig = extIntegrationInterface.getApConfig(apId);
ovsdbDao.vifBridge = connectNodeInfo.ifName;
try {
ovsdbDao.provisionBridgePortInterface(ovsdbClient);
@@ -193,10 +191,12 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface {
}
ovsdbDao.removeAllSsids(ovsdbClient); // always
String apId = clientCn + "_" + connectNodeInfo.serialNumber;
OpensyncAPConfig opensyncAPConfig = extIntegrationInterface.getApConfig(apId);
if (opensyncAPConfig != null) {
ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig);
ovsdbDao.configureSsids(ovsdbClient, opensyncAPConfig);
ovsdbDao.configureWifiInet(ovsdbClient, opensyncAPConfig);
}
ovsdbDao.configureStats(ovsdbClient);
@@ -208,8 +208,6 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface {
ovsdbDao.updateDeviceStatsReportingInterval(ovsdbClient, collectionIntervalSecDeviceStats);
}
// ovsdbDao.configureWifiInet(ovsdbClient);
LOG.debug("Client connect Done");
return connectNodeInfo;
}
@@ -307,22 +305,22 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface {
for (Entry<UUID, RowUpdate> rowUpdate : tableUpdate.getValue().getRowUpdates()
.entrySet()) {
if (rowUpdate.getValue().getOld() != null
&& rowUpdate.getValue().getNew() == null) {
if ((rowUpdate.getValue().getOld() != null)
&& (rowUpdate.getValue().getNew() == null)) {
Row row = rowUpdate.getValue().getOld();
String ifName = null;
String ssid = null;
if (row.getColumns().get("ssid") != null
if ((row.getColumns().get("ssid") != null)
&& row.getColumns().get("ssid").getClass().equals(
com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
ssid = row.getStringColumn("ssid");
}
if (row.getColumns().get("if_name") != null
if ((row.getColumns().get("if_name") != null)
&& row.getColumns().get("if_name").getClass().equals(
com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
ifName = row.getStringColumn("if_name");
}
if (ifName != null && ssid != null) {
if ((ifName != null) && (ssid != null)) {
OpensyncAPVIFState toBeDeleted = new OpensyncAPVIFState();
toBeDeleted.setSsid(ssid);
toBeDeleted.setIfName(ifName);
@@ -333,7 +331,7 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface {
}
if (tableUpdate.getValue().getRowUpdates().values().isEmpty()) {
if (tableUpdate.getValue().getRowUpdates().isEmpty()) {
tableUpdates.getTableUpdates().remove(tableUpdate.getKey());
}
@@ -378,7 +376,7 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface {
for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
if (rowUpdate.getOld() != null && rowUpdate.getNew() == null) {
if ((rowUpdate.getOld() != null) && (rowUpdate.getNew() == null)) {
Row row = rowUpdate.getOld();
String deletedClientMac = row.getStringColumn("mac");
extIntegrationInterface.wifiAssociatedClientsDbTableDelete(deletedClientMac,