blob: 2c25bc5b9e46fb6c83f09062d034d0f8b332ce91 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connorce2a03d2017-08-03 19:21:03 -07002 * Copyright 2014-present Open Networking Foundation
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07003 *
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'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.device;
tom41a2c5f2014-09-19 09:20:35 -070017
Brian O'Connorabafb502014-12-02 22:26:20 -080018import org.onosproject.net.Device;
19import org.onosproject.net.DeviceId;
20import org.onosproject.net.Port;
21import org.onosproject.net.PortNumber;
22import org.onosproject.net.provider.ProviderId;
23import org.onosproject.store.Store;
tom41a2c5f2014-09-19 09:20:35 -070024
sangho538108b2015-04-08 14:29:20 -070025import java.util.Collection;
tom41a2c5f2014-09-19 09:20:35 -070026import java.util.List;
Yuta HIGUCHI6eb00cc2016-06-10 11:55:12 -070027import java.util.stream.Stream;
tom41a2c5f2014-09-19 09:20:35 -070028
29/**
tome4729872014-09-23 00:37:37 -070030 * Manages inventory of infrastructure devices; not intended for direct use.
tom41a2c5f2014-09-19 09:20:35 -070031 */
tomf80c9722014-09-24 14:49:18 -070032public interface DeviceStore extends Store<DeviceEvent, DeviceStoreDelegate> {
tom41a2c5f2014-09-19 09:20:35 -070033
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 HIGUCHIf1f2ac02014-11-26 14:02:22 -080049 * Returns an iterable collection of all devices currently available to the system.
50 *
51 * @return device collection
52 */
53 Iterable<Device> getAvailableDevices();
54
Yuta HIGUCHIf1f2ac02014-11-26 14:02:22 -080055 /**
tom41a2c5f2014-09-19 09:20:35 -070056 * 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
helenyrwufd296b62016-06-22 17:43:02 -070075
Yuta HIGUCHI5f6739c2014-10-01 14:04:01 -070076 // TODO: We may need to enforce that ancillary cannot interfere this state
tom41a2c5f2014-09-19 09:20:35 -070077 /**
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 /**
helenyrwufd296b62016-06-22 17:43:02 -070086 * 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 /**
tom41a2c5f2014-09-19 09:20:35 -070094 * 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 HIGUCHI5f6739c2014-10-01 14:04:01 -070097 * @param providerId provider identifier
tom41a2c5f2014-09-19 09:20:35 -070098 * @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 HIGUCHI5f6739c2014-10-01 14:04:01 -0700102 List<DeviceEvent> updatePorts(ProviderId providerId, DeviceId deviceId,
tom41a2c5f2014-09-19 09:20:35 -0700103 List<PortDescription> portDescriptions);
104
105 /**
106 * Updates the port status of the specified infrastructure device using the
107 * given port description.
108 *
Yuta HIGUCHI5f6739c2014-10-01 14:04:01 -0700109 * @param providerId provider identifier
tom41a2c5f2014-09-19 09:20:35 -0700110 * @param deviceId device identifier
111 * @param portDescription port description
112 * @return ready to send event describing what occurred; null if no change
113 */
Yuta HIGUCHI5f6739c2014-10-01 14:04:01 -0700114 DeviceEvent updatePortStatus(ProviderId providerId, DeviceId deviceId,
tom41a2c5f2014-09-19 09:20:35 -0700115 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 HIGUCHI6eb00cc2016-06-10 11:55:12 -0700126 * 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 /**
sangho538108b2015-04-08 14:29:20 -0700135 * 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 KSP22774cd2016-08-20 20:06:30 +0530155 * 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 Pajin11ff4a82015-08-20 18:03:05 +0200166 * Returns the list of delta port statistics of the specified device.
167 *
Madan Jampanif97edc12015-08-31 14:41:01 -0700168 * @param deviceId device identifier
Dusan Pajin11ff4a82015-08-20 18:03:05 +0200169 * @return list of delta port statistics of all ports of the device
170 */
171 List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId);
172
173 /**
Viswanath KSP22774cd2016-08-20 20:06:30 +0530174 * 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 /**
tom41a2c5f2014-09-19 09:20:35 -0700185 * 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 HIGUCHI6eb00cc2016-06-10 11:55:12 -0700194 * 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 /**
tom41a2c5f2014-09-19 09:20:35 -0700204 * 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 /**
tom41a2c5f2014-09-19 09:20:35 -0700212 * Administratively removes the specified device from the store.
213 *
214 * @param deviceId device to be removed
Yuta HIGUCHI5c947272014-11-03 21:39:21 -0800215 * @return null if no such device, or was forwarded to remove master
tom41a2c5f2014-09-19 09:20:35 -0700216 */
217 DeviceEvent removeDevice(DeviceId deviceId);
sangho538108b2015-04-08 14:29:20 -0700218
tom41a2c5f2014-09-19 09:20:35 -0700219}