use of org.onosproject.net.device.PortStatistics in project onos by opennetworkinglab.
the class RestDeviceProvider method updatePortStatistics.
private void updatePortStatistics(DeviceId deviceId) {
Device device = deviceService.getDevice(deviceId);
checkNotNull(device, "device cannot be null");
if (device.is(PortStatisticsDiscovery.class)) {
PortStatisticsDiscovery portStatisticsDiscovery = device.as(PortStatisticsDiscovery.class);
Collection<PortStatistics> portStatistics = portStatisticsDiscovery.discoverPortStatistics();
if (portStatistics != null && !portStatistics.isEmpty()) {
providerService.updatePortStatistics(deviceId, portStatistics);
}
} else {
log.debug("No port statistics getter behaviour for device {}", deviceId);
}
}
use of org.onosproject.net.device.PortStatistics in project onos by opennetworkinglab.
the class ECDeviceStore method getStatisticsForPort.
@Override
public PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
Map<PortNumber, PortStatistics> portStatsMap = devicePortStats.get(deviceId);
if (portStatsMap == null) {
return null;
}
PortStatistics portStats = portStatsMap.get(portNumber);
return portStats;
}
use of org.onosproject.net.device.PortStatistics in project onos by opennetworkinglab.
the class ECDeviceStore method getDeltaStatisticsForPort.
@Override
public PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
Map<PortNumber, PortStatistics> portStatsMap = devicePortDeltaStats.get(deviceId);
if (portStatsMap == null) {
return null;
}
PortStatistics portStats = portStatsMap.get(portNumber);
return portStats;
}
use of org.onosproject.net.device.PortStatistics in project onos by opennetworkinglab.
the class GossipDeviceStore method getStatisticsForPort.
@Override
public PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
Map<PortNumber, PortStatistics> portStatsMap = devicePortStats.get(deviceId);
if (portStatsMap == null) {
return null;
}
PortStatistics portStats = portStatsMap.get(portNumber);
return portStats;
}
use of org.onosproject.net.device.PortStatistics in project onos by opennetworkinglab.
the class GossipDeviceStore method updatePortStatistics.
@Override
public DeviceEvent updatePortStatistics(ProviderId providerId, DeviceId deviceId, Collection<PortStatistics> newStatsCollection) {
Map<PortNumber, PortStatistics> prvStatsMap = devicePortStats.get(deviceId);
Map<PortNumber, PortStatistics> newStatsMap = Maps.newHashMap();
Map<PortNumber, PortStatistics> deltaStatsMap = Maps.newHashMap();
if (prvStatsMap != null) {
for (PortStatistics newStats : newStatsCollection) {
PortNumber port = newStats.portNumber();
PortStatistics prvStats = prvStatsMap.get(port);
DefaultPortStatistics.Builder builder = DefaultPortStatistics.builder();
PortStatistics deltaStats = builder.build();
if (prvStats != null) {
deltaStats = calcDeltaStats(deviceId, prvStats, newStats);
}
deltaStatsMap.put(port, deltaStats);
newStatsMap.put(port, newStats);
}
} else {
for (PortStatistics newStats : newStatsCollection) {
PortNumber port = newStats.portNumber();
newStatsMap.put(port, newStats);
}
}
devicePortDeltaStats.put(deviceId, deltaStatsMap);
devicePortStats.put(deviceId, newStatsMap);
// DeviceEvent returns null because of InternalPortStatsListener usage
return null;
}
Aggregations