blob: 86d902596fbf529a3dd1a993f0e36fe9ac908e70 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -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;
tome33cc1a2014-08-25 21:59:41 -070017
Thomas Vachuska42e8cce2015-07-29 19:25:18 -070018import org.onosproject.event.ListenerService;
Yuta HIGUCHI22ba76d2016-11-11 16:56:24 -080019import org.onosproject.net.ConnectPoint;
Brian O'Connorabafb502014-12-02 22:26:20 -080020import org.onosproject.net.Device;
21import org.onosproject.net.DeviceId;
22import org.onosproject.net.MastershipRole;
23import org.onosproject.net.Port;
24import org.onosproject.net.PortNumber;
tomb36046e2014-08-27 00:22:24 -070025
26import java.util.List;
tome33cc1a2014-08-25 21:59:41 -070027
28/**
29 * Service for interacting with the inventory of infrastructure devices.
30 */
Thomas Vachuska42e8cce2015-07-29 19:25:18 -070031public interface DeviceService
32 extends ListenerService<DeviceEvent, DeviceListener> {
tome33cc1a2014-08-25 21:59:41 -070033
34 /**
tomad2d2092014-09-06 23:24:20 -070035 * Returns the number of infrastructure devices known to the system.
tome33cc1a2014-08-25 21:59:41 -070036 *
tomad2d2092014-09-06 23:24:20 -070037 * @return number of infrastructure devices
tome33cc1a2014-08-25 21:59:41 -070038 */
tomad2d2092014-09-06 23:24:20 -070039 int getDeviceCount();
tome33cc1a2014-08-25 21:59:41 -070040
41 /**
mskala32000d32017-07-14 16:27:06 +020042 * Returns the number of currently available devices known to the system.
43 *
44 * @return number of available devices
45 */
46 default int getAvailableDeviceCount() {
47 return getDeviceCount();
48 }
49
50 /**
tomedf06bb2014-08-27 16:22:15 -070051 * Returns a collection of the currently known infrastructure
tome33cc1a2014-08-25 21:59:41 -070052 * devices.
53 *
54 * @return collection of devices
55 */
56 Iterable<Device> getDevices();
57
58 /**
samuel738dfaf2015-07-11 11:08:57 +080059 * Returns a collection of the currently known infrastructure
60 * devices by device type.
61 *
62 * @param type device type
63 * @return collection of devices
64 */
65 Iterable<Device> getDevices(Device.Type type);
66
67 /**
Yuta HIGUCHIf1f2ac02014-11-26 14:02:22 -080068 * Returns an iterable collection of all devices
69 * currently available to the system.
70 *
71 * @return device collection
72 */
73 Iterable<Device> getAvailableDevices();
74
75 /**
samuel738dfaf2015-07-11 11:08:57 +080076 * Returns an iterable collection of all devices currently available to the system by device type.
77 *
78 * @param type device type
79 * @return device collection
80 */
81 Iterable<Device> getAvailableDevices(Device.Type type);
82
83 /**
tome33cc1a2014-08-25 21:59:41 -070084 * Returns the device with the specified identifier.
85 *
86 * @param deviceId device identifier
87 * @return device or null if one with the given identifier is not known
88 */
89 Device getDevice(DeviceId deviceId);
90
tomad2d2092014-09-06 23:24:20 -070091 /**
92 * Returns the current mastership role for the specified device.
93 *
94 * @param deviceId device identifier
95 * @return designated mastership role
96 */
Ayaka Koshibe25fd23a2014-10-03 15:50:43 -070097 //XXX do we want this method here when MastershipService already does?
tomad2d2092014-09-06 23:24:20 -070098 MastershipRole getRole(DeviceId deviceId);
99
tome33cc1a2014-08-25 21:59:41 -0700100
tomb36046e2014-08-27 00:22:24 -0700101 /**
102 * Returns the list of ports associated with the device.
103 *
104 * @param deviceId device identifier
105 * @return list of ports
106 */
107 List<Port> getPorts(DeviceId deviceId);
108
109 /**
sangho538108b2015-04-08 14:29:20 -0700110 * Returns the list of port statistics associated with the device.
111 *
Sho SHIMIZUceb6f132015-08-24 11:46:25 -0700112 * @param deviceId device identifier
sangho538108b2015-04-08 14:29:20 -0700113 * @return list of port statistics
114 */
115 List<PortStatistics> getPortStatistics(DeviceId deviceId);
116
117 /**
Dusan Pajin11ff4a82015-08-20 18:03:05 +0200118 * Returns the list of port delta statistics associated with the device.
119 *
Sho SHIMIZUceb6f132015-08-24 11:46:25 -0700120 * @param deviceId device identifier
Dusan Pajin11ff4a82015-08-20 18:03:05 +0200121 * @return list of port statistics
122 */
123 List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId);
124
125 /**
Viswanath KSP22774cd2016-08-20 20:06:30 +0530126 * Returns the port specific port statistics associated with the device and port.
127 *
128 * @param deviceId device identifier
129 * @param portNumber port identifier
130 * @return port statistics of specified port
131 */
132 default PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
133 return null;
134 }
135
136 /**
137 * Returns the port specific port delta statistics associated with the device and port.
138 *
139 * @param deviceId device identifier
140 * @param portNumber port identifier
141 * @return port delta statistics of specified port
142 */
143 default PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
144 return null;
145 }
146
147 /**
tomb36046e2014-08-27 00:22:24 -0700148 * Returns the port with the specified number and hosted by the given device.
tomff7eb7c2014-09-08 12:49:03 -0700149 *
150 * @param deviceId device identifier
tomb36046e2014-08-27 00:22:24 -0700151 * @param portNumber port number
152 * @return device port
153 */
154 Port getPort(DeviceId deviceId, PortNumber portNumber);
tome33cc1a2014-08-25 21:59:41 -0700155
156 /**
Yuta HIGUCHI22ba76d2016-11-11 16:56:24 -0800157 * Returns the port with the specified connect point.
158 *
159 * @param cp connect point
160 * @return device port
161 */
162 default Port getPort(ConnectPoint cp) {
163 return getPort(cp.deviceId(), cp.port());
164 }
165
166 /**
tomff7eb7c2014-09-08 12:49:03 -0700167 * Indicates whether or not the device is presently online and available.
Aaron Kruglikov8e0a08a2016-06-21 14:31:03 -0700168 * Availability, unlike reachability, denotes whether ANY node in the
169 * cluster can discover that this device is in an operational state,
170 * this does not necessarily mean that there exists a node that can
171 * control this device.
tomff7eb7c2014-09-08 12:49:03 -0700172 *
173 * @param deviceId device identifier
174 * @return true if the device is available
175 */
176 boolean isAvailable(DeviceId deviceId);
177
Saurav Dasd5ec9e92017-01-17 10:40:18 -0800178 /**
179 * Indicates how long ago the device connected or disconnected from this
180 * controller instance.
181 *
182 * @param deviceId device identifier
183 * @return a human readable string indicating the time since the device
184 * connected-to or disconnected-from this controller instance.
185 */
186 String localStatus(DeviceId deviceId);
187
Ray Milkey054e23d2018-03-22 13:37:11 -0700188
189 /**
Saurav Das9a554292018-04-27 18:42:30 -0700190 * Indicates the time at which the given device connected or disconnected
191 * from this controller instance.
Ray Milkey054e23d2018-03-22 13:37:11 -0700192 *
193 * @param deviceId device identifier
Saurav Das9a554292018-04-27 18:42:30 -0700194 * @return time offset in miliseconds from Epoch
Ray Milkey054e23d2018-03-22 13:37:11 -0700195 */
196 long getLastUpdatedInstant(DeviceId deviceId);
197
tome33cc1a2014-08-25 21:59:41 -0700198}