WIFI-1255: OSGW Dhcp Event Publishing -- robustness to guard against invalid populated proto messages, adding additional logs

This commit is contained in:
Mike Hansen
2021-01-12 17:00:35 -05:00
parent b245061ed9
commit 346476ef33
3 changed files with 25 additions and 5 deletions

View File

@@ -226,7 +226,7 @@ public class MqttStatsPublisher {
// equipmentId, locationId);
} catch (Exception e) {
LOG.error("Exception when processing populateApSsidMetrics", e);
LOG.error("Exception when processing stats messages from AP", e);
}
if (!metricRecordList.isEmpty()) {

View File

@@ -37,6 +37,7 @@ import com.telecominfraproject.wlan.systemevent.equipment.realtime.SIPCallReport
import com.telecominfraproject.wlan.systemevent.equipment.realtime.SipCallStopReason;
import com.telecominfraproject.wlan.systemevent.models.SystemEvent;
import io.netty.util.internal.MacAddressUtil;
import sts.OpensyncStats;
import sts.OpensyncStats.AssocType;
import sts.OpensyncStats.CTReasonType;
@@ -545,7 +546,7 @@ public class RealtimeEventPublisher {
void publishDhcpTransactionEvents(int customerId, long equipmentId,
List<DhcpTransaction> dhcpTransactionList) {
LOG.info("Publish Dhcp Transaction Events for customer {} equipmentId {}", customerId, equipmentId);
List<SystemEvent> dhcpEventsList = new ArrayList<>();
for (DhcpTransaction dhcpTransaction : dhcpTransactionList) {
@@ -609,6 +610,8 @@ public class RealtimeEventPublisher {
cloudDhcpAck.setTimeOffset(ackEvent.getTimeOffset());
}
LOG.debug("Cloud DhcpAckEvent {}", cloudDhcpAck);
dhcpEventsList.add(cloudDhcpAck);
}
@@ -629,7 +632,10 @@ public class RealtimeEventPublisher {
if (nakEvent.hasFromInternal()) {
cloudDhcpNak.setFromInternal(nakEvent.getFromInternal());
}
}
LOG.debug("Cloud DhcpNakEvent {}", cloudDhcpNak);
dhcpEventsList.add(cloudDhcpNak);
}
@@ -692,6 +698,9 @@ public class RealtimeEventPublisher {
cloudDhcpDecline.setxId(dhcpTransaction.getXId());
}
LOG.debug("Cloud DhcpDeclineEvent {}", cloudDhcpDecline);
dhcpEventsList.add(cloudDhcpDecline);
}
@@ -715,6 +724,9 @@ public class RealtimeEventPublisher {
cloudDhcpRequest.setHostName(requestEvent.getHostname());
}
LOG.debug("Cloud DhcpRequestEvent {}", cloudDhcpRequest);
dhcpEventsList.add(cloudDhcpRequest);
@@ -739,12 +751,15 @@ public class RealtimeEventPublisher {
cloudDhcpDiscover.setHostName(discoverEvent.getHostname());
}
LOG.debug("Cloud DhcpDiscoverEvent {}", cloudDhcpDiscover);
dhcpEventsList.add(cloudDhcpDiscover);
}
}
if (dhcpEventsList.size() > 0) {
LOG.info("Publishing DhcpEvents {}", dhcpEventsList);
cloudEventDispatcherInterface.publishEventsBulk(dhcpEventsList);
}
}
@@ -760,7 +775,12 @@ public class RealtimeEventPublisher {
}
if (dhcpCommonData.hasDeviceMacAddress()) {
cloudDhcpEvent.setDeviceMacAddress(MacAddress.valueOf(dhcpCommonData.getDeviceMacAddress()));
try {
cloudDhcpEvent.setDeviceMacAddress(MacAddress.valueOf(dhcpCommonData.getDeviceMacAddress()));
} catch (Exception e) {
LOG.error("Could not parse device_mac_address from DhcpCommonData ", dhcpCommonData, e);
}
}
if (dhcpCommonData.hasDhcpServerIp()) {

View File

@@ -274,7 +274,7 @@ public class RealtimeEventPublisherTest {
realtimeEventPublisher.publishDhcpTransactionEvents(2, 1L, dhcpTransactionList);
Mockito.verify(cloudEventDispatcherInterface).publishEventsBulk(Mockito.anyList());
Mockito.verify(cloudEventDispatcherInterface,Mockito.times(1)).publishEventsBulk(Mockito.anyList());
}