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