WIFI-767: Cloud Back End for Events Integration

This commit is contained in:
Mike Hansen
2021-01-06 15:56:48 -05:00
parent 9659433e76
commit cd4874ae18
3 changed files with 382 additions and 259 deletions

View File

@@ -158,7 +158,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
public String defaultWanInterfaceType;
@Value("${tip.wlan.ovsdb.wifi-iface.default_wan_name:wan}")
public String defaultWanInterfaceName;
@Value("${tip.wlan.ovsdb.syncUpRadioConfigsForProvisionedEquipment:true}")
private boolean syncUpRadioConfigsForProvisionedEquipment;
@@ -305,47 +305,49 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
}
}
if(syncUpRadioConfigsForProvisionedEquipment) {
//sync up available radios reported by AP with the ApElementConfiguration, update equipment in DB if needed
if (syncUpRadioConfigsForProvisionedEquipment) {
// sync up available radios reported by AP with the
// ApElementConfiguration, update equipment in DB if needed
boolean needToUpdateEquipment = false;
ApElementConfiguration apElementConfig = (ApElementConfiguration) ce.getDetails();
if(apElementConfig == null) {
if (apElementConfig == null) {
apElementConfig = ApElementConfiguration.createWithDefaults();
ce.setDetails(apElementConfig);
needToUpdateEquipment = true;
}
if(apElementConfig.getDeviceName()==null || !apElementConfig.getDeviceName().equals(ce.getName())) {
if (apElementConfig.getDeviceName() == null
|| !apElementConfig.getDeviceName().equals(ce.getName())) {
apElementConfig.setDeviceName(ce.getName());
needToUpdateEquipment = true;
}
if(apElementConfig.getEquipmentModel()==null || !apElementConfig.getEquipmentModel().equals(connectNodeInfo.model)) {
if (apElementConfig.getEquipmentModel() == null
|| !apElementConfig.getEquipmentModel().equals(connectNodeInfo.model)) {
apElementConfig.setEquipmentModel(connectNodeInfo.model);
needToUpdateEquipment = true;
}
Map<RadioType, RadioConfiguration> advancedRadioMap = apElementConfig.getAdvancedRadioMap();
Map<RadioType, ElementRadioConfiguration> radioMap = apElementConfig.getRadioMap();
if(advancedRadioMap == null) {
advancedRadioMap = new HashMap<>();
if (advancedRadioMap == null) {
advancedRadioMap = new HashMap<>();
apElementConfig.setAdvancedRadioMap(advancedRadioMap);
needToUpdateEquipment = true;
}
if(radioMap == null) {
if (radioMap == null) {
radioMap = new HashMap<>();
apElementConfig.setRadioMap(radioMap);
needToUpdateEquipment = true;
}
Set<RadioType> radiosFromAp = new HashSet<>();
//add missing radio configs from the AP into the DB
// add missing radio configs from the AP into the DB
for (String radio : connectNodeInfo.wifiRadioStates.keySet()) {
RadioType radioType = RadioType.UNSUPPORTED;
if (radio.equals("2.4G")) {
@@ -357,51 +359,52 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
} else if (radio.equals("5GU")) {
radioType = RadioType.is5GHzU;
}
if (!radioType.equals(RadioType.UNSUPPORTED)) {
radiosFromAp.add(radioType);
RadioConfiguration advancedRadioConfiguration = advancedRadioMap.get(radioType);
ElementRadioConfiguration radioConfiguration = radioMap.get(radioType);
if(advancedRadioConfiguration == null) {
advancedRadioConfiguration = RadioConfiguration.createWithDefaults(radioType);
advancedRadioMap.put(radioType, advancedRadioConfiguration);
needToUpdateEquipment = true;
if (advancedRadioConfiguration == null) {
advancedRadioConfiguration = RadioConfiguration.createWithDefaults(radioType);
advancedRadioMap.put(radioType, advancedRadioConfiguration);
needToUpdateEquipment = true;
}
if(radioConfiguration == null) {
radioConfiguration = ElementRadioConfiguration.createWithDefaults(radioType);
radioMap.put(radioType, radioConfiguration);
needToUpdateEquipment = true;
if (radioConfiguration == null) {
radioConfiguration = ElementRadioConfiguration.createWithDefaults(radioType);
radioMap.put(radioType, radioConfiguration);
needToUpdateEquipment = true;
}
}
}
//remove radio configs from the DB that are no longer present in the AP but still exist in DB
for(RadioType radioType: RadioType.validValues()) {
// remove radio configs from the DB that are no longer
// present in the AP but still exist in DB
for (RadioType radioType : RadioType.validValues()) {
RadioConfiguration advancedRadioConfiguration = advancedRadioMap.get(radioType);
if(advancedRadioConfiguration != null || !radiosFromAp.contains(radioType)) {
if (advancedRadioConfiguration != null || !radiosFromAp.contains(radioType)) {
advancedRadioMap.remove(radioType);
needToUpdateEquipment = true;
}
ElementRadioConfiguration radioConfiguration = radioMap.get(radioType);
if(radioConfiguration != null || !radiosFromAp.contains(radioType)) {
if (radioConfiguration != null || !radiosFromAp.contains(radioType)) {
radioMap.remove(radioType);
needToUpdateEquipment = true;
}
}
if(needToUpdateEquipment) {
if (needToUpdateEquipment) {
ce = equipmentServiceInterface.update(ce);
}
}
}
@@ -911,7 +914,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
List<ClientSession> toBeDisconnected = new ArrayList<>();
clientSessions.getItems().stream().forEach(c -> {
if (!c.getDetails().getAssociationState().equals(AssociationState.Disconnected)) {
if (c.getDetails().getAssociationState() != null
&& !c.getDetails().getAssociationState().equals(AssociationState.Disconnected)) {
LOG.info("Change association state for client {} from {} to {}", c.getMacAddress(),
c.getDetails().getAssociationState(), AssociationState.Disconnected);
@@ -1226,29 +1230,35 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
}
if (radioState.getAllowedChannels() != null) {
apElementConfiguration.getRadioMap().get(radioState.getFreqBand())
.setAllowedChannels(new ArrayList<>(radioState.getAllowedChannels()));
if (apElementConfiguration.getRadioMap().containsKey(radioState.getFreqBand())
&& apElementConfiguration.getRadioMap().get(radioState.getFreqBand()) != null) {
apElementConfiguration.getRadioMap().get(radioState.getFreqBand())
.setAllowedChannels(new ArrayList<>(radioState.getAllowedChannels()));
LOG.debug("Updated AllowedChannels from Wifi_Radio_State table change for AP {}", apId);
LOG.debug("Updated AllowedChannels from Wifi_Radio_State table change for AP {}", apId);
}
}
if (radioState.getTxPower() > 0) {
SourceType txPowerSource = apElementConfiguration.getRadioMap().get(radioState.getFreqBand())
.getEirpTxPower().getSource();
// Preserve the source while updating the value
if (txPowerSource == SourceType.auto) {
apElementConfiguration.getRadioMap().get(radioState.getFreqBand())
.setEirpTxPower(SourceSelectionValue.createAutomaticInstance(radioState.getTxPower()));
} else if (txPowerSource == SourceType.profile) {
apElementConfiguration.getRadioMap().get(radioState.getFreqBand())
.setEirpTxPower(SourceSelectionValue.createProfileInstance(radioState.getTxPower()));
} else {
apElementConfiguration.getRadioMap().get(radioState.getFreqBand())
.setEirpTxPower(SourceSelectionValue.createManualInstance(radioState.getTxPower()));
}
if (apElementConfiguration.getRadioMap().containsKey(radioState.getFreqBand())
&& apElementConfiguration.getRadioMap().get(radioState.getFreqBand()) != null) {
SourceType txPowerSource = apElementConfiguration.getRadioMap().get(radioState.getFreqBand())
.getEirpTxPower().getSource();
// Preserve the source while updating the value
if (txPowerSource == SourceType.auto) {
apElementConfiguration.getRadioMap().get(radioState.getFreqBand())
.setEirpTxPower(SourceSelectionValue.createAutomaticInstance(radioState.getTxPower()));
} else if (txPowerSource == SourceType.profile) {
apElementConfiguration.getRadioMap().get(radioState.getFreqBand())
.setEirpTxPower(SourceSelectionValue.createProfileInstance(radioState.getTxPower()));
} else {
apElementConfiguration.getRadioMap().get(radioState.getFreqBand())
.setEirpTxPower(SourceSelectionValue.createManualInstance(radioState.getTxPower()));
}
LOG.debug("Updated TxPower from Wifi_Radio_State table change for AP {}", apId);
LOG.debug("Updated TxPower from Wifi_Radio_State table change for AP {}", apId);
}
}
StateSetting state = StateSetting.disabled;
@@ -1256,13 +1266,17 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
state = StateSetting.enabled;
}
if (!apElementConfiguration.getAdvancedRadioMap().get(radioState.getFreqBand()).getRadioAdminState()
.equals(state)) {
// only update if changed
apElementConfiguration.getAdvancedRadioMap().get(radioState.getFreqBand()).setRadioAdminState(state);
if (apElementConfiguration.getAdvancedRadioMap().containsKey(radioState.getFreqBand())
&& apElementConfiguration.getAdvancedRadioMap().get(radioState.getFreqBand()) != null) {
if (!apElementConfiguration.getAdvancedRadioMap().get(radioState.getFreqBand()).getRadioAdminState()
.equals(state)) {
// only update if changed
apElementConfiguration.getAdvancedRadioMap().get(radioState.getFreqBand())
.setRadioAdminState(state);
LOG.debug("Updated RadioAdminState from Wifi_Radio_State table change for AP {}", apId);
LOG.debug("Updated RadioAdminState from Wifi_Radio_State table change for AP {}", apId);
}
}
protocolStatus = statusServiceInterface.getOrNull(customerId, equipmentId, StatusDataType.PROTOCOL);
@@ -1350,7 +1364,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
currentActiveBSSIDs = new ArrayList<>();
} else {
currentActiveBSSIDs = currentActiveBSSIDs.stream()
.filter(p -> (p.getRadioType() != null && p.getSsid() != null)).filter(p -> !p.getRadioType().equals(freqBand) || !p.getSsid().equals(ssid))
.filter(p -> (p.getRadioType() != null && p.getSsid() != null))
.filter(p -> !p.getRadioType().equals(freqBand) || !p.getSsid().equals(ssid))
.collect(Collectors.toList());
LOG.debug(
"Processing Wifi_VIF_State table update for AP {}, activeBSSIDs bssidList without current radio freq {} and ssid {}",
@@ -1576,17 +1591,41 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
clientSession.setMacAddress(clientInstance.getMacAddress());
clientSession.setLocationId(ce.getLocationId());
ClientSessionDetails clientSessionDetails = new ClientSessionDetails();
clientSessionDetails.setSessionId(clientInstance.getMacAddress().getAddressAsLong());
clientSessionDetails.setIsReassociation(isReassociation);
clientSessionDetails.setAssociationState(AssociationState._802_11_Associated);
clientSessionDetails.setAssocTimestamp(System.currentTimeMillis());
clientSession.setDetails(clientSessionDetails);
clientSessionDetails.setAssocTimestamp(System.currentTimeMillis());
LOG.info(
"Client {} associated with AP, no current session. Adding session with a generated session id of {}.",
clientInstance, clientInstance.getMacAddress().getAddressAsLong());
clientSession = clientServiceInterface.updateSession(clientSession);
LOG.info("Client {} associated with AP, no current session. Created session {}.", clientInstance,
clientSession);
}
ClientSessionDetails clientSessionDetails = clientSession.getDetails();
clientSessionDetails.setAssociationState(AssociationState._802_11_Associated);
clientSessionDetails.setAssocTimestamp(System.currentTimeMillis());
clientSession.getDetails().mergeSession(clientSessionDetails);
if (opensyncWifiAssociatedClients.state != null
&& opensyncWifiAssociatedClients.state.equalsIgnoreCase("active")) {
clientSession.getDetails().setAssociationState(AssociationState.Active_Data);
clientSession = clientServiceInterface.updateSession(clientSession);
clientSession = clientServiceInterface.updateSession(clientSession);
} else {
if (clientSession.getDetails().getAssociationState() != null) {
if (!clientSession.getDetails().getAssociationState().equals(AssociationState._802_11_Associated)) {
clientSession.getDetails().setAssociationState(AssociationState._802_11_Associated);
clientSession.getDetails().setAssocTimestamp(System.currentTimeMillis());
clientSession = clientServiceInterface.updateSession(clientSession);
}
} else {
clientSession.getDetails().setAssociationState(AssociationState._802_11_Associated);
clientSession.getDetails().setAssocTimestamp(System.currentTimeMillis());
clientSession = clientServiceInterface.updateSession(clientSession);
}
}
}

View File

@@ -109,7 +109,6 @@ import sts.OpensyncStats.EventReport.ClientFirstDataEvent;
import sts.OpensyncStats.EventReport.ClientIdEvent;
import sts.OpensyncStats.EventReport.ClientIpEvent;
import sts.OpensyncStats.EventReport.ClientTimeoutEvent;
import sts.OpensyncStats.EventReport.DhcpTransaction;
import sts.OpensyncStats.FrameType;
import sts.OpensyncStats.Neighbor;
import sts.OpensyncStats.Neighbor.NeighborBss;
@@ -302,167 +301,175 @@ public class MqttStatsPublisher {
for (sts.OpensyncStats.EventReport.ClientSession apEventClientSession : e.getClientSessionList()) {
LOG.debug("Processing EventReport::ClientSession {}", apEventClientSession);
processClientConnectEvent(customerId, equipmentId, locationId, e, apEventClientSession);
processClientDisconnectEvent(customerId, equipmentId, locationId, apEventClientSession);
processClientAuthEvent(customerId, equipmentId, locationId, apEventClientSession);
processClientAssocEvent(customerId, equipmentId, locationId, apEventClientSession);
processClientFailureEvent(customerId, equipmentId, locationId, apEventClientSession);
processClientFirstDataEvent(customerId, equipmentId, locationId, apEventClientSession);
processClientIdEvent(customerId, equipmentId, locationId, apEventClientSession);
processClientIpEvent(customerId, equipmentId, locationId, apEventClientSession);
processClientTimeoutEvent(customerId, equipmentId, locationId, apEventClientSession);
if (apEventClientSession.hasClientConnectEvent()) {
processClientConnectEvent(customerId, equipmentId, locationId, e, apEventClientSession);
}
if (apEventClientSession.hasClientDisconnectEvent()) {
processClientDisconnectEvent(customerId, equipmentId, locationId, apEventClientSession);
}
if (apEventClientSession.hasClientAuthEvent()) {
processClientAuthEvent(customerId, equipmentId, locationId, apEventClientSession);
}
if (apEventClientSession.hasClientAssocEvent()) {
processClientAssocEvent(customerId, equipmentId, locationId, apEventClientSession);
}
if (apEventClientSession.hasClientFailureEvent()) {
processClientFailureEvent(customerId, equipmentId, locationId, apEventClientSession);
}
if (apEventClientSession.hasClientFirstDataEvent()) {
processClientFirstDataEvent(customerId, equipmentId, locationId, apEventClientSession);
}
if (apEventClientSession.hasClientIdEvent()) {
processClientIdEvent(customerId, equipmentId, locationId, apEventClientSession);
}
if (apEventClientSession.hasClientIpEvent()) {
processClientIpEvent(customerId, equipmentId, locationId, apEventClientSession);
}
if (apEventClientSession.hasClientTimeoutEvent()) {
processClientTimeoutEvent(customerId, equipmentId, locationId, apEventClientSession);
}
}
realtimeEventPublisher.publishChannelHopEvents(customerId, equipmentId, e);
realtimeEventPublisher.publishDhcpTransactionEvents(customerId,equipmentId,e.getDhcpTransactionList());
// TODO: add DHCP transaction processing, for now just log it
for (DhcpTransaction dhcpTransaction : e.getDhcpTransactionList()) {
LOG.info("DhcpTransaction {}", dhcpTransaction);
}
});
}
protected void processClientConnectEvent(int customerId, long equipmentId, long locationId, EventReport e,
sts.OpensyncStats.EventReport.ClientSession apEventClientSession) {
ClientConnectEvent clientConnectEvent = apEventClientSession.getClientConnectEvent();
realtimeEventPublisher.publishClientConnectSuccessEvent(customerId, equipmentId, clientConnectEvent);
ClientConnectEvent clientConnectEvent = apEventClientSession.getClientConnectEvent();
com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId,
MacAddress.valueOf(clientConnectEvent.getStaMac()));
if (client == null) {
client = new com.telecominfraproject.wlan.client.models.Client();
client.setCustomerId(customerId);
client.setMacAddress(MacAddress.valueOf(clientConnectEvent.getStaMac()));
if (clientConnectEvent.hasStaMac()) {
com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId,
MacAddress.valueOf(clientConnectEvent.getStaMac()));
if (client == null) {
client = new com.telecominfraproject.wlan.client.models.Client();
client.setDetails(new ClientInfoDetails());
client.setCustomerId(customerId);
client.setMacAddress(MacAddress.valueOf(clientConnectEvent.getStaMac()));
client = clientServiceInterface.create(client);
client.setDetails(new ClientInfoDetails());
}
client = clientServiceInterface.create(client);
ClientSession clientSession = clientServiceInterface.getSessionOrNull(customerId, equipmentId,
MacAddress.valueOf(clientConnectEvent.getStaMac()));
if (clientSession == null) {
clientSession = new ClientSession();
}
clientSession.setCustomerId(customerId);
clientSession.setEquipmentId(equipmentId);
clientSession.setLocationId(locationId);
clientSession.setMacAddress(MacAddress.valueOf(clientConnectEvent.getStaMac()));
ClientSessionDetails clientSessionDetails = new ClientSessionDetails();
clientSessionDetails.setSessionId(clientConnectEvent.getSessionId());
if (clientConnectEvent.hasEvTimeBootupInUsAssoc()) {
clientSessionDetails.setAssocTimestamp(clientConnectEvent.getEvTimeBootupInUsAssoc());
}
if (clientConnectEvent.hasEvTimeBootupInUsAuth()) {
clientSessionDetails.setAuthTimestamp(clientConnectEvent.getEvTimeBootupInUsAuth());
}
if (clientConnectEvent.hasEvTimeBootupInUsEapol()) {
ClientEapDetails eapDetails = new ClientEapDetails();
eapDetails.setEapSuccessTimestamp(clientConnectEvent.getEvTimeBootupInUsEapol());
clientSessionDetails.setEapDetails(eapDetails);
}
if (clientConnectEvent.hasEvTimeBootupInUsFirstRx()) {
clientSessionDetails.setFirstDataRcvdTimestamp(clientConnectEvent.getEvTimeBootupInUsFirstRx());
}
if (clientConnectEvent.hasEvTimeBootupInUsFirstTx()) {
clientSessionDetails.setFirstDataSentTimestamp(clientConnectEvent.getEvTimeBootupInUsFirstTx());
}
if (clientConnectEvent.hasEvTimeBootupInUsIp()) {
clientSessionDetails.setIpTimestamp(clientConnectEvent.getEvTimeBootupInUsIp());
}
if (clientConnectEvent.hasEvTimeBootupInUsPortEnable()) {
clientSessionDetails.setPortEnabledTimestamp(clientConnectEvent.getEvTimeBootupInUsPortEnable());
}
if (clientConnectEvent.hasCltId()) {
clientSessionDetails.setHostname(clientConnectEvent.getCltId());
}
if (clientConnectEvent.hasSecType()) {
clientSessionDetails.setSecurityType(OvsdbToWlanCloudTypeMappingUtility
.getCloudSecurityTypeFromOpensyncStats(clientConnectEvent.getSecType()));
}
clientSessionDetails.setRadioType(OvsdbToWlanCloudTypeMappingUtility
.getRadioTypeFromOpensyncStatsRadioBandType(clientConnectEvent.getBand()));
if (clientConnectEvent.hasAssocType()) {
clientSessionDetails.setIsReassociation(clientConnectEvent.getAssocType().equals(AssocType.REASSOC));
}
if (clientConnectEvent.hasAssocRssi()) {
clientSessionDetails.setAssocRssi(clientConnectEvent.getAssocRssi());
}
clientSessionDetails.setSsid(clientConnectEvent.getSsid());
if (clientConnectEvent.hasUsing11K()) {
clientSessionDetails.setIs11KUsed(clientConnectEvent.getUsing11K());
}
if (clientConnectEvent.hasUsing11R()) {
clientSessionDetails.setIs11RUsed(clientConnectEvent.getUsing11R());
}
if (clientConnectEvent.hasUsing11V()) {
clientSessionDetails.setIs11VUsed(clientConnectEvent.getUsing11V());
}
if (clientConnectEvent.hasIpAddr()) {
try {
clientSessionDetails
.setIpAddress(InetAddress.getByAddress(clientConnectEvent.getIpAddr().toByteArray()));
} catch (UnknownHostException e1) {
LOG.error("Invalid Ip Address for client {}", clientConnectEvent.getIpAddr(), e);
}
}
clientSessionDetails.setAssociationState(AssociationState._802_11_Associated);
ClientSession clientSession = clientServiceInterface.getSessionOrNull(customerId, equipmentId,
MacAddress.valueOf(clientConnectEvent.getStaMac()));
if (clientSession.getDetails() == null) {
clientSession.setDetails(clientSessionDetails);
if (clientSession == null) {
clientSession = new ClientSession();
}
clientSession.setCustomerId(customerId);
clientSession.setEquipmentId(equipmentId);
clientSession.setLocationId(locationId);
clientSession.setMacAddress(MacAddress.valueOf(clientConnectEvent.getStaMac()));
ClientSessionDetails clientSessionDetails = new ClientSessionDetails();
clientSessionDetails.setSessionId(clientConnectEvent.getSessionId());
if (clientConnectEvent.hasEvTimeBootupInUsAssoc()) {
clientSessionDetails.setAssocTimestamp(clientConnectEvent.getEvTimeBootupInUsAssoc());
}
if (clientConnectEvent.hasEvTimeBootupInUsAuth()) {
clientSessionDetails.setAuthTimestamp(clientConnectEvent.getEvTimeBootupInUsAuth());
}
if (clientConnectEvent.hasEvTimeBootupInUsEapol()) {
ClientEapDetails eapDetails = new ClientEapDetails();
eapDetails.setEapSuccessTimestamp(clientConnectEvent.getEvTimeBootupInUsEapol());
clientSessionDetails.setEapDetails(eapDetails);
}
if (clientConnectEvent.hasEvTimeBootupInUsFirstRx()) {
clientSessionDetails.setFirstDataRcvdTimestamp(clientConnectEvent.getEvTimeBootupInUsFirstRx());
}
if (clientConnectEvent.hasEvTimeBootupInUsFirstTx()) {
clientSessionDetails.setFirstDataSentTimestamp(clientConnectEvent.getEvTimeBootupInUsFirstTx());
}
if (clientConnectEvent.hasEvTimeBootupInUsIp()) {
clientSessionDetails.setIpTimestamp(clientConnectEvent.getEvTimeBootupInUsIp());
}
if (clientConnectEvent.hasEvTimeBootupInUsPortEnable()) {
clientSessionDetails.setPortEnabledTimestamp(clientConnectEvent.getEvTimeBootupInUsPortEnable());
}
if (clientConnectEvent.hasCltId()) {
clientSessionDetails.setHostname(clientConnectEvent.getCltId());
}
if (clientConnectEvent.hasSecType()) {
clientSessionDetails.setSecurityType(OvsdbToWlanCloudTypeMappingUtility
.getCloudSecurityTypeFromOpensyncStats(clientConnectEvent.getSecType()));
}
clientSessionDetails.setRadioType(OvsdbToWlanCloudTypeMappingUtility
.getRadioTypeFromOpensyncStatsRadioBandType(clientConnectEvent.getBand()));
if (clientConnectEvent.hasAssocType()) {
clientSessionDetails.setIsReassociation(clientConnectEvent.getAssocType().equals(AssocType.REASSOC));
}
if (clientConnectEvent.hasAssocRssi()) {
clientSessionDetails.setAssocRssi(clientConnectEvent.getAssocRssi());
}
clientSessionDetails.setSsid(clientConnectEvent.getSsid());
if (clientConnectEvent.hasUsing11K()) {
clientSessionDetails.setIs11KUsed(clientConnectEvent.getUsing11K());
}
if (clientConnectEvent.hasUsing11R()) {
clientSessionDetails.setIs11RUsed(clientConnectEvent.getUsing11R());
}
if (clientConnectEvent.hasUsing11V()) {
clientSessionDetails.setIs11VUsed(clientConnectEvent.getUsing11V());
}
if (clientConnectEvent.hasIpAddr()) {
try {
clientSessionDetails
.setIpAddress(InetAddress.getByAddress(clientConnectEvent.getIpAddr().toByteArray()));
} catch (UnknownHostException e1) {
LOG.error("Invalid Ip Address for client {}", clientConnectEvent.getIpAddr(), e);
}
}
clientSessionDetails.setAssociationState(AssociationState._802_11_Associated);
if (clientSession.getDetails() == null) {
clientSession.setDetails(clientSessionDetails);
} else {
clientSession.getDetails().mergeSession(clientSessionDetails);
}
clientSession = clientServiceInterface.updateSession(clientSession);
realtimeEventPublisher.publishClientConnectSuccessEvent(customerId, equipmentId, clientConnectEvent);
} else {
clientSession.getDetails().mergeSession(clientSessionDetails);
LOG.warn("Cannot update client or client session when no client mac address is present");
}
clientSession = clientServiceInterface.updateSession(clientSession);
}
protected void processClientDisconnectEvent(int customerId, long equipmentId, long locationId,
sts.OpensyncStats.EventReport.ClientSession apEventClientSession) {
ClientDisconnectEvent clientDisconnectEvent = apEventClientSession.getClientDisconnectEvent();
realtimeEventPublisher.publishClientDisconnectEvent(customerId, equipmentId, clientDisconnectEvent);
if (clientDisconnectEvent.hasStaMac()) {
com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId,
@@ -536,6 +543,8 @@ public class MqttStatsPublisher {
clientSession = clientServiceInterface.updateSession(clientSession);
realtimeEventPublisher.publishClientDisconnectEvent(customerId, equipmentId, clientDisconnectEvent);
} else {
LOG.warn("Cannot update client or client session when no client mac address is present");
}
@@ -545,7 +554,6 @@ public class MqttStatsPublisher {
protected void processClientAuthEvent(int customerId, long equipmentId, long locationId,
sts.OpensyncStats.EventReport.ClientSession apEventClientSession) {
ClientAuthEvent clientAuthEvent = apEventClientSession.getClientAuthEvent();
realtimeEventPublisher.publishClientAuthSystemEvent(customerId, equipmentId, clientAuthEvent);
if (clientAuthEvent.hasStaMac()) {
com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId,
@@ -596,6 +604,7 @@ public class MqttStatsPublisher {
}
clientSession = clientServiceInterface.updateSession(clientSession);
realtimeEventPublisher.publishClientAuthSystemEvent(customerId, equipmentId, clientAuthEvent);
} else {
LOG.warn("Cannot update client or client session when no client mac address is present");
@@ -603,11 +612,9 @@ public class MqttStatsPublisher {
}
protected void processClientAssocEvent(int customerId, long equipmentId, long locationId,
sts.OpensyncStats.EventReport.ClientSession apEventClientSession) {
ClientAssocEvent clientAssocEvent = apEventClientSession.getClientAssocEvent();
realtimeEventPublisher.publishClientAssocEvent(customerId, equipmentId, clientAssocEvent);
if (clientAssocEvent.hasStaMac()) {
com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId,
@@ -672,6 +679,7 @@ public class MqttStatsPublisher {
}
clientSession = clientServiceInterface.updateSession(clientSession);
realtimeEventPublisher.publishClientAssocEvent(customerId, equipmentId, clientAssocEvent);
} else {
LOG.warn("Cannot update client or client session when no client mac address is present");
@@ -679,8 +687,6 @@ public class MqttStatsPublisher {
}
protected void processClientFailureEvent(int customerId, long equipmentId, long locationId,
sts.OpensyncStats.EventReport.ClientSession apEventClientSession) {
ClientFailureEvent clientFailureEvent = apEventClientSession.getClientFailureEvent();
@@ -736,19 +742,16 @@ public class MqttStatsPublisher {
}
clientSession = clientServiceInterface.updateSession(clientSession);
realtimeEventPublisher.publishClientFailureEvent(customerId, equipmentId, clientFailureEvent);
} else {
LOG.warn("Cannot update client or client session when no client mac address is present");
}
}
protected void processClientFirstDataEvent(int customerId, long equipmentId, long locationId,
sts.OpensyncStats.EventReport.ClientSession apEventClientSession) {
ClientFirstDataEvent clientFirstDataEvent = apEventClientSession.getClientFirstDataEvent();
realtimeEventPublisher.publishClientFirstDataEvent(customerId, equipmentId, clientFirstDataEvent);
if (clientFirstDataEvent.hasStaMac()) {
com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId,
@@ -798,6 +801,7 @@ public class MqttStatsPublisher {
}
clientSession = clientServiceInterface.updateSession(clientSession);
realtimeEventPublisher.publishClientFirstDataEvent(customerId, equipmentId, clientFirstDataEvent);
} else {
LOG.warn("Cannot update client or client session when no client mac address is present");
@@ -805,11 +809,9 @@ public class MqttStatsPublisher {
}
protected void processClientIdEvent(int customerId, long equipmentId, long locationId,
sts.OpensyncStats.EventReport.ClientSession apEventClientSession) {
ClientIdEvent clientIdEvent = apEventClientSession.getClientIdEvent();
realtimeEventPublisher.publishClientIdEvent(customerId, equipmentId, clientIdEvent);
if (clientIdEvent.hasCltMac()) {
com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId,
@@ -849,6 +851,7 @@ public class MqttStatsPublisher {
}
clientSession = clientServiceInterface.updateSession(clientSession);
realtimeEventPublisher.publishClientIdEvent(customerId, equipmentId, clientIdEvent);
} else {
LOG.warn("Cannot update client or client session when no client mac address is present");
@@ -856,12 +859,9 @@ public class MqttStatsPublisher {
}
protected void processClientIpEvent(int customerId, long equipmentId, long locationId,
sts.OpensyncStats.EventReport.ClientSession apEventClientSession) {
ClientIpEvent clientIpEvent = apEventClientSession.getClientIpEvent();
realtimeEventPublisher.publishClientIpEvent(customerId, equipmentId, clientIpEvent);
if (clientIpEvent.hasStaMac()) {
com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId,
@@ -908,6 +908,7 @@ public class MqttStatsPublisher {
}
clientSession = clientServiceInterface.updateSession(clientSession);
realtimeEventPublisher.publishClientIpEvent(customerId, equipmentId, clientIpEvent);
} else {
LOG.warn("Cannot update client or client session when no clientmac address is present");
@@ -918,7 +919,6 @@ public class MqttStatsPublisher {
protected void processClientTimeoutEvent(int customerId, long equipmentId, long locationId,
sts.OpensyncStats.EventReport.ClientSession apEventClientSession) {
ClientTimeoutEvent clientTimeoutEvent = apEventClientSession.getClientTimeoutEvent();
realtimeEventPublisher.publishClientTimeoutEvent(customerId, equipmentId, clientTimeoutEvent);
if (clientTimeoutEvent.hasStaMac()) {
com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId,
@@ -976,6 +976,7 @@ public class MqttStatsPublisher {
}
clientSession = clientServiceInterface.updateSession(clientSession);
realtimeEventPublisher.publishClientTimeoutEvent(customerId, equipmentId, clientTimeoutEvent);
} else {
LOG.warn("Cannot update client or client session when no client mac address is present");
@@ -983,8 +984,6 @@ public class MqttStatsPublisher {
}
void populateSipCallReport(List<ServiceMetric> metricRecordList, Report report, int customerId, long equipmentId,
String apId, long locationId) {
// only in case it is not there, we will just use the time when we

View File

@@ -25,14 +25,12 @@ import com.telecominfraproject.wlan.opensync.util.OvsdbToWlanCloudTypeMappingUti
import com.telecominfraproject.wlan.systemevent.equipment.realtime.RealTimeChannelHopEvent;
import com.telecominfraproject.wlan.systemevent.equipment.realtime.RealTimeEventType;
import com.telecominfraproject.wlan.systemevent.models.SystemEvent;
import com.telecominfraproject.wlan.systemevent.models.SystemEventRecord;
import sts.OpensyncStats.AssocType;
import sts.OpensyncStats.CTReasonType;
import sts.OpensyncStats.ChannelSwitchReason;
import sts.OpensyncStats.DeviceType;
import sts.OpensyncStats.EventReport;
import sts.OpensyncStats.FrameType;
import sts.OpensyncStats.EventReport.ClientAssocEvent;
import sts.OpensyncStats.EventReport.ClientAuthEvent;
import sts.OpensyncStats.EventReport.ClientConnectEvent;
@@ -42,6 +40,15 @@ import sts.OpensyncStats.EventReport.ClientFirstDataEvent;
import sts.OpensyncStats.EventReport.ClientIdEvent;
import sts.OpensyncStats.EventReport.ClientIpEvent;
import sts.OpensyncStats.EventReport.ClientTimeoutEvent;
import sts.OpensyncStats.EventReport.DhcpAckEvent;
import sts.OpensyncStats.EventReport.DhcpDeclineEvent;
import sts.OpensyncStats.EventReport.DhcpDiscoverEvent;
import sts.OpensyncStats.EventReport.DhcpInformEvent;
import sts.OpensyncStats.EventReport.DhcpNakEvent;
import sts.OpensyncStats.EventReport.DhcpOfferEvent;
import sts.OpensyncStats.EventReport.DhcpRequestEvent;
import sts.OpensyncStats.EventReport.DhcpTransaction;
import sts.OpensyncStats.FrameType;
@org.springframework.context.annotation.Profile("opensync_cloud_config")
@Component
@@ -49,21 +56,21 @@ public class RealtimeEventPublisher {
@Autowired
private CloudEventDispatcherInterface cloudEventDispatcherInterface;
@Autowired
private EquipmentServiceInterface equipmentServiceInterface;
private static final Logger LOG = LoggerFactory
.getLogger(RealtimeEventPublisher.class);
private static final Logger LOG = LoggerFactory.getLogger(RealtimeEventPublisher.class);
void publishChannelHopEvents(int customerId, long equipmentId, EventReport e) {
LOG.info("publishChannelHopEvents for customerId {} equipmentId {}");
List<SystemEvent> events = new ArrayList<>();
List<SystemEventRecord> eventRecords = new ArrayList<>();
for (sts.OpensyncStats.EventReport.ChannelSwitchEvent channelSwitchEvent : e.getChannelSwitchList()) {
LOG.info("Received ClientEvent {} for customerId {} equipmentId {}", e, customerId, equipmentId);
Equipment equipment = equipmentServiceInterface.getOrNull(equipmentId);
if (equipment == null)
continue;
@@ -116,21 +123,27 @@ public class RealtimeEventPublisher {
reason, timestamp);
events.add(channelHopEvent);
eventRecords.add(new SystemEventRecord(channelHopEvent));
LOG.debug("publishChannelHopEvents:Adding ChannelHopEvent to bulk list {}", channelHopEvent);
}
if (events.size() > 0) {
LOG.info("publishChannelHopEvents:publishEventsBulk: {}", events);
cloudEventDispatcherInterface.publishEventsBulk(events);
} else {
LOG.info("publishChannelHopEvents:No ChannelHopEvents in report");
}
}
void publishClientConnectSuccessEvent(int customerId, long equipmentId, ClientConnectEvent clientConnectEvent) {
ClientConnectSuccessEvent clientEvent = new ClientConnectSuccessEvent();
LOG.info("Received ClientEvent {} for customerId {} equipmentId {}", clientConnectEvent, customerId,
equipmentId);
ClientConnectSuccessEvent clientEvent;
if (clientConnectEvent.hasTimestampMs()) {
clientEvent = new ClientConnectSuccessEvent(Long.valueOf(clientConnectEvent.getTimestampMs()));
} else {
clientEvent = new ClientConnectSuccessEvent(System.currentTimeMillis());
}
clientEvent.setMacAddress(MacAddress.valueOf(clientConnectEvent.getStaMac()));
clientEvent.setRadioType(OvsdbToWlanCloudTypeMappingUtility
.getRadioTypeFromOpensyncStatsRadioBandType(clientConnectEvent.getBand()));
@@ -208,17 +221,22 @@ public class RealtimeEventPublisher {
clientEvent.setCustomerId(customerId);
clientEvent.setEquipmentId(equipmentId);
LOG.info("publishing client event {} to cloud", clientEvent);
cloudEventDispatcherInterface.publishEvent(clientEvent);
}
void publishClientDisconnectEvent(int customerId, long equipmentId, ClientDisconnectEvent clientDisconnectEvent) {
LOG.info("Received ClientEvent {} for customerId {} equipmentId {}", clientDisconnectEvent, customerId,
equipmentId);
com.telecominfraproject.wlan.client.models.events.realtime.ClientDisconnectEvent clientEvent;
if (clientDisconnectEvent.hasTimestampMs()) {
long timestampMs = clientDisconnectEvent.getTimestampMs();
clientEvent = new com.telecominfraproject.wlan.client.models.events.realtime.ClientDisconnectEvent(
timestampMs);
Long.valueOf(clientDisconnectEvent.getTimestampMs()));
} else {
clientEvent = new com.telecominfraproject.wlan.client.models.events.realtime.ClientDisconnectEvent(
System.currentTimeMillis());
@@ -261,17 +279,19 @@ public class RealtimeEventPublisher {
clientEvent.setCustomerId(customerId);
clientEvent.setEquipmentId(equipmentId);
LOG.info("publishing client event {} to cloud", clientEvent);
cloudEventDispatcherInterface.publishEvent(clientEvent);
}
void publishClientAuthSystemEvent(int customerId, long equipmentId, ClientAuthEvent clientAuthEvent) {
LOG.info("Received ClientEvent {} for customerId {} equipmentId {}", clientAuthEvent, customerId, equipmentId);
com.telecominfraproject.wlan.client.models.events.realtime.ClientAuthEvent clientEvent;
if (clientAuthEvent.hasTimestampMs()) {
long timestamp = clientAuthEvent.getTimestampMs();
clientEvent = new com.telecominfraproject.wlan.client.models.events.realtime.ClientAuthEvent(timestamp);
clientEvent = new com.telecominfraproject.wlan.client.models.events.realtime.ClientAuthEvent(Long.valueOf(clientAuthEvent.getTimestampMs()));
} else {
clientEvent = new com.telecominfraproject.wlan.client.models.events.realtime.ClientAuthEvent(
System.currentTimeMillis());
@@ -288,17 +308,19 @@ public class RealtimeEventPublisher {
}
clientEvent.setCustomerId(customerId);
clientEvent.setEquipmentId(equipmentId);
LOG.info("publishing client event {} to cloud", clientEvent);
cloudEventDispatcherInterface.publishEvent(clientEvent);
}
void publishClientAssocEvent(int customerId, long equipmentId, ClientAssocEvent clientAssocEvent) {
LOG.info("Received ClientEvent {} for customerId {} equipmentId {}", clientAssocEvent, customerId, equipmentId);
com.telecominfraproject.wlan.client.models.events.realtime.ClientAssocEvent clientEvent;
if (clientAssocEvent.hasTimestampMs()) {
long timestamp = clientAssocEvent.getTimestampMs();
clientEvent = new com.telecominfraproject.wlan.client.models.events.realtime.ClientAssocEvent(timestamp);
if (clientAssocEvent.hasTimestampMs()) {
clientEvent = new com.telecominfraproject.wlan.client.models.events.realtime.ClientAssocEvent(Long.valueOf(clientAssocEvent.getTimestampMs()));
} else {
clientEvent = new com.telecominfraproject.wlan.client.models.events.realtime.ClientAssocEvent(
System.currentTimeMillis());
@@ -340,16 +362,20 @@ public class RealtimeEventPublisher {
clientEvent.setCustomerId(customerId);
clientEvent.setEquipmentId(equipmentId);
LOG.info("publishing client event {} to cloud", clientEvent);
cloudEventDispatcherInterface.publishEvent(clientEvent);
}
void publishClientFailureEvent(int customerId, long equipmentId, ClientFailureEvent clientFailureEvent) {
LOG.info("Received ClientEvent {} for customerId {} equipmentId {}", clientFailureEvent, customerId,
equipmentId);
com.telecominfraproject.wlan.client.models.events.realtime.ClientFailureEvent clientEvent;
if (clientFailureEvent.hasTimestampMs()) {
long timestamp = clientFailureEvent.getTimestampMs();
clientEvent = new com.telecominfraproject.wlan.client.models.events.realtime.ClientFailureEvent(timestamp);
clientEvent = new com.telecominfraproject.wlan.client.models.events.realtime.ClientFailureEvent(Long.valueOf(clientFailureEvent.getTimestampMs()));
} else {
clientEvent = new com.telecominfraproject.wlan.client.models.events.realtime.ClientFailureEvent(
System.currentTimeMillis());
@@ -369,16 +395,20 @@ public class RealtimeEventPublisher {
clientEvent.setCustomerId(customerId);
clientEvent.setEquipmentId(equipmentId);
LOG.info("publishing client event {} to cloud", clientEvent);
cloudEventDispatcherInterface.publishEvent(clientEvent);
}
void publishClientFirstDataEvent(int customerId, long equipmentId, ClientFirstDataEvent clientFirstDataEvent) {
LOG.info("Received ClientEvent {} for customerId {} equipmentId {}", clientFirstDataEvent, customerId,
equipmentId);
com.telecominfraproject.wlan.client.models.events.realtime.ClientFirstDataEvent clientEvent;
if (clientFirstDataEvent.hasTimestampMs()) {
long timestamp = clientFirstDataEvent.getTimestampMs();
clientEvent = new com.telecominfraproject.wlan.client.models.events.realtime.ClientFirstDataEvent(
timestamp);
Long.valueOf(clientFirstDataEvent.getTimestampMs()));
} else {
clientEvent = new com.telecominfraproject.wlan.client.models.events.realtime.ClientFirstDataEvent(
System.currentTimeMillis());
@@ -397,16 +427,20 @@ public class RealtimeEventPublisher {
clientEvent.setCustomerId(customerId);
clientEvent.setEquipmentId(equipmentId);
LOG.info("publishing client event {} to cloud", clientEvent);
cloudEventDispatcherInterface.publishEvent(clientEvent);
}
void publishClientIdEvent(int customerId, long equipmentId, ClientIdEvent clientIdEvent) {
LOG.info("Received ClientEvent {} for customerId {} equipmentId {}", clientIdEvent, customerId, equipmentId);
com.telecominfraproject.wlan.client.models.events.realtime.ClientIdEvent clientEvent;
if (clientIdEvent.hasTimestampMs()) {
long timestamp = clientIdEvent.getTimestampMs();
clientEvent = new com.telecominfraproject.wlan.client.models.events.realtime.ClientIdEvent(timestamp);
clientEvent = new com.telecominfraproject.wlan.client.models.events.realtime.ClientIdEvent(Long.valueOf(clientIdEvent.getTimestampMs()));
} else {
clientEvent = new com.telecominfraproject.wlan.client.models.events.realtime.ClientIdEvent(
System.currentTimeMillis());
@@ -420,16 +454,20 @@ public class RealtimeEventPublisher {
clientEvent.setCustomerId(customerId);
clientEvent.setEquipmentId(equipmentId);
LOG.info("publishing client event {} to cloud", clientEvent);
cloudEventDispatcherInterface.publishEvent(clientEvent);
}
void publishClientIpEvent(int customerId, long equipmentId, ClientIpEvent clientIpEvent) {
LOG.info("Received ClientEvent {} for customerId {} equipmentId {}", clientIpEvent, customerId, equipmentId);
com.telecominfraproject.wlan.client.models.events.realtime.ClientIpAddressEvent clientEvent;
if (clientIpEvent.hasTimestampMs()) {
long timestamp = clientIpEvent.getTimestampMs();
clientEvent = new com.telecominfraproject.wlan.client.models.events.realtime.ClientIpAddressEvent(
timestamp);
Long.valueOf(clientIpEvent.getTimestampMs()));
} else {
clientEvent = new com.telecominfraproject.wlan.client.models.events.realtime.ClientIpAddressEvent(
System.currentTimeMillis());
@@ -443,16 +481,20 @@ public class RealtimeEventPublisher {
clientEvent.setCustomerId(customerId);
clientEvent.setEquipmentId(equipmentId);
LOG.info("publishing client event {} to cloud", clientEvent);
cloudEventDispatcherInterface.publishEvent(clientEvent);
}
void publishClientTimeoutEvent(int customerId, long equipmentId, ClientTimeoutEvent clientTimeoutEvent) {
LOG.info("Received ClientEvent {} for customerId {} equipmentId {}", clientTimeoutEvent, customerId,
equipmentId);
com.telecominfraproject.wlan.client.models.events.realtime.ClientTimeoutEvent clientEvent;
if (clientTimeoutEvent.hasTimestampMs()) {
long timestamp = clientTimeoutEvent.getTimestampMs();
clientEvent = new com.telecominfraproject.wlan.client.models.events.realtime.ClientTimeoutEvent(timestamp);
clientEvent = new com.telecominfraproject.wlan.client.models.events.realtime.ClientTimeoutEvent(Long.valueOf(clientTimeoutEvent.getTimestampMs()));
} else {
clientEvent = new com.telecominfraproject.wlan.client.models.events.realtime.ClientTimeoutEvent(
System.currentTimeMillis());
@@ -474,7 +516,50 @@ public class RealtimeEventPublisher {
clientEvent.setCustomerId(customerId);
clientEvent.setEquipmentId(equipmentId);
LOG.info("publishing client event {} to cloud", clientEvent);
cloudEventDispatcherInterface.publishEvent(clientEvent);
}
void publishDhcpTransactionEvents(int customerId, long equipmentId,
List<DhcpTransaction> dhcpTransactionList) {
for (DhcpTransaction dhcpTransaction : dhcpTransactionList) {
for (DhcpAckEvent ackEvent : dhcpTransaction.getDhcpAckEventList()) {
LOG.info("DhcpAckEvent {}", ackEvent);
}
for (DhcpNakEvent nakEvent : dhcpTransaction.getDhcpNakEventList()) {
LOG.info("DhcpNakEvent {}", nakEvent);
}
for (DhcpOfferEvent offerEvent : dhcpTransaction.getDhcpOfferEventList()) {
LOG.info("DhcpOfferEvent {}", offerEvent);
}
for (DhcpInformEvent informEvent : dhcpTransaction.getDhcpInformEventList()) {
LOG.info("DhcpInformEvent {}", informEvent);
}
for (DhcpDeclineEvent declineEvent : dhcpTransaction.getDhcpDeclineEventList()) {
LOG.info("DhcpDeclineEvent {}", declineEvent);
}
for (DhcpRequestEvent requestEvent : dhcpTransaction.getDhcpRequestEventList()) {
LOG.info("DhcpRequestEvent {}", requestEvent);
}
for (DhcpDiscoverEvent discoverEvent : dhcpTransaction.getDhcpDiscoverEventList()) {
LOG.info("DhcpDiscoverEvent {}", discoverEvent);
}
}
}
}