Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
Ray Milkey | 34c9590 | 2015-04-15 09:47:53 -0700 | [diff] [blame] | 2 | * Copyright 2014-2015 Open Networking Laboratory |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 3 | * |
| 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'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.device; |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 17 | |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame] | 18 | import org.onosproject.event.ListenerService; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 19 | import org.onosproject.net.Device; |
| 20 | import org.onosproject.net.DeviceId; |
| 21 | import org.onosproject.net.MastershipRole; |
| 22 | import org.onosproject.net.Port; |
| 23 | import org.onosproject.net.PortNumber; |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 24 | |
| 25 | import java.util.List; |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 26 | |
| 27 | /** |
| 28 | * Service for interacting with the inventory of infrastructure devices. |
| 29 | */ |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame] | 30 | public interface DeviceService |
| 31 | extends ListenerService<DeviceEvent, DeviceListener> { |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 32 | |
| 33 | /** |
tom | ad2d209 | 2014-09-06 23:24:20 -0700 | [diff] [blame] | 34 | * Returns the number of infrastructure devices known to the system. |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 35 | * |
tom | ad2d209 | 2014-09-06 23:24:20 -0700 | [diff] [blame] | 36 | * @return number of infrastructure devices |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 37 | */ |
tom | ad2d209 | 2014-09-06 23:24:20 -0700 | [diff] [blame] | 38 | int getDeviceCount(); |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 39 | |
| 40 | /** |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 41 | * Returns a collection of the currently known infrastructure |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 42 | * devices. |
| 43 | * |
| 44 | * @return collection of devices |
| 45 | */ |
| 46 | Iterable<Device> getDevices(); |
| 47 | |
| 48 | /** |
samuel | 738dfaf | 2015-07-11 11:08:57 +0800 | [diff] [blame] | 49 | * 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 HIGUCHI | f1f2ac0 | 2014-11-26 14:02:22 -0800 | [diff] [blame] | 58 | * 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 | /** |
samuel | 738dfaf | 2015-07-11 11:08:57 +0800 | [diff] [blame] | 66 | * 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 | /** |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 74 | * 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 | |
tom | ad2d209 | 2014-09-06 23:24:20 -0700 | [diff] [blame] | 81 | /** |
| 82 | * Returns the current mastership role for the specified device. |
| 83 | * |
| 84 | * @param deviceId device identifier |
| 85 | * @return designated mastership role |
| 86 | */ |
Ayaka Koshibe | 25fd23a | 2014-10-03 15:50:43 -0700 | [diff] [blame] | 87 | //XXX do we want this method here when MastershipService already does? |
tom | ad2d209 | 2014-09-06 23:24:20 -0700 | [diff] [blame] | 88 | MastershipRole getRole(DeviceId deviceId); |
| 89 | |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 90 | |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 91 | /** |
| 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 | /** |
sangho | 538108b | 2015-04-08 14:29:20 -0700 | [diff] [blame] | 100 | * Returns the list of port statistics associated with the device. |
| 101 | * |
Sho SHIMIZU | ceb6f13 | 2015-08-24 11:46:25 -0700 | [diff] [blame] | 102 | * @param deviceId device identifier |
sangho | 538108b | 2015-04-08 14:29:20 -0700 | [diff] [blame] | 103 | * @return list of port statistics |
| 104 | */ |
| 105 | List<PortStatistics> getPortStatistics(DeviceId deviceId); |
| 106 | |
| 107 | /** |
Dusan Pajin | 11ff4a8 | 2015-08-20 18:03:05 +0200 | [diff] [blame] | 108 | * Returns the list of port delta statistics associated with the device. |
| 109 | * |
Sho SHIMIZU | ceb6f13 | 2015-08-24 11:46:25 -0700 | [diff] [blame] | 110 | * @param deviceId device identifier |
Dusan Pajin | 11ff4a8 | 2015-08-20 18:03:05 +0200 | [diff] [blame] | 111 | * @return list of port statistics |
| 112 | */ |
| 113 | List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId); |
| 114 | |
| 115 | /** |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 116 | * Returns the port with the specified number and hosted by the given device. |
tom | ff7eb7c | 2014-09-08 12:49:03 -0700 | [diff] [blame] | 117 | * |
| 118 | * @param deviceId device identifier |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 119 | * @param portNumber port number |
| 120 | * @return device port |
| 121 | */ |
| 122 | Port getPort(DeviceId deviceId, PortNumber portNumber); |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 123 | |
| 124 | /** |
tom | ff7eb7c | 2014-09-08 12:49:03 -0700 | [diff] [blame] | 125 | * Indicates whether or not the device is presently online and available. |
| 126 | * |
| 127 | * @param deviceId device identifier |
| 128 | * @return true if the device is available |
| 129 | */ |
| 130 | boolean isAvailable(DeviceId deviceId); |
| 131 | |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 132 | } |