Search in sources :

Example 26 with PortStatistics

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);
    }
}
Also used : PortStatisticsDiscovery(org.onosproject.net.device.PortStatisticsDiscovery) RestSBDevice(org.onosproject.protocol.rest.RestSBDevice) DefaultRestSBDevice(org.onosproject.protocol.rest.DefaultRestSBDevice) Device(org.onosproject.net.Device) PortStatistics(org.onosproject.net.device.PortStatistics)

Example 27 with PortStatistics

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;
}
Also used : PortNumber(org.onosproject.net.PortNumber) DefaultPortStatistics(org.onosproject.net.device.DefaultPortStatistics) PortStatistics(org.onosproject.net.device.PortStatistics)

Example 28 with PortStatistics

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;
}
Also used : PortNumber(org.onosproject.net.PortNumber) DefaultPortStatistics(org.onosproject.net.device.DefaultPortStatistics) PortStatistics(org.onosproject.net.device.PortStatistics)

Example 29 with PortStatistics

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;
}
Also used : PortNumber(org.onosproject.net.PortNumber) DefaultPortStatistics(org.onosproject.net.device.DefaultPortStatistics) PortStatistics(org.onosproject.net.device.PortStatistics)

Example 30 with PortStatistics

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;
}
Also used : DefaultPortStatistics(org.onosproject.net.device.DefaultPortStatistics) PortNumber(org.onosproject.net.PortNumber) DefaultPortStatistics(org.onosproject.net.device.DefaultPortStatistics) PortStatistics(org.onosproject.net.device.PortStatistics)

Aggregations

PortStatistics (org.onosproject.net.device.PortStatistics)52 DefaultPortStatistics (org.onosproject.net.device.DefaultPortStatistics)26 DeviceId (org.onosproject.net.DeviceId)14 PortNumber (org.onosproject.net.PortNumber)14 DeviceService (org.onosproject.net.device.DeviceService)14 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)11 Device (org.onosproject.net.Device)10 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)8 ArrayList (java.util.ArrayList)8 Map (java.util.Map)8 Port (org.onosproject.net.Port)7 GET (javax.ws.rs.GET)6 Path (javax.ws.rs.Path)6 Produces (javax.ws.rs.Produces)6 PortStatisticsDiscovery (org.onosproject.net.device.PortStatisticsDiscovery)6 ConnectPoint (org.onosproject.net.ConnectPoint)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 Maps (com.google.common.collect.Maps)4 Collection (java.util.Collection)4 Set (java.util.Set)4