Package org.onosproject.net.device
Class DeviceServiceAdapter
- java.lang.Object
-
- org.onosproject.net.device.DeviceServiceAdapter
-
- All Implemented Interfaces:
ListenerService<DeviceEvent,DeviceListener>,DeviceService
public class DeviceServiceAdapter extends java.lang.Object implements DeviceService
Test adapter for device service.
-
-
Constructor Summary
Constructors Constructor Description DeviceServiceAdapter()Default constructor.DeviceServiceAdapter(java.util.List<Port> portList)Constructor with port list.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(DeviceListener listener)Adds the specified listener.intgetAvailableDeviceCount()Returns the number of currently available devices known to the system.java.lang.Iterable<Device>getAvailableDevices()Returns an iterable collection of all devices currently available to the system.java.lang.Iterable<Device>getAvailableDevices(Device.Type type)Returns an iterable collection of all devices currently available to the system by device type.PortStatisticsgetDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber)Returns the port specific port delta statistics associated with the device and port.DevicegetDevice(DeviceId deviceId)Returns the device with the specified identifier.intgetDeviceCount()Returns the number of infrastructure devices known to the system.java.lang.Iterable<Device>getDevices()Returns a collection of the currently known infrastructure devices.java.lang.Iterable<Device>getDevices(Device.Type type)Returns a collection of the currently known infrastructure devices by device type.longgetLastUpdatedInstant(DeviceId deviceId)Indicates the time at which the given device connected or disconnected from this controller instance.PortgetPort(DeviceId deviceId, PortNumber portNumber)Returns the port with the specified number and hosted by the given device.java.util.List<PortStatistics>getPortDeltaStatistics(DeviceId deviceId)Returns the list of port delta statistics associated with the device.java.util.List<Port>getPorts(DeviceId deviceId)Returns the list of ports associated with the device.java.util.List<PortStatistics>getPortStatistics(DeviceId deviceId)Returns the list of port statistics associated with the device.MastershipRolegetRole(DeviceId deviceId)Returns the current mastership role for the specified device.PortStatisticsgetStatisticsForPort(DeviceId deviceId, PortNumber portNumber)Returns the port specific port statistics associated with the device and port.booleanisAvailable(DeviceId deviceId)Indicates whether or not the device is presently online and available.java.lang.StringlocalStatus(DeviceId deviceId)Indicates how long ago the device connected or disconnected from this controller instance.voidremoveListener(DeviceListener listener)Removes the specified listener.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.onosproject.net.device.DeviceService
getPort
-
-
-
-
Constructor Detail
-
DeviceServiceAdapter
public DeviceServiceAdapter(java.util.List<Port> portList)
Constructor with port list.- Parameters:
portList- port list
-
DeviceServiceAdapter
public DeviceServiceAdapter()
Default constructor.
-
-
Method Detail
-
getDeviceCount
public int getDeviceCount()
Description copied from interface:DeviceServiceReturns the number of infrastructure devices known to the system.- Specified by:
getDeviceCountin interfaceDeviceService- Returns:
- number of infrastructure devices
-
getAvailableDeviceCount
public int getAvailableDeviceCount()
Description copied from interface:DeviceServiceReturns the number of currently available devices known to the system.- Specified by:
getAvailableDeviceCountin interfaceDeviceService- Returns:
- number of available devices
-
getDevices
public java.lang.Iterable<Device> getDevices()
Description copied from interface:DeviceServiceReturns a collection of the currently known infrastructure devices.- Specified by:
getDevicesin interfaceDeviceService- Returns:
- collection of devices
-
getAvailableDevices
public java.lang.Iterable<Device> getAvailableDevices()
Description copied from interface:DeviceServiceReturns an iterable collection of all devices currently available to the system.- Specified by:
getAvailableDevicesin interfaceDeviceService- Returns:
- device collection
-
getDevice
public Device getDevice(DeviceId deviceId)
Description copied from interface:DeviceServiceReturns the device with the specified identifier.- Specified by:
getDevicein interfaceDeviceService- Parameters:
deviceId- device identifier- Returns:
- device or null if one with the given identifier is not known
-
getRole
public MastershipRole getRole(DeviceId deviceId)
Description copied from interface:DeviceServiceReturns the current mastership role for the specified device.- Specified by:
getRolein interfaceDeviceService- Parameters:
deviceId- device identifier- Returns:
- designated mastership role
-
getPorts
public java.util.List<Port> getPorts(DeviceId deviceId)
Description copied from interface:DeviceServiceReturns the list of ports associated with the device.- Specified by:
getPortsin interfaceDeviceService- Parameters:
deviceId- device identifier- Returns:
- list of ports
-
getPortStatistics
public java.util.List<PortStatistics> getPortStatistics(DeviceId deviceId)
Description copied from interface:DeviceServiceReturns the list of port statistics associated with the device.- Specified by:
getPortStatisticsin interfaceDeviceService- Parameters:
deviceId- device identifier- Returns:
- list of port statistics
-
getPortDeltaStatistics
public java.util.List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId)
Description copied from interface:DeviceServiceReturns the list of port delta statistics associated with the device.- Specified by:
getPortDeltaStatisticsin interfaceDeviceService- Parameters:
deviceId- device identifier- Returns:
- list of port statistics
-
getStatisticsForPort
public PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber)
Description copied from interface:DeviceServiceReturns the port specific port statistics associated with the device and port.- Specified by:
getStatisticsForPortin interfaceDeviceService- Parameters:
deviceId- device identifierportNumber- port identifier- Returns:
- port statistics of specified port
-
getDeltaStatisticsForPort
public PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber)
Description copied from interface:DeviceServiceReturns the port specific port delta statistics associated with the device and port.- Specified by:
getDeltaStatisticsForPortin interfaceDeviceService- Parameters:
deviceId- device identifierportNumber- port identifier- Returns:
- port delta statistics of specified port
-
getPort
public Port getPort(DeviceId deviceId, PortNumber portNumber)
Description copied from interface:DeviceServiceReturns the port with the specified number and hosted by the given device.- Specified by:
getPortin interfaceDeviceService- Parameters:
deviceId- device identifierportNumber- port number- Returns:
- device port
-
isAvailable
public boolean isAvailable(DeviceId deviceId)
Description copied from interface:DeviceServiceIndicates whether or not the device is presently online and available. Availability, unlike reachability, denotes whether ANY node in the cluster can discover that this device is in an operational state, this does not necessarily mean that there exists a node that can control this device.- Specified by:
isAvailablein interfaceDeviceService- Parameters:
deviceId- device identifier- Returns:
- true if the device is available
-
addListener
public void addListener(DeviceListener listener)
Description copied from interface:ListenerServiceAdds the specified listener.- Specified by:
addListenerin interfaceListenerService<DeviceEvent,DeviceListener>- Parameters:
listener- listener to be added
-
removeListener
public void removeListener(DeviceListener listener)
Description copied from interface:ListenerServiceRemoves the specified listener.- Specified by:
removeListenerin interfaceListenerService<DeviceEvent,DeviceListener>- Parameters:
listener- listener to be removed
-
getDevices
public java.lang.Iterable<Device> getDevices(Device.Type type)
Description copied from interface:DeviceServiceReturns a collection of the currently known infrastructure devices by device type.- Specified by:
getDevicesin interfaceDeviceService- Parameters:
type- device type- Returns:
- collection of devices
-
getAvailableDevices
public java.lang.Iterable<Device> getAvailableDevices(Device.Type type)
Description copied from interface:DeviceServiceReturns an iterable collection of all devices currently available to the system by device type.- Specified by:
getAvailableDevicesin interfaceDeviceService- Parameters:
type- device type- Returns:
- device collection
-
localStatus
public java.lang.String localStatus(DeviceId deviceId)
Description copied from interface:DeviceServiceIndicates how long ago the device connected or disconnected from this controller instance.- Specified by:
localStatusin interfaceDeviceService- Parameters:
deviceId- device identifier- Returns:
- a human readable string indicating the time since the device connected-to or disconnected-from this controller instance.
-
getLastUpdatedInstant
public long getLastUpdatedInstant(DeviceId deviceId)
Description copied from interface:DeviceServiceIndicates the time at which the given device connected or disconnected from this controller instance.- Specified by:
getLastUpdatedInstantin interfaceDeviceService- Parameters:
deviceId- device identifier- Returns:
- time offset in miliseconds from Epoch
-
-