blob: 055934a0ad8f49b39984db867befc00945821519 [file] [log] [blame]
wei wei89ddc322015-03-22 16:29:04 -05001/*
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 Vachuskabf916ea2015-05-20 18:24:34 -070016package org.onosproject.incubator.net.tunnel;
wei wei89ddc322015-03-22 16:29:04 -050017
Brian O'Connor2bed5ce2015-06-25 15:10:28 -040018import com.google.common.annotations.Beta;
jcc4a20a5f2015-04-30 15:43:39 +080019import org.onosproject.core.DefaultGroupId;
wei wei89ddc322015-03-22 16:29:04 -050020import org.onosproject.net.AbstractDescription;
samuel7a5691a2015-05-23 00:36:32 +080021import org.onosproject.net.Path;
wei wei89ddc322015-03-22 16:29:04 -050022import org.onosproject.net.SparseAnnotations;
jcc4a20a5f2015-04-30 15:43:39 +080023import org.onosproject.net.provider.ProviderId;
24
25import com.google.common.base.MoreObjects;
wei wei89ddc322015-03-22 16:29:04 -050026
27/**
28 * Default implementation of immutable tunnel description entity.
29 */
Brian O'Connor2bed5ce2015-06-25 15:10:28 -040030@Beta
wei wei89ddc322015-03-22 16:29:04 -050031public class DefaultTunnelDescription extends AbstractDescription
32 implements TunnelDescription {
33
jcc4a20a5f2015-04-30 15:43:39 +080034 private final TunnelId tunnelId;
35 private final TunnelEndPoint src;
36 private final TunnelEndPoint dst;
wei wei89ddc322015-03-22 16:29:04 -050037 private final Tunnel.Type type;
jcc4a20a5f2015-04-30 15:43:39 +080038 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
samuel7a5691a2015-05-23 00:36:32 +080043 private final Path path;
wei wei89ddc322015-03-22 16:29:04 -050044
45 /**
46 * Creates a tunnel description using the supplied information.
47 *
jcc4a20a5f2015-04-30 15:43:39 +080048 * @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
samuel7a5691a2015-05-23 00:36:32 +080055 * @param path the path of tunnel
wei wei89ddc322015-03-22 16:29:04 -050056 * @param annotations optional key/value annotations
57 */
jcc4a20a5f2015-04-30 15:43:39 +080058 public DefaultTunnelDescription(TunnelId id, TunnelEndPoint src,
59 TunnelEndPoint dst, Tunnel.Type type,
60 DefaultGroupId groupId,
61 ProviderId producerName,
62 TunnelName tunnelName,
samuel7a5691a2015-05-23 00:36:32 +080063 Path path,
jcc4a20a5f2015-04-30 15:43:39 +080064 SparseAnnotations... annotations) {
wei wei89ddc322015-03-22 16:29:04 -050065 super(annotations);
66 this.tunnelId = id;
67 this.src = src;
68 this.dst = dst;
69 this.type = type;
jcc4a20a5f2015-04-30 15:43:39 +080070 this.groupId = groupId;
71 this.producerName = producerName;
72 this.tunnelName = tunnelName;
samuel7a5691a2015-05-23 00:36:32 +080073 this.path = path;
wei wei89ddc322015-03-22 16:29:04 -050074 }
75
76 @Override
77 public TunnelId id() {
78 return tunnelId;
79 }
80
81 @Override
jcc4a20a5f2015-04-30 15:43:39 +080082 public TunnelEndPoint src() {
wei wei89ddc322015-03-22 16:29:04 -050083 return src;
84 }
85
86 @Override
jcc4a20a5f2015-04-30 15:43:39 +080087 public TunnelEndPoint dst() {
wei wei89ddc322015-03-22 16:29:04 -050088 return dst;
89 }
90
91 @Override
92 public Tunnel.Type type() {
93 return type;
94 }
95
96 @Override
jcc4a20a5f2015-04-30 15:43:39 +080097 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 wei89ddc322015-03-22 16:29:04 -0500109 }
110
samuel7a5691a2015-05-23 00:36:32 +0800111
112 @Override
113 public Path path() {
114 return path;
115 }
116
wei wei89ddc322015-03-22 16:29:04 -0500117 @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())
jcc4a20a5f2015-04-30 15:43:39 +0800124 .add("tunnelName", tunnelName())
125 .add("producerName", producerName())
126 .add("groupId", groupId())
samuel7a5691a2015-05-23 00:36:32 +0800127 .add("path", path)
wei wei89ddc322015-03-22 16:29:04 -0500128 .toString();
129 }
wei wei89ddc322015-03-22 16:29:04 -0500130}