Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Laboratory |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.device; |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 17 | |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame] | 18 | import org.onosproject.event.ListenerService; |
Yuta HIGUCHI | 22ba76d | 2016-11-11 16:56:24 -0800 | [diff] [blame] | 19 | import org.onosproject.net.ConnectPoint; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 20 | import org.onosproject.net.Device; |
| 21 | import org.onosproject.net.DeviceId; |
| 22 | import org.onosproject.net.MastershipRole; |
| 23 | import org.onosproject.net.Port; |
| 24 | import org.onosproject.net.PortNumber; |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 25 | |
| 26 | import java.util.List; |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 27 | |
| 28 | /** |
| 29 | * Service for interacting with the inventory of infrastructure devices. |
| 30 | */ |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame] | 31 | public interface DeviceService |
| 32 | extends ListenerService<DeviceEvent, DeviceListener> { |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 33 | |
| 34 | /** |
tom | ad2d209 | 2014-09-06 23:24:20 -0700 | [diff] [blame] | 35 | * Returns the number of infrastructure devices known to the system. |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 36 | * |
tom | ad2d209 | 2014-09-06 23:24:20 -0700 | [diff] [blame] | 37 | * @return number of infrastructure devices |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 38 | */ |
tom | ad2d209 | 2014-09-06 23:24:20 -0700 | [diff] [blame] | 39 | int getDeviceCount(); |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 40 | |
| 41 | /** |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 42 | * Returns a collection of the currently known infrastructure |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 43 | * devices. |
| 44 | * |
| 45 | * @return collection of devices |
| 46 | */ |
| 47 | Iterable<Device> getDevices(); |
| 48 | |
| 49 | /** |
samuel | 738dfaf | 2015-07-11 11:08:57 +0800 | [diff] [blame] | 50 | * Returns a collection of the currently known infrastructure |
| 51 | * devices by device type. |
| 52 | * |
| 53 | * @param type device type |
| 54 | * @return collection of devices |
| 55 | */ |
| 56 | Iterable<Device> getDevices(Device.Type type); |
| 57 | |
| 58 | /** |
Yuta HIGUCHI | f1f2ac0 | 2014-11-26 14:02:22 -0800 | [diff] [blame] | 59 | * Returns an iterable collection of all devices |
| 60 | * currently available to the system. |
| 61 | * |
| 62 | * @return device collection |
| 63 | */ |
| 64 | Iterable<Device> getAvailableDevices(); |
| 65 | |
| 66 | /** |
samuel | 738dfaf | 2015-07-11 11:08:57 +0800 | [diff] [blame] | 67 | * Returns an iterable collection of all devices currently available to the system by device type. |
| 68 | * |
| 69 | * @param type device type |
| 70 | * @return device collection |
| 71 | */ |
| 72 | Iterable<Device> getAvailableDevices(Device.Type type); |
| 73 | |
| 74 | /** |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 75 | * Returns the device with the specified identifier. |
| 76 | * |
| 77 | * @param deviceId device identifier |
| 78 | * @return device or null if one with the given identifier is not known |
| 79 | */ |
| 80 | Device getDevice(DeviceId deviceId); |
| 81 | |
tom | ad2d209 | 2014-09-06 23:24:20 -0700 | [diff] [blame] | 82 | /** |
| 83 | * Returns the current mastership role for the specified device. |
| 84 | * |
| 85 | * @param deviceId device identifier |
| 86 | * @return designated mastership role |
| 87 | */ |
Ayaka Koshibe | 25fd23a | 2014-10-03 15:50:43 -0700 | [diff] [blame] | 88 | //XXX do we want this method here when MastershipService already does? |
tom | ad2d209 | 2014-09-06 23:24:20 -0700 | [diff] [blame] | 89 | MastershipRole getRole(DeviceId deviceId); |
| 90 | |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 91 | |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 92 | /** |
| 93 | * Returns the list of ports associated with the device. |
| 94 | * |
| 95 | * @param deviceId device identifier |
| 96 | * @return list of ports |
| 97 | */ |
| 98 | List<Port> getPorts(DeviceId deviceId); |
| 99 | |
| 100 | /** |
sangho | 538108b | 2015-04-08 14:29:20 -0700 | [diff] [blame] | 101 | * Returns the list of port statistics associated with the device. |
| 102 | * |
Sho SHIMIZU | ceb6f13 | 2015-08-24 11:46:25 -0700 | [diff] [blame] | 103 | * @param deviceId device identifier |
sangho | 538108b | 2015-04-08 14:29:20 -0700 | [diff] [blame] | 104 | * @return list of port statistics |
| 105 | */ |
| 106 | List<PortStatistics> getPortStatistics(DeviceId deviceId); |
| 107 | |
| 108 | /** |
Dusan Pajin | 11ff4a8 | 2015-08-20 18:03:05 +0200 | [diff] [blame] | 109 | * Returns the list of port delta statistics associated with the device. |
| 110 | * |
Sho SHIMIZU | ceb6f13 | 2015-08-24 11:46:25 -0700 | [diff] [blame] | 111 | * @param deviceId device identifier |
Dusan Pajin | 11ff4a8 | 2015-08-20 18:03:05 +0200 | [diff] [blame] | 112 | * @return list of port statistics |
| 113 | */ |
| 114 | List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId); |
| 115 | |
| 116 | /** |
Viswanath KSP | 22774cd | 2016-08-20 20:06:30 +0530 | [diff] [blame] | 117 | * Returns the port specific port statistics associated with the device and port. |
| 118 | * |
| 119 | * @param deviceId device identifier |
| 120 | * @param portNumber port identifier |
| 121 | * @return port statistics of specified port |
| 122 | */ |
| 123 | default PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) { |
| 124 | return null; |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Returns the port specific port delta statistics associated with the device and port. |
| 129 | * |
| 130 | * @param deviceId device identifier |
| 131 | * @param portNumber port identifier |
| 132 | * @return port delta statistics of specified port |
| 133 | */ |
| 134 | default PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) { |
| 135 | return null; |
| 136 | } |
| 137 | |
| 138 | /** |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 139 | * Returns the port with the specified number and hosted by the given device. |
tom | ff7eb7c | 2014-09-08 12:49:03 -0700 | [diff] [blame] | 140 | * |
| 141 | * @param deviceId device identifier |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 142 | * @param portNumber port number |
| 143 | * @return device port |
| 144 | */ |
| 145 | Port getPort(DeviceId deviceId, PortNumber portNumber); |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 146 | |
| 147 | /** |
Yuta HIGUCHI | 22ba76d | 2016-11-11 16:56:24 -0800 | [diff] [blame] | 148 | * Returns the port with the specified connect point. |
| 149 | * |
| 150 | * @param cp connect point |
| 151 | * @return device port |
| 152 | */ |
| 153 | default Port getPort(ConnectPoint cp) { |
| 154 | return getPort(cp.deviceId(), cp.port()); |
| 155 | } |
| 156 | |
| 157 | /** |
tom | ff7eb7c | 2014-09-08 12:49:03 -0700 | [diff] [blame] | 158 | * Indicates whether or not the device is presently online and available. |
Aaron Kruglikov | 8e0a08a | 2016-06-21 14:31:03 -0700 | [diff] [blame] | 159 | * Availability, unlike reachability, denotes whether ANY node in the |
| 160 | * cluster can discover that this device is in an operational state, |
| 161 | * this does not necessarily mean that there exists a node that can |
| 162 | * control this device. |
tom | ff7eb7c | 2014-09-08 12:49:03 -0700 | [diff] [blame] | 163 | * |
| 164 | * @param deviceId device identifier |
| 165 | * @return true if the device is available |
| 166 | */ |
| 167 | boolean isAvailable(DeviceId deviceId); |
| 168 | |
Saurav Das | d5ec9e9 | 2017-01-17 10:40:18 -0800 | [diff] [blame] | 169 | /** |
| 170 | * Indicates how long ago the device connected or disconnected from this |
| 171 | * controller instance. |
| 172 | * |
| 173 | * @param deviceId device identifier |
| 174 | * @return a human readable string indicating the time since the device |
| 175 | * connected-to or disconnected-from this controller instance. |
| 176 | */ |
| 177 | String localStatus(DeviceId deviceId); |
| 178 | |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 179 | } |