Disable monitor when handle config changed, optimization of handle Wifi_Radio_State changes

This commit is contained in:
Mike Hansen
2020-06-30 13:44:51 -04:00
parent f176c82d81
commit a4575f8d12
2 changed files with 143 additions and 133 deletions

View File

@@ -1778,6 +1778,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
@Override
public void wifiVIFStateDbTableUpdate(List<OpensyncAPVIFState> 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<OpensyncAPRadioState> radioStateTables, String apId) {
LOG.debug("Received Wifi_Radio_State table update for AP {}", apId);
OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId);
if (ovsdbSession == null) {
@@ -1894,24 +1896,22 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
return;
}
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());
for (OpensyncAPRadioState radioState : radioStateTables) {
if (radioState.getFreqBand().equals(RadioType.UNSUPPORTED)) {
LOG.debug("Could not get radio configuration for AP {}", apId);
continue;
}
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);
}
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());
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);
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);
}
RadioUtilizationReport radioUtilizationReport = (RadioUtilizationReport) radioUtilizationStatus.getDetails();
Map<RadioType, EquipmentPerRadioUtilizationDetails> radioEquipment = radioUtilizationReport
.getRadioUtilization();
if (!radioEquipment.containsKey(radioFreqBand)) {
radioEquipment.put(radioFreqBand, new EquipmentPerRadioUtilizationDetails());
radioUtilizationReport.setRadioUtilization(radioEquipment);
}
Map<RadioType, EquipmentCapacityDetails> capacityDetails = radioUtilizationReport.getCapacityDetails();
if (!capacityDetails.containsKey(radioFreqBand)) {
EquipmentCapacityDetails details = new EquipmentCapacityDetails();
details.setTotalCapacity(100);
capacityDetails.put(radioFreqBand, details);
radioUtilizationReport.setCapacityDetails(capacityDetails);
}
Map<RadioType, Integer> 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<OpensyncAPInetState> inetStateTables, String apId) {
LOG.debug("Received Wifi_Inet_State table update for AP {}", apId);
OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId);
if (ovsdbSession == null) {

View File

@@ -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,6 +159,8 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface {
ConnectusOvsdbClient.this.ovsdbSessionMapInterface.getNumSessions());
}
};
listener.startListeningWithSsl(ovsdbListenPort, sslContext, connectionCallback).join();
@@ -176,6 +168,20 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface {
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,18 +257,30 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface {
OpensyncAPConfig opensyncAPConfig = extIntegrationInterface.getApConfig(apId);
if (opensyncAPConfig != null) {
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);
}
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<TableUpdates> 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<TableUpdates> 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<TableUpdates> 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<TableUpdates> 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<TableUpdates> 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<TableUpdates> 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<TableUpdates> 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<TableUpdates> 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<TableUpdates> acCf = ovsdbClient
.monitor(OvsdbDao.ovsdbName, OvsdbDao.wifiAssociatedClientsDbTable + "_" + key,
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiAssociatedClientsDbTable,
private void monitorWifiVifStateDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
CompletableFuture<TableUpdates> 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<TableUpdates> 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