blob: 290f7d7f69e4563502a53041d2747855667dba30 [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;
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 /**
tomedf06bb2014-08-27 16:22:15 -070042 * Returns a collection of the currently known infrastructure
tome33cc1a2014-08-25 21:59:41 -070043 * devices.
44 *
45 * @return collection of devices
46 */
47 Iterable<Device> getDevices();
48
49 /**
samuel738dfaf2015-07-11 11:08:57 +080050 * Returns a collection of the currently known infrastructure
51 * devices by device type.
52 *
53 * @param type device type
54 * @return collection of devices
55 */
56 Iterable<Device> getDevices(Device.Type type);
57
58 /**
Yuta HIGUCHIf1f2ac02014-11-26 14:02:22 -080059 * Returns an iterable collection of all devices
60 * currently available to the system.
61 *
62 * @return device collection
63 */
64 Iterable<Device> getAvailableDevices();
65
66 /**
samuel738dfaf2015-07-11 11:08:57 +080067 * Returns an iterable collection of all devices currently available to the system by device type.
68 *
69 * @param type device type
70 * @return device collection
71 */
72 Iterable<Device> getAvailableDevices(Device.Type type);
73
74 /**
tome33cc1a2014-08-25 21:59:41 -070075 * Returns the device with the specified identifier.
76 *
77 * @param deviceId device identifier
78 * @return device or null if one with the given identifier is not known
79 */
80 Device getDevice(DeviceId deviceId);
81
tomad2d2092014-09-06 23:24:20 -070082 /**
83 * Returns the current mastership role for the specified device.
84 *
85 * @param deviceId device identifier
86 * @return designated mastership role
87 */
Ayaka Koshibe25fd23a2014-10-03 15:50:43 -070088 //XXX do we want this method here when MastershipService already does?
tomad2d2092014-09-06 23:24:20 -070089 MastershipRole getRole(DeviceId deviceId);
90
tome33cc1a2014-08-25 21:59:41 -070091
tomb36046e2014-08-27 00:22:24 -070092 /**
93 * Returns the list of ports associated with the device.
94 *
95 * @param deviceId device identifier
96 * @return list of ports
97 */
98 List<Port> getPorts(DeviceId deviceId);
99
100 /**
sangho538108b2015-04-08 14:29:20 -0700101 * Returns the list of port statistics associated with the device.
102 *
Sho SHIMIZUceb6f132015-08-24 11:46:25 -0700103 * @param deviceId device identifier
sangho538108b2015-04-08 14:29:20 -0700104 * @return list of port statistics
105 */
106 List<PortStatistics> getPortStatistics(DeviceId deviceId);
107
108 /**
Dusan Pajin11ff4a82015-08-20 18:03:05 +0200109 * Returns the list of port delta statistics associated with the device.
110 *
Sho SHIMIZUceb6f132015-08-24 11:46:25 -0700111 * @param deviceId device identifier
Dusan Pajin11ff4a82015-08-20 18:03:05 +0200112 * @return list of port statistics
113 */
114 List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId);
115
116 /**
Viswanath KSP22774cd2016-08-20 20:06:30 +0530117 * Returns the port specific port statistics associated with the device and port.
118 *
119 * @param deviceId device identifier
120 * @param portNumber port identifier
121 * @return port statistics of specified port
122 */
123 default PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
124 return null;
125 }
126
127 /**
128 * Returns the port specific port delta statistics associated with the device and port.
129 *
130 * @param deviceId device identifier
131 * @param portNumber port identifier
132 * @return port delta statistics of specified port
133 */
134 default PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
135 return null;
136 }
137
138 /**
tomb36046e2014-08-27 00:22:24 -0700139 * Returns the port with the specified number and hosted by the given device.
tomff7eb7c2014-09-08 12:49:03 -0700140 *
141 * @param deviceId device identifier
tomb36046e2014-08-27 00:22:24 -0700142 * @param portNumber port number
143 * @return device port
144 */
145 Port getPort(DeviceId deviceId, PortNumber portNumber);
tome33cc1a2014-08-25 21:59:41 -0700146
147 /**
Yuta HIGUCHI22ba76d2016-11-11 16:56:24 -0800148 * Returns the port with the specified connect point.
149 *
150 * @param cp connect point
151 * @return device port
152 */
153 default Port getPort(ConnectPoint cp) {
154 return getPort(cp.deviceId(), cp.port());
155 }
156
157 /**
tomff7eb7c2014-09-08 12:49:03 -0700158 * Indicates whether or not the device is presently online and available.
Aaron Kruglikov8e0a08a2016-06-21 14:31:03 -0700159 * Availability, unlike reachability, denotes whether ANY node in the
160 * cluster can discover that this device is in an operational state,
161 * this does not necessarily mean that there exists a node that can
162 * control this device.
tomff7eb7c2014-09-08 12:49:03 -0700163 *
164 * @param deviceId device identifier
165 * @return true if the device is available
166 */
167 boolean isAvailable(DeviceId deviceId);
168
tome33cc1a2014-08-25 21:59:41 -0700169}