From a4575f8d12e82b49b997a619c153d0b46703cac2 Mon Sep 17 00:00:00 2001 From: Mike Hansen Date: Tue, 30 Jun 2020 13:44:51 -0400 Subject: [PATCH] Disable monitor when handle config changed, optimization of handle Wifi_Radio_State changes --- .../OpensyncExternalIntegrationCloud.java | 92 +++------ .../opensync/ovsdb/ConnectusOvsdbClient.java | 184 +++++++++++------- 2 files changed, 143 insertions(+), 133 deletions(-) diff --git a/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloud.java b/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloud.java index 2e4bc1c..396e8c8 100644 --- a/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloud.java +++ b/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloud.java @@ -1724,8 +1724,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra channelInfo.setBandwidth(((ApElementConfiguration) equipmentServiceInterface.get(equipmentId).getDetails()) .getRadioMap().get(radioType).getChannelBandwidth()); channelInfo.setNoiseFloor(-84); // TODO: when this - // becomes available - // add + // becomes available + // add return channelInfo; } @@ -1778,6 +1778,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra @Override public void wifiVIFStateDbTableUpdate(List vifStateTables, String apId) { + LOG.debug("Received Wifi_VIF_State table update for AP {}", apId); OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId); @@ -1878,6 +1879,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra @Override public void wifiRadioStatusDbTableUpdate(List radioStateTables, String apId) { + LOG.debug("Received Wifi_Radio_State table update for AP {}", apId); OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId); if (ovsdbSession == null) { @@ -1894,16 +1896,15 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra return; } + Equipment ce = equipmentServiceInterface.getByInventoryIdOrNull(apId); + if (ce == null) { + LOG.debug("wifiRadioStatusDbTableUpdate::Cannot get Equipment for AP {}", apId); + return; + } + + ApElementConfiguration apElementConfiguration = ((ApElementConfiguration) ce.getDetails()); + for (OpensyncAPRadioState radioState : radioStateTables) { - Equipment ce = equipmentServiceInterface.getByInventoryIdOrNull(apId); - if (ce == null) { - LOG.debug("wifiRadioStatusDbTableUpdate::Cannot get Equipment for AP {}", apId); - return; - } - - gatewayController.updateActiveCustomer(ce.getCustomerId()); - - ApElementConfiguration apElementConfiguration = ((ApElementConfiguration) ce.getDetails()); if (radioState.getFreqBand().equals(RadioType.UNSUPPORTED)) { LOG.debug("Could not get radio configuration for AP {}", apId); @@ -1911,7 +1912,6 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra } if (radioState.getAllowedChannels() != null) { - apElementConfiguration = ((ApElementConfiguration) ce.getDetails()); apElementConfiguration.getRadioMap().get(radioState.getFreqBand()) .setAllowedChannels(new ArrayList<>(radioState.getAllowedChannels())); @@ -1920,7 +1920,6 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra } if (radioState.getTxPower() > 0) { - apElementConfiguration = ((ApElementConfiguration) ce.getDetails()); apElementConfiguration.getRadioMap().get(radioState.getFreqBand()) .setEirpTxPower(AutoOrManualValue.createManualInstance(radioState.getTxPower())); @@ -1941,17 +1940,6 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra } - ce.setDetails(apElementConfiguration); - try { - equipmentServiceInterface.update(ce); - } catch (DsConcurrentModificationException e) { - LOG.debug("Equipment reference changed, update instance and retry.", e.getMessage()); - ce = equipmentServiceInterface.getByInventoryIdOrNull(apId); - ce.setDetails(apElementConfiguration); - ce = equipmentServiceInterface.update(ce); - } - - initializeRadioUtilizationReport(customerId, equipmentId, radioState.getFreqBand()); Status protocolStatus = statusServiceInterface.getOrNull(customerId, equipmentId, StatusDataType.PROTOCOL); if (protocolStatus == null) { @@ -1983,54 +1971,30 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra protocolStatus = statusServiceInterface.update(protocolStatus); } - } - - private void initializeRadioUtilizationReport(int customerId, long equipmentId, RadioType radioFreqBand) { - Status radioUtilizationStatus = statusServiceInterface.getOrNull(customerId, equipmentId, - StatusDataType.RADIO_UTILIZATION); - if (radioUtilizationStatus == null) { - radioUtilizationStatus = new Status(); - radioUtilizationStatus.setCustomerId(customerId); - radioUtilizationStatus.setEquipmentId(equipmentId); - radioUtilizationStatus.setStatusDataType(StatusDataType.RADIO_UTILIZATION); - RadioUtilizationReport radioUtilizationReport = new RadioUtilizationReport(); - radioUtilizationStatus.setDetails(radioUtilizationReport); - - radioUtilizationStatus = statusServiceInterface.update(radioUtilizationStatus); - + ce = equipmentServiceInterface.getByInventoryIdOrNull(apId); + if (ce == null) { + LOG.debug("wifiRadioStatusDbTableUpdate::Cannot get Equipment for AP {}", apId); + return; } + ((ApElementConfiguration) ce.getDetails()).setRadioMap(apElementConfiguration.getRadioMap()); + ((ApElementConfiguration) ce.getDetails()).setAdvancedRadioMap(apElementConfiguration.getAdvancedRadioMap()); - RadioUtilizationReport radioUtilizationReport = (RadioUtilizationReport) radioUtilizationStatus.getDetails(); - - Map radioEquipment = radioUtilizationReport - .getRadioUtilization(); - if (!radioEquipment.containsKey(radioFreqBand)) { - radioEquipment.put(radioFreqBand, new EquipmentPerRadioUtilizationDetails()); - radioUtilizationReport.setRadioUtilization(radioEquipment); + try { + equipmentServiceInterface.update(ce); + } catch (DsConcurrentModificationException e) { + LOG.debug("Equipment reference changed, update instance and retry.", e.getMessage()); + ce = equipmentServiceInterface.getByInventoryIdOrNull(apId); + ce.setDetails(apElementConfiguration); + ce = equipmentServiceInterface.update(ce); } - Map capacityDetails = radioUtilizationReport.getCapacityDetails(); - if (!capacityDetails.containsKey(radioFreqBand)) { - EquipmentCapacityDetails details = new EquipmentCapacityDetails(); - details.setTotalCapacity(100); - capacityDetails.put(radioFreqBand, details); - radioUtilizationReport.setCapacityDetails(capacityDetails); - } - - Map avgNoiseFloor = radioUtilizationReport.getAvgNoiseFloor(); - if (!avgNoiseFloor.containsKey(radioFreqBand)) { - avgNoiseFloor.put(radioFreqBand, null); - radioUtilizationReport.setAvgNoiseFloor(avgNoiseFloor); - } - - radioUtilizationStatus.setDetails(radioUtilizationReport); - - radioUtilizationStatus = statusServiceInterface.update(radioUtilizationStatus); - } @Override public void wifiInetStateDbTableUpdate(List inetStateTables, String apId) { + + LOG.debug("Received Wifi_Inet_State table update for AP {}", apId); + OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId); if (ovsdbSession == null) { diff --git a/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/ConnectusOvsdbClient.java b/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/ConnectusOvsdbClient.java index 967bbbc..c5296b1 100644 --- a/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/ConnectusOvsdbClient.java +++ b/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/ConnectusOvsdbClient.java @@ -142,17 +142,7 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface { String key = ConnectusOvsdbClient.this.ovsdbSessionMapInterface.lookupClientId(ovsdbClient); if (key != null) { - try { - ovsdbClient.cancelMonitor(OvsdbDao.wifiRadioStateDbTable + "_" + key).join(); - ovsdbClient.cancelMonitor(OvsdbDao.wifiVifStateDbTable + "_delete_" + key).join(); - ovsdbClient.cancelMonitor(OvsdbDao.wifiVifStateDbTable + "_" + key).join(); - ovsdbClient.cancelMonitor(OvsdbDao.wifiInetStateDbTable + "_" + key).join(); - ovsdbClient.cancelMonitor(OvsdbDao.wifiAssociatedClientsDbTable + "_" + key).join(); - ovsdbClient.cancelMonitor(OvsdbDao.wifiAssociatedClientsDbTable + "_delete_" + key).join(); - ovsdbClient.cancelMonitor(OvsdbDao.awlanNodeDbTable + "_" + key).join(); - } catch (OvsdbClientException e) { - LOG.debug("Unable to cancel monitor for state table. {}", e.getMessage()); - } + cancelMonitors(ovsdbClient, key); try { extIntegrationInterface.apDisconnected(key); ConnectusOvsdbClient.this.ovsdbSessionMapInterface.removeSession(key); @@ -169,12 +159,28 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface { ConnectusOvsdbClient.this.ovsdbSessionMapInterface.getNumSessions()); } + + }; listener.startListeningWithSsl(ovsdbListenPort, sslContext, connectionCallback).join(); LOG.info("Manager waiting for connection on port {}...", ovsdbListenPort); } + + private void cancelMonitors(OvsdbClient ovsdbClient, String key) { + try { + ovsdbClient.cancelMonitor(OvsdbDao.wifiRadioStateDbTable + "_" + key).join(); + ovsdbClient.cancelMonitor(OvsdbDao.wifiVifStateDbTable + "_delete_" + key).join(); + ovsdbClient.cancelMonitor(OvsdbDao.wifiVifStateDbTable + "_" + key).join(); + ovsdbClient.cancelMonitor(OvsdbDao.wifiInetStateDbTable + "_" + key).join(); + ovsdbClient.cancelMonitor(OvsdbDao.wifiAssociatedClientsDbTable + "_" + key).join(); + ovsdbClient.cancelMonitor(OvsdbDao.wifiAssociatedClientsDbTable + "_delete_" + key).join(); + ovsdbClient.cancelMonitor(OvsdbDao.awlanNodeDbTable + "_" + key).join(); + } catch (OvsdbClientException e) { + LOG.debug("Unable to cancel monitor for state table. {}", e.getMessage()); + } + } private ConnectNodeInfo processConnectRequest(OvsdbClient ovsdbClient, String clientCn, ConnectNodeInfo connectNodeInfo) { @@ -251,19 +257,31 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface { OpensyncAPConfig opensyncAPConfig = extIntegrationInterface.getApConfig(apId); if (opensyncAPConfig != null) { - - ovsdbDao.removeAllSsids(ovsdbClient); + try { + ovsdbClient.cancelMonitor(OvsdbDao.wifiRadioStateDbTable + "_" + apId).join(); + ovsdbClient.cancelMonitor(OvsdbDao.wifiVifStateDbTable + "_" + apId).join(); + ovsdbDao.removeAllSsids(ovsdbClient); - ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig); - ovsdbDao.configureSsids(ovsdbClient, opensyncAPConfig); - - ovsdbDao.removeAllStatsConfigs(ovsdbClient); // always - ovsdbDao.configureStats(ovsdbClient); - - if (ovsdbDao.getDeviceStatsReportingInterval(ovsdbClient) != collectionIntervalSecDeviceStats) { - ovsdbDao.updateDeviceStatsReportingInterval(ovsdbClient, collectionIntervalSecDeviceStats); + ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig); + ovsdbDao.configureSsids(ovsdbClient, opensyncAPConfig); + + + ovsdbDao.removeAllStatsConfigs(ovsdbClient); // always + ovsdbDao.configureStats(ovsdbClient); + + if (ovsdbDao.getDeviceStatsReportingInterval(ovsdbClient) != collectionIntervalSecDeviceStats) { + ovsdbDao.updateDeviceStatsReportingInterval(ovsdbClient, collectionIntervalSecDeviceStats); + } + monitorWifiRadioStateDbTable(ovsdbClient, apId); + monitorWifiVifStateDbTable(ovsdbClient, apId); + + } catch (OvsdbClientException e) { + LOG.error("Could not enable/disable table state monitors, cannot proccess config change for AP {}", apId); } + + + } else { LOG.warn("Could not get provisioned configuration for AP {}", apId); } @@ -274,20 +292,61 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface { } private void monitorOvsdbStateTables(OvsdbClient ovsdbClient, String key) throws OvsdbClientException { - CompletableFuture rsCf = ovsdbClient - .monitor(OvsdbDao.ovsdbName, OvsdbDao.wifiRadioStateDbTable + "_" + key, - new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiRadioStateDbTable, + monitorWifiRadioStateDbTable(ovsdbClient, key); +// monitorWifiInetStateDbTable(ovsdbClient, key); + + monitorWifiVifStateDbTableDeletion(ovsdbClient, key); + + monitorWifiVifStateDbTable(ovsdbClient, key); + +// monitorWifiAssociatedClientsDbTableDeletion(ovsdbClient, key); + +// monitorWifiAssociatedClientsDbTable(ovsdbClient, key); + + monitorAwlanNodeDbTable(ovsdbClient, key); + + } + + private void monitorAwlanNodeDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException { + CompletableFuture awCf = ovsdbClient + .monitor(OvsdbDao.ovsdbName, OvsdbDao.awlanNodeDbTable + "_" + key, + new MonitorRequests(ImmutableMap.of(OvsdbDao.awlanNodeDbTable, new MonitorRequest(new MonitorSelect(true, false, false, true)))), new MonitorCallback() { @Override public void update(TableUpdates tableUpdates) { - extIntegrationInterface.wifiRadioStatusDbTableUpdate( - ovsdbDao.getOpensyncAPRadioState(tableUpdates, key, ovsdbClient), key); + extIntegrationInterface.awlanNodeDbTableUpdate( + ovsdbDao.getOpensyncAWLANNode(tableUpdates, key, ovsdbClient), key); } }); - rsCf.join(); + awCf.join(); + } + + private void monitorWifiAssociatedClientsDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException { + CompletableFuture acCf = ovsdbClient + .monitor(OvsdbDao.ovsdbName, OvsdbDao.wifiAssociatedClientsDbTable + "_" + key, + new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiAssociatedClientsDbTable, + new MonitorRequest(new MonitorSelect(true, true, false, true)))), + new MonitorCallback() { + + @Override + public void update(TableUpdates tableUpdates) { + + for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) { + + extIntegrationInterface.wifiAssociatedClientsDbTableUpdate( + ovsdbDao.getOpensyncWifiAssociatedClients(tableUpdates, key, ovsdbClient), + key); + } + } + + }); + acCf.join(); + } + + private void monitorWifiInetStateDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException { CompletableFuture isCf = ovsdbClient.monitor(OvsdbDao.ovsdbName, OvsdbDao.wifiInetStateDbTable + "_" + key, new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiInetStateDbTable, @@ -304,7 +363,26 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface { }); isCf.join(); + } + private void monitorWifiRadioStateDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException { + CompletableFuture rsCf = ovsdbClient + .monitor(OvsdbDao.ovsdbName, OvsdbDao.wifiRadioStateDbTable + "_" + key, + new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiRadioStateDbTable, + new MonitorRequest(new MonitorSelect(true, false, false, true)))), + new MonitorCallback() { + + @Override + public void update(TableUpdates tableUpdates) { + extIntegrationInterface.wifiRadioStatusDbTableUpdate( + ovsdbDao.getOpensyncAPRadioState(tableUpdates, key, ovsdbClient), key); + } + + }); + rsCf.join(); + } + + private void monitorWifiVifStateDbTableDeletion(OvsdbClient ovsdbClient, String key) throws OvsdbClientException { CompletableFuture vsdCf = ovsdbClient .monitor(OvsdbDao.ovsdbName, OvsdbDao.wifiVifStateDbTable + "_delete_" + key, new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiVifStateDbTable, @@ -362,24 +440,9 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface { }); vsdCf.join(); + } - CompletableFuture vsCf = ovsdbClient - .monitor(OvsdbDao.ovsdbName, OvsdbDao.wifiVifStateDbTable + "_" + key, - new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiVifStateDbTable, - new MonitorRequest(new MonitorSelect(true, true, false, true)))), - new MonitorCallback() { - @Override - public void update(TableUpdates tableUpdates) { - - extIntegrationInterface.wifiVIFStateDbTableUpdate( - ovsdbDao.getOpensyncAPVIFState(tableUpdates, key, ovsdbClient), key); - - } - - }); - - vsCf.join(); - + private void monitorWifiAssociatedClientsDbTableDeletion(OvsdbClient ovsdbClient, String key) throws OvsdbClientException { CompletableFuture acdCf = ovsdbClient .monitor(OvsdbDao.ovsdbName, OvsdbDao.wifiAssociatedClientsDbTable + "_delete_" + key, new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiAssociatedClientsDbTable, @@ -406,42 +469,25 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface { }); acdCf.join(); + } - CompletableFuture acCf = ovsdbClient - .monitor(OvsdbDao.ovsdbName, OvsdbDao.wifiAssociatedClientsDbTable + "_" + key, - new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiAssociatedClientsDbTable, + private void monitorWifiVifStateDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException { + CompletableFuture vsCf = ovsdbClient + .monitor(OvsdbDao.ovsdbName, OvsdbDao.wifiVifStateDbTable + "_" + key, + new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiVifStateDbTable, new MonitorRequest(new MonitorSelect(true, true, false, true)))), new MonitorCallback() { - @Override public void update(TableUpdates tableUpdates) { - for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) { + extIntegrationInterface.wifiVIFStateDbTableUpdate( + ovsdbDao.getOpensyncAPVIFState(tableUpdates, key, ovsdbClient), key); - extIntegrationInterface.wifiAssociatedClientsDbTableUpdate( - ovsdbDao.getOpensyncWifiAssociatedClients(tableUpdates, key, ovsdbClient), - key); - } } }); - acCf.join(); - - CompletableFuture awCf = ovsdbClient - .monitor(OvsdbDao.ovsdbName, OvsdbDao.awlanNodeDbTable + "_" + key, - new MonitorRequests(ImmutableMap.of(OvsdbDao.awlanNodeDbTable, - new MonitorRequest(new MonitorSelect(true, false, false, true)))), - new MonitorCallback() { - - @Override - public void update(TableUpdates tableUpdates) { - extIntegrationInterface.awlanNodeDbTableUpdate( - ovsdbDao.getOpensyncAWLANNode(tableUpdates, key, ovsdbClient), key); - } - - }); - awCf.join(); + vsCf.join(); } @Override