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