Viswanath KSP
Committed by Gerrit Code Review

Addressing review comments of patch-3

Addressing review comments of patch-2
Fixing javadoc warnings
Pushing changes for onos-5146 - Added 2 new APIs in DeviceService.java to get port specific PortStatistics by specifying Device ID & Port Number. Also implemented the APIs in SimpleDeviceStore etc. This will be a very useful API for app developers who are intersted to query port specific port statistics

Change-Id: I8f3e5a443eb5b50237a679999311b48609e54a44
......@@ -24,6 +24,7 @@ import java.util.Optional;
import org.onosproject.net.device.DeviceEvent;
import org.onosproject.net.device.DeviceListener;
import org.onosproject.net.device.DeviceService;
import org.onosproject.net.device.PortStatistics;
import org.onosproject.net.optical.OpticalDevice;
import org.onosproject.net.utils.ForwardingDeviceService;
import org.slf4j.Logger;
......@@ -148,6 +149,16 @@ public class OpticalDeviceServiceView
}
@Override
public PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
return null;
}
@Override
public PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
return null;
}
@Override
public Port getPort(DeviceId deviceId, PortNumber portNumber) {
return augment(super.getPort(deviceId, portNumber));
}
......
......@@ -113,6 +113,28 @@ public interface DeviceService
List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId);
/**
* Returns the port specific port statistics associated with the device and port.
*
* @param deviceId device identifier
* @param portNumber port identifier
* @return port statistics of specified port
*/
default PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
return null;
}
/**
* Returns the port specific port delta statistics associated with the device and port.
*
* @param deviceId device identifier
* @param portNumber port identifier
* @return port delta statistics of specified port
*/
default PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
return null;
}
/**
* Returns the port with the specified number and hosted by the given device.
*
* @param deviceId device identifier
......
......@@ -152,6 +152,17 @@ public interface DeviceStore extends Store<DeviceEvent, DeviceStoreDelegate> {
List<PortStatistics> getPortStatistics(DeviceId deviceId);
/**
* Returns the port statistics of the specified device and port.
*
* @param deviceId device identifier
* @param portNumber port identifier
* @return port statistics of specific port of the device
*/
default PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
return null;
}
/**
* Returns the list of delta port statistics of the specified device.
*
* @param deviceId device identifier
......@@ -160,6 +171,17 @@ public interface DeviceStore extends Store<DeviceEvent, DeviceStoreDelegate> {
List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId);
/**
* Returns the port delta statistics of the specified device and port.
*
* @param deviceId device identifier
* @param portNumber port identifier
* @return port statistics of specific port of the device
*/
default PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
return null;
}
/**
* Returns the specified device port.
*
* @param deviceId device identifier
......
......@@ -92,6 +92,16 @@ public class DeviceServiceAdapter implements DeviceService {
}
@Override
public PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
return null;
}
@Override
public PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
return null;
}
@Override
public Port getPort(DeviceId deviceId, PortNumber portNumber) {
return null;
}
......
......@@ -101,11 +101,21 @@ public class DeviceStoreAdapter implements DeviceStore {
}
@Override
public PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
return null;
}
@Override
public List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId) {
return null;
}
@Override
public PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
return null;
}
@Override
public Port getPort(DeviceId deviceId, PortNumber portNumber) {
return null;
}
......
......@@ -514,6 +514,16 @@ public class SimpleDeviceStore
}
@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;
}
@Override
public List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId) {
Map<PortNumber, PortStatistics> portStats = devicePortDeltaStats.get(deviceId);
if (portStats == null) {
......@@ -523,6 +533,16 @@ public class SimpleDeviceStore
}
@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;
}
@Override
public boolean isAvailable(DeviceId deviceId) {
return availableDevices.contains(deviceId);
}
......
......@@ -228,6 +228,22 @@ public class DeviceManager
}
@Override
public PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
checkPermission(DEVICE_READ);
checkNotNull(deviceId, DEVICE_ID_NULL);
checkNotNull(portNumber, PORT_NUMBER_NULL);
return store.getStatisticsForPort(deviceId, portNumber);
}
@Override
public PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
checkPermission(DEVICE_READ);
checkNotNull(deviceId, DEVICE_ID_NULL);
checkNotNull(portNumber, PORT_NUMBER_NULL);
return store.getDeltaStatisticsForPort(deviceId, portNumber);
}
@Override
public Port getPort(DeviceId deviceId, PortNumber portNumber) {
checkPermission(DEVICE_READ);
checkNotNull(deviceId, DEVICE_ID_NULL);
......
......@@ -679,6 +679,16 @@ public class ECDeviceStore
}
@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;
}
@Override
public List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId) {
Map<PortNumber, PortStatistics> portStats = devicePortDeltaStats.get(deviceId);
if (portStats == null) {
......@@ -688,6 +698,16 @@ public class ECDeviceStore
}
@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;
}
@Override
public boolean isAvailable(DeviceId deviceId) {
return availableDevices.contains(deviceId);
}
......
......@@ -998,6 +998,16 @@ public class GossipDeviceStore
}
@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;
}
@Override
public List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId) {
Map<PortNumber, PortStatistics> portStats = devicePortDeltaStats.get(deviceId);
if (portStats == null) {
......@@ -1007,6 +1017,16 @@ public class GossipDeviceStore
}
@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;
}
@Override
public Port getPort(DeviceId deviceId, PortNumber portNumber) {
Map<PortNumber, Port> ports = devicePorts.get(deviceId);
return ports == null ? null : ports.get(portNumber);
......
......@@ -47,6 +47,7 @@ public class VirtualNetworkDeviceService extends AbstractListenerManager<DeviceE
private static final String NETWORK_NULL = "Network ID cannot be null";
private static final String TYPE_NULL = "Type cannot be null";
private static final String DEVICE_NULL = "Device cannot be null";
private static final String PORT_NUMBER_NULL = "PortNumber cannot be null";
private final VirtualNetwork network;
private final VirtualNetworkService manager;
......@@ -135,6 +136,22 @@ public class VirtualNetworkDeviceService extends AbstractListenerManager<DeviceE
}
@Override
public PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
checkNotNull(deviceId, DEVICE_NULL);
checkNotNull(deviceId, PORT_NUMBER_NULL);
// TODO not supported at the moment.
return null;
}
@Override
public PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
checkNotNull(deviceId, DEVICE_NULL);
checkNotNull(deviceId, PORT_NUMBER_NULL);
// TODO not supported at the moment.
return null;
}
@Override
public Port getPort(DeviceId deviceId, PortNumber portNumber) {
checkNotNull(deviceId, DEVICE_NULL);
......
......@@ -83,6 +83,16 @@ class NetconfDeviceServiceMock implements DeviceService {
}
@Override
public PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
return null;
}
@Override
public PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
return null;
}
@Override
public Port getPort(DeviceId deviceId, PortNumber portNumber) {
return null;
}
......