jcc
Committed by Gerrit Code Review

[ONOS-700][ONOS-1801]refactor tunnel subsystem api.

1.use more abstract and more flexible entity[TunnelPoint] to represent
for source or destination point of tunnel,instead of Label
2.suport for muti-producer
3.use Order entity to record tunnel-order relationship
4.modify Tunnel entity to add more properties.
5.rename Label and LabelId to OpticalTunnelPoint and OpticalLogicId in
order to keep code style consistently,at the same time
OpticalTunnelPoint implements TunnelPoint
6.add junit test

Change-Id: I371afcef5501e468a43758c5982e7a93b443b114
Showing 23 changed files with 1157 additions and 447 deletions
1 package org.onosproject.net.tunnel; 1 package org.onosproject.net.tunnel;
2 2
3 +import static com.google.common.base.Preconditions.checkNotNull;
3 import static com.google.common.base.MoreObjects.toStringHelper; 4 import static com.google.common.base.MoreObjects.toStringHelper;
4 5
5 import java.util.Objects; 6 import java.util.Objects;
...@@ -12,43 +13,46 @@ import org.onosproject.net.PortNumber; ...@@ -12,43 +13,46 @@ import org.onosproject.net.PortNumber;
12 import org.onosproject.net.provider.ProviderId; 13 import org.onosproject.net.provider.ProviderId;
13 14
14 /** 15 /**
15 - * Default label model implementation. 16 + * Default optical tunnel point model implementation.
16 */ 17 */
17 -public class DefaultLabel extends AbstractModel implements Label { 18 +public class DefaultOpticalTunnelEndPoint extends AbstractModel implements OpticalTunnelEndPoint {
18 private final Optional<ElementId> elementId; 19 private final Optional<ElementId> elementId;
19 private final Optional<PortNumber> portNumber; 20 private final Optional<PortNumber> portNumber;
20 - private final Optional<Label> parentLabel; 21 + private final Optional<OpticalTunnelEndPoint> parentPoint;
21 private final Type type; 22 private final Type type;
22 - private final LabelId id; 23 + private final OpticalLogicId id;
23 private final boolean isGlobal; 24 private final boolean isGlobal;
24 25
25 /** 26 /**
26 - * Creates a label attributed to the specified provider (may be null). 27 + * Creates a optical tunnel point attributed to the specified provider (may be null).
27 - * if provider is null, which means the label is not managed by the SB. 28 + * if provider is null, which means the optical tunnel point is not managed by the SB.
28 * 29 *
29 * @param providerId tunnelProvider Id 30 * @param providerId tunnelProvider Id
30 * @param elementId parent network element 31 * @param elementId parent network element
31 * @param number port number 32 * @param number port number
32 - * @param parentLabel parent port or parent label 33 + * @param parentPoint parent port or parent label
33 * @param type port type 34 * @param type port type
34 * @param id LabelId 35 * @param id LabelId
35 * @param isGlobal indicator whether the label is global significant or not 36 * @param isGlobal indicator whether the label is global significant or not
36 * @param annotations optional key/value annotations 37 * @param annotations optional key/value annotations
37 */ 38 */
38 - public DefaultLabel(ProviderId providerId, Optional<ElementId> elementId, 39 + public DefaultOpticalTunnelEndPoint(ProviderId providerId, Optional<ElementId> elementId,
39 - Optional<PortNumber> number, Optional<Label> parentLabel, 40 + Optional<PortNumber> number, Optional<OpticalTunnelEndPoint> parentPoint,
40 - Type type, LabelId id, boolean isGlobal, Annotations... annotations) { 41 + Type type, OpticalLogicId id, boolean isGlobal, Annotations... annotations) {
41 super(providerId, annotations); 42 super(providerId, annotations);
43 + checkNotNull(type, "type cannot be null");
44 + checkNotNull(id, "id cannot be null");
45 + checkNotNull(isGlobal, "isGlobal cannot be null");
42 this.elementId = elementId; 46 this.elementId = elementId;
43 this.portNumber = number; 47 this.portNumber = number;
44 - this.parentLabel = parentLabel; 48 + this.parentPoint = parentPoint;
45 this.id = id; 49 this.id = id;
46 this.type = type; 50 this.type = type;
47 this.isGlobal = isGlobal; 51 this.isGlobal = isGlobal;
48 } 52 }
49 53
50 @Override 54 @Override
51 - public LabelId id() { 55 + public OpticalLogicId id() {
52 return id; 56 return id;
53 } 57 }
54 58
...@@ -63,8 +67,8 @@ public class DefaultLabel extends AbstractModel implements Label { ...@@ -63,8 +67,8 @@ public class DefaultLabel extends AbstractModel implements Label {
63 } 67 }
64 68
65 @Override 69 @Override
66 - public Optional<Label> parentLabel() { 70 + public Optional<OpticalTunnelEndPoint> parentPoint() {
67 - return parentLabel; 71 + return parentPoint;
68 } 72 }
69 73
70 @Override 74 @Override
...@@ -79,7 +83,7 @@ public class DefaultLabel extends AbstractModel implements Label { ...@@ -79,7 +83,7 @@ public class DefaultLabel extends AbstractModel implements Label {
79 83
80 @Override 84 @Override
81 public int hashCode() { 85 public int hashCode() {
82 - return Objects.hash(elementId, portNumber, parentLabel, id); 86 + return Objects.hash(elementId, portNumber, parentPoint, id);
83 } 87 }
84 88
85 @Override 89 @Override
...@@ -87,14 +91,14 @@ public class DefaultLabel extends AbstractModel implements Label { ...@@ -87,14 +91,14 @@ public class DefaultLabel extends AbstractModel implements Label {
87 if (this == obj) { 91 if (this == obj) {
88 return true; 92 return true;
89 } 93 }
90 - if (obj instanceof DefaultLabel) { 94 + if (obj instanceof DefaultOpticalTunnelEndPoint) {
91 - final DefaultLabel other = (DefaultLabel) obj; 95 + final DefaultOpticalTunnelEndPoint other = (DefaultOpticalTunnelEndPoint) obj;
92 return Objects.equals(this.id, other.id) && 96 return Objects.equals(this.id, other.id) &&
93 Objects.equals(this.type, other.type) && 97 Objects.equals(this.type, other.type) &&
94 Objects.equals(this.isGlobal, other.isGlobal) && 98 Objects.equals(this.isGlobal, other.isGlobal) &&
95 Objects.equals(this.elementId, other.elementId) && 99 Objects.equals(this.elementId, other.elementId) &&
96 Objects.equals(this.portNumber, other.portNumber) && 100 Objects.equals(this.portNumber, other.portNumber) &&
97 - Objects.equals(this.parentLabel, other.parentLabel); 101 + Objects.equals(this.parentPoint, other.parentPoint);
98 } 102 }
99 return false; 103 return false;
100 } 104 }
...@@ -104,7 +108,7 @@ public class DefaultLabel extends AbstractModel implements Label { ...@@ -104,7 +108,7 @@ public class DefaultLabel extends AbstractModel implements Label {
104 return toStringHelper(this) 108 return toStringHelper(this)
105 .add("elementId", elementId) 109 .add("elementId", elementId)
106 .add("portNumber", portNumber) 110 .add("portNumber", portNumber)
107 - .add("parentLabel", parentLabel) 111 + .add("parentPoint", parentPoint)
108 .add("type", type) 112 .add("type", type)
109 .add("id", id) 113 .add("id", id)
110 .add("isGlobal", isGlobal) 114 .add("isGlobal", isGlobal)
......
1 package org.onosproject.net.tunnel; 1 package org.onosproject.net.tunnel;
2 2
3 +import static com.google.common.base.Preconditions.checkNotNull;
3 import static com.google.common.base.MoreObjects.toStringHelper; 4 import static com.google.common.base.MoreObjects.toStringHelper;
4 -import static com.google.common.base.Preconditions.checkState;
5 5
6 import java.util.Objects; 6 import java.util.Objects;
7 7
8 -import org.onosproject.core.IdGenerator; 8 +import org.onosproject.core.DefaultGroupId;
9 import org.onosproject.net.AbstractModel; 9 import org.onosproject.net.AbstractModel;
10 import org.onosproject.net.Annotations; 10 import org.onosproject.net.Annotations;
11 +import org.onosproject.net.NetworkResource;
11 import org.onosproject.net.provider.ProviderId; 12 import org.onosproject.net.provider.ProviderId;
12 -import org.onosproject.net.resource.BandwidthResource;
13 13
14 /** 14 /**
15 - * Default tunnel model implementation. 15 + * The default implementation of an network tunnel. supports for creating a
16 + * tunnel by connect point ,IP address, MAC address, device and so on.
16 */ 17 */
17 public final class DefaultTunnel extends AbstractModel implements Tunnel { 18 public final class DefaultTunnel extends AbstractModel implements Tunnel {
18 - private final TunnelId id; 19 +
19 - private final Label src; 20 + private final TunnelEndPoint src; // a source point of tunnel.
20 - private final Label dst; 21 + private final TunnelEndPoint dst; // a destination point of tunnel.
21 - private final Type type;
22 private final State state; 22 private final State state;
23 - private final boolean isDurable; 23 + private final Type type; // tunnel type
24 - private final boolean isBidirectional; 24 + private final DefaultGroupId groupId; // represent for a group flow table
25 - private final BandwidthResource bandwidth; 25 + // which a tunnel match up
26 + // tunnel producer
27 + private final TunnelId tunnelId; // tunnel identify generated by
28 + // ONOS as primary key
29 + private final TunnelName tunnelName; // name of a tunnel
26 30
27 /** 31 /**
28 - * Constructs an tunnel using the builder pattern. 32 + * Creates an active infrastructure tunnel using the supplied information.
29 * 33 *
30 - * @param providerId provider identity, can be null if comes from the NB 34 + * @param producerName provider identity
31 - * @param builder tunnelBuilder 35 + * @param src tunnel source
36 + * @param dst tunnel destination
37 + * @param type tunnel type
38 + * @param groupId groupId
39 + * @param tunnelId tunnelId
40 + * @param tunnelName tunnel name
32 * @param annotations optional key/value annotations 41 * @param annotations optional key/value annotations
33 - * @return
34 */ 42 */
35 - private DefaultTunnel(ProviderId providerId, TunnelBuilder builder, Annotations... annotations) { 43 + public DefaultTunnel(ProviderId producerName, TunnelEndPoint src,
36 - super(providerId, annotations); 44 + TunnelEndPoint dst, Type type, DefaultGroupId groupId,
37 - this.id = builder.id; 45 + TunnelId tunnelId, TunnelName tunnelName,
38 - this.src = builder.src; 46 + Annotations... annotations) {
39 - this.dst = builder.dst; 47 + this(producerName, src, dst, type, Tunnel.State.ACTIVE, groupId,
40 - this.type = builder.type; 48 + tunnelId, tunnelName, annotations);
41 - this.state = builder.state;
42 - this.isDurable = builder.isDurable;
43 - this.isBidirectional = builder.isBidirectional;
44 - this.bandwidth = builder.bandwidth;
45 } 49 }
46 50
47 - @Override 51 + /**
48 - public TunnelId id() { 52 + * Creates an tunnel using the supplied information.
49 - return id; 53 + *
54 + * @param producerName provider identity
55 + * @param src tunnel source
56 + * @param dst tunnel destination
57 + * @param type tunnel type
58 + * @param state tunnel state
59 + * @param groupId groupId
60 + * @param tunnelId tunnelId
61 + * @param tunnelName tunnel name
62 + * @param annotations optional key/value annotations
63 + */
64 + public DefaultTunnel(ProviderId producerName, TunnelEndPoint src,
65 + TunnelEndPoint dst, Type type, State state,
66 + DefaultGroupId groupId, TunnelId tunnelId,
67 + TunnelName tunnelName, Annotations... annotations) {
68 + super(producerName, annotations);
69 + checkNotNull(producerName, "producerName cannot be null");
70 + checkNotNull(src, "src cannot be null");
71 + checkNotNull(dst, "dst cannot be null");
72 + checkNotNull(type, "type cannot be null");
73 + checkNotNull(state, "state cannot be null");
74 + this.src = src;
75 + this.dst = dst;
76 + this.type = type;
77 + this.state = state;
78 + this.groupId = groupId;
79 + this.tunnelId = tunnelId;
80 + this.tunnelName = tunnelName;
50 } 81 }
51 82
52 @Override 83 @Override
53 - public Label src() { 84 + public TunnelEndPoint src() {
54 return src; 85 return src;
55 } 86 }
56 87
57 @Override 88 @Override
58 - public Label dst() { 89 + public TunnelEndPoint dst() {
59 return dst; 90 return dst;
60 } 91 }
61 92
...@@ -70,29 +101,31 @@ public final class DefaultTunnel extends AbstractModel implements Tunnel { ...@@ -70,29 +101,31 @@ public final class DefaultTunnel extends AbstractModel implements Tunnel {
70 } 101 }
71 102
72 @Override 103 @Override
73 - public boolean isDurable() { 104 + public NetworkResource resource() {
74 - return isDurable; 105 + return null;
75 } 106 }
76 107
77 @Override 108 @Override
78 - public boolean isBidirectional() { 109 + public TunnelId tunnelId() {
79 - return isBidirectional; 110 + return tunnelId;
80 } 111 }
81 112
82 @Override 113 @Override
83 - public BandwidthResource bandwidth() { 114 + public DefaultGroupId groupId() {
84 - return bandwidth; 115 + return groupId;
116 + }
117 +
118 + @Override
119 + public TunnelName tunnelName() {
120 + return tunnelName;
85 } 121 }
86 122
87 @Override 123 @Override
88 public int hashCode() { 124 public int hashCode() {
89 - return Objects.hash(id); 125 + return Objects.hash(src, dst, type, groupId, tunnelId, tunnelName,
126 + state);
90 } 127 }
91 128
92 - /**
93 - * {@inheritDoc}
94 - * Note that only TunnelId is considered on equality check.
95 - */
96 @Override 129 @Override
97 public boolean equals(Object obj) { 130 public boolean equals(Object obj) {
98 if (this == obj) { 131 if (this == obj) {
...@@ -100,69 +133,23 @@ public final class DefaultTunnel extends AbstractModel implements Tunnel { ...@@ -100,69 +133,23 @@ public final class DefaultTunnel extends AbstractModel implements Tunnel {
100 } 133 }
101 if (obj instanceof DefaultTunnel) { 134 if (obj instanceof DefaultTunnel) {
102 final DefaultTunnel other = (DefaultTunnel) obj; 135 final DefaultTunnel other = (DefaultTunnel) obj;
103 - return Objects.equals(this.id, other.id); 136 + return Objects.equals(this.src, other.src)
137 + && Objects.equals(this.dst, other.dst)
138 + && Objects.equals(this.type, other.type)
139 + && Objects.equals(this.groupId, other.groupId)
140 + && Objects.equals(this.tunnelId, other.tunnelId)
141 + && Objects.equals(this.tunnelName, other.tunnelName)
142 + && Objects.equals(this.state, other.state);
104 } 143 }
105 return false; 144 return false;
106 } 145 }
107 146
108 @Override 147 @Override
109 public String toString() { 148 public String toString() {
110 - return toStringHelper(this) 149 + return toStringHelper(this).add("src", src).add("dst", dst)
111 - .add("tunnelId", id) 150 + .add("type", type).add("state", state).add("groupId", groupId)
112 - .add("src", src) 151 + .add("producerTunnelId", tunnelId)
113 - .add("dst", dst) 152 + .add("tunnelName", tunnelName).toString();
114 - .add("type", type)
115 - .add("state", state)
116 - .add("durable", isDurable)
117 - .add("isBidirectional", isBidirectional)
118 - .add("bandwidth", bandwidth)
119 - .toString();
120 - }
121 -
122 - public static class TunnelBuilder {
123 - private TunnelId id = null;
124 - private Label src = null;
125 - private Label dst = null;
126 - private Type type = null;
127 - private State state = null;
128 - private boolean isDurable = false;
129 - private boolean isBidirectional = false;
130 - private BandwidthResource bandwidth = null;
131 -
132 - private static IdGenerator idGenerator;
133 -
134 - public TunnelBuilder labelSrcDst(Label src, Label dst) {
135 - this.src = src;
136 - this.dst = dst;
137 - return this;
138 - }
139 -
140 - public TunnelBuilder state(State state) {
141 - this.state = state;
142 - return this;
143 - }
144 -
145 - public TunnelBuilder isDurable(boolean isDurable) {
146 - this.isDurable = isDurable;
147 - return this;
148 - }
149 -
150 - public TunnelBuilder isBidirectional(boolean isBidirectional) {
151 - this.isBidirectional = isBidirectional;
152 - return this;
153 - }
154 -
155 - public TunnelBuilder bandwidth(BandwidthResource bandwidth) {
156 - this.bandwidth = bandwidth;
157 - return this;
158 - }
159 -
160 - public DefaultTunnel build(ProviderId providerId, Annotations... annotations) {
161 - checkState(idGenerator != null, "Id generator is not bound.");
162 - this.id = TunnelId.valueOf(idGenerator.getNewId());
163 - return new DefaultTunnel(providerId, this, annotations);
164 - }
165 -
166 } 153 }
167 154
168 } 155 }
......
...@@ -15,11 +15,13 @@ ...@@ -15,11 +15,13 @@
15 */ 15 */
16 package org.onosproject.net.tunnel; 16 package org.onosproject.net.tunnel;
17 17
18 -import com.google.common.base.MoreObjects; 18 +import static com.google.common.base.Preconditions.checkNotNull;
19 - 19 +import org.onosproject.core.DefaultGroupId;
20 import org.onosproject.net.AbstractDescription; 20 import org.onosproject.net.AbstractDescription;
21 -import org.onosproject.net.ConnectPoint;
22 import org.onosproject.net.SparseAnnotations; 21 import org.onosproject.net.SparseAnnotations;
22 +import org.onosproject.net.provider.ProviderId;
23 +
24 +import com.google.common.base.MoreObjects;
23 25
24 /** 26 /**
25 * Default implementation of immutable tunnel description entity. 27 * Default implementation of immutable tunnel description entity.
...@@ -28,30 +30,45 @@ public class DefaultTunnelDescription extends AbstractDescription ...@@ -28,30 +30,45 @@ public class DefaultTunnelDescription extends AbstractDescription
28 implements TunnelDescription { 30 implements TunnelDescription {
29 31
30 private final TunnelId tunnelId; 32 private final TunnelId tunnelId;
31 - private final ConnectPoint src; 33 + private final TunnelEndPoint src;
32 - private final ConnectPoint dst; 34 + private final TunnelEndPoint dst;
33 private final Tunnel.Type type; 35 private final Tunnel.Type type;
34 - private final boolean isBidirectional; 36 + private final DefaultGroupId groupId; // represent for a group flow table
37 + // which a tunnel match up
38 + // tunnel producer
39 + private final ProviderId producerName; // tunnel producer name
40 + private final TunnelName tunnelName; // name of a tunnel
35 41
36 /** 42 /**
37 * Creates a tunnel description using the supplied information. 43 * Creates a tunnel description using the supplied information.
38 * 44 *
39 * @param id TunnelId 45 * @param id TunnelId
40 - * @param src ConnectPoint source 46 + * @param src TunnelPoint source
41 - * @param dst ConnectPoint destination 47 + * @param dst TunnelPoint destination
42 * @param type tunnel type 48 * @param type tunnel type
43 - * @param isBidirectional boolean 49 + * @param groupId groupId
50 + * @param producerName tunnel producer
51 + * @param tunnelName tunnel name
44 * @param annotations optional key/value annotations 52 * @param annotations optional key/value annotations
45 */ 53 */
46 - public DefaultTunnelDescription(TunnelId id, ConnectPoint src, ConnectPoint dst, 54 + public DefaultTunnelDescription(TunnelId id, TunnelEndPoint src,
47 - Tunnel.Type type, boolean isBidirectional, 55 + TunnelEndPoint dst, Tunnel.Type type,
56 + DefaultGroupId groupId,
57 + ProviderId producerName,
58 + TunnelName tunnelName,
48 SparseAnnotations... annotations) { 59 SparseAnnotations... annotations) {
49 super(annotations); 60 super(annotations);
61 + checkNotNull(producerName, "producerName cannot be null");
62 + checkNotNull(src, "src cannot be null");
63 + checkNotNull(dst, "dst cannot be null");
64 + checkNotNull(type, "type cannot be null");
50 this.tunnelId = id; 65 this.tunnelId = id;
51 this.src = src; 66 this.src = src;
52 this.dst = dst; 67 this.dst = dst;
53 this.type = type; 68 this.type = type;
54 - this.isBidirectional = isBidirectional; 69 + this.groupId = groupId;
70 + this.producerName = producerName;
71 + this.tunnelName = tunnelName;
55 } 72 }
56 73
57 @Override 74 @Override
...@@ -60,12 +77,12 @@ public class DefaultTunnelDescription extends AbstractDescription ...@@ -60,12 +77,12 @@ public class DefaultTunnelDescription extends AbstractDescription
60 } 77 }
61 78
62 @Override 79 @Override
63 - public ConnectPoint src() { 80 + public TunnelEndPoint src() {
64 return src; 81 return src;
65 } 82 }
66 83
67 @Override 84 @Override
68 - public ConnectPoint dst() { 85 + public TunnelEndPoint dst() {
69 return dst; 86 return dst;
70 } 87 }
71 88
...@@ -75,8 +92,18 @@ public class DefaultTunnelDescription extends AbstractDescription ...@@ -75,8 +92,18 @@ public class DefaultTunnelDescription extends AbstractDescription
75 } 92 }
76 93
77 @Override 94 @Override
78 - public boolean isBidirectional() { 95 + public DefaultGroupId groupId() {
79 - return isBidirectional; 96 + return groupId;
97 + }
98 +
99 + @Override
100 + public ProviderId producerName() {
101 + return producerName;
102 + }
103 +
104 + @Override
105 + public TunnelName tunnelName() {
106 + return tunnelName;
80 } 107 }
81 108
82 @Override 109 @Override
...@@ -86,7 +113,9 @@ public class DefaultTunnelDescription extends AbstractDescription ...@@ -86,7 +113,9 @@ public class DefaultTunnelDescription extends AbstractDescription
86 .add("src", src()) 113 .add("src", src())
87 .add("dst", dst()) 114 .add("dst", dst())
88 .add("type", type()) 115 .add("type", type())
89 - .add("isBidirectional", isBidirectional()) 116 + .add("tunnelName", tunnelName())
117 + .add("producerName", producerName())
118 + .add("groupId", groupId())
90 .toString(); 119 .toString();
91 } 120 }
92 121
......
1 +package org.onosproject.net.tunnel;
2 +
3 +import java.util.Objects;
4 +
5 +import org.onlab.packet.IpAddress;
6 +
7 +import com.google.common.base.MoreObjects;
8 +/**
9 + * Represent for a tunnel point using ip address.
10 + */
11 +public final class IpTunnelEndPoint implements TunnelEndPoint {
12 +
13 + private final IpAddress ip;
14 +
15 + /**
16 + * Public construction is prohibited.
17 + * @param ip ip address
18 + */
19 + private IpTunnelEndPoint(IpAddress ip) {
20 + this.ip = ip;
21 + }
22 +
23 + /**
24 + * Create a IP tunnel end point.
25 + * @param ip IP address
26 + * @return IpTunnelEndPoint
27 + */
28 + public static IpTunnelEndPoint ipTunnelPoint(IpAddress ip) {
29 + return new IpTunnelEndPoint(ip);
30 + }
31 +
32 + @Override
33 + public int hashCode() {
34 + return Objects.hash(ip);
35 + }
36 +
37 + @Override
38 + public boolean equals(Object obj) {
39 + if (this == obj) {
40 + return true;
41 + }
42 + if (obj instanceof IpTunnelEndPoint) {
43 + final IpTunnelEndPoint other = (IpTunnelEndPoint) obj;
44 + return Objects.equals(this.ip, other.ip);
45 + }
46 + return false;
47 + }
48 +
49 + @Override
50 + public String toString() {
51 + return MoreObjects.toStringHelper(getClass()).add("ip", ip).toString();
52 + }
53 +}
...@@ -21,17 +21,17 @@ import com.google.common.primitives.UnsignedLongs; ...@@ -21,17 +21,17 @@ import com.google.common.primitives.UnsignedLongs;
21 /** 21 /**
22 * Representation of a label Id, a logical port identifier. 22 * Representation of a label Id, a logical port identifier.
23 */ 23 */
24 -public final class LabelId { 24 +public final class OpticalLogicId {
25 /** 25 /**
26 * Represents a logical Id. 26 * Represents a logical Id.
27 */ 27 */
28 - private final long labelId; 28 + private final long logicId;
29 29
30 /** 30 /**
31 * Constructor, public creation is prohibited. 31 * Constructor, public creation is prohibited.
32 */ 32 */
33 - private LabelId(long id) { 33 + private OpticalLogicId(long id) {
34 - this.labelId = id; 34 + this.logicId = id;
35 } 35 }
36 36
37 /** 37 /**
...@@ -40,26 +40,26 @@ public final class LabelId { ...@@ -40,26 +40,26 @@ public final class LabelId {
40 * @param id identifier as long value 40 * @param id identifier as long value
41 * @return LabelId 41 * @return LabelId
42 */ 42 */
43 - public static LabelId labelId(long id) { 43 + public static OpticalLogicId logicId(long id) {
44 - return new LabelId(id); 44 + return new OpticalLogicId(id);
45 } 45 }
46 46
47 - public static LabelId labelId(String string) { 47 + public static OpticalLogicId logicId(String string) {
48 - return new LabelId(UnsignedLongs.decode(string)); 48 + return new OpticalLogicId(UnsignedLongs.decode(string));
49 } 49 }
50 50
51 public long toLong() { 51 public long toLong() {
52 - return labelId; 52 + return logicId;
53 } 53 }
54 54
55 @Override 55 @Override
56 public String toString() { 56 public String toString() {
57 - return UnsignedLongs.toString(labelId); 57 + return UnsignedLongs.toString(logicId);
58 } 58 }
59 59
60 @Override 60 @Override
61 public int hashCode() { 61 public int hashCode() {
62 - return Objects.hash(labelId); 62 + return Objects.hash(logicId);
63 } 63 }
64 64
65 @Override 65 @Override
...@@ -67,9 +67,9 @@ public final class LabelId { ...@@ -67,9 +67,9 @@ public final class LabelId {
67 if (this == obj) { 67 if (this == obj) {
68 return true; 68 return true;
69 } 69 }
70 - if (obj instanceof LabelId) { 70 + if (obj instanceof OpticalLogicId) {
71 - final LabelId other = (LabelId) obj; 71 + final OpticalLogicId other = (OpticalLogicId) obj;
72 - return this.labelId == other.labelId; 72 + return this.logicId == other.logicId;
73 } 73 }
74 return false; 74 return false;
75 } 75 }
......
...@@ -25,76 +25,51 @@ import org.onosproject.net.Provided; ...@@ -25,76 +25,51 @@ import org.onosproject.net.Provided;
25 25
26 /** 26 /**
27 * Generic representation of a logical port entity in a consistent way, 27 * Generic representation of a logical port entity in a consistent way,
28 - * it is used to identify e.g., VLAN#, MPLS label#, ODUk timeSlot, WDM lambda, etc. 28 + * it is used to identify e.g., ODUk timeSlot, WDM lambda, etc.
29 * It supports nested case. 29 * It supports nested case.
30 */ 30 */
31 -public interface Label extends Annotated, Provided, NetworkResource { 31 +public interface OpticalTunnelEndPoint extends TunnelEndPoint, Annotated, Provided, NetworkResource {
32 32
33 - /** Represents coarse Label type classification. */ 33 + /** Represents coarse tunnel point type classification. */
34 - enum Type { 34 + public enum Type {
35 /** 35 /**
36 - * Signifies VLAN-based tag. 36 + * Signifies optical data unit-based tunnel point.
37 - */
38 - VLAN,
39 -
40 - /**
41 - * Signifies LAG-based label.
42 - */
43 - LAG,
44 -
45 - /**
46 - * Signifies MPLS-based label.
47 - */
48 - MPLS,
49 -
50 - /**
51 - * Signifies IP-based label.
52 - */
53 - IP,
54 -
55 - /**
56 - * Signifies optical data unit-based label.
57 */ 37 */
58 TIMESLOT, 38 TIMESLOT,
59 39
60 /** 40 /**
61 - * Signifies optical wavelength-based label. 41 + * Signifies optical wavelength-based tunnel point.
62 - */
63 - LAMBDA,
64 -
65 - /**
66 - * Signifies device-based identifier for the label.
67 */ 42 */
68 - DEVICE 43 + LAMBDA
69 } 44 }
70 45
71 /** 46 /**
72 - * Returns the identifier to this Label. 47 + * Returns the identifier.
73 * 48 *
74 * @return identifier 49 * @return identifier
75 */ 50 */
76 - LabelId id(); 51 + OpticalLogicId id();
77 52
78 /** 53 /**
79 - * Returns the parent network element to which this label belongs. 54 + * Returns the parent network element to which this tunnel point belongs.
80 * 55 *
81 * @return parent network element 56 * @return parent network element
82 */ 57 */
83 Optional<ElementId> elementId(); 58 Optional<ElementId> elementId();
84 59
85 /** 60 /**
86 - * Returns the parent network port to which this label belongs, can not be be null. 61 + * Returns the parent network port to which this tunnel point belongs, can not be be null.
87 * 62 *
88 * @return port number 63 * @return port number
89 */ 64 */
90 Optional<PortNumber> portNumber(); 65 Optional<PortNumber> portNumber();
91 66
92 /** 67 /**
93 - * Returns the parent label to which this label belongs, optional. 68 + * Returns the parent tunnel point to which this tunnel point belongs, optional.
94 * 69 *
95 - * @return parent label, if it is null, the parent is a physical port 70 + * @return parent tunnel point, if it is null, the parent is a physical port
96 */ 71 */
97 - Optional<Label> parentLabel(); 72 + Optional<OpticalTunnelEndPoint> parentPoint();
98 73
99 /** 74 /**
100 * Indicates whether or not the port is global significant. 75 * Indicates whether or not the port is global significant.
...@@ -104,9 +79,9 @@ public interface Label extends Annotated, Provided, NetworkResource { ...@@ -104,9 +79,9 @@ public interface Label extends Annotated, Provided, NetworkResource {
104 boolean isGlobal(); 79 boolean isGlobal();
105 80
106 /** 81 /**
107 - * Returns the label type. 82 + * Returns the tunnel point type.
108 * 83 *
109 - * @return label type 84 + * @return tunnel point type
110 */ 85 */
111 Type type(); 86 Type type();
112 } 87 }
......
...@@ -15,50 +15,44 @@ ...@@ -15,50 +15,44 @@
15 */ 15 */
16 package org.onosproject.net.tunnel; 16 package org.onosproject.net.tunnel;
17 17
18 +import org.onosproject.core.DefaultGroupId;
18 import org.onosproject.net.Annotated; 19 import org.onosproject.net.Annotated;
19 import org.onosproject.net.NetworkResource; 20 import org.onosproject.net.NetworkResource;
20 import org.onosproject.net.Provided; 21 import org.onosproject.net.Provided;
21 -import org.onosproject.net.resource.BandwidthResource;
22 -
23 22
24 /** 23 /**
25 - * Abstraction of a generalized Tunnel entity (bandwidth pipe) for either L3/L2 networks or L1/L0 networks, 24 + * Abstraction of a generalized Tunnel entity (bandwidth pipe) for either L3/L2
26 - * representation of e.g., VLAN, GRE tunnel, MPLS LSP, L1 ODUk connection, WDM OCH, etc.. Each Tunnel is 25 + * networks or L1/L0 networks, representation of e.g., VLAN, GRE tunnel, MPLS
27 - * associated with at least two Label objects that model the logical ports essentially. 26 + * LSP, L1 ODUk connection, WDM OCH, etc.. Each Tunnel is associated with at
27 + * least two tunnel end point objects that model the logical ports essentially.
28 * Note that it supports nested case. 28 * Note that it supports nested case.
29 */ 29 */
30 -
31 public interface Tunnel extends Annotated, Provided, NetworkResource { 30 public interface Tunnel extends Annotated, Provided, NetworkResource {
32 31
33 /** 32 /**
34 - * Coarse representation of the Tunnel types. 33 + * Tunnel technology type.
35 */ 34 */
36 enum Type { 35 enum Type {
37 /** 36 /**
37 + * Signifies that this is a MPLS tunnel.
38 + */
39 + MPLS,
40 + /**
38 * Signifies that this is a L2 tunnel. 41 * Signifies that this is a L2 tunnel.
39 */ 42 */
40 VLAN, 43 VLAN,
41 -
42 /** 44 /**
43 * Signifies that this is a DC L2 extension tunnel. 45 * Signifies that this is a DC L2 extension tunnel.
44 */ 46 */
45 VXLAN, 47 VXLAN,
46 -
47 /** 48 /**
48 * Signifies that this is a L3 tunnel. 49 * Signifies that this is a L3 tunnel.
49 */ 50 */
50 GRE, 51 GRE,
51 -
52 - /**
53 - * Signifies that this is a MPLS tunnel.
54 - */
55 - LSP,
56 -
57 /** 52 /**
58 * Signifies that this is a L1 OTN tunnel. 53 * Signifies that this is a L1 OTN tunnel.
59 */ 54 */
60 - ODUk, 55 + ODUK,
61 -
62 /** 56 /**
63 * Signifies that this is a L0 OCH tunnel. 57 * Signifies that this is a L0 OCH tunnel.
64 */ 58 */
...@@ -67,53 +61,52 @@ public interface Tunnel extends Annotated, Provided, NetworkResource { ...@@ -67,53 +61,52 @@ public interface Tunnel extends Annotated, Provided, NetworkResource {
67 61
68 /** 62 /**
69 * Representation of the tunnel state. 63 * Representation of the tunnel state.
70 - *
71 */ 64 */
72 - enum State { 65 + public enum State {
73 -
74 /** 66 /**
75 * Signifies that a tunnel is currently in a initialized state. 67 * Signifies that a tunnel is currently in a initialized state.
76 */ 68 */
77 INIT, 69 INIT,
78 -
79 /** 70 /**
80 * Signifies that a tunnel is currently established but no traffic. 71 * Signifies that a tunnel is currently established but no traffic.
81 */ 72 */
82 ESTABLISHED, 73 ESTABLISHED,
83 -
84 /** 74 /**
85 - * Signifies that a tunnel is currently serving the traffic. 75 + * Signifies that a tunnel is currently active. This state means that
76 + * this tunnel is available. It can be borrowed by consumer.
86 */ 77 */
87 ACTIVE, 78 ACTIVE,
88 -
89 /** 79 /**
90 * Signifies that a tunnel is currently out of service. 80 * Signifies that a tunnel is currently out of service.
91 */ 81 */
92 FAILED, 82 FAILED,
93 -
94 /** 83 /**
95 - * Signifies that a tunnel is currently in maintenance state. 84 + * Signifies that a tunnel is currently inactive. This state means that
85 + * this tunnel can not be borrowed by consumer.
96 */ 86 */
97 INACTIVE 87 INACTIVE
98 -
99 } 88 }
100 89
101 - TunnelId id(); 90 + /**
102 - 91 + * Returns the tunnel state.
92 + *
93 + * @return tunnel state
94 + */
95 + State state();
103 96
104 /** 97 /**
105 - * Returns the tunnel source point (source Label object). 98 + * the origin of a tunnel.
106 * 99 *
107 - * @return source Label object 100 + * @return the origin of a tunnel
108 */ 101 */
109 - Label src(); 102 + TunnelEndPoint src();
110 103
111 /** 104 /**
112 - * Returns the tunnel destination point (destination Label object). 105 + * the terminal of a tunnel.
113 * 106 *
114 - * @return destination Label object 107 + * @return the terminal of a tunnel
115 */ 108 */
116 - Label dst(); 109 + TunnelEndPoint dst();
117 110
118 /** 111 /**
119 * Returns the tunnel type. 112 * Returns the tunnel type.
...@@ -123,36 +116,31 @@ public interface Tunnel extends Annotated, Provided, NetworkResource { ...@@ -123,36 +116,31 @@ public interface Tunnel extends Annotated, Provided, NetworkResource {
123 Type type(); 116 Type type();
124 117
125 /** 118 /**
126 - * Returns the tunnel state. 119 + * Returns group flow table id which a tunnel match up.
127 * 120 *
128 - * @return tunnel state 121 + * @return OpenFlowGroupId
129 */ 122 */
130 - State state(); 123 + DefaultGroupId groupId();
131 124
132 /** 125 /**
133 - * Indicates if the tunnel is to be considered durable. 126 + * Returns tunnel identify generated by ONOS as primary key.
134 * 127 *
135 - * @return true if the tunnel is durable 128 + * @return TunnelId
136 */ 129 */
137 - boolean isDurable(); 130 + TunnelId tunnelId();
138 -
139 131
140 /** 132 /**
141 - * Indicates if the tunnel is to be considered Bidirectional. 133 + * Return the name of a tunnel.
142 * 134 *
143 - * @return true if the tunnel is Bidirectional 135 + * @return Tunnel Name
144 */ 136 */
145 - boolean isBidirectional(); 137 + TunnelName tunnelName();
146 138
147 /** 139 /**
148 - * Return the tunnel bandwidth. 140 + * Network resource backing the tunnel, e.g. lambda, VLAN id, MPLS tag.
149 * 141 *
150 - * @return tunnel bandwidth 142 + * @return backing resource
151 */ 143 */
152 - BandwidthResource bandwidth(); 144 + NetworkResource resource();
153 -}
154 -
155 -
156 -
157 -
158 145
146 +}
......
...@@ -15,9 +15,8 @@ ...@@ -15,9 +15,8 @@
15 */ 15 */
16 package org.onosproject.net.tunnel; 16 package org.onosproject.net.tunnel;
17 17
18 -import org.onosproject.net.ConnectPoint;
19 -import org.onosproject.net.DeviceId;
20 import org.onosproject.net.Path; 18 import org.onosproject.net.Path;
19 +import org.onosproject.net.provider.ProviderId;
21 20
22 /** 21 /**
23 * Service for administering the inventory of provisioned tunnels. 22 * Service for administering the inventory of provisioned tunnels.
...@@ -37,17 +36,9 @@ public interface TunnelAdminService { ...@@ -37,17 +36,9 @@ public interface TunnelAdminService {
37 * 36 *
38 * @param src source label 37 * @param src source label
39 * @param dst destination label 38 * @param dst destination label
39 + * @param producerName producer name
40 */ 40 */
41 - void removeTunnels(Label src, Label dst); 41 + void removeTunnels(TunnelEndPoint src, TunnelEndPoint dst, ProviderId producerName);
42 -
43 - /**
44 - * Removes all provisioned tunnels leading to and from the
45 - * specified connection point.
46 - *
47 - * @param src source connection point
48 - * @param dst destination connection point
49 - */
50 - void removeTunnels(ConnectPoint src, ConnectPoint dst);
51 42
52 /** 43 /**
53 * Removes all provisioned tunnels leading to and from the 44 * Removes all provisioned tunnels leading to and from the
...@@ -56,24 +47,9 @@ public interface TunnelAdminService { ...@@ -56,24 +47,9 @@ public interface TunnelAdminService {
56 * @param src source connection point 47 * @param src source connection point
57 * @param dst destination connection point 48 * @param dst destination connection point
58 * @param type tunnel type 49 * @param type tunnel type
50 + * @param producerName producer name
59 */ 51 */
60 - void removeTunnels(ConnectPoint src, ConnectPoint dst, Tunnel.Type type); 52 + void removeTunnels(TunnelEndPoint src, TunnelEndPoint dst, Tunnel.Type type, ProviderId producerName);
61 -
62 - /**
63 - * Removes all provisioned tunnels leading to and from the
64 - * specified connection point.
65 - *
66 - * @param connectPoint connection point
67 - */
68 - void removeTunnels(ConnectPoint connectPoint);
69 -
70 - /**
71 - * Removes all provisioned tunnels leading to and from the
72 - * specified device.
73 - *
74 - * @param deviceId device identifier
75 - */
76 - void removeTunnels(DeviceId deviceId);
77 53
78 /** 54 /**
79 * Invokes the core to update a tunnel based on specified tunnel parameters. 55 * Invokes the core to update a tunnel based on specified tunnel parameters.
......
...@@ -15,13 +15,16 @@ ...@@ -15,13 +15,16 @@
15 */ 15 */
16 package org.onosproject.net.tunnel; 16 package org.onosproject.net.tunnel;
17 17
18 -import org.onosproject.net.ConnectPoint; 18 +import org.onosproject.core.DefaultGroupId;
19 +import org.onosproject.net.Annotated;
19 import org.onosproject.net.Description; 20 import org.onosproject.net.Description;
21 +import org.onosproject.net.provider.ProviderId;
22 +import org.onosproject.net.tunnel.Tunnel.Type;
20 23
21 /** 24 /**
22 - * Describes the tunnel. 25 + * Describes a tunnel.
23 */ 26 */
24 -public interface TunnelDescription extends Description { 27 +public interface TunnelDescription extends Description, Annotated {
25 28
26 /** 29 /**
27 * Returns the tunnel id. 30 * Returns the tunnel id.
...@@ -35,27 +38,40 @@ public interface TunnelDescription extends Description { ...@@ -35,27 +38,40 @@ public interface TunnelDescription extends Description {
35 * 38 *
36 * @return tunnel source ConnectionPoint 39 * @return tunnel source ConnectionPoint
37 */ 40 */
38 - ConnectPoint src(); 41 + TunnelEndPoint src();
39 42
40 /** 43 /**
41 * Returns the connection point destination. 44 * Returns the connection point destination.
42 * 45 *
43 * @return tunnel destination 46 * @return tunnel destination
44 */ 47 */
45 - ConnectPoint dst(); 48 + TunnelEndPoint dst();
46 49
47 /** 50 /**
48 * Returns the tunnel type. 51 * Returns the tunnel type.
49 * 52 *
50 * @return tunnel type 53 * @return tunnel type
51 */ 54 */
52 - Tunnel.Type type(); 55 + Type type();
53 56
54 /** 57 /**
55 - * Returns if the tunnel is bidirectional. 58 + * Returns group flow table id which a tunnel match up.
56 * 59 *
57 - * @return true if bidirectional, otherwise false 60 + * @return OpenFlowGroupId
58 */ 61 */
59 - boolean isBidirectional(); 62 + DefaultGroupId groupId();
60 63
64 + /**
65 + * Returns tunnel producer name.
66 + *
67 + * @return producer name
68 + */
69 + ProviderId producerName();
70 +
71 + /**
72 + * Return the name of a tunnel.
73 + *
74 + * @return Tunnel Name
75 + */
76 + TunnelName tunnelName();
61 } 77 }
......
1 +package org.onosproject.net.tunnel;
2 +
3 +/**
4 + * Represents for source end point or destination end point of a tunnel. Maybe a tunnel
5 + * based on ConnectPoint, IpAddress, MacAddress and so on is built.
6 + */
7 +public interface TunnelEndPoint {
8 +
9 +}
...@@ -20,7 +20,7 @@ import org.onosproject.event.AbstractEvent; ...@@ -20,7 +20,7 @@ import org.onosproject.event.AbstractEvent;
20 /** 20 /**
21 * Describes tunnel events. 21 * Describes tunnel events.
22 */ 22 */
23 -public class TunnelEvent extends AbstractEvent<TunnelEvent.Type, Tunnel> { 23 +public final class TunnelEvent extends AbstractEvent<TunnelEvent.Type, Tunnel> {
24 24
25 /** 25 /**
26 * Type of tunnel events. 26 * Type of tunnel events.
......
1 +package org.onosproject.net.tunnel;
2 +
3 +import java.util.Objects;
4 +
5 +/**
6 + * Represents for a unique tunnel name. TunnelId is generated by ONOS while
7 + * TunnelName is given by producer. The consumer can borrow tunnels with
8 + * TunnelId or TunnelName.
9 + */
10 +public final class TunnelName {
11 + private final String str;
12 +
13 + // Default constructor for serialization
14 + private TunnelName(String tunnelName) {
15 + this.str = tunnelName;
16 + }
17 +
18 +
19 + /**
20 + * Creates a tunnel name using the supplied URI string.
21 + *
22 + * @param tunnelName tunnel name string
23 + * @return tunnel name object
24 + */
25 + public static TunnelName tunnelName(String tunnelName) {
26 + return new TunnelName(tunnelName);
27 + }
28 +
29 + /**
30 + * The string of tunnel name.
31 + *
32 + * @return the string of tunnel name
33 + */
34 + public String value() {
35 + return str;
36 + }
37 +
38 + @Override
39 + public int hashCode() {
40 + return Objects.hash(str);
41 + }
42 +
43 + @Override
44 + public boolean equals(Object obj) {
45 + if (this == obj) {
46 + return true;
47 + }
48 + if (obj instanceof TunnelName) {
49 + final TunnelName that = (TunnelName) obj;
50 + return this.getClass() == that.getClass()
51 + && Objects.equals(this.str, that.str);
52 + }
53 + return false;
54 + }
55 +
56 + @Override
57 + public String toString() {
58 + return str;
59 + }
60 +}
...@@ -25,7 +25,7 @@ import org.onosproject.net.provider.Provider; ...@@ -25,7 +25,7 @@ import org.onosproject.net.provider.Provider;
25 public interface TunnelProvider extends Provider { 25 public interface TunnelProvider extends Provider {
26 26
27 /** 27 /**
28 - * Instructs the provider to setup a tunnel. 28 + * Instructs the provider to setup a tunnel. It's used by consumers.
29 * 29 *
30 * @param tunnel Tunnel 30 * @param tunnel Tunnel
31 * @param path explicit route or null for the tunnel 31 * @param path explicit route or null for the tunnel
...@@ -34,6 +34,7 @@ public interface TunnelProvider extends Provider { ...@@ -34,6 +34,7 @@ public interface TunnelProvider extends Provider {
34 34
35 /** 35 /**
36 * Instructs the provider to setup a tunnel given the respective device. 36 * Instructs the provider to setup a tunnel given the respective device.
37 + * It's used by consumers.
37 * 38 *
38 * @param srcElement device 39 * @param srcElement device
39 * @param tunnel Tunnel 40 * @param tunnel Tunnel
...@@ -42,7 +43,7 @@ public interface TunnelProvider extends Provider { ...@@ -42,7 +43,7 @@ public interface TunnelProvider extends Provider {
42 void setupTunnel(ElementId srcElement, Tunnel tunnel, Path path); 43 void setupTunnel(ElementId srcElement, Tunnel tunnel, Path path);
43 44
44 /** 45 /**
45 - * Instructs the provider to release a tunnel. 46 + * Instructs the provider to release a tunnel. It's used by consumers.
46 * 47 *
47 * @param tunnel Tunnel 48 * @param tunnel Tunnel
48 */ 49 */
...@@ -50,6 +51,7 @@ public interface TunnelProvider extends Provider { ...@@ -50,6 +51,7 @@ public interface TunnelProvider extends Provider {
50 51
51 /** 52 /**
52 * Instructs the provider to release a tunnel given the respective device. 53 * Instructs the provider to release a tunnel given the respective device.
54 + * It's used by consumers.
53 * 55 *
54 * @param srcElement device 56 * @param srcElement device
55 * @param tunnel Tunnel 57 * @param tunnel Tunnel
...@@ -57,20 +59,46 @@ public interface TunnelProvider extends Provider { ...@@ -57,20 +59,46 @@ public interface TunnelProvider extends Provider {
57 void releaseTunnel(ElementId srcElement, Tunnel tunnel); 59 void releaseTunnel(ElementId srcElement, Tunnel tunnel);
58 60
59 /** 61 /**
60 - * Instructs the provider to update a tunnel. 62 + * Instructs the provider to update a tunnel. It's used by consumers. Maybe
63 + * some consumers enable to update a tunnel.
61 * 64 *
62 * @param tunnel Tunnel 65 * @param tunnel Tunnel
63 - * @param path explicit route (path changed) or null (path not changed) for the tunnel 66 + * @param path explicit route (path changed) or null (path not changed) for
67 + * the tunnel
64 */ 68 */
65 void updateTunnel(Tunnel tunnel, Path path); 69 void updateTunnel(Tunnel tunnel, Path path);
66 70
67 /** 71 /**
68 * Instructs the provider to update a tunnel given the respective device. 72 * Instructs the provider to update a tunnel given the respective device.
73 + * It's used by consumers. Maybe some consumers enable to update a tunnel.
69 * 74 *
70 * @param srcElement device 75 * @param srcElement device
71 * @param tunnel Tunnel 76 * @param tunnel Tunnel
72 - * @param path explicit route (path changed) or null (path not changed) for the tunnel 77 + * @param path explicit route (path changed) or null (path not changed) for
78 + * the tunnel
73 */ 79 */
74 void updateTunnel(ElementId srcElement, Tunnel tunnel, Path path); 80 void updateTunnel(ElementId srcElement, Tunnel tunnel, Path path);
75 81
82 + /**
83 + * Signals that the provider has added a tunnel. It's used by producers.
84 + *
85 + * @param tunnel tunnel information
86 + * @return tunnel identity
87 + */
88 + TunnelId tunnelAdded(TunnelDescription tunnel);
89 +
90 + /**
91 + * Signals that the provider has removed a tunnel. It's used by producers.
92 + *
93 + * @param tunnel tunnel information
94 + */
95 + void tunnelRemoved(TunnelDescription tunnel);
96 +
97 + /**
98 + * Signals that the a tunnel was changed (e.g., sensing changes of
99 + * tunnel).It's used by producers.
100 + *
101 + * @param tunnel tunnel information
102 + */
103 + void tunnelUpdated(TunnelDescription tunnel);
76 } 104 }
......
...@@ -26,8 +26,9 @@ public interface TunnelProviderService extends ProviderService<TunnelProvider> { ...@@ -26,8 +26,9 @@ public interface TunnelProviderService extends ProviderService<TunnelProvider> {
26 * Signals that the provider has added a tunnel. 26 * Signals that the provider has added a tunnel.
27 * 27 *
28 * @param tunnel tunnel information 28 * @param tunnel tunnel information
29 + * @return tunnel identity
29 */ 30 */
30 - void tunnelAdded(TunnelDescription tunnel); 31 + TunnelId tunnelAdded(TunnelDescription tunnel);
31 32
32 /** 33 /**
33 * Signals that the provider has removed a tunnel. 34 * Signals that the provider has removed a tunnel.
......
...@@ -17,88 +17,166 @@ package org.onosproject.net.tunnel; ...@@ -17,88 +17,166 @@ package org.onosproject.net.tunnel;
17 17
18 import java.util.Collection; 18 import java.util.Collection;
19 19
20 -import org.onosproject.net.ConnectPoint; 20 +import org.onosproject.core.ApplicationId;
21 -import org.onosproject.net.Path; 21 +import org.onosproject.net.Annotations;
22 -import org.onosproject.net.resource.BandwidthResource; 22 +import org.onosproject.net.tunnel.Tunnel.Type;
23 23
24 /** 24 /**
25 - * Service for interacting with the tunnel inventory. 25 + * Service for interacting with the inventory of tunnels.
26 */ 26 */
27 public interface TunnelService { 27 public interface TunnelService {
28 28
29 /** 29 /**
30 - * Invokes the core to create a tunnel based on specified parameters. 30 + * Borrows a specific tunnel. Annotations parameter is reserved.If there
31 + * is no tunnel in the store, returns a "null" object, and record the tunnel subscription.
32 + * Where tunnel is created, ONOS notifies this consumer actively.
31 * 33 *
32 - * @param src sourcePoint 34 + * @param consumerId a tunnel consumer
33 - * @param dst destinationPoint 35 + * @param tunnelId tunnel identify generated by onos
34 - * @param bw bandwidth 36 + * @param annotations Annotations
35 - * @param path explicit path or null 37 + * @return Tunnel subscribed tunnel
36 */ 38 */
37 - void requestTunnel(ConnectPoint src, ConnectPoint dst, BandwidthResource bw, Path path); 39 + Tunnel borrowTunnel(ApplicationId consumerId, TunnelId tunnelId,
40 + Annotations... annotations);
38 41
39 /** 42 /**
40 - * Invokes the core to create a tunnel based on specified parameters with a tunnel type. 43 + * Borrows a specific tunnel by tunnelName. Annotations parameter is reserved.If there
44 + * is no tunnel in the store, return a "null" object, and record the tunnel subscription.
45 + * Where tunnel is created, ONOS notifies this consumer actively.
41 * 46 *
42 - * @param src sourcePoint 47 + * @param consumerId a tunnel consumer
43 - * @param dst destinationPoint 48 + * @param tunnelName tunnel name
44 - * @param type tunnelType 49 + * @param annotations Annotations
45 - * @param bw bandwidth 50 + * @return collection of subscribed Tunnels
46 - * @param path explicit path or null
47 */ 51 */
48 - void requestTunnel(ConnectPoint src, ConnectPoint dst, Tunnel.Type type, BandwidthResource bw, Path path); 52 + Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelName tunnelName,
53 + Annotations... annotations);
49 54
50 /** 55 /**
51 - * Returns the count of all known tunnels in the dataStore. 56 + * Borrows all tunnels between source and destination. Annotations
57 + * parameter is reserved.If there is no any tunnel in the store, return a
58 + * empty collection,and record the tunnel subscription. Where tunnel is created, ONOS
59 + * notifies this consumer actively. Otherwise ONOS core returns all the
60 + * tunnels, consumer determined which one to use.
52 * 61 *
53 - * @return number of tunnels 62 + * @param consumerId a tunnel consumer
63 + * @param src a source point of tunnel.
64 + * @param dst a destination point of tunnel
65 + * @param annotations Annotations
66 + * @return collection of subscribed Tunnels
54 */ 67 */
55 - int getTunnelCount(); 68 + Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src,
69 + TunnelEndPoint dst, Annotations... annotations);
56 70
57 /** 71 /**
58 - * Returns a collection of all known tunnel based on the type. 72 + * Borrows all specified type tunnels between source and destination.
73 + * Annotations parameter is reserved.If there is no any tunnel in the store,
74 + * return a empty collection, and record the tunnel subscription. Where tunnel is
75 + * created, ONOS notifies this consumer actively. Otherwise,ONOS core returns
76 + * all available tunnels, consumer determined which one to use.
59 * 77 *
60 - *@param type tunnelType 78 + * @param consumerId a tunnel consumer
61 - * @return all tunnels for a specific type 79 + * @param src a source point of tunnel.
80 + * @param dst a destination point of tunnel
81 + * @param type tunnel type
82 + * @param annotations Annotations
83 + * @return collection of available Tunnels
84 + */
85 + Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src,
86 + TunnelEndPoint dst, Type type,
87 + Annotations... annotations);
88 +
89 + /**
90 + * Returns back a specific tunnel to store.
91 + *
92 + * @param consumerId a tunnel consumer
93 + * @param tunnelId tunnel identify generated by ONOS
94 + * @param annotations Annotations
95 + * @return success or fail
62 */ 96 */
63 - Collection<Tunnel> getTunnels(Tunnel.Type type); 97 + boolean returnTunnel(ApplicationId consumerId, TunnelId tunnelId,
98 + Annotations... annotations);
64 99
65 /** 100 /**
66 - * Returns set of all tunnels from the specified connectpoint. 101 + * Returns all specific name tunnel back store. Annotations parameter is reserved.if there
102 + * is no tunnel in the store, return a "null" object, and record the tunnel subscription.
103 + * Where tunnel is created, ONOS notifies this consumer actively.
67 * 104 *
68 - * @param connectPoint device/portnumber 105 + * @param consumerId a tunnel consumer
69 - * @param type tunnelType 106 + * @param tunnelName tunnel name
70 - * @return set of tunnels 107 + * @param annotations Annotations
108 + * @return boolean
71 */ 109 */
72 - Collection<Tunnel> getTunnels(ConnectPoint connectPoint, Tunnel.Type type); 110 + boolean returnTunnel(ApplicationId consumerId, TunnelName tunnelName,
111 + Annotations... annotations);
73 112
74 /** 113 /**
75 - * Returns set of all tunnels from the 114 + * Returns all specific type tunnels between source and destination back
76 - * specified source connectpoint and destination connectpoint. 115 + * store. Annotations parameter is reserved.
77 * 116 *
78 - * @param src sourcePoint 117 + * @param consumerId a tunnel consumer
79 - * @param dst destinationPoint 118 + * @param src a source point of tunnel.
119 + * @param dst a destination point of tunnel
80 * @param type tunnel type 120 * @param type tunnel type
81 - * @return set of tunnels 121 + * @param annotations Annotations
122 + * @return success or fail
123 + */
124 + boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src,
125 + TunnelEndPoint dst, Type type,
126 + Annotations... annotations);
127 +
128 + /**
129 + * Returns all tunnels between source and destination back the store.
130 + * Annotations parameter is reserved.
131 + *
132 + * @param consumerId a tunnel consumer
133 + * @param src a source point of tunnel.
134 + * @param dst a destination point of tunnel.
135 + * @param annotations Annotations
136 + * @return success or fail
82 */ 137 */
83 - Collection<Tunnel> getTunnels(ConnectPoint src, ConnectPoint dst, Tunnel.Type type); 138 + boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src,
139 + TunnelEndPoint dst, Annotations... annotations);
84 140
85 /** 141 /**
86 - * Returns the tunnel between the specified source 142 + * Returns a tunnel by a specific tunnel identity.
87 - * and destination connection points.
88 * 143 *
89 - * @param src source label 144 + * @param tunnelId tunnel identify generated by tunnel producer
90 - * @param dst destination label 145 + * @return Tunnel
91 - * @return tunnel from source to destination; null if none found
92 */ 146 */
93 - Tunnel getTunnel(Label src, Label dst); 147 + Tunnel queryTunnel(TunnelId tunnelId);
94 148
95 /** 149 /**
96 - * Returns the tunnel based on the Id. 150 + * Returns all tunnel subscription record by consumer.
97 * 151 *
98 - * @param id tunnelId 152 + * @param consumerId consumer identity
99 - * @return tunnel with specified Id 153 + * @return Collection of TunnelSubscription
100 */ 154 */
101 - Tunnel getTunnel(TunnelId id); 155 + Collection<TunnelSubscription> queryTunnelSubscription(ApplicationId consumerId);
156 +
157 + /**
158 + * Returns all specified type tunnels.
159 + *
160 + * @param type tunnel type
161 + * @return Collection of tunnels
162 + */
163 + Collection<Tunnel> queryTunnel(Type type);
164 +
165 + /**
166 + * Returns all tunnels between source point and destination point.
167 + *
168 + * @param src a source point of tunnel.
169 + * @param dst a destination point of tunnel.
170 + * @return Collection of tunnels
171 + */
172 + Collection<Tunnel> queryTunnel(TunnelEndPoint src, TunnelEndPoint dst);
173 +
174 + /**
175 + * Returns all tunnels.
176 + *
177 + * @return all tunnels
178 + */
179 + int tunnelCount();
102 180
103 /** 181 /**
104 * Adds the specified tunnel listener. 182 * Adds the specified tunnel listener.
...@@ -113,5 +191,4 @@ public interface TunnelService { ...@@ -113,5 +191,4 @@ public interface TunnelService {
113 * @param listener tunnel listener 191 * @param listener tunnel listener
114 */ 192 */
115 void removeListener(TunnelListener listener); 193 void removeListener(TunnelListener listener);
116 -
117 } 194 }
......
...@@ -15,100 +15,206 @@ ...@@ -15,100 +15,206 @@
15 */ 15 */
16 package org.onosproject.net.tunnel; 16 package org.onosproject.net.tunnel;
17 17
18 -import org.onosproject.net.ConnectPoint; 18 +import java.util.Collection;
19 -import org.onosproject.net.DeviceId; 19 +
20 +import org.onosproject.core.ApplicationId;
21 +import org.onosproject.net.Annotations;
20 import org.onosproject.net.provider.ProviderId; 22 import org.onosproject.net.provider.ProviderId;
23 +import org.onosproject.net.tunnel.Tunnel.Type;
21 import org.onosproject.store.Store; 24 import org.onosproject.store.Store;
22 25
23 /** 26 /**
24 - * Manages inventory of tunnels. 27 + * Manages inventory of tunnel; not intended for direct use.
25 */ 28 */
26 public interface TunnelStore extends Store<TunnelEvent, TunnelStoreDelegate> { 29 public interface TunnelStore extends Store<TunnelEvent, TunnelStoreDelegate> {
30 + /**
31 + * Creates or updates a tunnel.
32 + *
33 + * @param tunnel tunnel
34 + * @return tunnel identity
35 + */
36 + TunnelId createOrUpdateTunnel(Tunnel tunnel);
37 +
38 + /**
39 + * Deletes a tunnel by a specific tunnel identifier.
40 + *
41 + * @param tunnelId tunnel unique identifier generated by ONOS
42 + */
43 + void deleteTunnel(TunnelId tunnelId);
44 +
45 + /**
46 + * Deletes all tunnels between source point and destination point.
47 + *
48 + * @param src a source point of tunnel.
49 + * @param dst a destination point of tunnel.
50 + * @param producerName producerName
51 + */
52 + void deleteTunnel(TunnelEndPoint src, TunnelEndPoint dst,
53 + ProviderId producerName);
27 54
28 /** 55 /**
29 - * Returns the number of tunnels in the store. 56 + * Deletes all specific type tunnels between source point and destination
57 + * point.
30 * 58 *
31 - * @return number of tunnels 59 + * @param src a source point of tunnel.
60 + * @param dst a destination point of tunnel.
61 + * @param type tunnel type
62 + * @param producerName producerName
32 */ 63 */
33 - int getTunnelCount(); 64 + void deleteTunnel(TunnelEndPoint src, TunnelEndPoint dst,
65 + Tunnel.Type type, ProviderId producerName);
34 66
35 /** 67 /**
36 - * Returns an iterable collection of all tunnel in the inventory. 68 + * Returns a specific tunnel. Annotations parameter is reserved. If there
69 + * is no tunnel in the store, return a "null" object, and record the tunnel subscription.
70 + * Where tunnel is created, ONOS notifies this consumer actively.
37 * 71 *
38 - * @return collection of all tunnels 72 + * @param consumerId a tunnel consumer
73 + * @param tunnelId tunnel identify generated by onos
74 + * @param annotations parameter
75 + * @return Tunnel subscribed tunnel
39 */ 76 */
40 - Iterable<Tunnel> getTunnels(); 77 + Tunnel borrowTunnel(ApplicationId consumerId, TunnelId tunnelId,
78 + Annotations... annotations);
41 79
42 /** 80 /**
43 - * Returns all tunnels egressing from the specified device. 81 + * Returns a specific tunnel by tunnelName. Annotations parameter is
82 + * reserved. If there is no tunnel in the store, return a "null" object,and
83 + * record the tunnel subscription. Where tunnel is created, ONOS notifies this consumer
84 + * actively.
44 * 85 *
45 - * @param deviceId device identifier 86 + * @param consumerId a tunnel consumer
46 - * @return set of device tunnels 87 + * @param tunnelName tunnel name
88 + * @param annotations parameter
89 + * @return collection of subscribed Tunnels
47 */ 90 */
48 - Iterable<Tunnel> getDeviceEgressTunnels(DeviceId deviceId); 91 + Collection<Tunnel> borrowTunnel(ApplicationId consumerId,
92 + TunnelName tunnelName,
93 + Annotations... annotations);
49 94
50 /** 95 /**
51 - * Returns all tunnels ingressing from the specified device. 96 + * Returns all tunnels between source and destination. Annotations
97 + * parameter is reserved. If there is no any tunnel in the store, return a
98 + * empty collection, and record the tunnel subscription. Where tunnel is created, ONOS
99 + * notifies this consumer actively. Otherwise ONOS core returns all the
100 + * tunnels, consumer determined which one to use.
52 * 101 *
53 - * @param deviceId device identifier 102 + * @param consumerId a tunnel consumer
54 - * @return set of device tunnels 103 + * @param src a source point of tunnel.
104 + * @param dst a destination point of tunnel
105 + * @param annotations parameter
106 + * @return collection of subscribed Tunnels
55 */ 107 */
56 - Iterable<Tunnel> getDeviceIngressTunnels(DeviceId deviceId); 108 + Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src,
109 + TunnelEndPoint dst, Annotations... annotations);
57 110
58 /** 111 /**
59 - * Returns the tunnel between the two end-points and the tunnel type. 112 + * Returns all specified type tunnels between source and destination.
113 + * Annotations parameter is reserved. If there is no any tunnel in the store,
114 + * return a empty collection, and record the tunnel subscription. Where tunnel is
115 + * created, ONOS notifies this consumer actively. Otherwise,ONOS core returns
116 + * all available tunnels, consumer determined which one to use.
60 * 117 *
61 - * @param src source connection point 118 + * @param consumerId a tunnel consumer
62 - * @param dst destination connection point 119 + * @param src a source point of tunnel.
120 + * @param dst a destination point of tunnel
63 * @param type tunnel type 121 * @param type tunnel type
64 - * @return tunnels or null if one not found between the end-points 122 + * @param annotations Annotations
123 + * @return collection of available Tunnels
65 */ 124 */
66 - Iterable<Tunnel> getTunnel(ConnectPoint src, ConnectPoint dst, Tunnel.Type type); 125 + Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src,
126 + TunnelEndPoint dst, Type type,
127 + Annotations... annotations);
67 128
68 /** 129 /**
69 - * Returns all tunnels egressing from the specified connection point. 130 + * Returns back a specific tunnel to store.
70 * 131 *
71 - * @param src source connection point 132 + * @param consumerId a tunnel consumer
72 - * @return set of connection point tunnels 133 + * @param tunnelId tunnel identify generated by ONOS
134 + * @param annotations Annotations
135 + * @return success or fail
73 */ 136 */
74 - Iterable<Tunnel> getEgressTunnels(ConnectPoint src); 137 + boolean returnTunnel(ApplicationId consumerId, TunnelId tunnelId,
138 + Annotations... annotations);
75 139
76 /** 140 /**
77 - * Returns all tunnels ingressing to the specified connection point. 141 + * Returns all specific name tunnel back store. Annotations parameter is
142 + * reserved.If there is no tunnel in the store, return a "null" object,and
143 + * record the tunnel subscription. Where tunnel is created, ONOS notifies this consumer
144 + * actively.
78 * 145 *
79 - * @param dst destination connection point 146 + * @param consumerId a tunnel consumer
80 - * @return set of connection point tunnels 147 + * @param tunnelName tunnel name
148 + * @param annotations Annotations
149 + * @return boolean
81 */ 150 */
82 - Iterable<Tunnel> getIngressTunnels(ConnectPoint dst); 151 + boolean returnTunnel(ApplicationId consumerId, TunnelName tunnelName,
152 + Annotations... annotations);
83 153
84 /** 154 /**
85 - * Creates a new tunnel based on the given information. 155 + * Returns all specific type tunnels between source and destination back
156 + * store. Annotations parameter is reserved.
86 * 157 *
87 - * @param providerId provider identity (e.g., PCEP provider) 158 + * @param consumerId a tunnel consumer
88 - * @param tunnel tunnel information 159 + * @param src a source point of tunnel.
89 - * @return create tunnel event 160 + * @param dst a destination point of tunnel
161 + * @param type tunnel type
162 + * @param annotations Annotations
163 + * @return success or fail
90 */ 164 */
91 - TunnelEvent addTunnel(ProviderId providerId, 165 + boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src,
92 - Tunnel tunnel); 166 + TunnelEndPoint dst, Type type,
167 + Annotations... annotations);
93 168
94 /** 169 /**
95 - * Updates a new tunnel based on the given information. 170 + * Returns all tunnels between source and destination back the store.
171 + * Annotations parameter is reserved.
96 * 172 *
97 - * @param providerId provider identity (e.g., PCEP provider) 173 + * @param consumerId a tunnel consumer
98 - * @param tunnel tunnel 174 + * @param src a source point of tunnel.
99 - * @return update tunnel event 175 + * @param dst a destination point of tunnel.
176 + * @param annotations Annotations
177 + * @return success or fail
100 */ 178 */
101 - TunnelEvent updateTunnel(ProviderId providerId, 179 + boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src,
102 - Tunnel tunnel); 180 + TunnelEndPoint dst, Annotations... annotations);
103 181
104 /** 182 /**
105 - * Removes a new tunnel based on the given information. 183 + * Returns a tunnel by a specific tunnel identity.
106 * 184 *
107 - * @param providerId provider identity (e.g., PCEP provider) 185 + * @param tunnelId tunnel identify generated by tunnel producer
108 - * @param tunnel tunnel 186 + * @return Tunnel
109 - * @return remove tunnel event 187 + */
188 + Tunnel queryTunnel(TunnelId tunnelId);
189 +
190 + /**
191 + * Returns all tunnel subscription record by consumer.
192 + *
193 + * @param consumerId consumer identity
194 + * @return Collection of TunnelSubscription
195 + */
196 + Collection<TunnelSubscription> queryTunnelSubscription(ApplicationId consumerId);
197 +
198 + /**
199 + * Returns all specified type tunnels.
200 + *
201 + * @param type tunnel type
202 + * @return Collection of tunnels
203 + */
204 + Collection<Tunnel> queryTunnel(Type type);
205 +
206 + /**
207 + * Returns all tunnels between source point and destination point.
208 + *
209 + * @param src a source point of tunnel.
210 + * @param dst a destination point of tunnel.
211 + * @return Collection of tunnels
110 */ 212 */
111 - TunnelEvent removeTunnel(ProviderId providerId, 213 + Collection<Tunnel> queryTunnel(TunnelEndPoint src, TunnelEndPoint dst);
112 - Tunnel tunnel);
113 214
215 + /**
216 + * Returns all tunnels.
217 + * @return all tunnels
218 + */
219 + int tunnelCount();
114 } 220 }
......
1 +package org.onosproject.net.tunnel;
2 +
3 +import static com.google.common.base.Preconditions.checkNotNull;
4 +
5 +import java.util.Objects;
6 +
7 +import org.onosproject.core.ApplicationId;
8 +import org.onosproject.net.AbstractAnnotated;
9 +import org.onosproject.net.Annotations;
10 +import org.onosproject.net.tunnel.Tunnel.Type;
11 +
12 +import com.google.common.base.MoreObjects;
13 +
14 +/**
15 + * Represents for a order that consumer subscribe tunnel. ONOS maintains request
16 + * information, it means ONOS knows how much resource echo consumer uses in the
17 + * ONOS. Although there is no a tunnel that consumer want to use, when producer
18 + * creates a new tunnel, ONOS will notify the consumers that want to use it.
19 + */
20 +public final class TunnelSubscription extends AbstractAnnotated {
21 + private final ApplicationId consumerId;
22 + private final TunnelEndPoint src;
23 + private final TunnelEndPoint dst;
24 + private final Type type;
25 + private final TunnelId tunnelId;
26 + private final TunnelName tunnelName;
27 +
28 + /**
29 + * Creates a TunnelSubscription.
30 + *
31 + * @param consumerId consumer identity
32 + * @param src source tunnel end point of tunnel
33 + * @param dst destination tunnel end point of tunnel
34 + * @param tunnelId tunnel identity
35 + * @param type tunnel type
36 + * @param tunnelName the name of a tunnel
37 + * @param annotations parameter
38 + */
39 + public TunnelSubscription(ApplicationId consumerId, TunnelEndPoint src,
40 + TunnelEndPoint dst, TunnelId tunnelId, Type type,
41 + TunnelName tunnelName, Annotations... annotations) {
42 + super(annotations);
43 + checkNotNull(consumerId, "consumerId cannot be null");
44 + this.consumerId = consumerId;
45 + this.src = src;
46 + this.dst = dst;
47 + this.type = type;
48 + this.tunnelId = tunnelId;
49 + this.tunnelName = tunnelName;
50 + }
51 +
52 + /**
53 + * Returns consumer identity.
54 + *
55 + * @return consumerId consumer id
56 + */
57 + public ApplicationId consumerId() {
58 + return consumerId;
59 + }
60 +
61 + /**
62 + * Returns source point of tunnel.
63 + *
64 + * @return source point
65 + */
66 + public TunnelEndPoint src() {
67 + return src;
68 + }
69 +
70 + /**
71 + * Returns destination point of tunnel.
72 + *
73 + * @return destination point
74 + */
75 + public TunnelEndPoint dst() {
76 + return dst;
77 + }
78 +
79 + /**
80 + * Returns tunnel type.
81 + *
82 + * @return tunnel type
83 + */
84 + public Type type() {
85 + return type;
86 + }
87 +
88 + /**
89 + * Returns tunnel identity.
90 + *
91 + * @return tunnel id
92 + */
93 + public TunnelId tunnelId() {
94 + return tunnelId;
95 + }
96 +
97 + /**
98 + * Returns tunnel name.
99 + *
100 + * @return tunnel name
101 + */
102 + public TunnelName tunnelName() {
103 + return tunnelName;
104 + }
105 +
106 + @Override
107 + public int hashCode() {
108 + return Objects.hash(consumerId, src, dst, type, tunnelId, tunnelName);
109 + }
110 +
111 + @Override
112 + public boolean equals(Object obj) {
113 + if (this == obj) {
114 + return true;
115 + }
116 + if (obj instanceof TunnelSubscription) {
117 + final TunnelSubscription other = (TunnelSubscription) obj;
118 + return Objects.equals(this.src, other.src)
119 + && Objects.equals(this.dst, other.dst)
120 + && Objects.equals(this.consumerId, other.consumerId)
121 + && Objects.equals(this.type, other.type)
122 + && Objects.equals(this.tunnelId, other.tunnelId)
123 + && Objects.equals(this.tunnelName, other.tunnelName);
124 + }
125 + return false;
126 + }
127 +
128 + @Override
129 + public String toString() {
130 + return MoreObjects.toStringHelper(getClass())
131 + .add("src", src)
132 + .add("dst", dst)
133 + .add("consumerId", consumerId)
134 + .add("type", type)
135 + .add("tunnelId", tunnelId)
136 + .add("tunnelName", tunnelName).toString();
137 + }
138 +}
1 +package org.onosproject.net.tunnel;
2 +
3 +import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
4 +
5 +import org.junit.Test;
6 +import org.onlab.packet.IpAddress;
7 +import org.onosproject.core.DefaultGroupId;
8 +import org.onosproject.net.provider.ProviderId;
9 +
10 +import com.google.common.testing.EqualsTester;
11 +
12 +/**
13 + * Test of the default tunnel model entity.
14 + */
15 +public class DefaultTunnelTest {
16 + /**
17 + * Checks that the Order class is immutable.
18 + */
19 + @Test
20 + public void testImmutability() {
21 + assertThatClassIsImmutable(DefaultTunnel.class);
22 + }
23 +
24 + @Test
25 + public void testEquality() {
26 + TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress
27 + .valueOf(23423));
28 + TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress
29 + .valueOf(32421));
30 + DefaultGroupId groupId = new DefaultGroupId(92034);
31 + TunnelName tunnelName = TunnelName.tunnelName("TunnelName");
32 + TunnelId tunnelId = TunnelId.valueOf(41654654);
33 + ProviderId producerName1 = new ProviderId("producer1", "13");
34 + ProviderId producerName2 = new ProviderId("producer2", "13");
35 + Tunnel p1 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN,
36 + Tunnel.State.ACTIVE, groupId, tunnelId,
37 + tunnelName);
38 + Tunnel p2 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN,
39 + Tunnel.State.ACTIVE, groupId, tunnelId,
40 + tunnelName);
41 + Tunnel p3 = new DefaultTunnel(producerName2, src, dst, Tunnel.Type.OCH,
42 + Tunnel.State.ACTIVE, groupId, tunnelId,
43 + tunnelName);
44 + new EqualsTester().addEqualityGroup(p1, p2).addEqualityGroup(p3)
45 + .testEquals();
46 + }
47 +}
1 +package org.onosproject.net.tunnel;
2 +
3 +import static org.hamcrest.MatcherAssert.assertThat;
4 +import static org.hamcrest.Matchers.is;
5 +import static org.hamcrest.Matchers.notNullValue;
6 +import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
7 +
8 +import org.junit.Test;
9 +import org.onlab.packet.IpAddress;
10 +import org.onosproject.core.DefaultGroupId;
11 +import org.onosproject.net.provider.ProviderId;
12 +
13 +/**
14 + * Test of a tunnel event.
15 + */
16 +public class TunnelEventTest {
17 + /**
18 + * Checks that the Order class is immutable.
19 + */
20 + @Test
21 + public void testImmutability() {
22 + assertThatClassIsImmutable(TunnelEvent.class);
23 + }
24 +
25 + /**
26 + * Checks the operation of equals(), hashCode() and toString() methods.
27 + */
28 + @Test
29 + public void testConstructor() {
30 + TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress
31 + .valueOf(23423));
32 + TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress
33 + .valueOf(32421));
34 + DefaultGroupId groupId = new DefaultGroupId(92034);
35 + TunnelName tunnelName = TunnelName.tunnelName("TunnelName");
36 + TunnelId tunnelId = TunnelId.valueOf(41654654);
37 + ProviderId producerName1 = new ProviderId("producer1", "13");
38 + Tunnel p1 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN,
39 + Tunnel.State.ACTIVE, groupId, tunnelId,
40 + tunnelName);
41 + TunnelEvent e1 = new TunnelEvent(TunnelEvent.Type.TUNNEL_ADDED, p1);
42 + assertThat(e1, is(notNullValue()));
43 + assertThat(e1.type(), is(TunnelEvent.Type.TUNNEL_ADDED));
44 + assertThat(e1.subject(), is(p1));
45 + }
46 +}
1 +package org.onosproject.net.tunnel;
2 +
3 +import static org.hamcrest.MatcherAssert.assertThat;
4 +import static org.hamcrest.Matchers.is;
5 +import static org.hamcrest.Matchers.notNullValue;
6 +import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
7 +
8 +import org.junit.Test;
9 +
10 +import com.google.common.testing.EqualsTester;
11 +
12 +/**
13 + * Unit tests for tunnel id class.
14 + */
15 +public class TunnelIdTest {
16 +
17 + final TunnelId tunnelId1 = TunnelId.valueOf(1);
18 + final TunnelId sameAstunnelId1 = TunnelId.valueOf(1);
19 + final TunnelId tunnelId2 = TunnelId.valueOf(2);
20 +
21 + /**
22 + * Checks that the TunnelId class is immutable.
23 + */
24 + @Test
25 + public void testImmutability() {
26 + assertThatClassIsImmutable(TunnelId.class);
27 + }
28 +
29 + /**
30 + * Checks the operation of equals(), hashCode() and toString() methods.
31 + */
32 + @Test
33 + public void testEquals() {
34 + new EqualsTester()
35 + .addEqualityGroup(tunnelId1, sameAstunnelId1)
36 + .addEqualityGroup(tunnelId2)
37 + .testEquals();
38 + }
39 +
40 + /**
41 + * Checks the construction of a FlowId object.
42 + */
43 + @Test
44 + public void testConstruction() {
45 + final long tunnelIdValue = 7777L;
46 + final TunnelId tunnelId = TunnelId.valueOf(tunnelIdValue);
47 + assertThat(tunnelId, is(notNullValue()));
48 + assertThat(tunnelId.id(), is(tunnelIdValue));
49 + }
50 +}
1 +package org.onosproject.net.tunnel;
2 +
3 +import static org.hamcrest.MatcherAssert.assertThat;
4 +import static org.hamcrest.Matchers.is;
5 +import static org.hamcrest.Matchers.notNullValue;
6 +import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
7 +
8 +import org.junit.Test;
9 +
10 +import com.google.common.testing.EqualsTester;
11 +
12 +/**
13 + * Unit tests for tunnel name class.
14 + */
15 +public class TunnelNameTest {
16 + final TunnelName name1 = TunnelName.tunnelName("name1");
17 + final TunnelName sameAsName1 = TunnelName.tunnelName("name1");
18 + final TunnelName name2 = TunnelName.tunnelName("name2");
19 +
20 + /**
21 + * Checks that the TunnelName class is immutable.
22 + */
23 + @Test
24 + public void testImmutability() {
25 + assertThatClassIsImmutable(TunnelName.class);
26 + }
27 +
28 + /**
29 + * Checks the operation of equals(), hashCode() and toString() methods.
30 + */
31 + @Test
32 + public void testEquals() {
33 + new EqualsTester().addEqualityGroup(name1, sameAsName1)
34 + .addEqualityGroup(name2).testEquals();
35 + }
36 +
37 + /**
38 + * Checks the construction of a OpenFlowGroupId object.
39 + */
40 + @Test
41 + public void testConstruction() {
42 + final String nameValue = "name3";
43 + final TunnelName name = TunnelName.tunnelName(nameValue);
44 + assertThat(name, is(notNullValue()));
45 + assertThat(name.value(), is(nameValue));
46 + }
47 +
48 +}
1 +package org.onosproject.net.tunnel;
2 +
3 +import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
4 +
5 +import org.junit.Test;
6 +import org.onlab.packet.IpAddress;
7 +import org.onosproject.core.ApplicationId;
8 +import org.onosproject.core.DefaultApplicationId;
9 +
10 +import com.google.common.testing.EqualsTester;
11 +
12 +/**
13 + * Test of order model entity.
14 + */
15 +public class TunnelSubscriptionTest {
16 + /**
17 + * Checks that the Order class is immutable.
18 + */
19 + @Test
20 + public void testImmutability() {
21 + assertThatClassIsImmutable(TunnelSubscription.class);
22 + }
23 +
24 + /**
25 + * Checks the operation of equals(), hashCode() and toString() methods.
26 + */
27 + @Test
28 + public void testEquality() {
29 + TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(23423));
30 + TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(32421));
31 + ApplicationId appId = new DefaultApplicationId(243, "test");
32 + ApplicationId appId2 = new DefaultApplicationId(2431, "test1");
33 + TunnelId tunnelId = TunnelId.valueOf(41654654);
34 + TunnelSubscription p1 = new TunnelSubscription(appId, src, dst, tunnelId, Tunnel.Type.VXLAN,
35 + null);
36 + TunnelSubscription p2 = new TunnelSubscription(appId, src, dst, tunnelId, Tunnel.Type.VXLAN,
37 + null);
38 + TunnelSubscription p3 = new TunnelSubscription(appId2, src, dst, tunnelId, Tunnel.Type.VXLAN,
39 + null);
40 + new EqualsTester().addEqualityGroup(p1, p2).addEqualityGroup(p3)
41 + .testEquals();
42 + }
43 +}
...@@ -15,52 +15,54 @@ ...@@ -15,52 +15,54 @@
15 */ 15 */
16 package org.onosproject.net.tunnel.impl; 16 package org.onosproject.net.tunnel.impl;
17 17
18 +import static org.slf4j.LoggerFactory.getLogger;
19 +
20 +import java.util.Collection;
21 +import java.util.Set;
22 +import java.util.concurrent.ExecutorService;
23 +
18 import org.apache.felix.scr.annotations.Activate; 24 import org.apache.felix.scr.annotations.Activate;
19 import org.apache.felix.scr.annotations.Component; 25 import org.apache.felix.scr.annotations.Component;
20 import org.apache.felix.scr.annotations.Deactivate; 26 import org.apache.felix.scr.annotations.Deactivate;
21 import org.apache.felix.scr.annotations.Reference; 27 import org.apache.felix.scr.annotations.Reference;
22 import org.apache.felix.scr.annotations.ReferenceCardinality; 28 import org.apache.felix.scr.annotations.ReferenceCardinality;
23 import org.apache.felix.scr.annotations.Service; 29 import org.apache.felix.scr.annotations.Service;
30 +import org.onosproject.core.ApplicationId;
24 import org.onosproject.core.CoreService; 31 import org.onosproject.core.CoreService;
25 import org.onosproject.event.EventDeliveryService; 32 import org.onosproject.event.EventDeliveryService;
26 import org.onosproject.event.ListenerRegistry; 33 import org.onosproject.event.ListenerRegistry;
27 -import org.onosproject.net.ConnectPoint; 34 +import org.onosproject.net.Annotations;
28 -import org.onosproject.net.DeviceId;
29 import org.onosproject.net.Path; 35 import org.onosproject.net.Path;
30 import org.onosproject.net.link.LinkEvent; 36 import org.onosproject.net.link.LinkEvent;
31 import org.onosproject.net.link.LinkListener; 37 import org.onosproject.net.link.LinkListener;
32 import org.onosproject.net.provider.AbstractProviderRegistry; 38 import org.onosproject.net.provider.AbstractProviderRegistry;
33 import org.onosproject.net.provider.AbstractProviderService; 39 import org.onosproject.net.provider.AbstractProviderService;
34 import org.onosproject.net.provider.ProviderId; 40 import org.onosproject.net.provider.ProviderId;
35 -import org.onosproject.net.resource.BandwidthResource;
36 -import org.onosproject.net.tunnel.Label;
37 import org.onosproject.net.tunnel.Tunnel; 41 import org.onosproject.net.tunnel.Tunnel;
38 import org.onosproject.net.tunnel.Tunnel.Type; 42 import org.onosproject.net.tunnel.Tunnel.Type;
39 import org.onosproject.net.tunnel.TunnelAdminService; 43 import org.onosproject.net.tunnel.TunnelAdminService;
40 import org.onosproject.net.tunnel.TunnelDescription; 44 import org.onosproject.net.tunnel.TunnelDescription;
45 +import org.onosproject.net.tunnel.TunnelEndPoint;
41 import org.onosproject.net.tunnel.TunnelEvent; 46 import org.onosproject.net.tunnel.TunnelEvent;
42 import org.onosproject.net.tunnel.TunnelId; 47 import org.onosproject.net.tunnel.TunnelId;
43 import org.onosproject.net.tunnel.TunnelListener; 48 import org.onosproject.net.tunnel.TunnelListener;
49 +import org.onosproject.net.tunnel.TunnelName;
44 import org.onosproject.net.tunnel.TunnelProvider; 50 import org.onosproject.net.tunnel.TunnelProvider;
45 import org.onosproject.net.tunnel.TunnelProviderRegistry; 51 import org.onosproject.net.tunnel.TunnelProviderRegistry;
46 import org.onosproject.net.tunnel.TunnelProviderService; 52 import org.onosproject.net.tunnel.TunnelProviderService;
47 import org.onosproject.net.tunnel.TunnelService; 53 import org.onosproject.net.tunnel.TunnelService;
48 import org.onosproject.net.tunnel.TunnelStore; 54 import org.onosproject.net.tunnel.TunnelStore;
49 import org.onosproject.net.tunnel.TunnelStoreDelegate; 55 import org.onosproject.net.tunnel.TunnelStoreDelegate;
56 +import org.onosproject.net.tunnel.TunnelSubscription;
50 import org.slf4j.Logger; 57 import org.slf4j.Logger;
51 58
52 -import java.util.Collection;
53 -import java.util.Set;
54 -import java.util.concurrent.ExecutorService;
55 -
56 -import static org.slf4j.LoggerFactory.getLogger;
57 -
58 /** 59 /**
59 * Provides implementation of the tunnel NB/SB APIs. 60 * Provides implementation of the tunnel NB/SB APIs.
60 */ 61 */
61 @Component(immediate = true, enabled = true) 62 @Component(immediate = true, enabled = true)
62 @Service 63 @Service
63 -public class TunnelManager extends AbstractProviderRegistry<TunnelProvider, TunnelProviderService> 64 +public class TunnelManager
65 + extends AbstractProviderRegistry<TunnelProvider, TunnelProviderService>
64 implements TunnelService, TunnelAdminService, TunnelProviderRegistry { 66 implements TunnelService, TunnelAdminService, TunnelProviderRegistry {
65 67
66 private static final String TUNNNEL_ID_NULL = "Tunnel ID cannot be null"; 68 private static final String TUNNNEL_ID_NULL = "Tunnel ID cannot be null";
...@@ -120,162 +122,189 @@ public class TunnelManager extends AbstractProviderRegistry<TunnelProvider, Tunn ...@@ -120,162 +122,189 @@ public class TunnelManager extends AbstractProviderRegistry<TunnelProvider, Tunn
120 // TODO Auto-generated method stub 122 // TODO Auto-generated method stub
121 return null; 123 return null;
122 } 124 }
125 +
123 @Override 126 @Override
124 - public void removeTunnels(Label src, Label dst) { 127 + public void addListener(TunnelListener listener) {
125 // TODO Auto-generated method stub 128 // TODO Auto-generated method stub
126 129
127 } 130 }
128 131
129 @Override 132 @Override
130 - public void removeTunnels(ConnectPoint connectPoint) { 133 + public void removeListener(TunnelListener listener) {
131 // TODO Auto-generated method stub 134 // TODO Auto-generated method stub
132 135
133 } 136 }
134 137
138 + private class InternalTunnelListener implements TunnelListener {
135 @Override 139 @Override
136 - public void removeTunnels(DeviceId deviceId) { 140 + public void event(TunnelEvent event) {
137 // TODO Auto-generated method stub 141 // TODO Auto-generated method stub
138 142
139 } 143 }
144 + }
140 145
146 + private class InternalLinkListener implements LinkListener {
141 @Override 147 @Override
142 - public int getTunnelCount() { 148 + public void event(LinkEvent event) {
143 // TODO Auto-generated method stub 149 // TODO Auto-generated method stub
144 - return 0; 150 +
151 + }
152 + }
153 +
154 + private class InternalTunnelProviderService
155 + extends AbstractProviderService<TunnelProvider>
156 + implements TunnelProviderService {
157 + protected InternalTunnelProviderService(TunnelProvider provider) {
158 + super(provider);
159 + // TODO Auto-generated constructor stub
145 } 160 }
146 161
147 @Override 162 @Override
148 - public Collection<Tunnel> getTunnels(Type type) { 163 + public TunnelId tunnelAdded(TunnelDescription tunnel) {
149 // TODO Auto-generated method stub 164 // TODO Auto-generated method stub
150 return null; 165 return null;
151 } 166 }
152 167
153 @Override 168 @Override
154 - public Set<Tunnel> getTunnels(ConnectPoint connectPoint, Type type) { 169 + public void tunnelUpdated(TunnelDescription tunnel) {
155 // TODO Auto-generated method stub 170 // TODO Auto-generated method stub
156 - return null; 171 +
157 } 172 }
158 173
159 @Override 174 @Override
160 - public Tunnel getTunnel(Label src, Label dst) { 175 + public void tunnelRemoved(TunnelDescription tunnel) {
161 // TODO Auto-generated method stub 176 // TODO Auto-generated method stub
162 - return null; 177 +
178 + }
179 +
163 } 180 }
164 181
182 + private class InternalStoreDelegate implements TunnelStoreDelegate {
165 @Override 183 @Override
166 - public Tunnel getTunnel(TunnelId id) { 184 + public void notify(TunnelEvent event) {
167 // TODO Auto-generated method stub 185 // TODO Auto-generated method stub
168 - return null; 186 + if (event != null) {
187 + eventDispatcher.post(event);
188 + }
189 + }
169 } 190 }
170 191
171 @Override 192 @Override
172 - public void addListener(TunnelListener listener) { 193 + public void removeTunnel(TunnelId tunnelId) {
173 // TODO Auto-generated method stub 194 // TODO Auto-generated method stub
174 195
175 } 196 }
176 197
177 @Override 198 @Override
178 - public void removeListener(TunnelListener listener) { 199 + public void removeTunnels(TunnelEndPoint src, TunnelEndPoint dst,
200 + ProviderId producerName) {
179 // TODO Auto-generated method stub 201 // TODO Auto-generated method stub
180 202
181 } 203 }
182 204
183 - private class InternalTunnelListener implements TunnelListener {
184 @Override 205 @Override
185 - public void event(TunnelEvent event) { 206 + public void removeTunnels(TunnelEndPoint src, TunnelEndPoint dst,
207 + Type type, ProviderId producerName) {
186 // TODO Auto-generated method stub 208 // TODO Auto-generated method stub
187 209
188 } 210 }
189 - }
190 211
191 - private class InternalLinkListener implements LinkListener {
192 @Override 212 @Override
193 - public void event(LinkEvent event) { 213 + public void updateTunnel(Tunnel tunnel, Path path) {
194 // TODO Auto-generated method stub 214 // TODO Auto-generated method stub
195 215
196 } 216 }
197 - }
198 217
199 - private class InternalTunnelProviderService 218 + @Override
200 - extends AbstractProviderService<TunnelProvider> 219 + public Tunnel borrowTunnel(ApplicationId consumerId, TunnelId tunnelId,
201 - implements TunnelProviderService { 220 + Annotations... annotations) {
202 - protected InternalTunnelProviderService(TunnelProvider provider) { 221 + // TODO Auto-generated method stub
203 - super(provider); 222 + return null;
204 - // TODO Auto-generated constructor stub
205 } 223 }
206 224
207 @Override 225 @Override
208 - public void tunnelAdded(TunnelDescription tunnel) { 226 + public Collection<Tunnel> borrowTunnel(ApplicationId consumerId,
227 + TunnelName tunnelName,
228 + Annotations... annotations) {
209 // TODO Auto-generated method stub 229 // TODO Auto-generated method stub
210 - 230 + return null;
211 } 231 }
212 232
213 @Override 233 @Override
214 - public void tunnelUpdated(TunnelDescription tunnel) { 234 + public Collection<Tunnel> borrowTunnel(ApplicationId consumerId,
235 + TunnelEndPoint src,
236 + TunnelEndPoint dst,
237 + Annotations... annotations) {
215 // TODO Auto-generated method stub 238 // TODO Auto-generated method stub
216 - 239 + return null;
217 } 240 }
218 241
219 @Override 242 @Override
220 - public void tunnelRemoved(TunnelDescription tunnel) { 243 + public Collection<Tunnel> borrowTunnel(ApplicationId consumerId,
244 + TunnelEndPoint src,
245 + TunnelEndPoint dst, Type type,
246 + Annotations... annotations) {
221 // TODO Auto-generated method stub 247 // TODO Auto-generated method stub
222 - 248 + return null;
223 } 249 }
224 250
251 + @Override
252 + public boolean returnTunnel(ApplicationId consumerId, TunnelId tunnelId,
253 + Annotations... annotations) {
254 + // TODO Auto-generated method stub
255 + return false;
225 } 256 }
226 257
227 - private class InternalStoreDelegate implements TunnelStoreDelegate {
228 @Override 258 @Override
229 - public void notify(TunnelEvent event) { 259 + public boolean returnTunnel(ApplicationId consumerId,
260 + TunnelName tunnelName, Annotations... annotations) {
230 // TODO Auto-generated method stub 261 // TODO Auto-generated method stub
231 - if (event != null) { 262 + return false;
232 - eventDispatcher.post(event);
233 - }
234 - }
235 } 263 }
236 264
237 @Override 265 @Override
238 - public void requestTunnel(ConnectPoint src, ConnectPoint dst, 266 + public boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src,
239 - BandwidthResource bw, Path path) { 267 + TunnelEndPoint dst, Type type,
268 + Annotations... annotations) {
240 // TODO Auto-generated method stub 269 // TODO Auto-generated method stub
270 + return false;
241 } 271 }
242 272
243 -
244 @Override 273 @Override
245 - public void requestTunnel(ConnectPoint src, ConnectPoint dst, Type type, 274 + public boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src,
246 - BandwidthResource bw, Path path) { 275 + TunnelEndPoint dst, Annotations... annotations) {
247 // TODO Auto-generated method stub 276 // TODO Auto-generated method stub
248 - 277 + return false;
249 } 278 }
250 279
251 @Override 280 @Override
252 - public void removeTunnel(TunnelId tunnelId) { 281 + public Tunnel queryTunnel(TunnelId tunnelId) {
253 // TODO Auto-generated method stub 282 // TODO Auto-generated method stub
254 - 283 + return null;
255 } 284 }
256 285
257 @Override 286 @Override
258 - public void removeTunnels(ConnectPoint src, ConnectPoint dst) { 287 + public Collection<TunnelSubscription> queryTunnelSubscription(ApplicationId consumerId) {
259 // TODO Auto-generated method stub 288 // TODO Auto-generated method stub
260 - 289 + return null;
261 } 290 }
262 291
263 @Override 292 @Override
264 - public void removeTunnels(ConnectPoint src, ConnectPoint dst, Type type) { 293 + public Collection<Tunnel> queryTunnel(Type type) {
265 // TODO Auto-generated method stub 294 // TODO Auto-generated method stub
266 - 295 + return null;
267 } 296 }
268 297
269 @Override 298 @Override
270 - public void updateTunnel(Tunnel tunnel, Path path) { 299 + public Collection<Tunnel> queryTunnel(TunnelEndPoint src, TunnelEndPoint dst) {
271 // TODO Auto-generated method stub 300 // TODO Auto-generated method stub
272 - 301 + return null;
273 } 302 }
274 303
275 @Override 304 @Override
276 - public Collection<Tunnel> getTunnels(ConnectPoint src, ConnectPoint dst, 305 + public int tunnelCount() {
277 - Type type) {
278 // TODO Auto-generated method stub 306 // TODO Auto-generated method stub
279 - return null; 307 + return 0;
280 } 308 }
309 +
281 } 310 }
......