wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame^] | 2 | * Copyright 2015-present Open Networking Foundation |
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 | |
Brian O'Connor | 2bed5ce | 2015-06-25 15:10:28 -0400 | [diff] [blame] | 18 | import com.google.common.annotations.Beta; |
Yi Tseng | fa394de | 2017-02-01 11:26:40 -0800 | [diff] [blame] | 19 | import org.onosproject.core.GroupId; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 20 | import org.onosproject.net.AbstractDescription; |
Satish K | d70e957 | 2016-04-28 13:58:51 +0530 | [diff] [blame] | 21 | import org.onosproject.net.NetworkResource; |
samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame] | 22 | import org.onosproject.net.Path; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 23 | import org.onosproject.net.SparseAnnotations; |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 24 | import org.onosproject.net.provider.ProviderId; |
| 25 | |
| 26 | import com.google.common.base.MoreObjects; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 27 | |
| 28 | /** |
| 29 | * Default implementation of immutable tunnel description entity. |
| 30 | */ |
Brian O'Connor | 2bed5ce | 2015-06-25 15:10:28 -0400 | [diff] [blame] | 31 | @Beta |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 32 | public class DefaultTunnelDescription extends AbstractDescription |
| 33 | implements TunnelDescription { |
| 34 | |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 35 | private final TunnelId tunnelId; |
| 36 | private final TunnelEndPoint src; |
| 37 | private final TunnelEndPoint dst; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 38 | private final Tunnel.Type type; |
Yi Tseng | fa394de | 2017-02-01 11:26:40 -0800 | [diff] [blame] | 39 | private final GroupId groupId; // represent for a group flow table |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 40 | // which a tunnel match up |
| 41 | // tunnel producer |
| 42 | private final ProviderId producerName; // tunnel producer name |
| 43 | private final TunnelName tunnelName; // name of a tunnel |
samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame] | 44 | private final Path path; |
Satish K | d70e957 | 2016-04-28 13:58:51 +0530 | [diff] [blame] | 45 | private final NetworkResource networkRes; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 46 | |
| 47 | /** |
| 48 | * Creates a tunnel description using the supplied information. |
| 49 | * |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 50 | * @param id TunnelId |
| 51 | * @param src TunnelPoint source |
| 52 | * @param dst TunnelPoint destination |
| 53 | * @param type tunnel type |
| 54 | * @param groupId groupId |
| 55 | * @param producerName tunnel producer |
| 56 | * @param tunnelName tunnel name |
samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame] | 57 | * @param path the path of tunnel |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 58 | * @param annotations optional key/value annotations |
| 59 | */ |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 60 | public DefaultTunnelDescription(TunnelId id, TunnelEndPoint src, |
| 61 | TunnelEndPoint dst, Tunnel.Type type, |
Yi Tseng | fa394de | 2017-02-01 11:26:40 -0800 | [diff] [blame] | 62 | GroupId groupId, |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 63 | ProviderId producerName, |
| 64 | TunnelName tunnelName, |
samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame] | 65 | Path path, |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 66 | SparseAnnotations... annotations) { |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 67 | super(annotations); |
| 68 | this.tunnelId = id; |
| 69 | this.src = src; |
| 70 | this.dst = dst; |
| 71 | this.type = type; |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 72 | this.groupId = groupId; |
| 73 | this.producerName = producerName; |
| 74 | this.tunnelName = tunnelName; |
samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame] | 75 | this.path = path; |
Satish K | d70e957 | 2016-04-28 13:58:51 +0530 | [diff] [blame] | 76 | this.networkRes = null; |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Creates a tunnel description using the supplied information. |
| 81 | * |
| 82 | * @param id TunnelId |
| 83 | * @param src TunnelPoint source |
| 84 | * @param dst TunnelPoint destination |
| 85 | * @param type tunnel type |
| 86 | * @param groupId groupId |
| 87 | * @param producerName tunnel producer |
| 88 | * @param tunnelName tunnel name |
| 89 | * @param path the path of tunnel |
| 90 | * @param networkRes network resource of tunnel |
| 91 | * @param annotations optional key/value annotations |
| 92 | */ |
| 93 | public DefaultTunnelDescription(TunnelId id, TunnelEndPoint src, |
| 94 | TunnelEndPoint dst, Tunnel.Type type, |
Yi Tseng | fa394de | 2017-02-01 11:26:40 -0800 | [diff] [blame] | 95 | GroupId groupId, |
Satish K | d70e957 | 2016-04-28 13:58:51 +0530 | [diff] [blame] | 96 | ProviderId producerName, |
| 97 | TunnelName tunnelName, |
| 98 | Path path, |
| 99 | NetworkResource networkRes, |
| 100 | SparseAnnotations... annotations) { |
| 101 | super(annotations); |
| 102 | this.tunnelId = id; |
| 103 | this.src = src; |
| 104 | this.dst = dst; |
| 105 | this.type = type; |
| 106 | this.groupId = groupId; |
| 107 | this.producerName = producerName; |
| 108 | this.tunnelName = tunnelName; |
| 109 | this.path = path; |
| 110 | this.networkRes = networkRes; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | @Override |
| 114 | public TunnelId id() { |
| 115 | return tunnelId; |
| 116 | } |
| 117 | |
| 118 | @Override |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 119 | public TunnelEndPoint src() { |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 120 | return src; |
| 121 | } |
| 122 | |
| 123 | @Override |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 124 | public TunnelEndPoint dst() { |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 125 | return dst; |
| 126 | } |
| 127 | |
| 128 | @Override |
| 129 | public Tunnel.Type type() { |
| 130 | return type; |
| 131 | } |
| 132 | |
| 133 | @Override |
Yi Tseng | fa394de | 2017-02-01 11:26:40 -0800 | [diff] [blame] | 134 | public GroupId groupId() { |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 135 | return groupId; |
| 136 | } |
| 137 | |
| 138 | @Override |
| 139 | public ProviderId producerName() { |
| 140 | return producerName; |
| 141 | } |
| 142 | |
| 143 | @Override |
| 144 | public TunnelName tunnelName() { |
| 145 | return tunnelName; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 146 | } |
| 147 | |
samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame] | 148 | |
| 149 | @Override |
| 150 | public Path path() { |
| 151 | return path; |
| 152 | } |
| 153 | |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 154 | @Override |
Satish K | d70e957 | 2016-04-28 13:58:51 +0530 | [diff] [blame] | 155 | public NetworkResource resource() { |
| 156 | return networkRes; |
| 157 | } |
| 158 | |
| 159 | @Override |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 160 | public String toString() { |
| 161 | return MoreObjects.toStringHelper(this) |
| 162 | .add("tunnelId", id()) |
| 163 | .add("src", src()) |
| 164 | .add("dst", dst()) |
| 165 | .add("type", type()) |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 166 | .add("tunnelName", tunnelName()) |
| 167 | .add("producerName", producerName()) |
| 168 | .add("groupId", groupId()) |
samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame] | 169 | .add("path", path) |
Satish K | d70e957 | 2016-04-28 13:58:51 +0530 | [diff] [blame] | 170 | .add("resource", networkRes) |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 171 | .toString(); |
| 172 | } |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 173 | } |