Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Foundation |
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 | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 17 | |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 18 | import org.onosproject.net.Device; |
| 19 | import org.onosproject.net.DeviceId; |
| 20 | import org.onosproject.net.Port; |
| 21 | import org.onosproject.net.PortNumber; |
| 22 | import org.onosproject.net.provider.ProviderId; |
| 23 | import org.onosproject.store.Store; |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 24 | |
sangho | 538108b | 2015-04-08 14:29:20 -0700 | [diff] [blame] | 25 | import java.util.Collection; |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 26 | import java.util.List; |
Yuta HIGUCHI | 6eb00cc | 2016-06-10 11:55:12 -0700 | [diff] [blame] | 27 | import java.util.stream.Stream; |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 28 | |
| 29 | /** |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 30 | * Manages inventory of infrastructure devices; not intended for direct use. |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 31 | */ |
tom | f80c972 | 2014-09-24 14:49:18 -0700 | [diff] [blame] | 32 | public interface DeviceStore extends Store<DeviceEvent, DeviceStoreDelegate> { |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 33 | |
| 34 | /** |
| 35 | * Returns the number of devices known to the system. |
| 36 | * |
| 37 | * @return number of devices |
| 38 | */ |
| 39 | int getDeviceCount(); |
| 40 | |
| 41 | /** |
mskala | 0d0c683 | 2017-07-12 11:21:23 +0200 | [diff] [blame] | 42 | * Returns the number of currently available devices known to the system. |
| 43 | * |
| 44 | * @return number of devices |
| 45 | */ |
| 46 | int getAvailableDeviceCount(); |
| 47 | |
| 48 | /** |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 49 | * Returns an iterable collection of all devices known to the system. |
| 50 | * |
| 51 | * @return device collection |
| 52 | */ |
| 53 | Iterable<Device> getDevices(); |
| 54 | |
| 55 | /** |
Yuta HIGUCHI | f1f2ac0 | 2014-11-26 14:02:22 -0800 | [diff] [blame] | 56 | * Returns an iterable collection of all devices currently available to the system. |
| 57 | * |
| 58 | * @return device collection |
| 59 | */ |
| 60 | Iterable<Device> getAvailableDevices(); |
| 61 | |
Yuta HIGUCHI | f1f2ac0 | 2014-11-26 14:02:22 -0800 | [diff] [blame] | 62 | /** |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 63 | * Returns the device with the specified identifier. |
| 64 | * |
| 65 | * @param deviceId device identifier |
| 66 | * @return device |
| 67 | */ |
| 68 | Device getDevice(DeviceId deviceId); |
| 69 | |
| 70 | /** |
| 71 | * Creates a new infrastructure device, or updates an existing one using |
| 72 | * the supplied device description. |
| 73 | * |
| 74 | * @param providerId provider identifier |
| 75 | * @param deviceId device identifier |
| 76 | * @param deviceDescription device description |
| 77 | * @return ready to send event describing what occurred; null if no change |
| 78 | */ |
| 79 | DeviceEvent createOrUpdateDevice(ProviderId providerId, DeviceId deviceId, |
| 80 | DeviceDescription deviceDescription); |
| 81 | |
helenyrwu | fd296b6 | 2016-06-22 17:43:02 -0700 | [diff] [blame] | 82 | |
Yuta HIGUCHI | 5f6739c | 2014-10-01 14:04:01 -0700 | [diff] [blame] | 83 | // TODO: We may need to enforce that ancillary cannot interfere this state |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 84 | /** |
| 85 | * Removes the specified infrastructure device. |
| 86 | * |
| 87 | * @param deviceId device identifier |
| 88 | * @return ready to send event describing what occurred; null if no change |
| 89 | */ |
| 90 | DeviceEvent markOffline(DeviceId deviceId); |
| 91 | |
| 92 | /** |
helenyrwu | fd296b6 | 2016-06-22 17:43:02 -0700 | [diff] [blame] | 93 | * Marks the device as available. |
| 94 | * |
| 95 | * @param deviceId device identifier |
Palash Kala | 6c52606 | 2018-04-03 18:25:11 +0900 | [diff] [blame] | 96 | * @return ready to send event describing what occurred; null if no change |
helenyrwu | fd296b6 | 2016-06-22 17:43:02 -0700 | [diff] [blame] | 97 | */ |
Palash Kala | 6c52606 | 2018-04-03 18:25:11 +0900 | [diff] [blame] | 98 | DeviceEvent markOnline(DeviceId deviceId); |
helenyrwu | fd296b6 | 2016-06-22 17:43:02 -0700 | [diff] [blame] | 99 | |
| 100 | /** |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 101 | * Updates the ports of the specified infrastructure device using the given |
| 102 | * list of port descriptions. The list is assumed to be comprehensive. |
| 103 | * |
Yuta HIGUCHI | 5f6739c | 2014-10-01 14:04:01 -0700 | [diff] [blame] | 104 | * @param providerId provider identifier |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 105 | * @param deviceId device identifier |
| 106 | * @param portDescriptions list of port descriptions |
| 107 | * @return ready to send events describing what occurred; empty list if no change |
| 108 | */ |
Yuta HIGUCHI | 5f6739c | 2014-10-01 14:04:01 -0700 | [diff] [blame] | 109 | List<DeviceEvent> updatePorts(ProviderId providerId, DeviceId deviceId, |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 110 | List<PortDescription> portDescriptions); |
| 111 | |
| 112 | /** |
| 113 | * Updates the port status of the specified infrastructure device using the |
| 114 | * given port description. |
| 115 | * |
Yuta HIGUCHI | 5f6739c | 2014-10-01 14:04:01 -0700 | [diff] [blame] | 116 | * @param providerId provider identifier |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 117 | * @param deviceId device identifier |
| 118 | * @param portDescription port description |
| 119 | * @return ready to send event describing what occurred; null if no change |
| 120 | */ |
Yuta HIGUCHI | 5f6739c | 2014-10-01 14:04:01 -0700 | [diff] [blame] | 121 | DeviceEvent updatePortStatus(ProviderId providerId, DeviceId deviceId, |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 122 | PortDescription portDescription); |
| 123 | |
| 124 | /** |
| 125 | * Returns the list of ports that belong to the specified device. |
| 126 | * |
| 127 | * @param deviceId device identifier |
| 128 | * @return list of device ports |
| 129 | */ |
| 130 | List<Port> getPorts(DeviceId deviceId); |
| 131 | |
| 132 | /** |
Yuta HIGUCHI | 6eb00cc | 2016-06-10 11:55:12 -0700 | [diff] [blame] | 133 | * Returns the stream of port descriptions that belong to the specified device. |
| 134 | * |
| 135 | * @param providerId provider identifier |
| 136 | * @param deviceId device identifier |
| 137 | * @return stream of device portdescriptions |
| 138 | */ |
| 139 | Stream<PortDescription> getPortDescriptions(ProviderId providerId, DeviceId deviceId); |
| 140 | |
| 141 | /** |
sangho | 538108b | 2015-04-08 14:29:20 -0700 | [diff] [blame] | 142 | * Updates the port statistics of the specified device using the give port |
| 143 | * statistics. |
| 144 | * |
| 145 | * @param providerId provider identifier |
| 146 | * @param deviceId device identifier |
| 147 | * @param portStats list of port statistics |
| 148 | * @return ready to send event describing what occurred; |
| 149 | */ |
| 150 | DeviceEvent updatePortStatistics(ProviderId providerId, DeviceId deviceId, |
| 151 | Collection<PortStatistics> portStats); |
| 152 | |
| 153 | /** |
| 154 | * Returns the list of port statistics of the specified device. |
| 155 | * |
| 156 | * @param deviceId device identifier |
| 157 | * @return list of port statistics of all ports of the device |
| 158 | */ |
| 159 | List<PortStatistics> getPortStatistics(DeviceId deviceId); |
| 160 | |
| 161 | /** |
Viswanath KSP | 22774cd | 2016-08-20 20:06:30 +0530 | [diff] [blame] | 162 | * Returns the port statistics of the specified device and port. |
| 163 | * |
| 164 | * @param deviceId device identifier |
| 165 | * @param portNumber port identifier |
| 166 | * @return port statistics of specific port of the device |
| 167 | */ |
| 168 | default PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) { |
| 169 | return null; |
| 170 | } |
| 171 | |
| 172 | /** |
Dusan Pajin | 11ff4a8 | 2015-08-20 18:03:05 +0200 | [diff] [blame] | 173 | * Returns the list of delta port statistics of the specified device. |
| 174 | * |
Madan Jampani | f97edc1 | 2015-08-31 14:41:01 -0700 | [diff] [blame] | 175 | * @param deviceId device identifier |
Dusan Pajin | 11ff4a8 | 2015-08-20 18:03:05 +0200 | [diff] [blame] | 176 | * @return list of delta port statistics of all ports of the device |
| 177 | */ |
| 178 | List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId); |
| 179 | |
| 180 | /** |
Viswanath KSP | 22774cd | 2016-08-20 20:06:30 +0530 | [diff] [blame] | 181 | * Returns the port delta statistics of the specified device and port. |
| 182 | * |
| 183 | * @param deviceId device identifier |
| 184 | * @param portNumber port identifier |
| 185 | * @return port statistics of specific port of the device |
| 186 | */ |
| 187 | default PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) { |
| 188 | return null; |
| 189 | } |
| 190 | |
| 191 | /** |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 192 | * Returns the specified device port. |
| 193 | * |
| 194 | * @param deviceId device identifier |
| 195 | * @param portNumber port number |
| 196 | * @return device port |
| 197 | */ |
| 198 | Port getPort(DeviceId deviceId, PortNumber portNumber); |
| 199 | |
| 200 | /** |
Yuta HIGUCHI | 6eb00cc | 2016-06-10 11:55:12 -0700 | [diff] [blame] | 201 | * Returns the specified device port description. |
| 202 | * |
| 203 | * @param providerId provider identifier |
| 204 | * @param deviceId device identifier |
| 205 | * @param portNumber port number |
| 206 | * @return device port description |
| 207 | */ |
| 208 | PortDescription getPortDescription(ProviderId providerId, DeviceId deviceId, PortNumber portNumber); |
| 209 | |
| 210 | /** |
pierventre | e1f8010 | 2021-10-01 22:01:22 +0200 | [diff] [blame] | 211 | * Returns the specified device description. |
| 212 | * |
| 213 | * @param providerId provider identifier |
| 214 | * @param deviceId device identifier |
| 215 | * @return device description or null if not present |
| 216 | */ |
| 217 | default DeviceDescription getDeviceDescription(ProviderId providerId, DeviceId deviceId) { |
| 218 | return null; |
| 219 | } |
| 220 | |
| 221 | /** |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 222 | * Indicates whether the specified device is available/online. |
| 223 | * |
| 224 | * @param deviceId device identifier |
| 225 | * @return true if device is available |
| 226 | */ |
| 227 | boolean isAvailable(DeviceId deviceId); |
| 228 | |
| 229 | /** |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 230 | * Administratively removes the specified device from the store. |
| 231 | * |
| 232 | * @param deviceId device to be removed |
Yuta HIGUCHI | 5c94727 | 2014-11-03 21:39:21 -0800 | [diff] [blame] | 233 | * @return null if no such device, or was forwarded to remove master |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 234 | */ |
| 235 | DeviceEvent removeDevice(DeviceId deviceId); |
sangho | 538108b | 2015-04-08 14:29:20 -0700 | [diff] [blame] | 236 | |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 237 | } |