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