blob: cfc9626ea258ea4207b2a462971b9080b2e22f9e [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
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
55
56
57 /**
tom41a2c5f2014-09-19 09:20:35 -070058 * Returns the device with the specified identifier.
59 *
60 * @param deviceId device identifier
61 * @return device
62 */
63 Device getDevice(DeviceId deviceId);
64
65 /**
66 * Creates a new infrastructure device, or updates an existing one using
67 * the supplied device description.
68 *
69 * @param providerId provider identifier
70 * @param deviceId device identifier
71 * @param deviceDescription device description
72 * @return ready to send event describing what occurred; null if no change
73 */
74 DeviceEvent createOrUpdateDevice(ProviderId providerId, DeviceId deviceId,
75 DeviceDescription deviceDescription);
76
Yuta HIGUCHI5f6739c2014-10-01 14:04:01 -070077 // TODO: We may need to enforce that ancillary cannot interfere this state
tom41a2c5f2014-09-19 09:20:35 -070078 /**
79 * Removes the specified infrastructure device.
80 *
81 * @param deviceId device identifier
82 * @return ready to send event describing what occurred; null if no change
83 */
84 DeviceEvent markOffline(DeviceId deviceId);
85
86 /**
87 * Updates the ports of the specified infrastructure device using the given
88 * list of port descriptions. The list is assumed to be comprehensive.
89 *
Yuta HIGUCHI5f6739c2014-10-01 14:04:01 -070090 * @param providerId provider identifier
tom41a2c5f2014-09-19 09:20:35 -070091 * @param deviceId device identifier
92 * @param portDescriptions list of port descriptions
93 * @return ready to send events describing what occurred; empty list if no change
94 */
Yuta HIGUCHI5f6739c2014-10-01 14:04:01 -070095 List<DeviceEvent> updatePorts(ProviderId providerId, DeviceId deviceId,
tom41a2c5f2014-09-19 09:20:35 -070096 List<PortDescription> portDescriptions);
97
98 /**
99 * Updates the port status of the specified infrastructure device using the
100 * given port description.
101 *
Yuta HIGUCHI5f6739c2014-10-01 14:04:01 -0700102 * @param providerId provider identifier
tom41a2c5f2014-09-19 09:20:35 -0700103 * @param deviceId device identifier
104 * @param portDescription port description
105 * @return ready to send event describing what occurred; null if no change
106 */
Yuta HIGUCHI5f6739c2014-10-01 14:04:01 -0700107 DeviceEvent updatePortStatus(ProviderId providerId, DeviceId deviceId,
tom41a2c5f2014-09-19 09:20:35 -0700108 PortDescription portDescription);
109
110 /**
111 * Returns the list of ports that belong to the specified device.
112 *
113 * @param deviceId device identifier
114 * @return list of device ports
115 */
116 List<Port> getPorts(DeviceId deviceId);
117
118 /**
Yuta HIGUCHI6eb00cc2016-06-10 11:55:12 -0700119 * Returns the stream of port descriptions that belong to the specified device.
120 *
121 * @param providerId provider identifier
122 * @param deviceId device identifier
123 * @return stream of device portdescriptions
124 */
125 Stream<PortDescription> getPortDescriptions(ProviderId providerId, DeviceId deviceId);
126
127 /**
sangho538108b2015-04-08 14:29:20 -0700128 * Updates the port statistics of the specified device using the give port
129 * statistics.
130 *
131 * @param providerId provider identifier
132 * @param deviceId device identifier
133 * @param portStats list of port statistics
134 * @return ready to send event describing what occurred;
135 */
136 DeviceEvent updatePortStatistics(ProviderId providerId, DeviceId deviceId,
137 Collection<PortStatistics> portStats);
138
139 /**
140 * Returns the list of port statistics of the specified device.
141 *
142 * @param deviceId device identifier
143 * @return list of port statistics of all ports of the device
144 */
145 List<PortStatistics> getPortStatistics(DeviceId deviceId);
146
147 /**
Dusan Pajin11ff4a82015-08-20 18:03:05 +0200148 * Returns the list of delta port statistics of the specified device.
149 *
Madan Jampanif97edc12015-08-31 14:41:01 -0700150 * @param deviceId device identifier
Dusan Pajin11ff4a82015-08-20 18:03:05 +0200151 * @return list of delta port statistics of all ports of the device
152 */
153 List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId);
154
155 /**
tom41a2c5f2014-09-19 09:20:35 -0700156 * Returns the specified device port.
157 *
158 * @param deviceId device identifier
159 * @param portNumber port number
160 * @return device port
161 */
162 Port getPort(DeviceId deviceId, PortNumber portNumber);
163
164 /**
Yuta HIGUCHI6eb00cc2016-06-10 11:55:12 -0700165 * Returns the specified device port description.
166 *
167 * @param providerId provider identifier
168 * @param deviceId device identifier
169 * @param portNumber port number
170 * @return device port description
171 */
172 PortDescription getPortDescription(ProviderId providerId, DeviceId deviceId, PortNumber portNumber);
173
174 /**
tom41a2c5f2014-09-19 09:20:35 -0700175 * Indicates whether the specified device is available/online.
176 *
177 * @param deviceId device identifier
178 * @return true if device is available
179 */
180 boolean isAvailable(DeviceId deviceId);
181
182 /**
tom41a2c5f2014-09-19 09:20:35 -0700183 * Administratively removes the specified device from the store.
184 *
185 * @param deviceId device to be removed
Yuta HIGUCHI5c947272014-11-03 21:39:21 -0800186 * @return null if no such device, or was forwarded to remove master
tom41a2c5f2014-09-19 09:20:35 -0700187 */
188 DeviceEvent removeDevice(DeviceId deviceId);
sangho538108b2015-04-08 14:29:20 -0700189
tom41a2c5f2014-09-19 09:20:35 -0700190}