Compare commits

..

9 Commits

Author SHA1 Message Date
Kareem Dabbour
9cc501a8b9 WIFI-3216 using 0 rather than currentMillis() 2021-07-22 17:52:43 -04:00
Kareem Dabbour
b720f9882d WIFI-3216 using currentMillis() rather than 0 2021-07-22 17:39:14 -04:00
Kareem Dabbour
91f113505d WIFI-3216 Made the service metrics' timestamps 0 so that the CloudEventDispatcherController can assign unique TS 2021-07-22 17:09:26 -04:00
Mike Hansen
14adaaacbe APs running into Backoff shows as connected
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-07-22 15:32:21 -04:00
Mike Hansen
11f0aa8856 APs running into Backoff shows as connected.
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-07-22 13:38:06 -04:00
Mike Hansen
cbd27b37bf APs running into Backoff shows as connected.
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-07-21 10:56:39 -04:00
Mike Hansen
80834c0a31 Logs: Client Devices: isReassociation Flag is set to TRUE always
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-07-20 14:40:27 -04:00
Mike Hansen
45642464fc [WIFI-3181] check for null customer equipment when processing ovsdb table state updates
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-07-20 11:48:20 -04:00
Mike Hansen
be9d880bc3 [WIFI-3166] Session ID is a -ve number in opensyncgw logs and on UI logs
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-07-19 19:31:18 -04:00
7 changed files with 2474 additions and 2422 deletions

View File

