blob: ce988c5b6df14ff1ca5c706f44577aba453d92c4 [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;
Brian O'Connorabafb502014-12-02 22:26:20 -080019import org.onosproject.net.Device;
20import org.onosproject.net.DeviceId;
21import org.onosproject.net.MastershipRole;
22import org.onosproject.net.Port;
23import org.onosproject.net.PortNumber;
tomb36046e2014-08-27 00:22:24 -070024
25import java.util.List;
tome33cc1a2014-08-25 21:59:41 -070026
27/**
28 * Service for interacting with the inventory of infrastructure devices.
29 */
Thomas Vachuska42e8cce2015-07-29 19:25:18 -070030public interface DeviceService
31 extends ListenerService<DeviceEvent, DeviceListener> {
tome33cc1a2014-08-25 21:59:41 -070032
33 /**
tomad2d2092014-09-06 23:24:20 -070034 * Returns the number of infrastructure devices known to the system.
tome33cc1a2014-08-25 21:59:41 -070035 *
tomad2d2092014-09-06 23:24:20 -070036 * @return number of infrastructure devices
tome33cc1a2014-08-25 21:59:41 -070037 */
tomad2d2092014-09-06 23:24:20 -070038 int getDeviceCount();
tome33cc1a2014-08-25 21:59:41 -070039
40 /**
tomedf06bb2014-08-27 16:22:15 -070041 * Returns a collection of the currently known infrastructure
tome33cc1a2014-08-25 21:59:41 -070042 * devices.
43 *
44 * @return collection of devices
45 */
46 Iterable<Device> getDevices();
47
48 /**
samuel738dfaf2015-07-11 11:08:57 +080049 * Returns a collection of the currently known infrastructure
50 * devices by device type.
51 *
52 * @param type device type
53 * @return collection of devices
54 */
55 Iterable<Device> getDevices(Device.Type type);
56
57 /**
Yuta HIGUCHIf1f2ac02014-11-26 14:02:22 -080058 * Returns an iterable collection of all devices
59 * currently available to the system.
60 *
61 * @return device collection
62 */
63 Iterable<Device> getAvailableDevices();
64
65 /**
samuel738dfaf2015-07-11 11:08:57 +080066 * Returns an iterable collection of all devices currently available to the system by device type.
67 *
68 * @param type device type
69 * @return device collection
70 */
71 Iterable<Device> getAvailableDevices(Device.Type type);
72
73 /**
tome33cc1a2014-08-25 21:59:41 -070074 * Returns the device with the specified identifier.
75 *
76 * @param deviceId device identifier
77 * @return device or null if one with the given identifier is not known
78 */
79 Device getDevice(DeviceId deviceId);
80
tomad2d2092014-09-06 23:24:20 -070081 /**
82 * Returns the current mastership role for the specified device.
83 *
84 * @param deviceId device identifier
85 * @return designated mastership role
86 */
Ayaka Koshibe25fd23a2014-10-03 15:50:43 -070087 //XXX do we want this method here when MastershipService already does?
tomad2d2092014-09-06 23:24:20 -070088 MastershipRole getRole(DeviceId deviceId);
89
tome33cc1a2014-08-25 21:59:41 -070090
tomb36046e2014-08-27 00:22:24 -070091 /**
92 * Returns the list of ports associated with the device.
93 *
94 * @param deviceId device identifier
95 * @return list of ports
96 */
97 List<Port> getPorts(DeviceId deviceId);
98
99 /**
sangho538108b2015-04-08 14:29:20 -0700100 * Returns the list of port statistics associated with the device.
101 *
Sho SHIMIZUceb6f132015-08-24 11:46:25 -0700102 * @param deviceId device identifier
sangho538108b2015-04-08 14:29:20 -0700103 * @return list of port statistics
104 */
105 List<PortStatistics> getPortStatistics(DeviceId deviceId);
106
107 /**
Dusan Pajin11ff4a82015-08-20 18:03:05 +0200108 * Returns the list of port delta statistics associated with the device.
109 *
Sho SHIMIZUceb6f132015-08-24 11:46:25 -0700110 * @param deviceId device identifier
Dusan Pajin11ff4a82015-08-20 18:03:05 +0200111 * @return list of port statistics
112 */
113 List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId);
114
115 /**
Viswanath KSP22774cd2016-08-20 20:06:30 +0530116 * Returns the port specific port statistics associated with the device and port.
117 *
118 * @param deviceId device identifier
119 * @param portNumber port identifier
120 * @return port statistics of specified port
121 */
122 default PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
123 return null;
124 }
125
126 /**
127 * Returns the port specific port delta statistics associated with the device and port.
128 *
129 * @param deviceId device identifier
130 * @param portNumber port identifier
131 * @return port delta statistics of specified port
132 */
133 default PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
134 return null;
135 }
136
137 /**
tomb36046e2014-08-27 00:22:24 -0700138 * Returns the port with the specified number and hosted by the given device.
tomff7eb7c2014-09-08 12:49:03 -0700139 *
140 * @param deviceId device identifier
tomb36046e2014-08-27 00:22:24 -0700141 * @param portNumber port number
142 * @return device port
143 */
144 Port getPort(DeviceId deviceId, PortNumber portNumber);
tome33cc1a2014-08-25 21:59:41 -0700145
146 /**
tomff7eb7c2014-09-08 12:49:03 -0700147 * Indicates whether or not the device is presently online and available.
Aaron Kruglikov8e0a08a2016-06-21 14:31:03 -0700148 * Availability, unlike reachability, denotes whether ANY node in the
149 * cluster can discover that this device is in an operational state,
150 * this does not necessarily mean that there exists a node that can
151 * control this device.
tomff7eb7c2014-09-08 12:49:03 -0700152 *
153 * @param deviceId device identifier
154 * @return true if the device is available
155 */
156 boolean isAvailable(DeviceId deviceId);
157
tome33cc1a2014-08-25 21:59:41 -0700158}