mirror of
https://github.com/Telecominfraproject/wlan-cloud-opensync-controller.git
synced 2025-11-01 11:07:49 +00:00
Compare commits
1 Commits
release/v1
...
WIFI-7888-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1db594b656 |
@@ -1,5 +1,7 @@
|
|||||||
package com.telecominfraproject.wlan.opensync.external.integration;
|
package com.telecominfraproject.wlan.opensync.external.integration;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import com.vmware.ovsdb.service.OvsdbClient;
|
import com.vmware.ovsdb.service.OvsdbClient;
|
||||||
|
|
||||||
public class OvsdbSession {
|
public class OvsdbSession {
|
||||||
@@ -7,6 +9,7 @@ public class OvsdbSession {
|
|||||||
private String apId;
|
private String apId;
|
||||||
private long routingId;
|
private long routingId;
|
||||||
private long equipmentId;
|
private long equipmentId;
|
||||||
|
private AtomicInteger currentConfigNumInFlight = new AtomicInteger();
|
||||||
|
|
||||||
public OvsdbClient getOvsdbClient() {
|
public OvsdbClient getOvsdbClient() {
|
||||||
return ovsdbClient;
|
return ovsdbClient;
|
||||||
@@ -32,5 +35,9 @@ public class OvsdbSession {
|
|||||||
public void setEquipmentId(long equipmentId) {
|
public void setEquipmentId(long equipmentId) {
|
||||||
this.equipmentId = equipmentId;
|
this.equipmentId = equipmentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AtomicInteger getCurrentConfigNumInFlight() {
|
||||||
|
return currentConfigNumInFlight;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -440,29 +440,56 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
|
|
||||||
OvsdbClient ovsdbClient = ovsdbSession.getOvsdbClient();
|
OvsdbClient ovsdbClient = ovsdbSession.getOvsdbClient();
|
||||||
|
|
||||||
OpensyncAPConfig opensyncAPConfig = extIntegrationInterface.getApConfig(apId);
|
int currentConfigCount = ovsdbSession.getCurrentConfigNumInFlight().get();
|
||||||
|
if (currentConfigCount == 0L) {
|
||||||
if (opensyncAPConfig == null) {
|
// Current count is 0, start this config push
|
||||||
LOG.warn("AP with id " + apId + " does not have a config to apply.");
|
// Increment other incoming configs into the count until this config push is done
|
||||||
return;
|
currentConfigCount = ovsdbSession.getCurrentConfigNumInFlight().incrementAndGet();
|
||||||
|
do {
|
||||||
|
try {
|
||||||
|
OpensyncAPConfig opensyncAPConfig = extIntegrationInterface.getApConfig(apId);
|
||||||
|
|
||||||
|
if (opensyncAPConfig == null) {
|
||||||
|
LOG.warn("AP with id " + apId + " does not have a config to apply.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//get last known configVersion from the AP
|
||||||
|
long configVersionFromAp = checkBeforePushConfigVersionFromAp ? ovsdbDao.getConfigVersionFromNode(ovsdbClient) : 0;
|
||||||
|
|
||||||
|
//get last known configVersion from the EquipmentProtocolStatusData
|
||||||
|
long configVersionFromStatus = checkBeforePushConfigVersionFromStatus ? extIntegrationInterface.getConfigVersionFromStatus(apId) : 0;
|
||||||
|
|
||||||
|
//get current configVersion from the profiles and equipment
|
||||||
|
long configVersionFromProfiles = opensyncAPConfig.getConfigVersion();
|
||||||
|
|
||||||
|
boolean needToPushConfigToAP = needToPushToAp(configVersionFromAp, configVersionFromStatus, configVersionFromProfiles);
|
||||||
|
|
||||||
|
if(needToPushConfigToAP) {
|
||||||
|
pushConfigToAp(ovsdbClient, opensyncAPConfig, apId, configVersionFromProfiles);
|
||||||
|
}
|
||||||
|
LOG.debug("Finished processConfigChanged for {}", apId);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
// If anything fails in the ovsdb config push, clean up count and exit
|
||||||
|
ovsdbSession.getCurrentConfigNumInFlight().set(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int checkCount = ovsdbSession.getCurrentConfigNumInFlight().get();
|
||||||
|
if (checkCount == currentConfigCount) {
|
||||||
|
// Count didn't change from pre-config push, we can clean up and exit
|
||||||
|
if (ovsdbSession.getCurrentConfigNumInFlight().compareAndSet(currentConfigCount, 0)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Count has changed, update the currentConfigCount and rerun config push
|
||||||
|
ovsdbSession.getCurrentConfigNumInFlight().incrementAndGet();
|
||||||
|
}
|
||||||
|
} while (ovsdbSession.getCurrentConfigNumInFlight().get() != 0);
|
||||||
|
} else {
|
||||||
|
// Count is not 0, another request is being processed for this OvsdbSession
|
||||||
|
// Remember this request, and the other thread will check the count when it's done
|
||||||
|
ovsdbSession.getCurrentConfigNumInFlight().incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
//get last known configVersion from the AP
|
|
||||||
long configVersionFromAp = checkBeforePushConfigVersionFromAp ? ovsdbDao.getConfigVersionFromNode(ovsdbClient) : 0;
|
|
||||||
|
|
||||||
//get last known configVersion from the EquipmentProtocolStatusData
|
|
||||||
long configVersionFromStatus = checkBeforePushConfigVersionFromStatus ? extIntegrationInterface.getConfigVersionFromStatus(apId) : 0;
|
|
||||||
|
|
||||||
//get current configVersion from the profiles and equipment
|
|
||||||
long configVersionFromProfiles = opensyncAPConfig.getConfigVersion();
|
|
||||||
|
|
||||||
boolean needToPushConfigToAP = needToPushToAp(configVersionFromAp, configVersionFromStatus, configVersionFromProfiles);
|
|
||||||
|
|
||||||
if(needToPushConfigToAP) {
|
|
||||||
pushConfigToAp(ovsdbClient, opensyncAPConfig, apId, configVersionFromProfiles);
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG.debug("Finished processConfigChanged for {}", apId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user