@@ -209,9 +209,9 @@ public class OpensyncCloudGatewayController {
case CellSizeAttributesRequest: case CellSizeAttributesRequest:
ret.add(sendCellSizeRequest(session, (CEGWCellSizeAttributesRequest) command)); ret.add(sendCellSizeRequest(session, (CEGWCellSizeAttributesRequest) command));
break; break;
case MostRecentStatsTimestamp: // case MostRecentStatsTimestamp:
ret.add(sendGetMostRecentStatsTimestampRequest(command, inventoryId)); // ret.add(sendGetMostRecentStatsTimestampRequest(command, inventoryId));
break; // break;
default: default:
LOG.warn("[{}] Failed to deliver command {}, unsupported command type", inventoryId, command); LOG.warn("[{}] Failed to deliver command {}, unsupported command type", inventoryId, command);
ret.add(new EquipmentCommandResponse(CEGWCommandResultCode.UnsupportedCommand, ret.add(new EquipmentCommandResponse(CEGWCommandResultCode.UnsupportedCommand,
@@ -250,32 +250,7 @@ public class OpensyncCloudGatewayController {
return new GatewayDefaults(); return new GatewayDefaults();
} }
private EquipmentCommandResponse sendGetMostRecentStatsTimestampRequest(CEGWBaseCommand command, String inventoryId) {
Long ts = lastReceivedStatsTimestamp(inventoryId);
if (ts == null) {
return new EquipmentCommandResponse(CEGWCommandResultCode.NoRouteToCE,
null, command,
registeredGateway == null ? null : registeredGateway.getHostname(),
registeredGateway == null ? -1 : registeredGateway.getPort());
} else {
return new EquipmentCommandResponse(CEGWCommandResultCode.Success,
ts.toString(), command,
registeredGateway == null ? null : registeredGateway.getHostname(),
registeredGateway == null ? -1 : registeredGateway.getPort());
}
}
@RequestMapping(value = "/lastReceivedStatsTimestamp", method = RequestMethod.GET)
public Long lastReceivedStatsTimestamp(@RequestParam String apId) {
Long ret = null;
if (ovsdbSessionMapInterface.getSession(apId) != null) {
ret = ovsdbSessionMapInterface.getSession(apId).getMostRecentStatsTimestamp();
LOG.debug("lastReceivedStatsTimestamp for apId {} {}",apId,ret);
} else {
LOG.warn("lastReceivedStatsTimestamp found no session for {}, cannot get timestamp",apId);
}
return ret;
}
/** /**
* Verify a route to customer equipment * Verify a route to customer equipment

View File

@@ -5,7 +5,6 @@ import java.net.Inet4Address;
import java.net.Inet6Address; import java.net.Inet6Address;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
@@ -52,7 +51,6 @@ import com.telecominfraproject.wlan.equipment.EquipmentServiceInterface;
import com.telecominfraproject.wlan.equipment.models.Equipment; import com.telecominfraproject.wlan.equipment.models.Equipment;
import com.telecominfraproject.wlan.opensync.external.integration.OvsdbSession; import com.telecominfraproject.wlan.opensync.external.integration.OvsdbSession;
import com.telecominfraproject.wlan.opensync.external.integration.OvsdbSessionMapInterface; import com.telecominfraproject.wlan.opensync.external.integration.OvsdbSessionMapInterface;
import com.telecominfraproject.wlan.opensync.external.integration.controller.OpensyncCloudGatewayController;
import com.telecominfraproject.wlan.opensync.util.OvsdbToWlanCloudTypeMappingUtility; import com.telecominfraproject.wlan.opensync.util.OvsdbToWlanCloudTypeMappingUtility;
import com.telecominfraproject.wlan.profile.ProfileServiceInterface; import com.telecominfraproject.wlan.profile.ProfileServiceInterface;
import com.telecominfraproject.wlan.profile.models.Profile; import com.telecominfraproject.wlan.profile.models.Profile;
@@ -140,8 +138,6 @@ public class MqttStatsPublisher implements StatsPublisherInterface {
private RealtimeEventPublisher realtimeEventPublisher; private RealtimeEventPublisher realtimeEventPublisher;
@Autowired @Autowired
private AlarmServiceInterface alarmServiceInterface; private AlarmServiceInterface alarmServiceInterface;
@Autowired
private OpensyncCloudGatewayController gatewayController;
@Value("${tip.wlan.mqttStatsPublisher.temperatureThresholdInC:80}") @Value("${tip.wlan.mqttStatsPublisher.temperatureThresholdInC:80}")
private int temperatureThresholdInC; private int temperatureThresholdInC;
@@ -161,6 +157,7 @@ public class MqttStatsPublisher implements StatsPublisherInterface {
@Override @Override
@Async @Async
public void processMqttMessage(String topic, Report report) { public void processMqttMessage(String topic, Report report) {
long startTime = System.nanoTime(); long startTime = System.nanoTime();
String apId = extractApIdFromTopic(topic); String apId = extractApIdFromTopic(topic);
LOG.info("Received report on topic {} for ap {}", topic, report.getNodeID()); LOG.info("Received report on topic {} for ap {}", topic, report.getNodeID());
@@ -176,7 +173,6 @@ public class MqttStatsPublisher implements StatsPublisherInterface {
long profileId = ce.getProfileId(); long profileId = ce.getProfileId();
// update timestamp for active customer equipment // update timestamp for active customer equipment
gatewayController.updateActiveCustomer(customerId);
List<ServiceMetric> metricRecordList = new ArrayList<>(); List<ServiceMetric> metricRecordList = new ArrayList<>();
try { try {
@@ -212,8 +208,11 @@ public class MqttStatsPublisher implements StatsPublisherInterface {
if (!metricRecordList.isEmpty()) { if (!metricRecordList.isEmpty()) {
long serviceMetricTimestamp = System.currentTimeMillis(); long serviceMetricTimestamp = System.currentTimeMillis();
metricRecordList.stream().forEach(smr -> { metricRecordList.stream().forEach(smr -> {
smr.setCreatedTimestamp(serviceMetricTimestamp); // TODO use serviceMetricTimestamp rather than 0. This is done for now since there are some
// channel metrics that have overlapping keys which messes up Cassandra if the same time stamp is used
// and setting it to 0 allows the CloudEventDispatcherController to assign unique time stamps.
smr.setCreatedTimestamp(0);
if (smr.getLocationId() == 0) if (smr.getLocationId() == 0)
smr.setLocationId(locationId); smr.setLocationId(locationId);
if (smr.getCustomerId() == 0) if (smr.getCustomerId() == 0)
@@ -266,7 +265,6 @@ public class MqttStatsPublisher implements StatsPublisherInterface {
@Override @Override
public void publishSystemEventFromTableStateMonitor(SystemEvent event) { public void publishSystemEventFromTableStateMonitor(SystemEvent event) {
LOG.info("Publishing SystemEvent received by TableStateMonitor {}", event); LOG.info("Publishing SystemEvent received by TableStateMonitor {}", event);
gatewayController.updateActiveCustomer(event.getCustomerId());
cloudEventDispatcherInterface.publishEvent(event); cloudEventDispatcherInterface.publishEvent(event);
} }

View File

@@ -176,7 +176,7 @@ public class OpensyncExternalIntegrationCloudTest {
location.setDetails(details); location.setDetails(details);
location.setName("Location-UT"); location.setName("Location-UT");
location.setLocationType(LocationType.BUILDING); location.setLocationType(LocationType.BUILDING);
Mockito.when(locationServiceInterface.get(8L)).thenReturn(location); Mockito.when(locationServiceInterface.getOrNull(Mockito.anyLong())).thenReturn(location);
Customer customer = new Customer(); Customer customer = new Customer();
customer.setId(2); customer.setId(2);
CustomerDetails customerDetails = new CustomerDetails(); CustomerDetails customerDetails = new CustomerDetails();
@@ -232,7 +232,7 @@ public class OpensyncExternalIntegrationCloudTest {
opensyncExternalIntegrationCloud.apConnected("Test_Client_21P10C68818122", createConnectNodeInfo()); opensyncExternalIntegrationCloud.apConnected("Test_Client_21P10C68818122", createConnectNodeInfo());
Mockito.verify(firmwareServiceInterface).getDefaultCustomerTrackSetting(); Mockito.verify(firmwareServiceInterface).getDefaultCustomerTrackSetting();
Mockito.verify(locationServiceInterface).get(8L); Mockito.verify(locationServiceInterface).getOrNull(ArgumentMatchers.anyLong());
} }
@@ -246,7 +246,7 @@ public class OpensyncExternalIntegrationCloudTest {
location.setDetails(details); location.setDetails(details);
location.setName("Location-UT"); location.setName("Location-UT");
location.setLocationType(LocationType.BUILDING); location.setLocationType(LocationType.BUILDING);
Mockito.when(locationServiceInterface.get(8L)).thenReturn(location); Mockito.when(locationServiceInterface.getOrNull(8L)).thenReturn(location);
Customer customer = new Customer(); Customer customer = new Customer();
customer.setId(2); customer.setId(2);
@@ -326,7 +326,7 @@ public class OpensyncExternalIntegrationCloudTest {
Mockito.verify(customerServiceInterface).getOrNull(ArgumentMatchers.anyInt()); Mockito.verify(customerServiceInterface).getOrNull(ArgumentMatchers.anyInt());
Mockito.verify(equipmentServiceInterface).getByInventoryIdOrNull("Test_Client_21P10C68818122"); Mockito.verify(equipmentServiceInterface).getByInventoryIdOrNull("Test_Client_21P10C68818122");
Mockito.verify(firmwareServiceInterface).getDefaultCustomerTrackSetting(); Mockito.verify(firmwareServiceInterface).getDefaultCustomerTrackSetting();
Mockito.verify(locationServiceInterface, Mockito.times(2)).get(ArgumentMatchers.anyLong()); Mockito.verify(locationServiceInterface, Mockito.times(2)).getOrNull(ArgumentMatchers.anyLong());
} }

View File

@@ -54,4 +54,6 @@ public interface OpensyncExternalIntegrationInterface {
void nodeStateDbTableUpdate(List<Map<String, String>> nodeStateAttributes, String apId); void nodeStateDbTableUpdate(List<Map<String, String>> nodeStateAttributes, String apId);
void clearEquipmentStatus(String apId); void clearEquipmentStatus(String apId);
void processMqttMessage(String topic, Report report);
} }

View File

@@ -1,7 +1,5 @@
package com.telecominfraproject.wlan.opensync.external.integration; package com.telecominfraproject.wlan.opensync.external.integration;
import java.util.Objects;
import com.vmware.ovsdb.service.OvsdbClient; import com.vmware.ovsdb.service.OvsdbClient;
public class OvsdbSession { public class OvsdbSession {
@@ -9,7 +7,6 @@ public class OvsdbSession {
private String apId; private String apId;
private long routingId; private long routingId;
private long equipmentId; private long equipmentId;
private long mostRecentStatsTimestamp;
public OvsdbClient getOvsdbClient() { public OvsdbClient getOvsdbClient() {
return ovsdbClient; return ovsdbClient;
@@ -35,34 +32,5 @@ public class OvsdbSession {
public void setEquipmentId(long equipmentId) { public void setEquipmentId(long equipmentId) {
this.equipmentId = equipmentId; this.equipmentId = equipmentId;
} }
public long getMostRecentStatsTimestamp() {
return mostRecentStatsTimestamp;
}
public void setMostRecentStatsTimestamp(long mostRecentStatsTimestamp) {
this.mostRecentStatsTimestamp = mostRecentStatsTimestamp;
}
@Override
public int hashCode() {
return Objects.hash(apId, equipmentId, mostRecentStatsTimestamp, ovsdbClient, routingId);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
OvsdbSession other = (OvsdbSession) obj;
return Objects.equals(apId, other.apId) && equipmentId == other.equipmentId && mostRecentStatsTimestamp == other.mostRecentStatsTimestamp
&& Objects.equals(ovsdbClient, other.ovsdbClient) && routingId == other.routingId;
}
@Override
public String toString() {
return "OvsdbSession [ovsdbClient=" + ovsdbClient + ", apId=" + apId + ", routingId=" + routingId + ", equipmentId=" + equipmentId
+ ", mostRecentStatsTimestamp=" + mostRecentStatsTimestamp + "]";
}
} }

View File

@@ -11,10 +11,6 @@ import org.fusesource.mqtt.client.MQTT;
import org.fusesource.mqtt.client.Message; import org.fusesource.mqtt.client.Message;
import org.fusesource.mqtt.client.QoS; import org.fusesource.mqtt.client.QoS;
import org.fusesource.mqtt.client.Topic; import org.fusesource.mqtt.client.Topic;
import org.fusesource.mqtt.client.Tracer;
import org.fusesource.mqtt.codec.MQTTFrame;
import org.fusesource.mqtt.codec.PINGREQ;
import org.fusesource.mqtt.codec.PINGRESP;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -36,8 +32,7 @@ import com.netflix.servo.monitor.Stopwatch;
import com.netflix.servo.monitor.Timer; import com.netflix.servo.monitor.Timer;
import com.netflix.servo.tag.TagList; import com.netflix.servo.tag.TagList;
import com.telecominfraproject.wlan.cloudmetrics.CloudMetricsTags; import com.telecominfraproject.wlan.cloudmetrics.CloudMetricsTags;
import com.telecominfraproject.wlan.opensync.external.integration.OvsdbSession; import com.telecominfraproject.wlan.opensync.external.integration.OpensyncExternalIntegrationInterface;
import com.telecominfraproject.wlan.opensync.external.integration.OvsdbSessionMapInterface;
import com.telecominfraproject.wlan.opensync.external.integration.utils.StatsPublisherInterface; import com.telecominfraproject.wlan.opensync.external.integration.utils.StatsPublisherInterface;
import com.telecominfraproject.wlan.opensync.util.ZlibUtil; import com.telecominfraproject.wlan.opensync.util.ZlibUtil;
@@ -63,10 +58,7 @@ public class OpensyncMqttClient implements ApplicationListener<ContextClosedEven
private final Timer timerMessageProcess = new BasicTimer(MonitorConfig.builder("osgw-mqtt-messageProcessTimer").withTags(tags).build()); private final Timer timerMessageProcess = new BasicTimer(MonitorConfig.builder("osgw-mqtt-messageProcessTimer").withTags(tags).build());
@Autowired @Autowired
private StatsPublisherInterface statsPublisher; private OpensyncExternalIntegrationInterface opensyncExternalIntegrationInterface;
@Autowired
private OvsdbSessionMapInterface ovsdbSessionMapInterface;
// dtop: use anonymous constructor to ensure that the following code always // dtop: use anonymous constructor to ensure that the following code always
// get executed, // get executed,
@@ -193,18 +185,8 @@ public class OpensyncMqttClient implements ApplicationListener<ContextClosedEven
// Only supported protobuf on the TIP opensync APs is Report // Only supported protobuf on the TIP opensync APs is Report
Report statsReport = Report.parseFrom(payload); Report statsReport = Report.parseFrom(payload);
mqttMsg.ack(); mqttMsg.ack();
String apId = extractApIdFromTopic(mqttMsg.getTopic());
if (apId != null) {
OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(extractApIdFromTopic(mqttMsg.getTopic()));
if (ovsdbSession != null) {
ovsdbSession.setMostRecentStatsTimestamp(System.currentTimeMillis());
LOG.debug("Last metrics received from AP updated to {}",ovsdbSession.toString());
} else {
LOG.debug("No ovsdb session exists for this AP {}",apId);
}
}
MQTT_LOG.info("Topic {}\n{}", mqttMsg.getTopic(), jsonPrinter.print(statsReport)); MQTT_LOG.info("Topic {}\n{}", mqttMsg.getTopic(), jsonPrinter.print(statsReport));
statsPublisher.processMqttMessage(mqttMsg.getTopic(), statsReport); opensyncExternalIntegrationInterface.processMqttMessage(mqttMsg.getTopic(), statsReport);
LOG.debug("Dispatched report for topic {} to backend for processing", mqttMsg.getTopic()); LOG.debug("Dispatched report for topic {} to backend for processing", mqttMsg.getTopic());
} catch (Exception e) { } catch (Exception e) {
@@ -244,26 +226,5 @@ public class OpensyncMqttClient implements ApplicationListener<ContextClosedEven
mqttClientThread.interrupt(); mqttClientThread.interrupt();
} }
} }
/**
* @param topic
* @return apId extracted from the topic name, or null if it cannot be
* extracted
*/
static String extractApIdFromTopic(String topic) {
// Topic is formatted as
// "/ap/"+clientCn+"_"+ret.serialNumber+"/opensync"
if (topic == null) {
return null;
}
String[] parts = topic.split("/");
if (parts.length < 3) {
return null;
}
// apId is the third element in the topic
return parts[2];
}
} }