adjusted service metrics models

This commit is contained in:
Dmitry Toptygin
2020-05-28 22:06:55 -04:00
parent 3639167089
commit 4fbfde0762
47 changed files with 1206 additions and 1448 deletions

View File

@@ -4,19 +4,19 @@ import java.util.List;
import org.springframework.stereotype.Component;
import com.telecominfraproject.wlan.servicemetrics.models.SingleMetricRecord;
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetric;
import com.telecominfraproject.wlan.systemevent.models.SystemEventRecord;
@Component
public class CloudEventDispatcherEmpty implements CloudEventDispatcherInterface {
@Override
public void publishMetric(SingleMetricRecord metricRecord) {
public void publishMetric(ServiceMetric metricRecord) {
// do nothing
}
@Override
public void publishMetrics(List<SingleMetricRecord> metricRecordList) {
public void publishMetrics(List<ServiceMetric> metricRecordList) {
// do nothing
}

View File

@@ -18,7 +18,7 @@
<version>${tip-wlan-cloud.release.version}</version>
</dependency>
<dependency>
<artifactId>tip-wlan-cloud-service-metrics-models</artifactId>
<artifactId>service-metric-models</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>${tip-wlan-cloud.release.version}</version>
</dependency>

View File

@@ -3,7 +3,7 @@ package com.telecominfraproject.wlan.cloudeventdispatcher;
import java.util.ArrayList;
import java.util.List;
import com.telecominfraproject.wlan.servicemetrics.models.SingleMetricRecord;
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetric;
import com.telecominfraproject.wlan.systemevent.models.SystemEvent;
import com.telecominfraproject.wlan.systemevent.models.SystemEventRecord;
@@ -13,9 +13,9 @@ import com.telecominfraproject.wlan.systemevent.models.SystemEventRecord;
*/
public interface CloudEventDispatcherInterface {
void publishMetric(SingleMetricRecord metricRecord);
void publishMetric(ServiceMetric serviceMetric);
void publishMetrics(List<SingleMetricRecord> metricRecordList);
void publishMetrics(List<ServiceMetric> serviceMetricList);
void publishEvent(SystemEventRecord systemEventRecord);

View File

@@ -5,7 +5,7 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.telecominfraproject.wlan.servicemetrics.models.SingleMetricRecord;
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetric;
import com.telecominfraproject.wlan.systemevent.models.SystemEventRecord;
@Component
@@ -14,12 +14,12 @@ public class CloudEventDispatcherLocal implements CloudEventDispatcherInterface
@Autowired private CloudEventDispatcherController cloudEventDispatcherController;
@Override
public void publishMetric(SingleMetricRecord metricRecord) {
public void publishMetric(ServiceMetric metricRecord) {
cloudEventDispatcherController.publishMetric(metricRecord);
}
@Override
public void publishMetrics(List<SingleMetricRecord> metricRecordList) {
public void publishMetrics(List<ServiceMetric> metricRecordList) {
cloudEventDispatcherController.publishMetrics(metricRecordList);
}

View File

@@ -10,7 +10,7 @@ import org.springframework.stereotype.Component;
import com.telecominfraproject.wlan.core.client.BaseRemoteClient;
import com.telecominfraproject.wlan.core.model.json.GenericResponse;
import com.telecominfraproject.wlan.servicemetrics.models.SingleMetricRecord;
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetric;
import com.telecominfraproject.wlan.systemevent.models.SystemEventRecord;
@Component
@@ -21,7 +21,7 @@ public class CloudEventDispatcherRemote extends BaseRemoteClient implements Clou
private String baseUrl;
@Override
public void publishMetric(SingleMetricRecord metricRecord) {
public void publishMetric(ServiceMetric metricRecord) {
// @RequestMapping(value="/metric", method=RequestMethod.POST)
LOG.debug("calling publishMetric {} ", metricRecord);
@@ -36,7 +36,7 @@ public class CloudEventDispatcherRemote extends BaseRemoteClient implements Clou
}
@Override
public void publishMetrics(List<SingleMetricRecord> metricRecordList) {
public void publishMetrics(List<ServiceMetric> metricRecordList) {
// @RequestMapping(value="/metrics", method=RequestMethod.POST)
LOG.debug("calling publishMetrics {} ", metricRecordList);

View File

@@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ActiveProfiles;
import com.telecominfraproject.wlan.remote.tests.BaseRemoteTest;
import com.telecominfraproject.wlan.servicemetrics.models.SingleMetricRecord;
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetric;
import com.telecominfraproject.wlan.stream.StreamInterface;
import com.telecominfraproject.wlan.systemevent.models.SystemEventRecord;
import com.telecominfraproject.wlan.systemevent.models.TestSystemEvent;
@@ -38,15 +38,15 @@ public class CloudEventDispatcherRemoteTest extends BaseRemoteTest {
public static class Config {
@Bean
public StreamInterface<SingleMetricRecord> metricStreamInterface() {
StreamInterface<SingleMetricRecord> si = new StreamInterface<SingleMetricRecord>() {
public StreamInterface<ServiceMetric> metricStreamInterface() {
StreamInterface<ServiceMetric> si = new StreamInterface<ServiceMetric>() {
{
LOG.info("*** Using empty stream for the metrics");
}
@Override
public void publish(SingleMetricRecord record) {
public void publish(ServiceMetric record) {
LOG.info("publishing metric {}", record);
}
@@ -83,24 +83,22 @@ public class CloudEventDispatcherRemoteTest extends BaseRemoteTest {
@Test
public void testPublishMetric() throws Exception {
SingleMetricRecord metricRecord = new SingleMetricRecord();
ServiceMetric metricRecord = new ServiceMetric();
metricRecord.setCustomerId(customerId);
metricRecord.setCreatedTimestamp(System.currentTimeMillis());
metricRecord.setEquipmentId(equipmentId);
metricRecord.setLastModifiedTimestamp(metricRecord.getCreatedTimestamp());
remoteInterface.publishMetric(metricRecord);
}
@Test
public void testPublishMetricList() throws Exception {
List<SingleMetricRecord> recordList = new ArrayList<>(METRICS_COUNTS);
List<ServiceMetric> recordList = new ArrayList<>(METRICS_COUNTS);
for (int i = 0; i < METRICS_COUNTS; ++i) {
SingleMetricRecord metricRecord = new SingleMetricRecord();
ServiceMetric metricRecord = new ServiceMetric();
metricRecord.setCustomerId(customerId);
metricRecord.setCreatedTimestamp(System.currentTimeMillis());
metricRecord.setEquipmentId(equipmentId);
metricRecord.setLastModifiedTimestamp(metricRecord.getCreatedTimestamp());
recordList.add(metricRecord);
}

View File

@@ -10,9 +10,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.telecominfraproject.wlan.cloudmetrics.CloudMetricsTags;
import com.telecominfraproject.wlan.core.model.json.GenericResponse;
import com.telecominfraproject.wlan.servicemetrics.models.SingleMetricRecord;
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetric;
import com.telecominfraproject.wlan.stream.StreamInterface;
import com.telecominfraproject.wlan.systemevent.models.SystemEventRecord;
@@ -22,18 +21,14 @@ public class CloudEventDispatcherController {
private static final Logger LOG = LoggerFactory.getLogger(CloudEventDispatcherController.class);
@Autowired private StreamInterface<SingleMetricRecord> metricStream;
@Autowired private StreamInterface<ServiceMetric> metricStream;
@Autowired private StreamInterface<SystemEventRecord> systemEventStream;
@RequestMapping(value="/metric", method=RequestMethod.POST)
public GenericResponse publishMetric(@RequestBody SingleMetricRecord metricRecord) {
public GenericResponse publishMetric(@RequestBody ServiceMetric metricRecord) {
LOG.debug("calling publishMetric {}", metricRecord);
if(metricRecord.getDeploymentId()==null){
metricRecord.setDeploymentId(CloudMetricsTags.deployment);
}
metricStream.publish(metricRecord);
GenericResponse ret = new GenericResponse();
@@ -46,18 +41,12 @@ public class CloudEventDispatcherController {
}
@RequestMapping(value="/metrics", method=RequestMethod.POST)
public GenericResponse publishMetrics(@RequestBody List<SingleMetricRecord> metricList) {
public GenericResponse publishMetrics(@RequestBody List<ServiceMetric> metricList) {
LOG.debug("calling publishMetrics {}", metricList);
for (SingleMetricRecord metricRecord : metricList) {
if(metricRecord.getDeploymentId()==null){
metricRecord.setDeploymentId(CloudMetricsTags.deployment);
}
for (ServiceMetric metricRecord : metricList) {
metricStream.publish(metricRecord);
}
GenericResponse ret = new GenericResponse();

View File

@@ -39,7 +39,6 @@
<module>../cloud-event-dispatcher-interface</module>
<module>../cloud-event-dispatcher-local</module>
<module>../cloud-event-dispatcher-remote</module>
<module>../tip-wlan-cloud-service-metrics-models</module>
<module>../tip-wlan-cloud-system-event-models</module>
<module>../customer-models</module>
<module>../customer-datastore-interface</module>

View File

@@ -6,24 +6,23 @@ import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
import com.telecominfraproject.wlan.core.model.pagination.ColumnAndSort;
import com.telecominfraproject.wlan.core.model.pagination.PaginationContext;
import com.telecominfraproject.wlan.core.model.pagination.PaginationResponse;
import com.telecominfraproject.wlan.core.model.pagination.SortOrder;
import com.telecominfraproject.wlan.datastore.exceptions.DsConcurrentModificationException;
import com.telecominfraproject.wlan.datastore.exceptions.DsEntityNotFoundException;
import com.telecominfraproject.wlan.datastore.inmemory.BaseInMemoryDatastore;
import com.telecominfraproject.wlan.servicemetric.datastore.ServiceMetricDatastore;
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetric;
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetricDataType;
/**
* @author dtoptygin
@@ -34,119 +33,92 @@ public class ServiceMetricDatastoreInMemory extends BaseInMemoryDatastore implem
private static final Logger LOG = LoggerFactory.getLogger(ServiceMetricDatastoreInMemory.class);
private static final Map<Long, ServiceMetric> idToServiceMetricMap = new ConcurrentHashMap<Long, ServiceMetric>();
private static final Map<ServiceMetricKey, ServiceMetric> idToServiceMetricMap = new ConcurrentHashMap<ServiceMetricKey, ServiceMetric>();
private static final AtomicLong serviceMetricIdCounter = new AtomicLong();
private static class ServiceMetricKey{
final int customerId;
final long equipmentId;
final long clientMac;
final ServiceMetricDataType dataType;
final long createdTimestamp;
public ServiceMetricKey(ServiceMetric serviceMetric) {
this.customerId = serviceMetric.getCustomerId();
this.equipmentId = serviceMetric.getEquipmentId();
this.clientMac = serviceMetric.getClientMac();
this.dataType = serviceMetric.getDataType();
this.createdTimestamp = serviceMetric.getCreatedTimestamp();
}
@Override
public int hashCode() {
return Objects.hash(clientMac, createdTimestamp, customerId, dataType, equipmentId);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof ServiceMetricKey)) {
return false;
}
ServiceMetricKey other = (ServiceMetricKey) obj;
return clientMac == other.clientMac && createdTimestamp == other.createdTimestamp
&& customerId == other.customerId && dataType == other.dataType && equipmentId == other.equipmentId;
}
}
@Override
public ServiceMetric create(ServiceMetric serviceMetric) {
ServiceMetric serviceMetricCopy = serviceMetric.clone();
long id = serviceMetricIdCounter.incrementAndGet();
serviceMetricCopy.setId(id);
serviceMetricCopy.setCreatedTimestamp(System.currentTimeMillis());
serviceMetricCopy.setLastModifiedTimestamp(serviceMetricCopy.getCreatedTimestamp());
idToServiceMetricMap.put(id, serviceMetricCopy);
if(serviceMetricCopy.getCreatedTimestamp()==0) {
serviceMetricCopy.setCreatedTimestamp(System.currentTimeMillis());
}
idToServiceMetricMap.put(new ServiceMetricKey(serviceMetricCopy), serviceMetricCopy);
LOG.debug("Stored ServiceMetric {}", serviceMetricCopy);
return serviceMetricCopy.clone();
}
@Override
public ServiceMetric get(long serviceMetricId) {
LOG.debug("Looking up ServiceMetric for id {}", serviceMetricId);
ServiceMetric serviceMetric = idToServiceMetricMap.get(serviceMetricId);
if(serviceMetric==null){
LOG.debug("Cannot find ServiceMetric for id {}", serviceMetricId);
throw new DsEntityNotFoundException("Cannot find ServiceMetric for id " + serviceMetricId);
} else {
LOG.debug("Found ServiceMetric {}", serviceMetric);
}
return serviceMetric.clone();
}
@Override
public ServiceMetric getOrNull(long serviceMetricId) {
LOG.debug("Looking up ServiceMetric for id {}", serviceMetricId);
ServiceMetric serviceMetric = idToServiceMetricMap.get(serviceMetricId);
if(serviceMetric==null){
LOG.debug("Cannot find ServiceMetric for id {}", serviceMetricId);
return null;
} else {
LOG.debug("Found ServiceMetric {}", serviceMetric);
}
return serviceMetric.clone();
}
@Override
public ServiceMetric update(ServiceMetric serviceMetric) {
ServiceMetric existingServiceMetric = get(serviceMetric.getId());
if(existingServiceMetric.getLastModifiedTimestamp()!=serviceMetric.getLastModifiedTimestamp()){
LOG.debug("Concurrent modification detected for ServiceMetric with id {} expected version is {} but version in db was {}",
serviceMetric.getId(),
serviceMetric.getLastModifiedTimestamp(),
existingServiceMetric.getLastModifiedTimestamp()
);
throw new DsConcurrentModificationException("Concurrent modification detected for ServiceMetric with id " + serviceMetric.getId()
+" expected version is " + serviceMetric.getLastModifiedTimestamp()
+" but version in db was " + existingServiceMetric.getLastModifiedTimestamp()
);
}
ServiceMetric serviceMetricCopy = serviceMetric.clone();
serviceMetricCopy.setLastModifiedTimestamp(getNewLastModTs(serviceMetric.getLastModifiedTimestamp()));
idToServiceMetricMap.put(serviceMetricCopy.getId(), serviceMetricCopy);
LOG.debug("Updated ServiceMetric {}", serviceMetricCopy);
return serviceMetricCopy.clone();
}
@Override
public ServiceMetric delete(long serviceMetricId) {
ServiceMetric serviceMetric = get(serviceMetricId);
idToServiceMetricMap.remove(serviceMetric.getId());
LOG.debug("Deleted ServiceMetric {}", serviceMetric);
return serviceMetric.clone();
}
@Override
public List<ServiceMetric> get(Set<Long> serviceMetricIdSet) {
List<ServiceMetric> ret = new ArrayList<>();
if(serviceMetricIdSet!=null && !serviceMetricIdSet.isEmpty()) {
idToServiceMetricMap.forEach(
(id, c) -> {
if(serviceMetricIdSet.contains(id)) {
ret.add(c.clone());
} }
);
public List<ServiceMetric> create(List<ServiceMetric> serviceMetrics) {
if(serviceMetrics==null || serviceMetrics.isEmpty()) {
return Collections.emptyList();
}
LOG.debug("Found ServiceMetrics by ids {}", ret);
return ret;
List<ServiceMetric> ret = new ArrayList<>(serviceMetrics.size());
serviceMetrics.forEach(m -> ret.add(create(m)));
return ret;
}
@Override
public PaginationResponse<ServiceMetric> getForCustomer(int customerId,
final List<ColumnAndSort> sortBy, PaginationContext<ServiceMetric> context) {
public void delete(int customerId, long equipmentId, long createdBeforeTimestamp) {
List<ServiceMetricKey> keysToRemove = new ArrayList<>();
idToServiceMetricMap.keySet().forEach( k -> {
if(k.customerId == customerId && k.equipmentId == equipmentId && k.createdTimestamp < createdBeforeTimestamp) {
keysToRemove.add(k);
}
});
keysToRemove.forEach(k -> idToServiceMetricMap.remove(k) );
LOG.debug("Deleted ServiceMetric s for customer {} equipment {} createdBefore {}", customerId, equipmentId, createdBeforeTimestamp);
}
@Override
public PaginationResponse<ServiceMetric> getForCustomer(long fromTime, long toTime, int customerId,
Set<Long> equipmentIds, Set<MacAddress> clientMacAdresses, Set<ServiceMetricDataType> dataTypes,
List<ColumnAndSort> sortBy, PaginationContext<ServiceMetric> context) {
PaginationResponse<ServiceMetric> ret = new PaginationResponse<>();
ret.setContext(context.clone());
@@ -161,11 +133,15 @@ public class ServiceMetricDatastoreInMemory extends BaseInMemoryDatastore implem
// apply filters and build the full result list first - inefficient, but ok for testing
for (ServiceMetric mdl : idToServiceMetricMap.values()) {
if (mdl.getCustomerId() != customerId) {
continue;
if (mdl.getCustomerId() == customerId &&
(equipmentIds==null || equipmentIds.isEmpty() || equipmentIds.contains(mdl.getEquipmentId())) &&
(clientMacAdresses==null || clientMacAdresses.isEmpty() || clientMacAdresses.contains(mdl.getClientMacAddress())) &&
(dataTypes==null || dataTypes.isEmpty() || dataTypes.contains(mdl.getDataType())) &&
mdl.getCreatedTimestamp() >= fromTime &&
mdl.getCreatedTimestamp() <= toTime
) {
items.add(mdl);
}
items.add(mdl);
}
// apply sortBy columns
@@ -173,17 +149,23 @@ public class ServiceMetricDatastoreInMemory extends BaseInMemoryDatastore implem
@Override
public int compare(ServiceMetric o1, ServiceMetric o2) {
if (sortBy == null || sortBy.isEmpty()) {
// sort ascending by id by default
return Long.compare(o1.getId(), o2.getId());
// sort ascending by created time stamp by default
return Long.compare(o1.getCreatedTimestamp(), o2.getCreatedTimestamp());
} else {
int cmp;
for (ColumnAndSort column : sortBy) {
switch (column.getColumnName()) {
case "id":
cmp = Long.compare(o1.getId(), o2.getId());
case "createdTimestamp":
cmp = Long.compare(o1.getCreatedTimestamp(), o2.getCreatedTimestamp());
break;
case "sampleStr":
cmp = o1.getSampleStr().compareTo(o2.getSampleStr());
case "equipmentId":
cmp = Long.compare(o1.getEquipmentId(), o2.getEquipmentId());
break;
case "clientMac":
cmp = Long.compare(o1.getClientMac(), o2.getClientMac());
break;
case "dataType":
cmp = Integer.compare(o1.getDataType().getId(), o2.getDataType().getId());
break;
default:
// skip unknown column
@@ -204,9 +186,10 @@ public class ServiceMetricDatastoreInMemory extends BaseInMemoryDatastore implem
// find first item to add
int fromIndex = 0;
if (context.getStartAfterItem() != null) {
ServiceMetricKey startAfterKey = new ServiceMetricKey(context.getStartAfterItem());
for (ServiceMetric mdl : items) {
fromIndex++;
if (mdl.getId() == context.getStartAfterItem().getId()) {
if (new ServiceMetricKey(mdl).equals(startAfterKey)) {
break;
}
}
@@ -232,7 +215,14 @@ public class ServiceMetricDatastoreInMemory extends BaseInMemoryDatastore implem
if(ret.getContext().getStartAfterItem()!=null) {
//this datastore is only interested in the last item's id, so we'll clear all other fields on the startAfterItem in the pagination context
ServiceMetric newStartAfterItem = new ServiceMetric();
newStartAfterItem.setId(ret.getContext().getStartAfterItem().getId());
ServiceMetric oldStartAfterItem = ret.getContext().getStartAfterItem();
newStartAfterItem.setCustomerId(oldStartAfterItem.getCustomerId());
newStartAfterItem.setEquipmentId(oldStartAfterItem.getEquipmentId());
newStartAfterItem.setClientMac(oldStartAfterItem.getClientMac());
newStartAfterItem.setDataType(oldStartAfterItem.getDataType());
newStartAfterItem.setCreatedTimestamp(oldStartAfterItem.getCreatedTimestamp());
ret.getContext().setStartAfterItem(newStartAfterItem);
}

View File

@@ -3,11 +3,12 @@ package com.telecominfraproject.wlan.servicemetric.datastore;
import java.util.List;
import java.util.Set;
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
import com.telecominfraproject.wlan.core.model.pagination.ColumnAndSort;
import com.telecominfraproject.wlan.core.model.pagination.PaginationContext;
import com.telecominfraproject.wlan.core.model.pagination.PaginationResponse;
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetric;
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetricDataType;
/**
* @author dtoptygin
@@ -16,19 +17,9 @@ import com.telecominfraproject.wlan.servicemetric.models.ServiceMetric;
public interface ServiceMetricDatastore {
ServiceMetric create(ServiceMetric serviceMetric);
ServiceMetric get(long serviceMetricId);
ServiceMetric getOrNull(long serviceMetricId);
ServiceMetric update(ServiceMetric serviceMetric);
ServiceMetric delete(long serviceMetricId);
List<ServiceMetric> create(List<ServiceMetric> serviceMetrics);
void delete(int customerId, long equipmentId, long createdBeforeTimestamp);
/**
* Retrieves a list of ServiceMetric records that which have their Id in the provided set.
*
* @param serviceMetricIdSet
* @return list of matching ServiceMetric objects.
*/
List<ServiceMetric> get(Set<Long> serviceMetricIdSet);
/**
* <br>Retrieves all of the ServiceMetric records that are mapped to the provided customerId.
* Results are returned in pages.
@@ -38,14 +29,31 @@ public interface ServiceMetricDatastore {
* <br>The only time when a caller should be interacting with the properties of the paginationContext is during the
* call to the first page by setting property maxItemsPerPage.
* <br>If initial context is not provided, then the maxItemsPerPage will be set to 20.
* <br>If sortBy is not provided, then the data will be ordered by id.
* <ul>Allowed columns for sorting are:
*<li> "id"
*<li> "sampleStr"
* <br>If sortBy is not provided, then the data will be ordered by createdTimestamp.
* <ul>Allowed columns for sorting are:
*<li> "createdTimestamp"
*<li> "equipmentId"
*<li> "clientMac"
*<li> "dataType"
*<br>
* @param customerId
* @param fromTime
* @param toTime
* @param customerId
* @param equipmentIds - null or empty means all equipment for customer
* @param clientMacAdresses - null or empty means all client MAC addresses
* @param dataTypes - null or empty means all metric data types
* @param sortBy
* @param context
* @return next page of matching ServiceMetric objects.
*/
PaginationResponse<ServiceMetric> getForCustomer(int customerId, List<ColumnAndSort> sortBy, PaginationContext<ServiceMetric> context);
*/
PaginationResponse<ServiceMetric> getForCustomer(
long fromTime,
long toTime,
int customerId,
Set<Long> equipmentIds,
Set<MacAddress> clientMacAdresses,
Set<ServiceMetricDataType> dataTypes,
List<ColumnAndSort> sortBy,
PaginationContext<ServiceMetric> context);
}

View File

@@ -1,19 +1,25 @@
package com.telecominfraproject.wlan.servicemetrics.models;
package com.telecominfraproject.wlan.servicemetric.apnode.models;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import org.springframework.util.CollectionUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
import com.telecominfraproject.wlan.servicemetrics.models.WmmQueueStats.WmmQueueType;
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
import com.telecominfraproject.wlan.servicemetric.models.McsStats;
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetricDataType;
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetricDetails;
import com.telecominfraproject.wlan.servicemetric.models.WmmQueueStats;
import com.telecominfraproject.wlan.servicemetric.models.WmmQueueStats.WmmQueueType;
/**
* Node-level metric data from the Access Point.
@@ -21,12 +27,10 @@ import com.telecominfraproject.wlan.servicemetrics.models.WmmQueueStats.WmmQueue
* @author yongli
*
*/
public class ApNodeMetrics extends MetricData implements ClientMetricsInterface
public class ApNodeMetrics extends ServiceMetricDetails
{
private static final long serialVersionUID = 3133201391801512954L;
public static final String TYPE_NAME = ApNodeMetrics.class.getSimpleName();
/**
* How many seconds the AP measured for the metric
*/
@@ -35,41 +39,21 @@ public class ApNodeMetrics extends MetricData implements ClientMetricsInterface
/**
* Client MAC addresses seen during the period
*/
private List<byte[]> clientMacAddresses = new ArrayList<>();
private Map<RadioType, List<MacAddress>> clientMacAddressesPerRadio = new EnumMap<>(RadioType.class);
/**
* Total number the bytes transmitted on 2.4GHz radio
* Total number the bytes transmitted on radio
*/
private Long txBytes2G;
private Map<RadioType, Long> txBytesPerRadio = new EnumMap<>(RadioType.class);
/**
* Total number of byte received on 2.4GHz radio
* Total number of bytes received on radio
*/
private Long rxBytes2G;
private Map<RadioType, Long> rxBytesPerRadio = new EnumMap<>(RadioType.class);
/**
* Total number the bytes transmitted on 5GHz radio
*/
private Long txBytes5G;
/**
* Total number of byte received on 5GHz radio
*/
private Long rxBytes5G;
private Map<RadioType, Integer> noiseFloorPerRadio = new EnumMap<>(RadioType.class);
/**
* The noise floor for 2.4G radio
*/
private Integer noiseFloor2G;
/**
* The noise floor for 5G radio
*/
private Integer noiseFloor5G;
/**
* Tunnel metrics
*/
private List<TunnelMetricData> tunnelMetrics = new ArrayList<>();
private List<NetworkProbeMetrics> networkProbeMetrics = new ArrayList<>();
@@ -85,38 +69,23 @@ public class ApNodeMetrics extends MetricData implements ClientMetricsInterface
private Long cloudLinkLatencyInMs;
/**
* The channel utilization for 2.4G radio
* The channel utilization for radio
*/
private Integer channelUtilization2G;
/**
* The channel utilization for 5G radio
*/
private Integer channelUtilization5G;
private Map<RadioType, Integer> channelUtilizationPerRadio = new EnumMap<>(RadioType.class);
private ApPerformance apPerformance;
private List<VlanSubnet> vlanSubnet;
private List<RadioUtilization> radioUtilization2G;
private Map<RadioType, List<RadioUtilization>> radioUtilizationPerRadio = new EnumMap<>(RadioType.class);
private List<RadioUtilization> radioUtilization5G;
private RadioStatistics radioStats2G;
private RadioStatistics radioStats5G;
private Map<RadioType, RadioStatistics> radioStatsPerRadio = new EnumMap<>(RadioType.class);
private List<McsStats> mcsStats2G;
private List<McsStats> mcsStats5G;
private Map<RadioType, List<McsStats>> mcsStatsPerRadio = new EnumMap<>(RadioType.class);
/**
* Our wmm queues
*/
Map<WmmQueueType, WmmQueueStats> twoGWmmQueue;
Map<WmmQueueType, WmmQueueStats> fiveGWmmQueue;
private Map<RadioType, Map<WmmQueueType, WmmQueueStats>> wmmQueuesPerRadio = new EnumMap<>(RadioType.class);
public String getType() {
return TYPE_NAME;
}
public Integer getPeriodLengthSec() {
return periodLengthSec;
@@ -131,18 +100,31 @@ public class ApNodeMetrics extends MetricData implements ClientMetricsInterface
* @return total
*/
public long getClientCount() {
return clientMacAddresses != null ? clientMacAddresses.size() : 0;
Set<MacAddress> distinctMacs = new HashSet<>();
if(clientMacAddressesPerRadio!=null) {
clientMacAddressesPerRadio.values().forEach(macList -> macList.forEach(mac -> distinctMacs.add(mac) ) );
}
return distinctMacs.size();
}
public List<byte[]> getClientMacAddresses() {
return clientMacAddresses;
public List<MacAddress> getClientMacAddresses(RadioType radioType) {
return clientMacAddressesPerRadio.get(radioType);
}
public void setClientMacAddresses(List<byte[]> clientMacAddresses) {
this.clientMacAddresses = clientMacAddresses;
public void setClientMacAddresses(RadioType radioType, List<MacAddress> clientMacAddresses) {
this.clientMacAddressesPerRadio.put(radioType, clientMacAddresses);
}
public Map<RadioType, List<MacAddress>> getClientMacAddressesPerRadio() {
return clientMacAddressesPerRadio;
}
public List<TunnelMetricData> getTunnelMetrics() {
public void setClientMacAddressesPerRadio(Map<RadioType, List<MacAddress>> clientMacAddressesPerRadio) {
this.clientMacAddressesPerRadio = clientMacAddressesPerRadio;
}
public List<TunnelMetricData> getTunnelMetrics() {
return tunnelMetrics;
}
@@ -158,20 +140,20 @@ public class ApNodeMetrics extends MetricData implements ClientMetricsInterface
this.networkProbeMetrics = networkProbeMetrics;
}
public Integer getNoiseFloor2G() {
return noiseFloor2G;
public Integer getNoiseFloor(RadioType radioType) {
return noiseFloorPerRadio.get(radioType);
}
/**
* Return the last actual cell size which is measure at the same time as noise floor.
* Return the last actual cell size which is measured at the same time as noise floor.
* @return cell size
*/
public Integer getCellSize2G() {
if (null == this.radioStats2G) {
public Integer getCellSize(RadioType radioType) {
if (radioStatsPerRadio == null || radioStatsPerRadio.get(radioType) == null) {
return null;
}
List<Integer> values = this.radioStats2G.getActualCellSize();
if (null == values || values.isEmpty()) {
List<Integer> values = this.radioStatsPerRadio.get(radioType).getActualCellSize();
if (values == null || values.isEmpty()) {
return null;
}
return values.get(values.size()-1);
@@ -182,59 +164,21 @@ public class ApNodeMetrics extends MetricData implements ClientMetricsInterface
*
* @return cell size.
*/
public Integer getMinCellSize2G() {
if (null == this.radioStats2G) {
public Integer getMinCellSize(RadioType radioType) {
if (radioStatsPerRadio == null || radioStatsPerRadio.get(radioType) == null) {
return null;
}
List<Integer> values = this.radioStats2G.getActualCellSize();
List<Integer> values = this.radioStatsPerRadio.get(radioType).getActualCellSize();
if (null == values || values.isEmpty()) {
return null;
}
return Collections.max(values);
}
public void setNoiseFloor2G(Integer noiseFloor2G) {
this.noiseFloor2G = noiseFloor2G;
public void setNoiseFloor(RadioType radioType, Integer noiseFloor) {
this.noiseFloorPerRadio.put(radioType, noiseFloor);
}
public Integer getNoiseFloor5G() {
return noiseFloor5G;
}
/**
* Return the last actual cell size which is measure at the same time as noise floor.
* @return cell size
*/
public Integer getCellSize5G() {
if (null == this.radioStats5G) {
return null;
}
List<Integer> values = this.radioStats5G.getActualCellSize();
if (null == values || values.isEmpty()) {
return null;
}
return values.get(values.size()-1);
}
/**
* Grab the minimum cell size (largest value) from all the actual cell size.
*
* @return cell size.
*/
public Integer getMinCellSize5G() {
if (null == this.radioStats5G) {
return null;
}
List<Integer> values = this.radioStats5G.getActualCellSize();
if (null == values || values.isEmpty()) {
return null;
}
return Collections.max(values);
}
public void setNoiseFloor5G(Integer noiseFloor5G) {
this.noiseFloor5G = noiseFloor5G;
}
public Integer getCloudLinkAvailability() {
return this.cloudLinkAvailability;
@@ -252,53 +196,31 @@ public class ApNodeMetrics extends MetricData implements ClientMetricsInterface
this.cloudLinkLatencyInMs = cloudLatency;
}
public Integer getChannelUtilization2G() {
return channelUtilization2G;
public Integer getChannelUtilization(RadioType radioType) {
return channelUtilizationPerRadio.get(radioType);
}
public void setChannelUtilization2G(Integer channelUtilization2G) {
this.channelUtilization2G = channelUtilization2G;
public void setChannelUtilization(RadioType radioType, Integer channelUtilization) {
channelUtilizationPerRadio.put(radioType, channelUtilization);
}
public Integer getChannelUtilization5G() {
return channelUtilization5G;
public Long getTxBytes(RadioType radioType) {
return txBytesPerRadio.get(radioType);
}
public void setChannelUtilization5G(Integer channelUtilization5G) {
this.channelUtilization5G = channelUtilization5G;
public void setTxBytes(RadioType radioType, Long txBytes) {
txBytesPerRadio.put(radioType, txBytes);
}
public Long getTxBytes2G() {
return txBytes2G;
public Long getRxBytes(RadioType radioType) {
return rxBytesPerRadio.get(radioType);
}
public void setTxBytes2G(Long txBytes2G) {
this.txBytes2G = txBytes2G;
public void setRxBytes(RadioType radioType, Long rxBytes) {
this.rxBytesPerRadio.put(radioType, rxBytes);
}
public Long getRxBytes2G() {
return rxBytes2G;
}
public void setRxBytes2G(Long rxBytes2G) {
this.rxBytes2G = rxBytes2G;
}
public Long getTxBytes5G() {
return txBytes5G;
}
public void setTxBytes5G(Long txBytes5G) {
this.txBytes5G = txBytes5G;
}
public Long getRxBytes5G() {
return rxBytes5G;
}
public void setRxBytes5G(Long rxBytes5G) {
this.rxBytes5G = rxBytes5G;
}
public List<RadiusMetrics> getRadiusMetrics() {
return radiusMetrics;
@@ -324,73 +246,43 @@ public class ApNodeMetrics extends MetricData implements ClientMetricsInterface
this.vlanSubnet = vlanSubnet;
}
public List<RadioUtilization> getRadioUtilization2G() {
return radioUtilization2G;
public List<RadioUtilization> getRadioUtilization(RadioType radioType) {
return radioUtilizationPerRadio.get(radioType);
}
public void setRadioUtilization2G(List<RadioUtilization> radioUtilization2G) {
this.radioUtilization2G = radioUtilization2G;
public void setRadioUtilization(RadioType radioType, List<RadioUtilization> radioUtilization) {
this.radioUtilizationPerRadio.put(radioType, radioUtilization);
}
public List<RadioUtilization> getRadioUtilization5G() {
return radioUtilization5G;
public RadioStatistics getRadioStats(RadioType radioType) {
return radioStatsPerRadio.get(radioType);
}
public void setRadioUtilization5G(List<RadioUtilization> radioUtilization5G) {
this.radioUtilization5G = radioUtilization5G;
}
public RadioStatistics getRadioStats2G() {
return radioStats2G;
public void setRadioStats(RadioType radioType, RadioStatistics radioStats) {
this.radioStatsPerRadio.put(radioType, radioStats);
}
public void setRadioStats2G(RadioStatistics radioStats2G) {
this.radioStats2G = radioStats2G;
public List<McsStats> getMcsStats(RadioType radioType) {
return mcsStatsPerRadio.get(radioType);
}
public List<McsStats> getMcsStats2G() {
return mcsStats2G;
}
public void setMcsStats2G(List<McsStats> mcsStats2G) {
this.mcsStats2G = mcsStats2G;
}
public List<McsStats> getMcsStats5G() {
return mcsStats5G;
}
public void setMcsStats5G(List<McsStats> mcsStats5G) {
this.mcsStats5G = mcsStats5G;
}
public RadioStatistics getRadioStats5G() {
return radioStats5G;
}
public void setRadioStats5G(RadioStatistics radioStats5G) {
this.radioStats5G = radioStats5G;
public void setMcsStats(RadioType radioType, List<McsStats> mcsStats) {
this.mcsStatsPerRadio.put(radioType, mcsStats);
}
public Map<WmmQueueType, WmmQueueStats> getTwoGWmmQueue() {
return twoGWmmQueue;
public Map<WmmQueueType, WmmQueueStats> getWmmQueue(RadioType radioType) {
return wmmQueuesPerRadio.get(radioType);
}
public void setTwoGWmmQueue(Map<WmmQueueType, WmmQueueStats> twoGWmmQueue) {
this.twoGWmmQueue = twoGWmmQueue;
public void setWmmQueue(RadioType radioType, Map<WmmQueueType, WmmQueueStats> wmmQueue) {
this.wmmQueuesPerRadio.put(radioType, wmmQueue);
}
public Map<WmmQueueType, WmmQueueStats> getFiveGWmmQueue() {
return fiveGWmmQueue;
}
public void setFiveGWmmQueue(Map<WmmQueueType, WmmQueueStats> fiveGWmmQueue) {
this.fiveGWmmQueue = fiveGWmmQueue;
}
//
// Functions for use in rule engine
// Utility Functions
//
public boolean aggregateIsDhcpReachable() {
@@ -464,211 +356,114 @@ public class ApNodeMetrics extends MetricData implements ClientMetricsInterface
return RadiusMetricsUtil.getMinRadiusLatency(radiusMetrics);
}
public Map<RadioType, Long> getTxBytesPerRadio() {
return txBytesPerRadio;
}
//
public void setTxBytesPerRadio(Map<RadioType, Long> txBytesPerRadio) {
this.txBytesPerRadio = txBytesPerRadio;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((apPerformance == null) ? 0 : apPerformance.hashCode());
result = prime
* result
+ ((channelUtilization2G == null) ? 0 : channelUtilization2G
.hashCode());
result = prime
* result
+ ((channelUtilization5G == null) ? 0 : channelUtilization5G
.hashCode());
result = prime
* result
+ ((clientMacAddresses == null) ? 0 : clientMacAddresses.hashCode());
result = prime
* result
+ ((cloudLinkAvailability == null) ? 0 : cloudLinkAvailability
.hashCode());
result = prime
* result
+ ((cloudLinkLatencyInMs == null) ? 0 : cloudLinkLatencyInMs
.hashCode());
result = prime
* result
+ ((networkProbeMetrics == null) ? 0 : networkProbeMetrics
.hashCode());
result = prime * result
+ ((noiseFloor2G == null) ? 0 : noiseFloor2G.hashCode());
result = prime * result
+ ((noiseFloor5G == null) ? 0 : noiseFloor5G.hashCode());
result = prime * result
+ ((periodLengthSec == null) ? 0 : periodLengthSec.hashCode());
result = prime * result
+ ((radiusMetrics == null) ? 0 : radiusMetrics.hashCode());
result = prime * result
+ ((rxBytes2G == null) ? 0 : rxBytes2G.hashCode());
result = prime * result
+ ((rxBytes5G == null) ? 0 : rxBytes5G.hashCode());
result = prime * result
+ ((tunnelMetrics == null) ? 0 : tunnelMetrics.hashCode());
result = prime * result
+ ((txBytes2G == null) ? 0 : txBytes2G.hashCode());
result = prime * result
+ ((txBytes5G == null) ? 0 : txBytes5G.hashCode());
result = prime * result
+ ((vlanSubnet == null) ? 0 : vlanSubnet.hashCode());
result = prime * result
+ ((radioUtilization2G == null) ? 0 : radioUtilization2G.hashCode());
result = prime * result
+ ((radioUtilization5G == null) ? 0 : radioUtilization5G.hashCode());
result = prime * result
+ ((radioStats2G == null) ? 0 : radioStats2G.hashCode());
result = prime * result
+ ((radioStats5G == null) ? 0 : radioStats5G.hashCode());
result = prime * result
+ ((mcsStats2G == null) ? 0 : mcsStats2G.hashCode());
result = prime * result
+ ((mcsStats5G == null) ? 0 : mcsStats5G.hashCode());
return result;
}
public Map<RadioType, Long> getRxBytesPerRadio() {
return rxBytesPerRadio;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ApNodeMetrics other = (ApNodeMetrics) obj;
if (apPerformance == null) {
if (other.apPerformance != null)
return false;
} else if (!apPerformance.equals(other.apPerformance))
return false;
if (channelUtilization2G == null) {
if (other.channelUtilization2G != null)
return false;
} else if (!channelUtilization2G.equals(other.channelUtilization2G))
return false;
if (channelUtilization5G == null) {
if (other.channelUtilization5G != null)
return false;
} else if (!channelUtilization5G.equals(other.channelUtilization5G))
return false;
if (clientMacAddresses == null) {
if (other.clientMacAddresses != null)
return false;
}
else
{
for (int i = 0; i < clientMacAddresses.size(); i++)
{
if (!Arrays.equals(clientMacAddresses.get(i), other.clientMacAddresses.get(i)))
{
return false;
}
}
}
public void setRxBytesPerRadio(Map<RadioType, Long> rxBytesPerRadio) {
this.rxBytesPerRadio = rxBytesPerRadio;
}
if (cloudLinkAvailability == null) {
if (other.cloudLinkAvailability != null)
return false;
} else if (!cloudLinkAvailability.equals(other.cloudLinkAvailability))
return false;
if (cloudLinkLatencyInMs == null) {
if (other.cloudLinkLatencyInMs != null)
return false;
} else if (!cloudLinkLatencyInMs.equals(other.cloudLinkLatencyInMs))
return false;
if (networkProbeMetrics == null) {
if (other.networkProbeMetrics != null)
return false;
} else if (!networkProbeMetrics.equals(other.networkProbeMetrics))
return false;
if (noiseFloor2G == null) {
if (other.noiseFloor2G != null)
return false;
} else if (!noiseFloor2G.equals(other.noiseFloor2G))
return false;
if (noiseFloor5G == null) {
if (other.noiseFloor5G != null)
return false;
} else if (!noiseFloor5G.equals(other.noiseFloor5G))
return false;
if (periodLengthSec == null) {
if (other.periodLengthSec != null)
return false;
} else if (!periodLengthSec.equals(other.periodLengthSec))
return false;
if (radiusMetrics == null) {
if (other.radiusMetrics != null)
return false;
} else if (!radiusMetrics.equals(other.radiusMetrics))
return false;
if (rxBytes2G == null) {
if (other.rxBytes2G != null)
return false;
} else if (!rxBytes2G.equals(other.rxBytes2G))
return false;
if (rxBytes5G == null) {
if (other.rxBytes5G != null)
return false;
} else if (!rxBytes5G.equals(other.rxBytes5G))
return false;
if (tunnelMetrics == null) {
if (other.tunnelMetrics != null)
return false;
} else if (!tunnelMetrics.equals(other.tunnelMetrics))
return false;
if (txBytes2G == null) {
if (other.txBytes2G != null)
return false;
} else if (!txBytes2G.equals(other.txBytes2G))
return false;
if (txBytes5G == null) {
if (other.txBytes5G != null)
return false;
} else if (!txBytes5G.equals(other.txBytes5G))
return false;
if (vlanSubnet == null) {
if (other.vlanSubnet != null)
return false;
} else if (!vlanSubnet.equals(other.vlanSubnet))
return false;
if (radioUtilization2G == null) {
if (other.radioUtilization2G != null)
return false;
} else if (!radioUtilization2G.equals(other.radioUtilization2G))
return false;
if (radioUtilization5G == null) {
if (other.radioUtilization5G != null)
return false;
} else if (!radioUtilization5G.equals(other.radioUtilization5G))
return false;
if (radioStats2G == null) {
if (other.radioStats2G != null)
return false;
} else if (!radioStats2G.equals(other.radioStats2G))
return false;
if (radioStats5G == null) {
if (other.radioStats5G != null)
return false;
} else if (!radioStats5G.equals(other.radioStats5G))
return false;
if (mcsStats2G == null) {
if (other.mcsStats2G != null)
return false;
} else if (!mcsStats2G.equals(other.mcsStats2G))
return false;
if (mcsStats5G == null) {
if (other.mcsStats5G != null)
return false;
} else if (!mcsStats5G.equals(other.mcsStats5G))
return false;
return true;
}
public Map<RadioType, Integer> getNoiseFloorPerRadio() {
return noiseFloorPerRadio;
}
@Override
public void setNoiseFloorPerRadio(Map<RadioType, Integer> noiseFloorPerRadio) {
this.noiseFloorPerRadio = noiseFloorPerRadio;
}
public Map<RadioType, Integer> getChannelUtilizationPerRadio() {
return channelUtilizationPerRadio;
}
public void setChannelUtilizationPerRadio(Map<RadioType, Integer> channelUtilizationPerRadio) {
this.channelUtilizationPerRadio = channelUtilizationPerRadio;
}
public Map<RadioType, List<RadioUtilization>> getRadioUtilizationPerRadio() {
return radioUtilizationPerRadio;
}
public void setRadioUtilizationPerRadio(Map<RadioType, List<RadioUtilization>> radioUtilizationPerRadio) {
this.radioUtilizationPerRadio = radioUtilizationPerRadio;
}
public Map<RadioType, RadioStatistics> getRadioStatsPerRadio() {
return radioStatsPerRadio;
}
public void setRadioStatsPerRadio(Map<RadioType, RadioStatistics> radioStatsPerRadio) {
this.radioStatsPerRadio = radioStatsPerRadio;
}
public Map<RadioType, List<McsStats>> getMcsStatsPerRadio() {
return mcsStatsPerRadio;
}
public void setMcsStatsPerRadio(Map<RadioType, List<McsStats>> mcsStatsPerRadio) {
this.mcsStatsPerRadio = mcsStatsPerRadio;
}
public Map<RadioType, Map<WmmQueueType, WmmQueueStats>> getWmmQueuesPerRadio() {
return wmmQueuesPerRadio;
}
public void setWmmQueuesPerRadio(Map<RadioType, Map<WmmQueueType, WmmQueueStats>> wmmQueuesPerRadio) {
this.wmmQueuesPerRadio = wmmQueuesPerRadio;
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + Objects.hash(apPerformance, channelUtilizationPerRadio, clientMacAddressesPerRadio,
cloudLinkAvailability, cloudLinkLatencyInMs, mcsStatsPerRadio, networkProbeMetrics, noiseFloorPerRadio,
periodLengthSec, radioStatsPerRadio, radioUtilizationPerRadio, radiusMetrics, rxBytesPerRadio,
tunnelMetrics, txBytesPerRadio, vlanSubnet, wmmQueuesPerRadio);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof ApNodeMetrics)) {
return false;
}
ApNodeMetrics other = (ApNodeMetrics) obj;
return Objects.equals(apPerformance, other.apPerformance)
&& Objects.equals(channelUtilizationPerRadio, other.channelUtilizationPerRadio)
&& Objects.equals(clientMacAddressesPerRadio, other.clientMacAddressesPerRadio)
&& Objects.equals(cloudLinkAvailability, other.cloudLinkAvailability)
&& Objects.equals(cloudLinkLatencyInMs, other.cloudLinkLatencyInMs)
&& Objects.equals(mcsStatsPerRadio, other.mcsStatsPerRadio)
&& Objects.equals(networkProbeMetrics, other.networkProbeMetrics)
&& Objects.equals(noiseFloorPerRadio, other.noiseFloorPerRadio)
&& Objects.equals(periodLengthSec, other.periodLengthSec)
&& Objects.equals(radioStatsPerRadio, other.radioStatsPerRadio)
&& Objects.equals(radioUtilizationPerRadio, other.radioUtilizationPerRadio)
&& Objects.equals(radiusMetrics, other.radiusMetrics)
&& Objects.equals(rxBytesPerRadio, other.rxBytesPerRadio)
&& Objects.equals(tunnelMetrics, other.tunnelMetrics)
&& Objects.equals(txBytesPerRadio, other.txBytesPerRadio)
&& Objects.equals(vlanSubnet, other.vlanSubnet)
&& Objects.equals(wmmQueuesPerRadio, other.wmmQueuesPerRadio);
}
@Override
public boolean hasUnsupportedValue() {
if (super.hasUnsupportedValue()) {
return true;
@@ -676,13 +471,31 @@ public class ApNodeMetrics extends MetricData implements ClientMetricsInterface
if (hasUnsupportedValue(tunnelMetrics) || hasUnsupportedValue(networkProbeMetrics)
|| hasUnsupportedValue(radiusMetrics) || hasUnsupportedValue(apPerformance)
|| hasUnsupportedValue(vlanSubnet) || hasUnsupportedValue(radioUtilization2G)
|| hasUnsupportedValue(radioUtilization5G) || hasUnsupportedValue(radioStats2G)
|| hasUnsupportedValue(radioStats5G) || hasUnsupportedValue(mcsStats2G)
|| hasUnsupportedValue(mcsStats5G) || hasUnsupportedValue(twoGWmmQueue)
|| hasUnsupportedValue(fiveGWmmQueue)) {
|| hasUnsupportedValue(vlanSubnet) ) {
return true;
}
AtomicInteger ai = new AtomicInteger(0);
if(radioUtilizationPerRadio!=null) {
radioUtilizationPerRadio.values().forEach(c -> { if (hasUnsupportedValue(c)) { ai.incrementAndGet();} });
}
if(radioStatsPerRadio!=null) {
radioStatsPerRadio.values().forEach(c -> { if (hasUnsupportedValue(c)) { ai.incrementAndGet();} });
}
if(mcsStatsPerRadio!=null) {
mcsStatsPerRadio.values().forEach(c -> { if (hasUnsupportedValue(c)) { ai.incrementAndGet();} });
}
if(wmmQueuesPerRadio!=null) {
wmmQueuesPerRadio.values().forEach(c -> { if (hasUnsupportedValue(c)) { ai.incrementAndGet();} });
}
if(ai.get()>0) {
return true;
}
return false;
}
@@ -694,33 +507,35 @@ public class ApNodeMetrics extends MetricData implements ClientMetricsInterface
ret.apPerformance = this.apPerformance.clone();
}
if(this.clientMacAddresses !=null) {
ret.clientMacAddresses = new ArrayList<>();
for(byte[]cMac: this.clientMacAddresses){
ret.clientMacAddresses.add(cMac.clone());
}
if(this.clientMacAddressesPerRadio !=null) {
ret.clientMacAddressesPerRadio = new EnumMap<>(RadioType.class);
clientMacAddressesPerRadio.forEach((key, macList) -> {
List<MacAddress> newList = new ArrayList<>();
macList.forEach(m -> newList.add(m.clone()));
ret.clientMacAddressesPerRadio.put(key, newList);
});
}
if(this.fiveGWmmQueue !=null) {
ret.fiveGWmmQueue = new EnumMap<>(WmmQueueType.class);
for(Map.Entry<WmmQueueStats.WmmQueueType, WmmQueueStats> mapEntry: this.fiveGWmmQueue.entrySet()){
ret.fiveGWmmQueue.put(mapEntry.getKey(), mapEntry.getValue().clone());
}
if(this.wmmQueuesPerRadio!=null) {
ret.wmmQueuesPerRadio = new EnumMap<>(RadioType.class);
this.wmmQueuesPerRadio.forEach((rt, wq) -> {
Map<WmmQueueStats.WmmQueueType, WmmQueueStats> newWm = new EnumMap<>(WmmQueueType.class);
ret.wmmQueuesPerRadio.put(rt, newWm);
wq.forEach((k, v) -> newWm.put(k, v.clone()));
});
}
if(this.mcsStats2G !=null) {
ret.mcsStats2G = new ArrayList<>();
for(McsStats ms: this.mcsStats2G){
ret.mcsStats2G.add(ms.clone());
}
}
if(this.mcsStats5G !=null) {
ret.mcsStats5G = new ArrayList<>();
for(McsStats ms: this.mcsStats5G){
ret.mcsStats5G.add(ms.clone());
}
if(this.mcsStatsPerRadio !=null) {
ret.mcsStatsPerRadio = new EnumMap<>(RadioType.class);
this.mcsStatsPerRadio.forEach((k, listV) -> {
List<McsStats> newList = new ArrayList<>();
ret.mcsStatsPerRadio.put(k, newList);
listV.forEach(mcs -> newList.add(mcs.clone()));
});
}
if(this.networkProbeMetrics !=null) {
ret.networkProbeMetrics = new ArrayList<>();
@@ -729,27 +544,20 @@ public class ApNodeMetrics extends MetricData implements ClientMetricsInterface
}
}
if(this.radioStats2G !=null) {
ret.radioStats2G = this.radioStats2G.clone();
if(this.radioStatsPerRadio !=null) {
ret.radioStatsPerRadio = new EnumMap<>(RadioType.class);
this.radioStatsPerRadio.forEach((k, v) -> ret.radioStatsPerRadio.put(k, v.clone()));
}
if(this.radioStats5G !=null) {
ret.radioStats5G = this.radioStats5G.clone();
}
if(this.radioUtilization2G !=null) {
ret.radioUtilization2G = new ArrayList<>();
for(RadioUtilization ru: this.radioUtilization2G){
ret.radioUtilization2G.add(ru.clone());
}
}
if(this.radioUtilization5G !=null) {
ret.radioUtilization5G = new ArrayList<>();
for(RadioUtilization ru: this.radioUtilization5G){
ret.radioUtilization5G.add(ru.clone());
}
if(this.radioUtilizationPerRadio !=null) {
ret.radioUtilizationPerRadio = new EnumMap<>(RadioType.class);
this.radioUtilizationPerRadio.forEach((k, listV) -> {
List<RadioUtilization> newList = new ArrayList<>();
ret.radioUtilizationPerRadio.put(k, newList);
listV.forEach(ru -> newList.add(ru.clone()));
});
}
if(this.radiusMetrics !=null) {
ret.radiusMetrics = new ArrayList<>();
@@ -765,14 +573,6 @@ public class ApNodeMetrics extends MetricData implements ClientMetricsInterface
}
}
if(this.twoGWmmQueue !=null) {
ret.twoGWmmQueue = new EnumMap<>(WmmQueueType.class);
for(Map.Entry<WmmQueueStats.WmmQueueType, WmmQueueStats> mapEntry: this.twoGWmmQueue.entrySet()){
ret.twoGWmmQueue.put(mapEntry.getKey(), mapEntry.getValue().clone());
}
}
if(this.vlanSubnet !=null) {
ret.vlanSubnet = new ArrayList<>();
for(VlanSubnet vs: this.vlanSubnet){
@@ -784,31 +584,7 @@ public class ApNodeMetrics extends MetricData implements ClientMetricsInterface
}
@Override
public Set<MacAddress> getDeviceMacAddresses()
{
if(clientMacAddresses != null)
{
Set<MacAddress> returnValue = new HashSet<>();
for(byte[] mac : clientMacAddresses)
{
returnValue.add(new MacAddress(mac));
}
return returnValue;
}
return Collections.emptySet();
}
@Override
public boolean containsClientMac(MacAddress clientMac)
{
return getDeviceMacAddresses().contains(clientMac);
}
public static boolean isDataType(String dataType) {
return TYPE_NAME.equals(dataType);
public ServiceMetricDataType getDataType() {
return ServiceMetricDataType.ApNode;
}
}

View File

@@ -1,4 +1,4 @@
package com.telecominfraproject.wlan.servicemetrics.models;
package com.telecominfraproject.wlan.servicemetric.apnode.models;
import java.util.Arrays;

View File

@@ -1,4 +1,4 @@
package com.telecominfraproject.wlan.servicemetrics.models;
package com.telecominfraproject.wlan.servicemetric.apnode.models;
import java.net.InetAddress;

View File

@@ -1,7 +1,7 @@
/**
*
*/
package com.telecominfraproject.wlan.servicemetrics.models;
package com.telecominfraproject.wlan.servicemetric.apnode.models;
import java.util.HashMap;
import java.util.Map;
@@ -14,8 +14,13 @@ import com.telecominfraproject.wlan.core.model.json.JsonDeserializationUtils;
*
*/
public enum EthernetLinkState {
DOWN(0, 0, false), UP1000_FULL_DUPLEX(1, 1000, true), UP1000_HALF_DUPLEX(2, 1000, false), UP100_FULL_DUPLEX(3, 100,
true), UP100_HALF_DUPLEX(4, 100, false), UP10_FULL_DUPLEX(5, 10, true), UP10_HALF_DUPLEX(6, 10, false),
DOWN(0, 0, false),
UP1000_FULL_DUPLEX(1, 1000, true),
UP1000_HALF_DUPLEX(2, 1000, false),
UP100_FULL_DUPLEX(3, 100, true),
UP100_HALF_DUPLEX(4, 100, false),
UP10_FULL_DUPLEX(5, 10, true),
UP10_HALF_DUPLEX(6, 10, false),
UNSUPPORTED(-1, 0, false);

View File

@@ -1,4 +1,4 @@
package com.telecominfraproject.wlan.servicemetrics.models;
package com.telecominfraproject.wlan.servicemetric.apnode.models;
import java.util.List;
import java.util.Objects;

View File

@@ -1,4 +1,4 @@
package com.telecominfraproject.wlan.servicemetrics.models;
package com.telecominfraproject.wlan.servicemetric.apnode.models;
import java.io.Serializable;
import java.util.List;

View File

@@ -1,4 +1,4 @@
package com.telecominfraproject.wlan.servicemetrics.models;
package com.telecominfraproject.wlan.servicemetric.apnode.models;
import java.util.ArrayList;
import java.util.List;

View File

@@ -1,7 +1,7 @@
/**
*
*/
package com.telecominfraproject.wlan.servicemetrics.models;
package com.telecominfraproject.wlan.servicemetric.apnode.models;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;

View File

@@ -1,4 +1,4 @@
package com.telecominfraproject.wlan.servicemetrics.models;
package com.telecominfraproject.wlan.servicemetric.apnode.models;
import java.net.InetAddress;

View File

@@ -1,4 +1,4 @@
package com.telecominfraproject.wlan.servicemetrics.models;
package com.telecominfraproject.wlan.servicemetric.apnode.models;
import java.io.Serializable;
import java.util.List;

View File

@@ -1,4 +1,4 @@
package com.telecominfraproject.wlan.servicemetrics.models;
package com.telecominfraproject.wlan.servicemetric.apnode.models;
import java.util.HashMap;
import java.util.Map;

View File

@@ -1,4 +1,4 @@
package com.telecominfraproject.wlan.servicemetrics.models;
package com.telecominfraproject.wlan.servicemetric.apnode.models;
import java.net.InetAddress;

View File

@@ -1,4 +1,4 @@
package com.telecominfraproject.wlan.servicemetrics.models;
package com.telecominfraproject.wlan.servicemetric.apnode.models;
import java.net.InetAddress;

View File

@@ -1,4 +1,4 @@
package com.telecominfraproject.wlan.servicemetrics.models;
package com.telecominfraproject.wlan.servicemetric.apssid.models;
import java.util.ArrayList;
import java.util.EnumMap;
@@ -8,28 +8,25 @@ import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetricDataType;
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetricDetails;
/**
* Ssid metrics for the AP
* @author ekeddy
*
*/
public class ApSsidMetrics extends MetricData {
public class ApSsidMetrics extends ServiceMetricDetails {
private static final long serialVersionUID = 6334213644766085284L;
public static final String TYPE_NAME = ApSsidMetrics.class.getSimpleName();
private Map<RadioType, List<SsidStatistics>> ssidStats = new EnumMap<>(RadioType.class);
/* (non-Javadoc)
* @see com.whizcontrol.servicemetrics.models.MetricData#getType()
*/
@Override
public String getType() {
return TYPE_NAME;
public ServiceMetricDataType getDataType() {
return ServiceMetricDataType.ApSsid;
}
@JsonIgnore
public long getSsidStatsCount(RadioType radioType) {
List<SsidStatistics> sList = ssidStats.get(radioType);

View File

@@ -1,4 +1,4 @@
package com.telecominfraproject.wlan.servicemetrics.models;
package com.telecominfraproject.wlan.servicemetric.apssid.models;
import java.util.ArrayList;
import java.util.EnumMap;
@@ -8,7 +8,9 @@ import java.util.Map;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;
import com.telecominfraproject.wlan.servicemetrics.models.WmmQueueStats.WmmQueueType;
import com.telecominfraproject.wlan.servicemetric.models.McsStats;
import com.telecominfraproject.wlan.servicemetric.models.WmmQueueStats;
import com.telecominfraproject.wlan.servicemetric.models.WmmQueueStats.WmmQueueType;
/**
* @author ekeddy

View File

@@ -0,0 +1,77 @@
package com.telecominfraproject.wlan.servicemetric.channelinfo.models;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.telecominfraproject.wlan.core.model.equipment.ChannelBandwidth;
import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ChannelInfo extends BaseJsonModel
{
private static final long serialVersionUID = 3149015856936675456L;
private Integer chanNumber;
private ChannelBandwidth bandwidth;
private Integer totalUtilization;
private Integer wifiUtilization;
private Integer noiseFloor;
public ChannelInfo()
{
// serialization
}
public Integer getChanNumber() {
return chanNumber;
}
public void setChanNumber(Integer chanNumber) {
this.chanNumber = chanNumber;
}
public ChannelBandwidth getBandwidth() {
return bandwidth;
}
public void setBandwidth(ChannelBandwidth bandwidth) {
this.bandwidth = bandwidth;
}
public Integer getTotalUtilization() {
return totalUtilization;
}
public void setTotalUtilization(Integer totalUtilization) {
this.totalUtilization = totalUtilization;
}
public Integer getWifiUtilization() {
return wifiUtilization;
}
public void setWifiUtilization(Integer wifiUtilization) {
this.wifiUtilization = wifiUtilization;
}
public Integer getNoiseFloor() {
return noiseFloor;
}
public void setNoiseFloor(Integer noiseFloor) {
this.noiseFloor = noiseFloor;
}
@Override
public boolean hasUnsupportedValue() {
if (super.hasUnsupportedValue()) {
return true;
}
if (ChannelBandwidth.isUnsupported(bandwidth)) {
return true;
}
return false;
}
@Override
public ChannelInfo clone() {
return (ChannelInfo) super.clone();
}
}

View File

@@ -0,0 +1,104 @@
package com.telecominfraproject.wlan.servicemetric.channelinfo.models;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetricDataType;
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetricDetails;
public class ChannelInfoReports extends ServiceMetricDetails {
private static final long serialVersionUID = 8835774986697535976L;
private Map<RadioType, List<ChannelInfo>> channelInformationReportsPerRadio = new EnumMap<>(RadioType.class);
public Map<RadioType, List<ChannelInfo>> getChannelInformationReportsPerRadio() {
return channelInformationReportsPerRadio;
}
public void setChannelInformationReportsPerRadio(Map<RadioType, List<ChannelInfo>> channelInformationReportsPerRadio) {
this.channelInformationReportsPerRadio = channelInformationReportsPerRadio;
}
@Override
public ServiceMetricDataType getDataType() {
return ServiceMetricDataType.Channel;
}
@JsonIgnore
public long getChannelInformationReportCount(RadioType radioType) {
List<ChannelInfo> reports = channelInformationReportsPerRadio.get(radioType);
return (reports == null) ? 0 : reports.size();
}
@JsonIgnore
public List<ChannelInfo> getRadioInfo(RadioType radioType)
{
return channelInformationReportsPerRadio.get(radioType);
}
@Override
public boolean hasUnsupportedValue() {
if (super.hasUnsupportedValue()) {
return true;
}
if(channelInformationReportsPerRadio!=null) {
for( List<ChannelInfo> reports : channelInformationReportsPerRadio.values()) {
if (hasUnsupportedValue(reports)) {
return true;
}
}
}
return false;
}
@Override
public ChannelInfoReports clone() {
ChannelInfoReports ret = (ChannelInfoReports) super.clone();
if(this.channelInformationReportsPerRadio !=null) {
ret.channelInformationReportsPerRadio = new EnumMap<>(RadioType.class);
channelInformationReportsPerRadio.forEach((key, existingList) -> {
List<ChannelInfo> newList = new ArrayList<>();
existingList.forEach(m -> newList.add(m.clone()));
ret.channelInformationReportsPerRadio.put(key, newList);
});
}
return ret;
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + Objects.hash(channelInformationReportsPerRadio);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof ChannelInfoReports)) {
return false;
}
ChannelInfoReports other = (ChannelInfoReports) obj;
return Objects.equals(channelInformationReportsPerRadio, other.channelInformationReportsPerRadio);
}
}

View File

@@ -1,4 +1,4 @@
package com.telecominfraproject.wlan.servicemetrics.models;
package com.telecominfraproject.wlan.servicemetric.client.models;
import java.util.ArrayList;
import java.util.Arrays;
@@ -9,21 +9,27 @@ import java.util.Map.Entry;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
import com.telecominfraproject.wlan.core.model.equipment.ChannelBandwidth;
import com.telecominfraproject.wlan.core.model.equipment.GuardInterval;
import com.telecominfraproject.wlan.servicemetrics.models.WmmQueueStats.WmmQueueType;
import com.telecominfraproject.wlan.servicemetrics.models.utils.ClientRadioUtils;
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
import com.telecominfraproject.wlan.servicemetric.models.McsStats;
import com.telecominfraproject.wlan.servicemetric.models.McsType;
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetricDataType;
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetricDetails;
import com.telecominfraproject.wlan.servicemetric.models.WmmQueueStats;
import com.telecominfraproject.wlan.servicemetric.models.WmmQueueStats.WmmQueueType;
/**
* @author ekeddy
*
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ClientMetrics extends BaseClientMetrics {
public class ClientMetrics extends ServiceMetricDetails {
private static final long serialVersionUID = 7242365268669169773L;
private Integer secondsSinceLastRecv;
private Long numRxPackets;
private Long numTxPackets;
private Long numRxBytes;
@@ -576,6 +582,16 @@ public class ClientMetrics extends BaseClientMetrics {
*/
private RadioType radioType;
/**
* How many seconds the AP measured for the metric
*/
private Integer periodLengthSec = 5;
@Override
public ServiceMetricDataType getDataType() {
return ServiceMetricDataType.Client;
}
@Override
public ClientMetrics clone() {
ClientMetrics ret = (ClientMetrics) super.clone();
@@ -4006,4 +4022,20 @@ public class ClientMetrics extends BaseClientMetrics {
public void setAverageRxRate(Double averageRxRate) {
this.averageRxRate = averageRxRate;
}
public Integer getSecondsSinceLastRecv() {
return secondsSinceLastRecv;
}
public void setSecondsSinceLastRecv(Integer secondsSinceLastRecv) {
this.secondsSinceLastRecv = secondsSinceLastRecv;
}
public Integer getPeriodLengthSec() {
return periodLengthSec;
}
public void setPeriodLengthSec(Integer periodLengthSec) {
this.periodLengthSec = periodLengthSec;
}
}

View File

@@ -1,12 +1,12 @@
package com.telecominfraproject.wlan.servicemetrics.models.utils;
package com.telecominfraproject.wlan.servicemetric.client.models;
import java.util.EnumMap;
import java.util.Map;
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
import com.telecominfraproject.wlan.servicemetric.models.McsType;
import com.telecominfraproject.wlan.core.model.equipment.ChannelBandwidth;
import com.telecominfraproject.wlan.core.model.equipment.GuardInterval;
import com.telecominfraproject.wlan.servicemetrics.models.McsType;
/**
* Utility Routines for Client Radio

View File

@@ -1,6 +1,10 @@
package com.telecominfraproject.wlan.servicemetrics.models;
package com.telecominfraproject.wlan.servicemetric.client.qoe.models;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetricDataType;
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetricDetails;
/**
* QoE related metrics which is independent of RadioType
@@ -9,10 +13,17 @@ import com.fasterxml.jackson.annotation.JsonInclude;
*
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ClientQoEMetrics extends BaseClientMetrics {
public class ClientQoEMetrics extends ServiceMetricDetails {
private static final long serialVersionUID = 5242617221447159480L;
/**
* How many seconds the AP measured for the metric
*/
private Integer periodLengthSec = 5;
private Integer secondsSinceLastRecv;
// Connectivity QoE stats.
private Long qoeEventualSuccessTimeTaken;
private Long qoeNumOfAttempts;
@@ -23,86 +34,51 @@ public class ClientQoEMetrics extends BaseClientMetrics {
private Long qoeNumRepeatedAttempts;
private Long qoeUserError;
public ClientQoEMetrics() {
@Override
public ServiceMetricDataType getDataType() {
return ServiceMetricDataType.ClientQoE;
}
@Override
public ClientQoEMetrics clone() {
return (ClientQoEMetrics) super.clone();
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof ClientQoEMetrics)) {
return false;
}
ClientQoEMetrics other = (ClientQoEMetrics) obj;
if (this.qoeAssociatedDuration == null) {
if (other.qoeAssociatedDuration != null) {
return false;
}
} else if (!this.qoeAssociatedDuration.equals(other.qoeAssociatedDuration)) {
return false;
}
if (this.qoeAttemptDuration == null) {
if (other.qoeAttemptDuration != null) {
return false;
}
} else if (!this.qoeAttemptDuration.equals(other.qoeAttemptDuration)) {
return false;
}
if (this.qoeDeltaDuration == null) {
if (other.qoeDeltaDuration != null) {
return false;
}
} else if (!this.qoeDeltaDuration.equals(other.qoeDeltaDuration)) {
return false;
}
if (this.qoeEventualSuccessTimeTaken == null) {
if (other.qoeEventualSuccessTimeTaken != null) {
return false;
}
} else if (!this.qoeEventualSuccessTimeTaken.equals(other.qoeEventualSuccessTimeTaken)) {
return false;
}
if (this.qoeNumOfAttempts == null) {
if (other.qoeNumOfAttempts != null) {
return false;
}
} else if (!this.qoeNumOfAttempts.equals(other.qoeNumOfAttempts)) {
return false;
}
if (this.qoeNumOfSuccess == null) {
if (other.qoeNumOfSuccess != null) {
return false;
}
} else if (!this.qoeNumOfSuccess.equals(other.qoeNumOfSuccess)) {
return false;
}
if (this.qoeNumRepeatedAttempts == null) {
if (other.qoeNumRepeatedAttempts != null) {
return false;
}
} else if (!this.qoeNumRepeatedAttempts.equals(other.qoeNumRepeatedAttempts)) {
return false;
}
if (this.qoeUserError == null) {
if (other.qoeUserError != null) {
return false;
}
} else if (!this.qoeUserError.equals(other.qoeUserError)) {
return false;
}
return true;
}
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + Objects.hash(periodLengthSec, qoeAssociatedDuration, qoeAttemptDuration,
qoeDeltaDuration, qoeEventualSuccessTimeTaken, qoeNumOfAttempts, qoeNumOfSuccess,
qoeNumRepeatedAttempts, qoeUserError, secondsSinceLastRecv);
return result;
}
public Long getQoeAssociatedDuration() {
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof ClientQoEMetrics)) {
return false;
}
ClientQoEMetrics other = (ClientQoEMetrics) obj;
return Objects.equals(periodLengthSec, other.periodLengthSec)
&& Objects.equals(qoeAssociatedDuration, other.qoeAssociatedDuration)
&& Objects.equals(qoeAttemptDuration, other.qoeAttemptDuration)
&& Objects.equals(qoeDeltaDuration, other.qoeDeltaDuration)
&& Objects.equals(qoeEventualSuccessTimeTaken, other.qoeEventualSuccessTimeTaken)
&& Objects.equals(qoeNumOfAttempts, other.qoeNumOfAttempts)
&& Objects.equals(qoeNumOfSuccess, other.qoeNumOfSuccess)
&& Objects.equals(qoeNumRepeatedAttempts, other.qoeNumRepeatedAttempts)
&& Objects.equals(qoeUserError, other.qoeUserError)
&& Objects.equals(secondsSinceLastRecv, other.secondsSinceLastRecv);
}
public Long getQoeAssociatedDuration() {
return qoeAssociatedDuration;
}
@@ -134,22 +110,6 @@ public class ClientQoEMetrics extends BaseClientMetrics {
return qoeUserError;
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((this.qoeAssociatedDuration == null) ? 0 : this.qoeAssociatedDuration.hashCode());
result = prime * result + ((this.qoeAttemptDuration == null) ? 0 : this.qoeAttemptDuration.hashCode());
result = prime * result + ((this.qoeDeltaDuration == null) ? 0 : this.qoeDeltaDuration.hashCode());
result = prime * result
+ ((this.qoeEventualSuccessTimeTaken == null) ? 0 : this.qoeEventualSuccessTimeTaken.hashCode());
result = prime * result + ((this.qoeNumOfAttempts == null) ? 0 : this.qoeNumOfAttempts.hashCode());
result = prime * result + ((this.qoeNumOfSuccess == null) ? 0 : this.qoeNumOfSuccess.hashCode());
result = prime * result + ((this.qoeNumRepeatedAttempts == null) ? 0 : this.qoeNumRepeatedAttempts.hashCode());
result = prime * result + ((this.qoeUserError == null) ? 0 : this.qoeUserError.hashCode());
return result;
}
public void setQoeAssociatedDuration(Long qoeAssociatedDuration) {
this.qoeAssociatedDuration = qoeAssociatedDuration;
}
@@ -181,4 +141,20 @@ public class ClientQoEMetrics extends BaseClientMetrics {
public void setQoeUserError(Long qoeUserError) {
this.qoeUserError = qoeUserError;
}
public Integer getPeriodLengthSec() {
return periodLengthSec;
}
public void setPeriodLengthSec(Integer periodLengthSec) {
this.periodLengthSec = periodLengthSec;
}
public Integer getSecondsSinceLastRecv() {
return secondsSinceLastRecv;
}
public void setSecondsSinceLastRecv(Integer secondsSinceLastRecv) {
this.secondsSinceLastRecv = secondsSinceLastRecv;
}
}

View File

@@ -1,4 +1,4 @@
package com.telecominfraproject.wlan.servicemetrics.models;
package com.telecominfraproject.wlan.servicemetric.models;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;

View File

@@ -1,4 +1,4 @@
package com.telecominfraproject.wlan.servicemetrics.models;
package com.telecominfraproject.wlan.servicemetric.models;
import java.util.HashMap;
import java.util.Map;

View File

@@ -2,35 +2,53 @@ package com.telecominfraproject.wlan.servicemetric.models;
import java.util.Objects;
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;
import com.telecominfraproject.wlan.core.model.json.interfaces.HasClientMac;
import com.telecominfraproject.wlan.core.model.json.interfaces.HasCustomerId;
import com.telecominfraproject.wlan.core.model.json.interfaces.HasEquipmentId;
/**
* @author dtoptygin
*
*/
public class ServiceMetric extends BaseJsonModel implements HasCustomerId {
public class ServiceMetric extends BaseJsonModel implements HasCustomerId, HasEquipmentId, HasClientMac {
private static final long serialVersionUID = 5570757656953699233L;
private long id;
private int customerId;
private long equipmentId;
private long clientMac;
private ServiceMetricDataType dataType;
private long createdTimestamp;
//TODO: put more fields here, generate getters/setters for them
private String sampleStr;
private ServiceMetricDetails details;
private long createdTimestamp;
private long lastModifiedTimestamp;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public ServiceMetric() {
// for serialization
}
public ServiceMetric(int customerId, long equipmentId) {
super();
this.customerId = customerId;
this.equipmentId = equipmentId;
}
public ServiceMetric(int customerId, long equipmentId, long clientMac) {
super();
this.customerId = customerId;
this.equipmentId = equipmentId;
this.clientMac = clientMac;
}
public ServiceMetric(int customerId, long equipmentId, MacAddress clientMacAddress) {
super();
this.customerId = customerId;
this.equipmentId = equipmentId;
this.clientMac = clientMacAddress.getAddressAsLong();
}
public int getCustomerId() {
return customerId;
}
@@ -39,29 +57,21 @@ public class ServiceMetric extends BaseJsonModel implements HasCustomerId {
this.customerId = customerId;
}
public long getCreatedTimestamp() {
return createdTimestamp;
}
public long getEquipmentId() {
return equipmentId;
}
public void setCreatedTimestamp(long createdTimestamp) {
this.createdTimestamp = createdTimestamp;
}
public void setEquipmentId(long equipmentId) {
this.equipmentId = equipmentId;
}
public long getLastModifiedTimestamp() {
return lastModifiedTimestamp;
}
public long getClientMac() {
return clientMac;
}
public void setLastModifiedTimestamp(long lastModifiedTimestamp) {
this.lastModifiedTimestamp = lastModifiedTimestamp;
}
public void setSampleStr(String sampleStr) {
this.sampleStr = sampleStr;
}
public String getSampleStr() {
return sampleStr;
}
public void setClientMac(long clientMac) {
this.clientMac = clientMac;
}
public ServiceMetricDetails getDetails() {
return details;
@@ -69,6 +79,51 @@ public class ServiceMetric extends BaseJsonModel implements HasCustomerId {
public void setDetails(ServiceMetricDetails details) {
this.details = details;
//automatically set the status data type based on status details
if(details!=null) {
setDataType(details.getDataType());
}
}
public long getCreatedTimestamp() {
return createdTimestamp;
}
public void setCreatedTimestamp(long createdTimestamp) {
this.createdTimestamp = createdTimestamp;
}
@Override
public MacAddress getClientMacAddress() {
return new MacAddress(clientMac);
}
public ServiceMetricDataType getDataType() {
return dataType;
}
public void setDataType(ServiceMetricDataType dataType) {
this.dataType = dataType;
}
@Override
public int hashCode() {
return Objects.hash(clientMac, createdTimestamp, customerId, details, equipmentId, dataType);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof ServiceMetric)) {
return false;
}
ServiceMetric other = (ServiceMetric) obj;
return clientMac == other.clientMac && createdTimestamp == other.createdTimestamp
&& customerId == other.customerId && Objects.equals(details, other.details)
&& equipmentId == other.equipmentId && dataType == other.dataType;
}
@Override
@@ -88,30 +143,11 @@ public class ServiceMetric extends BaseJsonModel implements HasCustomerId {
public ServiceMetric clone() {
ServiceMetric ret = (ServiceMetric) super.clone();
if(details!=null) {
ret.setDetails(details.clone());
ret.details = (details.clone());
}
return ret;
}
@Override
public int hashCode() {
return Objects.hash(createdTimestamp, customerId, id, lastModifiedTimestamp, sampleStr, details);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof ServiceMetric)) {
return false;
}
ServiceMetric other = (ServiceMetric) obj;
return createdTimestamp == other.createdTimestamp && customerId == other.customerId && id == other.id
&& lastModifiedTimestamp == other.lastModifiedTimestamp
&& Objects.equals(sampleStr, other.sampleStr)
&& Objects.equals(details, other.details);
}
}

View File

@@ -0,0 +1,52 @@
package com.telecominfraproject.wlan.servicemetric.models;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.telecominfraproject.wlan.core.model.json.JsonDeserializationUtils;
public enum ServiceMetricDataType {
ApNode(1),
ApSsid(2),
Client(3),
Channel(4),
Neighbour(5),
QoE(6),
ClientQoE(7),
UNSUPPORTED (-1);
private final int id;
private static final Map<Integer, ServiceMetricDataType> ELEMENTS = new HashMap<>();
private ServiceMetricDataType(int id){
this.id = id;
}
public int getId(){
return this.id;
}
public static ServiceMetricDataType getById(int enumId){
if(ELEMENTS.isEmpty()){
//initialize elements map
for(ServiceMetricDataType met : ServiceMetricDataType.values()){
ELEMENTS.put(met.getId(), met);
}
}
return ELEMENTS.get(enumId);
}
@JsonCreator
public static ServiceMetricDataType getByName(String value) {
return JsonDeserializationUtils.deserializEnum(value, ServiceMetricDataType.class, UNSUPPORTED);
}
public static boolean isUnsupported(ServiceMetricDataType value) {
return (UNSUPPORTED.equals(value));
}
}

View File

@@ -8,20 +8,11 @@ import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;
* @author dtoptygin
*
*/
public class ServiceMetricDetails extends BaseJsonModel {
public abstract class ServiceMetricDetails extends BaseJsonModel {
private static final long serialVersionUID = 5570757656953699233L;
//TODO: put more fields here, generate getters/setters for them
private String sampleDetailsStr;
public String getSampleDetailsStr() {
return sampleDetailsStr;
}
public void setSampleDetailsStr(String sampleDetailsStr) {
this.sampleDetailsStr = sampleDetailsStr;
}
public abstract ServiceMetricDataType getDataType();
@Override
public boolean hasUnsupportedValue() {
@@ -39,7 +30,7 @@ public class ServiceMetricDetails extends BaseJsonModel {
@Override
public int hashCode() {
return Objects.hash(sampleDetailsStr);
return Objects.hash(getDataType());
}
@Override
@@ -51,7 +42,7 @@ public class ServiceMetricDetails extends BaseJsonModel {
return false;
}
ServiceMetricDetails other = (ServiceMetricDetails) obj;
return Objects.equals(sampleDetailsStr, other.sampleDetailsStr);
return Objects.equals(getDataType(), other.getDataType());
}
}

View File

@@ -1,4 +1,4 @@
package com.telecominfraproject.wlan.servicemetrics.models;
package com.telecominfraproject.wlan.servicemetric.models;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;

View File

@@ -0,0 +1,217 @@
package com.telecominfraproject.wlan.servicemetric.neighbourscan.models;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.telecominfraproject.wlan.core.model.equipment.DetectedAuthMode;
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
import com.telecominfraproject.wlan.core.model.equipment.NeighboreScanPacketType;
import com.telecominfraproject.wlan.core.model.equipment.NetworkType;
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
import com.telecominfraproject.wlan.core.model.equipment.Toggle;
import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;
/**
* @author ekeddy
*
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class NeighbourReport extends BaseJsonModel {
private static final long serialVersionUID = 4978041583453690066L;
private MacAddress macAddress;
private String ssid;
private int beaconInterval;
private NetworkType networkType;
private Toggle privacy;
private RadioType radioType;
private int channel;
private int rate;
private int rssi;
private int signal;
private long scanTimeInSeconds;
private Toggle nMode;
private Toggle acMode;
private Toggle bMode;
private NeighboreScanPacketType packetType;
private DetectedAuthMode secureMode;
public Toggle getAcMode() {
return acMode;
}
public int getBeaconInterval() {
return beaconInterval;
}
public Toggle getbMode() {
return bMode;
}
public int getChannel() {
return channel;
}
public MacAddress getMacAddress() {
return macAddress;
}
public NetworkType getNetworkType() {
return networkType;
}
public Toggle getnMode() {
return nMode;
}
public NeighboreScanPacketType getPacketType() {
return packetType;
}
public Toggle getPrivacy() {
return privacy;
}
public RadioType getRadioType() {
return radioType;
}
public int getRate() {
return rate;
}
public int getRssi() {
return rssi;
}
public long getScanTimeInSeconds() {
return scanTimeInSeconds;
}
public int getSignal() {
return signal;
}
public String getSsid() {
return ssid;
}
public void setAcMode(Toggle acMode) {
this.acMode = acMode;
}
public void setBeaconInterval(int beaconInterval) {
this.beaconInterval = beaconInterval;
}
public void setbMode(Toggle bMode) {
this.bMode = bMode;
}
public void setChannel(int channel) {
this.channel = channel;
}
public void setMacAddress(MacAddress macAddress) {
this.macAddress = macAddress;
}
public void setNetworkType(NetworkType networkType) {
this.networkType = networkType;
}
public void setnMode(Toggle nMode) {
this.nMode = nMode;
}
public void setPacketType(NeighboreScanPacketType packetType) {
this.packetType = packetType;
}
public void setPrivacy(Toggle privacy) {
this.privacy = privacy;
}
public void setRadioType(RadioType radioType) {
this.radioType = radioType;
}
public void setRate(int rate) {
this.rate = rate;
}
public void setRssi(int rssi) {
this.rssi = rssi;
}
public void setScanTimeInSeconds(long scanTimeInSeconds) {
this.scanTimeInSeconds = scanTimeInSeconds;
}
public void setSignal(int signal) {
this.signal = signal;
}
public void setSsid(String ssid) {
this.ssid = ssid;
}
public DetectedAuthMode getSecureMode() {
return secureMode;
}
public void setSecureMode(DetectedAuthMode secureMode) {
this.secureMode = secureMode;
}
@Override
public boolean hasUnsupportedValue() {
if (super.hasUnsupportedValue()) {
return true;
}
if (NetworkType.isUnsupported(networkType) || Toggle.isUnsupported(privacy)
|| RadioType.isUnsupported(radioType) || Toggle.isUnsupported(nMode) || Toggle.isUnsupported(acMode)
|| Toggle.isUnsupported(bMode) || NeighboreScanPacketType.isUnsupported(packetType)
|| DetectedAuthMode.isUnsupported(secureMode)) {
return true;
}
return false;
}
@Override
public NeighbourReport clone() {
NeighbourReport ret = (NeighbourReport) super.clone();
if(macAddress!=null) {
ret.macAddress = macAddress.clone();
}
return ret;
}
@Override
public int hashCode() {
return Objects.hash(acMode, bMode, beaconInterval, channel, macAddress, nMode, networkType, packetType, privacy,
radioType, rate, rssi, scanTimeInSeconds, secureMode, signal, ssid);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof NeighbourReport)) {
return false;
}
NeighbourReport other = (NeighbourReport) obj;
return acMode == other.acMode && bMode == other.bMode && beaconInterval == other.beaconInterval
&& channel == other.channel && Objects.equals(macAddress, other.macAddress) && nMode == other.nMode
&& networkType == other.networkType && packetType == other.packetType && privacy == other.privacy
&& radioType == other.radioType && rate == other.rate && rssi == other.rssi
&& scanTimeInSeconds == other.scanTimeInSeconds && secureMode == other.secureMode
&& signal == other.signal && Objects.equals(ssid, other.ssid);
}
}

View File

@@ -0,0 +1,118 @@
package com.telecominfraproject.wlan.servicemetric.neighbourscan.models;
import java.util.ArrayList;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.telecominfraproject.wlan.core.model.equipment.NeighboreScanPacketType;
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetricDataType;
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetricDetails;
/**
* @author ekeddy
*
*/
public class NeighbourScanReports extends ServiceMetricDetails {
private static final long serialVersionUID = 6091333623390501053L;
public static final String TYPE_NAME = NeighbourScanReports.class.getSimpleName();
private List<NeighbourReport> neighbourReports;
@Override
public ServiceMetricDataType getDataType() {
return ServiceMetricDataType.Neighbour;
}
@Override
public NeighbourScanReports clone() {
NeighbourScanReports ret = (NeighbourScanReports) super.clone();
if (this.neighbourReports != null) {
ret.neighbourReports = new ArrayList<>();
for (NeighbourReport p : this.neighbourReports) {
ret.neighbourReports.add(p.clone());
}
}
return ret;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof NeighbourScanReports)) {
return false;
}
NeighbourScanReports other = (NeighbourScanReports) obj;
if (neighbourReports == null) {
if (other.neighbourReports != null) {
return false;
}
} else if (!neighbourReports.equals(other.neighbourReports)) {
return false;
}
return true;
}
public List<NeighbourReport> getNeighbourReports() {
return neighbourReports;
}
@JsonIgnore
public long getNeighbourReportCount() {
return (neighbourReports == null) ? 0 : neighbourReports.size();
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((neighbourReports == null) ? 0 : neighbourReports.hashCode());
return result;
}
public void setNeighbourReports(List<NeighbourReport> reports) {
this.neighbourReports = reports;
}
@Override
public boolean hasUnsupportedValue() {
if (super.hasUnsupportedValue()) {
return true;
}
if (hasUnsupportedValue(neighbourReports)) {
return true;
}
return false;
}
@JsonIgnore
public boolean containsBeaconsOnRadio(RadioType radio)
{
if(this.neighbourReports != null)
{
return this.neighbourReports.stream().anyMatch(c -> c.getPacketType() == NeighboreScanPacketType.BEACON && c.getRadioType() == radio);
}
return false;
}
}

View File

@@ -19,7 +19,7 @@
</dependency>
<dependency>
<artifactId>tip-wlan-cloud-service-metrics-models</artifactId>
<artifactId>service-metric-models</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>${tip-wlan-cloud.release.version}</version>
</dependency>

View File

@@ -5,7 +5,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.telecominfraproject.wlan.servicemetrics.models.SingleMetricRecord;
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetric;
import com.telecominfraproject.wlan.stream.StreamInterface;
import com.telecominfraproject.wlan.systemevent.models.SystemEventRecord;
@@ -15,15 +15,15 @@ public class SimpleStreamsConfig {
private static final Logger LOG = LoggerFactory.getLogger(SimpleStreamsConfig.class);
@Bean
public StreamInterface<SingleMetricRecord> metricStreamInterface() {
StreamInterface<SingleMetricRecord> si = new StreamInterface<SingleMetricRecord>() {
public StreamInterface<ServiceMetric> metricStreamInterface() {
StreamInterface<ServiceMetric> si = new StreamInterface<ServiceMetric>() {
{
LOG.info("*** Using simple stream for the metrics");
}
@Override
public void publish(SingleMetricRecord record) {
public void publish(ServiceMetric record) {
LOG.info("publishing metric {}", record);
}

View File

@@ -1,24 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
<artifactId>tip-wlan-cloud-service-metrics-models</artifactId>
<name>tip-wlan-cloud-service-metrics-models</name>
<description>Data structures that define various service metrics.</description>
<dependencies>
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-models</artifactId>
<version>${tip-wlan-cloud.release.version}</version>
</dependency>
</dependencies>
</project>

View File

@@ -1,191 +0,0 @@
package com.telecominfraproject.wlan.servicemetrics.models;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
/**
* Set of client metrics reported by the access Point.
*
* @author ekeddy
*
*/
public class ApClientMetrics extends MetricData implements ClientMetricsInterface {
private static final long serialVersionUID = 6863684725639609684L;
public static final String TYPE_NAME = ApClientMetrics.class.getSimpleName();
private ClientMetrics[] clientMetrics2g;
private ClientMetrics[] clientMetrics5g;
private ClientQoEMetrics[] clientMetricsQoE;
/**
* How many seconds the AP measured for the metric
*/
private Integer periodLengthSec = 5;
@Override
public String getType() {
return TYPE_NAME;
}
public Integer getPeriodLengthSec() {
return periodLengthSec;
}
public void setPeriodLengthSec(Integer periodLengthSec) {
this.periodLengthSec = periodLengthSec;
}
public ClientMetrics[] getClientMetrics2g() {
return clientMetrics2g;
}
public void setClientMetrics2g(ClientMetrics[] clientMetrics2g) {
this.clientMetrics2g = clientMetrics2g;
}
public ClientMetrics[] getClientMetrics5g() {
return clientMetrics5g;
}
public void setClientMetrics5g(ClientMetrics[] clientMetrics5g) {
this.clientMetrics5g = clientMetrics5g;
}
public long getClientCount2g() {
return clientMetrics2g != null ? clientMetrics2g.length : 0;
}
public long getClientCount5g() {
return clientMetrics5g != null ? clientMetrics5g.length : 0;
}
@Override
@JsonIgnore
public Set<MacAddress> getDeviceMacAddresses() {
Set<MacAddress> ret = new HashSet<>();
if (clientMetrics2g != null) {
for (ClientMetrics cm : clientMetrics2g) {
ret.add(cm.getDeviceMacAddress());
}
}
if (clientMetrics5g != null) {
for (ClientMetrics cm : clientMetrics5g) {
ret.add(cm.getDeviceMacAddress());
}
}
if (clientMetricsQoE != null) {
for (ClientQoEMetrics cm : clientMetricsQoE) {
ret.add(cm.getDeviceMacAddress());
}
}
return ret;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + Arrays.hashCode(clientMetrics2g);
result = prime * result + Arrays.hashCode(clientMetrics5g);
result = prime * result + ((periodLengthSec == null) ? 0 : periodLengthSec.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ApClientMetrics other = (ApClientMetrics) obj;
if (!Arrays.equals(clientMetrics2g, other.clientMetrics2g))
return false;
if (!Arrays.equals(clientMetrics5g, other.clientMetrics5g))
return false;
if (!Arrays.equals(clientMetricsQoE, other.clientMetricsQoE))
if (periodLengthSec == null) {
if (other.periodLengthSec != null)
return false;
} else if (!periodLengthSec.equals(other.periodLengthSec))
return false;
return true;
}
@Override
public boolean containsClientMac(MacAddress clientMac) {
return containsClientMac(clientMetrics2g, clientMac) || containsClientMac(clientMetrics5g, clientMac)
|| containsClientMac(clientMetricsQoE, clientMac);
}
private boolean containsClientMac(BaseClientMetrics[] clientMetrics, MacAddress clientMac) {
if (clientMetrics == null)
return false;
for (BaseClientMetrics m : clientMetrics) {
if (m.getDeviceMacAddress() != null && m.getDeviceMacAddress().equals(clientMac)) {
return true;
}
}
return false;
}
@Override
public ApClientMetrics clone() {
ApClientMetrics ret = (ApClientMetrics) super.clone();
if (this.clientMetrics2g != null) {
ret.clientMetrics2g = new ClientMetrics[this.clientMetrics2g.length];
for (int i = 0; i < this.clientMetrics2g.length; i++) {
ret.clientMetrics2g[i] = this.clientMetrics2g[i].clone();
}
}
if (this.clientMetrics5g != null) {
ret.clientMetrics5g = new ClientMetrics[this.clientMetrics5g.length];
for (int i = 0; i < this.clientMetrics5g.length; i++) {
ret.clientMetrics5g[i] = this.clientMetrics5g[i].clone();
}
}
if (this.clientMetricsQoE != null) {
ret.clientMetricsQoE = new ClientQoEMetrics[this.clientMetricsQoE.length];
for (int i = 0; i < this.clientMetricsQoE.length; i++) {
ret.clientMetricsQoE[i] = this.clientMetricsQoE[i].clone();
}
}
return ret;
}
@JsonIgnore
public ClientMetrics[] getClientMetrics(RadioType type) {
if (type == RadioType.is2dot4GHz) {
return this.clientMetrics2g;
} else {
return this.clientMetrics5g;
}
}
public ClientQoEMetrics[] getClientMetricsQoE() {
return clientMetricsQoE;
}
public void setClientMetricsQoE(ClientQoEMetrics[] clientMetricsQoE) {
this.clientMetricsQoE = clientMetricsQoE;
}
public static boolean isDataType(String dataType) {
return TYPE_NAME.equals(dataType);
}
}

View File

@@ -1,88 +0,0 @@
package com.telecominfraproject.wlan.servicemetrics.models;
import java.util.Arrays;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;
/**
* @author yongli
*
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public abstract class BaseClientMetrics extends BaseJsonModel {
private static final long serialVersionUID = 7010806309246953581L;
private byte[] macAddress;
private MacAddress deviceMacAddress;
private Integer secondsSinceLastRecv;
@Override
public BaseClientMetrics clone() {
BaseClientMetrics ret = (BaseClientMetrics) super.clone();
if (this.macAddress != null) {
ret.macAddress = this.macAddress.clone();
}
return ret;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof BaseClientMetrics)) {
return false;
}
BaseClientMetrics other = (BaseClientMetrics) obj;
return Objects.equals(deviceMacAddress, other.deviceMacAddress) && Arrays.equals(macAddress, other.macAddress)
&& Objects.equals(secondsSinceLastRecv, other.secondsSinceLastRecv);
}
public MacAddress getDeviceMacAddress() {
return deviceMacAddress;
}
/**
* @deprecated use {@link #getDeviceMacAddress} instead.
*/
public byte[] getMacAddress() {
return macAddress;
}
public Integer getSecondsSinceLastRecv() {
return secondsSinceLastRecv;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + Arrays.hashCode(this.macAddress);
result = prime * result + Objects.hash(deviceMacAddress, secondsSinceLastRecv);
return result;
}
public void setDeviceMacAddress(MacAddress deviceMacAddress) {
this.deviceMacAddress = deviceMacAddress;
// For backward compatibility
this.macAddress = deviceMacAddress == null ? null : deviceMacAddress.getAddress();
}
/**
* @deprecated use {@link #setDeviceMacAddress(deviceMacAddress)} instead.
*/
public void setMacAddress(byte[] macAddress) {
this.macAddress = macAddress;
this.deviceMacAddress = macAddress == null ? null : new MacAddress(macAddress);
}
public void setSecondsSinceLastRecv(Integer secondsSinceLastRecv) {
this.secondsSinceLastRecv = secondsSinceLastRecv;
}
}

View File

@@ -1,14 +0,0 @@
package com.telecominfraproject.wlan.servicemetrics.models;
import java.util.Set;
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
/**
* @author dtop
*/
public interface ClientMetricsInterface {
Set<MacAddress> getDeviceMacAddresses();
boolean containsClientMac(MacAddress clientMac);
}

View File

@@ -1,18 +0,0 @@
/**
*
*/
package com.telecominfraproject.wlan.servicemetrics.models;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;
/**
* @author yongli
*
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public abstract class MetricData extends BaseJsonModel {
private static final long serialVersionUID = 1360838336969645855L;
public abstract String getType();
}

View File

@@ -1,172 +0,0 @@
package com.telecominfraproject.wlan.servicemetrics.models;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;
/**
* @author dtoptygin
*
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class MetricRecord extends BaseJsonModel {
private static final long serialVersionUID = -1875577097923070125L;
private long id;
private long createdTimestamp;
private long lastModifiedTimestamp;
private MetricData data;
private long processingStartTime;
private String deploymentId;
public MetricRecord(long id, long createdTimestamp, long lastModifiedTimestamp, MetricData data) {
this.id = id;
this.createdTimestamp = createdTimestamp;
this.lastModifiedTimestamp = lastModifiedTimestamp;
this.data = data;
}
public MetricRecord() {
}
/**
* Return the record type.
*
* @return
*/
public String getDataType() {
if (null != this.data) {
return this.data.getType();
}
return null;
}
/**
* Return the data as JSON document
*
* @return
*/
public String toJSONData() {
if (null != this.data) {
return data.toString();
}
return null;
}
/**
* Return the data as compressed JSON document
* @return
*/
public byte[] toZippedJSONData() {
if (null != this.data) {
return data.toZippedBytes();
}
return null;
}
/**
* Set data from JSON document
*
* @return
*/
public void fromJSONData(String jsonDoc) {
this.data = (MetricData) MetricData.fromString(jsonDoc,
MetricData.class);
}
/**
* Set the data from compressed JSON document
* @param compressedJson
*/
public void fromZippedJSONData(byte[] compressedJson) {
this.data = (MetricData) MetricData.fromZippedBytes(compressedJson, MetricData.class);
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getDeploymentId() {
return deploymentId;
}
public void setDeploymentId(String deploymentId) {
this.deploymentId = deploymentId;
}
public long getCreatedTimestamp() {
return createdTimestamp;
}
public void setCreatedTimestamp(long createdTimestamp) {
this.createdTimestamp = createdTimestamp;
}
public long getLastModifiedTimestamp() {
return lastModifiedTimestamp;
}
public void setLastModifiedTimestamp(long lastModifiedTimestamp) {
this.lastModifiedTimestamp = lastModifiedTimestamp;
}
public MetricData getData() {
return this.data;
}
public void setData(MetricData data) {
this.data = data;
}
public long getProcessingStartTime() {
return processingStartTime;
}
public void setProcessingStartTime(long processingStartTime) {
this.processingStartTime = processingStartTime;
}
@Override
public MetricRecord clone() {
MetricRecord ret = (MetricRecord) super.clone();
if (null != this.data) {
ret.data = (MetricData) this.data.clone();
}
return ret;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (int) (createdTimestamp ^ (createdTimestamp >>> 32));
result = prime * result + (int) (id ^ (id >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof MetricRecord)) {
return false;
}
MetricRecord other = (MetricRecord) obj;
if (createdTimestamp != other.createdTimestamp) {
return false;
}
if (id != other.id) {
return false;
}
return true;
}
}

View File

@@ -1,102 +0,0 @@
package com.telecominfraproject.wlan.servicemetrics.models;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.telecominfraproject.wlan.core.model.json.interfaces.HasCustomerId;
import com.telecominfraproject.wlan.core.model.json.interfaces.HasEquipmentId;
import com.telecominfraproject.wlan.core.model.json.interfaces.HasProducedTimestamp;
/**
* A single metric record contains normalized fields
*
* @author yongli
*
*/
public class SingleMetricRecord extends MetricRecord implements HasCustomerId, HasEquipmentId, HasProducedTimestamp {
private static final long serialVersionUID = 6213696913539984507L;
private int customerId;
private long equipmentId;
public SingleMetricRecord() {
}
public SingleMetricRecord(int customerId, long equipmentId) {
this.customerId = customerId;
this.equipmentId = equipmentId;
}
public int getCustomerId() {
return customerId;
}
public void setCustomerId(int customerId) {
this.customerId = customerId;
}
public long getEquipmentId() {
return equipmentId;
}
public void setEquipmentId(long equipmentId) {
this.equipmentId = equipmentId;
}
public SingleMetricRecord clone() {
SingleMetricRecord result = (SingleMetricRecord) super.clone();
return result;
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + customerId;
result = prime * result + (int) (equipmentId ^ (equipmentId >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof SingleMetricRecord)) {
return false;
}
SingleMetricRecord other = (SingleMetricRecord) obj;
if (customerId != other.customerId) {
return false;
}
if (equipmentId != other.equipmentId) {
return false;
}
return true;
}
@Override
@JsonIgnore
public long getProducedTimestampMs() {
return getCreatedTimestamp();
}
@JsonIgnore
public static SingleMetricRecord createDeviceMetrics(int customerId, long equipmentId, Long startTime, MetricData metrics)
{
SingleMetricRecord metricRecord = new SingleMetricRecord();
metricRecord.setCustomerId(customerId);
metricRecord.setEquipmentId(equipmentId);
if (null != startTime) {
metricRecord.setCreatedTimestamp(startTime);
}
metricRecord.setData(metrics);
return metricRecord;
}
}