Compare commits

...

2 Commits

4 changed files with 82 additions and 39 deletions

View File

@@ -138,6 +138,7 @@ import sts.OpensyncStats.Report;
@Component
public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegrationInterface {
public static final String DERIVED_SESSION_ID_PREFIX = "DERIVED-";
protected static final String standard_linux_date_format = "EEE MMM dd HH:mm:ss zzz yyyy";
private static final String VLAN_TRUNK_IF_TYPE = "vlan_trunk";
private static final String ALLOWED_VLANS = "allowed_vlans";
@@ -1825,7 +1826,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
clientSession.setLocationId(ce.getLocationId());
clientSession.setDetails(new ClientSessionDetails());
long derivedSessionId = WiFiSessionUtility.encodeWiFiAssociationId(timestamp / 1000, clientInstance.getMacAddress().getAddressAsLong());
clientSession.getDetails().setSessionId(Long.toUnsignedString(derivedSessionId));
clientSession.getDetails().setSessionId(DERIVED_SESSION_ID_PREFIX + Long.toUnsignedString(derivedSessionId));
clientSession.getDetails().setDhcpDetails(new ClientDhcpDetails(Long.toUnsignedString(derivedSessionId)));
clientSession.getDetails().setAssociationState(AssociationState._802_11_Associated);
clientSession.getDetails().setIsReassociation(false);

View File

@@ -21,6 +21,7 @@ import com.telecominfraproject.wlan.client.session.models.ClientSession;
import com.telecominfraproject.wlan.client.session.models.ClientSessionDetails;
import com.telecominfraproject.wlan.cloudeventdispatcher.CloudEventDispatcherInterface;
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
import com.telecominfraproject.wlan.opensync.external.integration.OpensyncExternalIntegrationCloud;
import com.telecominfraproject.wlan.opensync.util.OvsdbToWlanCloudTypeMappingUtility;
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetric;
@@ -105,10 +106,10 @@ public class AsyncPublishService {
processClientAssocEvent(customerId, equipmentId, locationId, apEventClientSession);
}
if (apEventClientSession.hasClientIpEvent()) {
processClientIpEvent(customerId, equipmentId, locationId, apEventClientSession);
processClientIpEvent(apId, customerId, equipmentId, locationId, apEventClientSession);
}
if (apEventClientSession.hasClientDisconnectEvent()) {
processClientDisconnectEvent(customerId, equipmentId, locationId, apEventClientSession);
processClientDisconnectEvent(apId, customerId, equipmentId, locationId, apEventClientSession);
}
}
realtimeEventPublisher.publishChannelHopEvents(customerId, equipmentId, locationId, eventReport);
@@ -238,7 +239,7 @@ public class AsyncPublishService {
}
private void processClientIpEvent(int customerId, long equipmentId, long locationId, sts.OpensyncStats.EventReport.ClientSession apEventClientSession) {
private void processClientIpEvent(String apId, int customerId, long equipmentId, long locationId, sts.OpensyncStats.EventReport.ClientSession apEventClientSession) {
ClientIpEvent apClientEvent = apEventClientSession.getClientIpEvent();
com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId, MacAddress.valueOf(apClientEvent.getStaMac()));
if (client == null) {
@@ -263,12 +264,16 @@ public class AsyncPublishService {
if (clientSession.getDetails().getPriorEquipmentId() == null) {
clientSession.getDetails().setPriorEquipmentId(clientSession.getEquipmentId());
}
if (clientSession.getDetails().getPriorSessionId() == null) {
if (!Objects.equal(clientSession.getDetails().getSessionId(), Long.toUnsignedString(apEventClientSession.getSessionId())))
clientSession.getDetails().setPriorSessionId(clientSession.getDetails().getSessionId());
}
if (!Objects.equal(clientSession.getDetails().getSessionId(), Long.toUnsignedString(apEventClientSession.getSessionId()))) {
clientSession.getDetails().setPriorSessionId(clientSession.getDetails().getSessionId());
String sessionId = clientSession.getDetails().getSessionId();
if (!Objects.equal(sessionId, Long.toUnsignedString(apEventClientSession.getSessionId()))) {
if (sessionId != null && !sessionId.startsWith(OpensyncExternalIntegrationCloud.DERIVED_SESSION_ID_PREFIX)) {
LOG.info("Ignored clientIpEvent for different session ID for AP {}, clientMac {}: currentSessionId {}, ipSessionID {} ", apId,
apClientEvent.getStaMac(), sessionId, apEventClientSession.getSessionId());
realtimeEventPublisher.publishClientIpEvent(customerId, equipmentId, locationId, apEventClientSession.getClientIpEvent());
return;
}
clientSession.getDetails().setPriorSessionId(sessionId);
}
clientSession.getDetails().setSessionId(Long.toUnsignedString(apEventClientSession.getSessionId()));
if (apClientEvent.hasIpAddr()) {
@@ -294,7 +299,7 @@ public class AsyncPublishService {
realtimeEventPublisher.publishClientIpEvent(customerId, equipmentId, locationId, apEventClientSession.getClientIpEvent());
}
private void processClientDisconnectEvent(int customerId, long equipmentId, long locationId,
private void processClientDisconnectEvent(String apId, int customerId, long equipmentId, long locationId,
sts.OpensyncStats.EventReport.ClientSession apEventClientSession) {
ClientDisconnectEvent apClientEvent = apEventClientSession.getClientDisconnectEvent();
com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId, MacAddress.valueOf(apClientEvent.getStaMac()));
@@ -316,12 +321,15 @@ public class AsyncPublishService {
clientSession.getDetails().setDhcpDetails(new ClientDhcpDetails(Long.toUnsignedString(apEventClientSession.getSessionId())));
}
if (clientSession.getDetails().getPriorSessionId() == null) {
if (!Objects.equal(clientSession.getDetails().getSessionId(), Long.toUnsignedString(apEventClientSession.getSessionId())))
clientSession.getDetails().setPriorSessionId(clientSession.getDetails().getSessionId());
}
if (!Objects.equal(clientSession.getDetails().getSessionId(), Long.toUnsignedString(apEventClientSession.getSessionId()))) {
clientSession.getDetails().setPriorSessionId(clientSession.getDetails().getSessionId());
String sessionId = clientSession.getDetails().getSessionId();
if (!Objects.equal(sessionId, Long.toUnsignedString(apEventClientSession.getSessionId()))) {
if (sessionId != null && !sessionId.startsWith(OpensyncExternalIntegrationCloud.DERIVED_SESSION_ID_PREFIX)) {
LOG.info("Ignored clientDisconnectEvent for different session ID for AP {}, clientMac {}: currentSessionId {}, disconnectSessionID {} ", apId,
apClientEvent.getStaMac(), sessionId, apEventClientSession.getSessionId());
realtimeEventPublisher.publishClientDisconnectEvent(customerId, equipmentId, locationId, apEventClientSession.getClientDisconnectEvent());
return;
}
clientSession.getDetails().setPriorSessionId(sessionId);
}
clientSession.getDetails().setSessionId(Long.toUnsignedString(apEventClientSession.getSessionId()));
clientSession.getDetails().setRadioType(OvsdbToWlanCloudTypeMappingUtility.getRadioTypeFromOpensyncStatsRadioBandType(apClientEvent.getBand()));

View File

@@ -1,5 +1,7 @@
package com.telecominfraproject.wlan.opensync.external.integration;
import java.util.concurrent.atomic.AtomicInteger;
import com.vmware.ovsdb.service.OvsdbClient;
public class OvsdbSession {
@@ -7,6 +9,7 @@ public class OvsdbSession {
private String apId;
private long routingId;
private long equipmentId;
private AtomicInteger currentConfigNumInFlight = new AtomicInteger();
public OvsdbClient getOvsdbClient() {
return ovsdbClient;
@@ -32,5 +35,9 @@ public class OvsdbSession {
public void setEquipmentId(long equipmentId) {
this.equipmentId = equipmentId;
}
public AtomicInteger getCurrentConfigNumInFlight() {
return currentConfigNumInFlight;
}
}

View File

@@ -440,29 +440,56 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
OvsdbClient ovsdbClient = ovsdbSession.getOvsdbClient();
OpensyncAPConfig opensyncAPConfig = extIntegrationInterface.getApConfig(apId);
if (opensyncAPConfig == null) {
LOG.warn("AP with id " + apId + " does not have a config to apply.");
return;
int currentConfigCount = ovsdbSession.getCurrentConfigNumInFlight().get();
if (currentConfigCount == 0L) {
// Current count is 0, start this config push
// Increment other incoming configs into the count until this config push is done
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