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 | |
Brian O'Connor | 2bed5ce | 2015-06-25 15:10:28 -0400 | [diff] [blame] | 18 | import com.google.common.annotations.Beta; |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 19 | import org.onosproject.core.DefaultGroupId; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 20 | import org.onosproject.net.AbstractDescription; |
samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame] | 21 | import org.onosproject.net.Path; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 22 | import org.onosproject.net.SparseAnnotations; |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 23 | import org.onosproject.net.provider.ProviderId; |
| 24 | |
| 25 | import com.google.common.base.MoreObjects; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 26 | |
| 27 | /** |
| 28 | * Default implementation of immutable tunnel description entity. |
| 29 | */ |
Brian O'Connor | 2bed5ce | 2015-06-25 15:10:28 -0400 | [diff] [blame] | 30 | @Beta |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 31 | public class DefaultTunnelDescription extends AbstractDescription |
| 32 | implements TunnelDescription { |
| 33 | |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 34 | private final TunnelId tunnelId; |
| 35 | private final TunnelEndPoint src; |
| 36 | private final TunnelEndPoint dst; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 37 | private final Tunnel.Type type; |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 38 | private final DefaultGroupId groupId; // represent for a group flow table |
| 39 | // which a tunnel match up |
| 40 | // tunnel producer |
| 41 | private final ProviderId producerName; // tunnel producer name |
| 42 | private final TunnelName tunnelName; // name of a tunnel |
samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame] | 43 | private final Path path; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 44 | |
| 45 | /** |
| 46 | * Creates a tunnel description using the supplied information. |
| 47 | * |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 48 | * @param id TunnelId |
| 49 | * @param src TunnelPoint source |
| 50 | * @param dst TunnelPoint destination |
| 51 | * @param type tunnel type |
| 52 | * @param groupId groupId |
| 53 | * @param producerName tunnel producer |
| 54 | * @param tunnelName tunnel name |
samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame] | 55 | * @param path the path of tunnel |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 56 | * @param annotations optional key/value annotations |
| 57 | */ |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 58 | public DefaultTunnelDescription(TunnelId id, TunnelEndPoint src, |
| 59 | TunnelEndPoint dst, Tunnel.Type type, |
| 60 | DefaultGroupId groupId, |
| 61 | ProviderId producerName, |
| 62 | TunnelName tunnelName, |
samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame] | 63 | Path path, |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 64 | SparseAnnotations... annotations) { |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 65 | super(annotations); |
| 66 | this.tunnelId = id; |
| 67 | this.src = src; |
| 68 | this.dst = dst; |
| 69 | this.type = type; |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 70 | this.groupId = groupId; |
| 71 | this.producerName = producerName; |
| 72 | this.tunnelName = tunnelName; |
samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame] | 73 | this.path = path; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | @Override |
| 77 | public TunnelId id() { |
| 78 | return tunnelId; |
| 79 | } |
| 80 | |
| 81 | @Override |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 82 | public TunnelEndPoint src() { |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 83 | return src; |
| 84 | } |
| 85 | |
| 86 | @Override |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 87 | public TunnelEndPoint dst() { |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 88 | return dst; |
| 89 | } |
| 90 | |
| 91 | @Override |
| 92 | public Tunnel.Type type() { |
| 93 | return type; |
| 94 | } |
| 95 | |
| 96 | @Override |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 97 | public DefaultGroupId groupId() { |
| 98 | return groupId; |
| 99 | } |
| 100 | |
| 101 | @Override |
| 102 | public ProviderId producerName() { |
| 103 | return producerName; |
| 104 | } |
| 105 | |
| 106 | @Override |
| 107 | public TunnelName tunnelName() { |
| 108 | return tunnelName; |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 109 | } |
| 110 | |
samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame] | 111 | |
| 112 | @Override |
| 113 | public Path path() { |
| 114 | return path; |
| 115 | } |
| 116 | |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 117 | @Override |
| 118 | public String toString() { |
| 119 | return MoreObjects.toStringHelper(this) |
| 120 | .add("tunnelId", id()) |
| 121 | .add("src", src()) |
| 122 | .add("dst", dst()) |
| 123 | .add("type", type()) |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 124 | .add("tunnelName", tunnelName()) |
| 125 | .add("producerName", producerName()) |
| 126 | .add("groupId", groupId()) |
samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame] | 127 | .add("path", path) |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 128 | .toString(); |
| 129 | } |
wei wei | 89ddc32 | 2015-03-22 16:29:04 -0500 | [diff] [blame] | 130 | } |