wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Open Networking Laboratory |
| 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 | */ |
Thomas Vachuska | bf916ea | 2015-05-20 18:24:34 -0700 | [diff] [blame] | 16 | package org.onosproject.incubator.net.tunnel; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 17 | |
| 18 | import java.util.Collection; |
| 19 | |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 20 | import org.onosproject.core.ApplicationId; |
samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame] | 21 | import org.onosproject.incubator.net.tunnel.Tunnel.Type; |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 22 | import org.onosproject.net.Annotations; |
cheng fan | 35dc0f2 | 2015-06-10 06:02:47 +0800 | [diff] [blame^] | 23 | import org.onosproject.net.DeviceId; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 24 | |
| 25 | /** |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 26 | * Service for interacting with the inventory of tunnels. |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 27 | */ |
| 28 | public interface TunnelService { |
| 29 | |
| 30 | /** |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 31 | * Borrows a specific tunnel. Annotations parameter is reserved.If there |
| 32 | * is no tunnel in the store, returns a "null" object, and record the tunnel subscription. |
| 33 | * Where tunnel is created, ONOS notifies this consumer actively. |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 34 | * |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 35 | * @param consumerId a tunnel consumer |
| 36 | * @param tunnelId tunnel identify generated by onos |
| 37 | * @param annotations Annotations |
| 38 | * @return Tunnel subscribed tunnel |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 39 | */ |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 40 | Tunnel borrowTunnel(ApplicationId consumerId, TunnelId tunnelId, |
| 41 | Annotations... annotations); |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 42 | |
| 43 | /** |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 44 | * Borrows a specific tunnel by tunnelName. Annotations parameter is reserved.If there |
| 45 | * is no tunnel in the store, return a "null" object, and record the tunnel subscription. |
| 46 | * Where tunnel is created, ONOS notifies this consumer actively. |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 47 | * |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 48 | * @param consumerId a tunnel consumer |
| 49 | * @param tunnelName tunnel name |
| 50 | * @param annotations Annotations |
| 51 | * @return collection of subscribed Tunnels |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 52 | */ |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 53 | Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelName tunnelName, |
| 54 | Annotations... annotations); |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 55 | |
| 56 | /** |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 57 | * Borrows all tunnels between source and destination. Annotations |
| 58 | * parameter is reserved.If there is no any tunnel in the store, return a |
| 59 | * empty collection,and record the tunnel subscription. Where tunnel is created, ONOS |
| 60 | * notifies this consumer actively. Otherwise ONOS core returns all the |
| 61 | * tunnels, consumer determined which one to use. |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 62 | * |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 63 | * @param consumerId a tunnel consumer |
| 64 | * @param src a source point of tunnel. |
| 65 | * @param dst a destination point of tunnel |
| 66 | * @param annotations Annotations |
| 67 | * @return collection of subscribed Tunnels |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 68 | */ |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 69 | Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src, |
| 70 | TunnelEndPoint dst, Annotations... annotations); |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 71 | |
| 72 | /** |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 73 | * Borrows all specified type tunnels between source and destination. |
| 74 | * Annotations parameter is reserved.If there is no any tunnel in the store, |
| 75 | * return a empty collection, and record the tunnel subscription. Where tunnel is |
| 76 | * created, ONOS notifies this consumer actively. Otherwise,ONOS core returns |
| 77 | * all available tunnels, consumer determined which one to use. |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 78 | * |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 79 | * @param consumerId a tunnel consumer |
| 80 | * @param src a source point of tunnel. |
| 81 | * @param dst a destination point of tunnel |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 82 | * @param type tunnel type |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 83 | * @param annotations Annotations |
| 84 | * @return collection of available Tunnels |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 85 | */ |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 86 | Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src, |
samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame] | 87 | TunnelEndPoint dst, Type type, |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 88 | Annotations... annotations); |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 89 | |
| 90 | /** |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 91 | * Returns back a specific tunnel to store. |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 92 | * |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 93 | * @param consumerId a tunnel consumer |
| 94 | * @param tunnelId tunnel identify generated by ONOS |
| 95 | * @param annotations Annotations |
| 96 | * @return success or fail |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 97 | */ |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 98 | boolean returnTunnel(ApplicationId consumerId, TunnelId tunnelId, |
| 99 | Annotations... annotations); |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 100 | |
| 101 | /** |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 102 | * Returns all specific name tunnel back store. Annotations parameter is reserved.if there |
| 103 | * is no tunnel in the store, return a "null" object, and record the tunnel subscription. |
| 104 | * Where tunnel is created, ONOS notifies this consumer actively. |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 105 | * |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 106 | * @param consumerId a tunnel consumer |
| 107 | * @param tunnelName tunnel name |
| 108 | * @param annotations Annotations |
| 109 | * @return boolean |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 110 | */ |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 111 | boolean returnTunnel(ApplicationId consumerId, TunnelName tunnelName, |
| 112 | Annotations... annotations); |
| 113 | |
| 114 | /** |
| 115 | * Returns all specific type tunnels between source and destination back |
| 116 | * store. Annotations parameter is reserved. |
| 117 | * |
| 118 | * @param consumerId a tunnel consumer |
| 119 | * @param src a source point of tunnel. |
| 120 | * @param dst a destination point of tunnel |
| 121 | * @param type tunnel type |
| 122 | * @param annotations Annotations |
| 123 | * @return success or fail |
| 124 | */ |
| 125 | boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src, |
samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame] | 126 | TunnelEndPoint dst, Type type, |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 127 | Annotations... annotations); |
| 128 | |
| 129 | /** |
| 130 | * Returns all tunnels between source and destination back the store. |
| 131 | * Annotations parameter is reserved. |
| 132 | * |
| 133 | * @param consumerId a tunnel consumer |
| 134 | * @param src a source point of tunnel. |
| 135 | * @param dst a destination point of tunnel. |
| 136 | * @param annotations Annotations |
| 137 | * @return success or fail |
| 138 | */ |
| 139 | boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src, |
| 140 | TunnelEndPoint dst, Annotations... annotations); |
| 141 | |
| 142 | /** |
| 143 | * Returns a tunnel by a specific tunnel identity. |
| 144 | * |
| 145 | * @param tunnelId tunnel identify generated by tunnel producer |
| 146 | * @return Tunnel |
| 147 | */ |
| 148 | Tunnel queryTunnel(TunnelId tunnelId); |
| 149 | |
| 150 | /** |
| 151 | * Returns all tunnel subscription record by consumer. |
| 152 | * |
| 153 | * @param consumerId consumer identity |
| 154 | * @return Collection of TunnelSubscription |
| 155 | */ |
| 156 | Collection<TunnelSubscription> queryTunnelSubscription(ApplicationId consumerId); |
| 157 | |
| 158 | /** |
| 159 | * Returns all specified type tunnels. |
| 160 | * |
| 161 | * @param type tunnel type |
| 162 | * @return Collection of tunnels |
| 163 | */ |
samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame] | 164 | Collection<Tunnel> queryTunnel(Type type); |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 165 | |
| 166 | /** |
| 167 | * Returns all tunnels between source point and destination point. |
| 168 | * |
| 169 | * @param src a source point of tunnel. |
| 170 | * @param dst a destination point of tunnel. |
| 171 | * @return Collection of tunnels |
| 172 | */ |
| 173 | Collection<Tunnel> queryTunnel(TunnelEndPoint src, TunnelEndPoint dst); |
| 174 | |
| 175 | /** |
| 176 | * Returns all tunnels. |
| 177 | * |
samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame] | 178 | * @return Collection of tunnels |
| 179 | */ |
| 180 | Collection<Tunnel> queryAllTunnels(); |
| 181 | |
| 182 | /** |
| 183 | * Returns all tunnels. |
| 184 | * |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 185 | * @return all tunnels |
| 186 | */ |
| 187 | int tunnelCount(); |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 188 | |
| 189 | /** |
cheng fan | 35dc0f2 | 2015-06-10 06:02:47 +0800 | [diff] [blame^] | 190 | * Returns the collection of tunnels applied on the specified device. |
| 191 | * |
| 192 | * @param deviceId device identifier |
| 193 | * @return collection of tunnels |
| 194 | */ |
| 195 | Iterable<Tunnel> getTunnels(DeviceId deviceId); |
| 196 | |
| 197 | /** |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 198 | * Adds the specified tunnel listener. |
| 199 | * |
| 200 | * @param listener tunnel listener |
| 201 | */ |
| 202 | void addListener(TunnelListener listener); |
| 203 | |
| 204 | /** |
| 205 | * Removes the specified tunnel listener. |
| 206 | * |
| 207 | * @param listener tunnel listener |
| 208 | */ |
| 209 | void removeListener(TunnelListener listener); |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 210 | } |