Committed by
Gerrit Code Review
Made OpticalPathProvisioner to store connectivity data in distributed store. (ONOS-4518)
Change-Id: I7f9ef02cab4aa1848c8926d2e88478e035076c99
Showing
8 changed files
with
150 additions
and
130 deletions
| ... | @@ -89,6 +89,12 @@ | ... | @@ -89,6 +89,12 @@ |
| 89 | </dependency> | 89 | </dependency> |
| 90 | 90 | ||
| 91 | <dependency> | 91 | <dependency> |
| 92 | + <groupId>org.onosproject</groupId> | ||
| 93 | + <artifactId>onos-core-serializers</artifactId> | ||
| 94 | + <version>${project.version}</version> | ||
| 95 | + </dependency> | ||
| 96 | + | ||
| 97 | + <dependency> | ||
| 92 | <groupId>com.google.guava</groupId> | 98 | <groupId>com.google.guava</groupId> |
| 93 | <artifactId>guava-testlib</artifactId> | 99 | <artifactId>guava-testlib</artifactId> |
| 94 | <scope>test</scope> | 100 | <scope>test</scope> | ... | ... |
| ... | @@ -22,14 +22,14 @@ import org.onlab.util.Bandwidth; | ... | @@ -22,14 +22,14 @@ import org.onlab.util.Bandwidth; |
| 22 | import org.onosproject.newoptical.api.OpticalConnectivityId; | 22 | import org.onosproject.newoptical.api.OpticalConnectivityId; |
| 23 | import org.onosproject.net.ConnectPoint; | 23 | import org.onosproject.net.ConnectPoint; |
| 24 | import org.onosproject.net.Link; | 24 | import org.onosproject.net.Link; |
| 25 | -import org.onosproject.net.Path; | ||
| 26 | 25 | ||
| 27 | import java.time.Duration; | 26 | import java.time.Duration; |
| 28 | -import java.util.HashSet; | ||
| 29 | import java.util.List; | 27 | import java.util.List; |
| 28 | +import java.util.Optional; | ||
| 30 | import java.util.Set; | 29 | import java.util.Set; |
| 30 | +import java.util.stream.Collectors; | ||
| 31 | 31 | ||
| 32 | -import static com.google.common.base.Preconditions.checkNotNull; | 32 | +import static com.google.common.base.Preconditions.checkState; |
| 33 | 33 | ||
| 34 | /** | 34 | /** |
| 35 | * Entity to store optical connectivity request and related information. | 35 | * Entity to store optical connectivity request and related information. |
| ... | @@ -42,48 +42,48 @@ public class OpticalConnectivity { | ... | @@ -42,48 +42,48 @@ public class OpticalConnectivity { |
| 42 | private final Bandwidth requestBandwidth; | 42 | private final Bandwidth requestBandwidth; |
| 43 | private final Duration requestLatency; | 43 | private final Duration requestLatency; |
| 44 | 44 | ||
| 45 | - // Bandwidth capacity of optical layer | 45 | + /** |
| 46 | - private Bandwidth opticalCapacity; | 46 | + * Set of packet link that is not yet established. |
| 47 | - | 47 | + * Packet links in this set are expected to be discovered after underlying (optical) path has been provisioned. |
| 48 | - private final Set<PacketLinkRealizedByOptical> realizingLinks = new HashSet<>(); | 48 | + */ |
| 49 | - | 49 | + private final ImmutableSet<PacketLinkRealizedByOptical> unestablishedLinks; |
| 50 | - private State state = State.CREATED; | ||
| 51 | - | ||
| 52 | - public enum State { | ||
| 53 | - CREATED, | ||
| 54 | - INSTALLING, | ||
| 55 | - INSTALLED, | ||
| 56 | - WITHDRAWING, | ||
| 57 | - WITHDRAWN, | ||
| 58 | - FAILED | ||
| 59 | - } | ||
| 60 | 50 | ||
| 61 | - public OpticalConnectivity(OpticalConnectivityId id, Path path, Bandwidth requestBandwidth, | 51 | + /** |
| 62 | - Duration requestLatency) { | 52 | + * Set of packet link that is already established. |
| 53 | + */ | ||
| 54 | + private final ImmutableSet<PacketLinkRealizedByOptical> establishedLinks; | ||
| 55 | + | ||
| 56 | + public OpticalConnectivity(OpticalConnectivityId id, | ||
| 57 | + List<Link> links, | ||
| 58 | + Bandwidth requestBandwidth, | ||
| 59 | + Duration requestLatency, | ||
| 60 | + Set<PacketLinkRealizedByOptical> unestablishedLinks, | ||
| 61 | + Set<PacketLinkRealizedByOptical> establishedLinks) { | ||
| 63 | this.id = id; | 62 | this.id = id; |
| 64 | - this.links = ImmutableList.copyOf(path.links()); | 63 | + this.links = ImmutableList.copyOf(links); |
| 65 | this.requestBandwidth = requestBandwidth; | 64 | this.requestBandwidth = requestBandwidth; |
| 66 | this.requestLatency = requestLatency; | 65 | this.requestLatency = requestLatency; |
| 66 | + this.unestablishedLinks = ImmutableSet.copyOf(unestablishedLinks); | ||
| 67 | + this.establishedLinks = ImmutableSet.copyOf(establishedLinks); | ||
| 67 | } | 68 | } |
| 68 | 69 | ||
| 69 | - public void setLinkEstablished(ConnectPoint src, ConnectPoint dst) { | 70 | + private OpticalConnectivity(OpticalConnectivity connectivity) { |
| 70 | - realizingLinks.stream().filter(l -> l.isBetween(src, dst)) | 71 | + this.id = connectivity.id; |
| 71 | - .findAny() | 72 | + this.links = ImmutableList.copyOf(connectivity.links); |
| 72 | - .ifPresent(l -> l.setEstablished(true)); | 73 | + this.requestBandwidth = connectivity.requestBandwidth; |
| 73 | - } | 74 | + this.requestLatency = connectivity.requestLatency; |
| 74 | - | 75 | + this.unestablishedLinks = ImmutableSet.copyOf(connectivity.unestablishedLinks); |
| 75 | - public void setLinkRemoved(ConnectPoint src, ConnectPoint dst) { | 76 | + this.establishedLinks = ImmutableSet.copyOf(connectivity.establishedLinks); |
| 76 | - realizingLinks.stream().filter(l -> l.isBetween(src, dst)) | ||
| 77 | - .findAny() | ||
| 78 | - .ifPresent(l -> l.setEstablished(false)); | ||
| 79 | } | 77 | } |
| 80 | 78 | ||
| 81 | public boolean isAllRealizingLinkEstablished() { | 79 | public boolean isAllRealizingLinkEstablished() { |
| 82 | - return realizingLinks.stream().allMatch(PacketLinkRealizedByOptical::isEstablished); | 80 | + // Check if all links are established |
| 81 | + return unestablishedLinks.isEmpty(); | ||
| 83 | } | 82 | } |
| 84 | 83 | ||
| 85 | public boolean isAllRealizingLinkNotEstablished() { | 84 | public boolean isAllRealizingLinkNotEstablished() { |
| 86 | - return !realizingLinks.stream().anyMatch(PacketLinkRealizedByOptical::isEstablished); | 85 | + // Check if any link is not established |
| 86 | + return establishedLinks.isEmpty(); | ||
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | public OpticalConnectivityId id() { | 89 | public OpticalConnectivityId id() { |
| ... | @@ -102,59 +102,64 @@ public class OpticalConnectivity { | ... | @@ -102,59 +102,64 @@ public class OpticalConnectivity { |
| 102 | return requestLatency; | 102 | return requestLatency; |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | - public State state() { | 105 | + public Set<PacketLinkRealizedByOptical> getEstablishedLinks() { |
| 106 | - return state; | 106 | + return establishedLinks; |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | - public boolean state(State state) { | 109 | + public Set<PacketLinkRealizedByOptical> getUnestablishedLinks() { |
| 110 | - boolean valid = true; | 110 | + return unestablishedLinks; |
| 111 | - // reject invalid state transition | ||
| 112 | - switch (this.state) { | ||
| 113 | - case CREATED: | ||
| 114 | - valid = (state == State.INSTALLING || state == State.FAILED); | ||
| 115 | - break; | ||
| 116 | - case INSTALLING: | ||
| 117 | - valid = (state == State.INSTALLED || state == State.FAILED); | ||
| 118 | - break; | ||
| 119 | - case INSTALLED: | ||
| 120 | - valid = (state == State.WITHDRAWING || state == State.FAILED); | ||
| 121 | - break; | ||
| 122 | - case WITHDRAWING: | ||
| 123 | - valid = (state == State.WITHDRAWN || state == State.FAILED); | ||
| 124 | - break; | ||
| 125 | - case FAILED: | ||
| 126 | - valid = (state == State.INSTALLING || state == State.WITHDRAWING || state == State.FAILED); | ||
| 127 | - break; | ||
| 128 | - default: | ||
| 129 | - break; | ||
| 130 | } | 111 | } |
| 131 | 112 | ||
| 132 | - if (valid) { | 113 | + public OpticalConnectivity setLinkEstablished(ConnectPoint src, |
| 133 | - this.state = state; | 114 | + ConnectPoint dst, |
| 134 | - } | 115 | + boolean established) { |
| 116 | + Set<PacketLinkRealizedByOptical> newEstablishedLinks; | ||
| 117 | + Set<PacketLinkRealizedByOptical> newUnestablishedLinks; | ||
| 135 | 118 | ||
| 136 | - return valid; | 119 | + if (established) { |
| 137 | - } | 120 | + // move PacketLink from unestablished set to established set |
| 121 | + Optional<PacketLinkRealizedByOptical> link = this.unestablishedLinks.stream() | ||
| 122 | + .filter(l -> l.isBetween(src, dst)).findAny(); | ||
| 123 | + checkState(link.isPresent()); | ||
| 138 | 124 | ||
| 139 | - public Bandwidth getOpticalCapacity() { | 125 | + newUnestablishedLinks = this.unestablishedLinks.stream() |
| 140 | - return opticalCapacity; | 126 | + .filter(l -> !l.isBetween(src, dst)) |
| 141 | - } | 127 | + .collect(Collectors.toSet()); |
| 128 | + newEstablishedLinks = ImmutableSet.<PacketLinkRealizedByOptical>builder() | ||
| 129 | + .addAll(this.establishedLinks) | ||
| 130 | + .add(link.get()) | ||
| 131 | + .build(); | ||
| 132 | + } else { | ||
| 133 | + // move PacketLink from established set to unestablished set | ||
| 134 | + Optional<PacketLinkRealizedByOptical> link = this.establishedLinks.stream() | ||
| 135 | + .filter(l -> l.isBetween(src, dst)).findAny(); | ||
| 136 | + checkState(link.isPresent()); | ||
| 142 | 137 | ||
| 143 | - public void setOpticalCapacity(Bandwidth opticalCapacity) { | 138 | + newEstablishedLinks = this.establishedLinks.stream() |
| 144 | - this.opticalCapacity = opticalCapacity; | 139 | + .filter(l -> !l.isBetween(src, dst)) |
| 140 | + .collect(Collectors.toSet()); | ||
| 141 | + newUnestablishedLinks = ImmutableSet.<PacketLinkRealizedByOptical>builder() | ||
| 142 | + .addAll(this.unestablishedLinks) | ||
| 143 | + .add(link.get()) | ||
| 144 | + .build(); | ||
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | - public void addRealizingLink(PacketLinkRealizedByOptical link) { | 147 | + return new OpticalConnectivity(this.id, |
| 148 | - checkNotNull(link); | 148 | + this.links, |
| 149 | - realizingLinks.add(link); | 149 | + this.requestBandwidth, |
| 150 | + this.requestLatency, | ||
| 151 | + newUnestablishedLinks, | ||
| 152 | + newEstablishedLinks); | ||
| 150 | } | 153 | } |
| 151 | 154 | ||
| 152 | - public void removeRealizingLink(PacketLinkRealizedByOptical link) { | 155 | + public Set<PacketLinkRealizedByOptical> getRealizingLinks() { |
| 153 | - checkNotNull(link); | 156 | + return ImmutableSet.<PacketLinkRealizedByOptical>builder() |
| 154 | - realizingLinks.remove(link); | 157 | + .addAll(unestablishedLinks) |
| 158 | + .addAll(establishedLinks) | ||
| 159 | + .build(); | ||
| 155 | } | 160 | } |
| 156 | 161 | ||
| 157 | - public Set<PacketLinkRealizedByOptical> getRealizingLinks() { | 162 | + public static OpticalConnectivity copyOf(OpticalConnectivity connectivity) { |
| 158 | - return ImmutableSet.copyOf(realizingLinks); | 163 | + return new OpticalConnectivity(connectivity); |
| 159 | } | 164 | } |
| 160 | } | 165 | } | ... | ... |
This diff is collapsed. Click to expand it.
| ... | @@ -33,9 +33,6 @@ public class PacketLinkRealizedByOptical { | ... | @@ -33,9 +33,6 @@ public class PacketLinkRealizedByOptical { |
| 33 | private final Bandwidth bandwidth; | 33 | private final Bandwidth bandwidth; |
| 34 | // TODO should be list of Intent Key? | 34 | // TODO should be list of Intent Key? |
| 35 | private final Key realizingIntentKey; | 35 | private final Key realizingIntentKey; |
| 36 | - // established=false represents that this (packet) link is expected to be | ||
| 37 | - // discovered after underlying (optical) path has been provisioned. | ||
| 38 | - private boolean established; | ||
| 39 | 36 | ||
| 40 | /** | 37 | /** |
| 41 | * Creates instance with specified parameters. | 38 | * Creates instance with specified parameters. |
| ... | @@ -51,7 +48,6 @@ public class PacketLinkRealizedByOptical { | ... | @@ -51,7 +48,6 @@ public class PacketLinkRealizedByOptical { |
| 51 | this.dst = dst; | 48 | this.dst = dst; |
| 52 | this.realizingIntentKey = realizingIntentKey; | 49 | this.realizingIntentKey = realizingIntentKey; |
| 53 | this.bandwidth = bandwidth; | 50 | this.bandwidth = bandwidth; |
| 54 | - this.established = false; | ||
| 55 | } | 51 | } |
| 56 | 52 | ||
| 57 | /** | 53 | /** |
| ... | @@ -129,24 +125,6 @@ public class PacketLinkRealizedByOptical { | ... | @@ -129,24 +125,6 @@ public class PacketLinkRealizedByOptical { |
| 129 | } | 125 | } |
| 130 | 126 | ||
| 131 | /** | 127 | /** |
| 132 | - * Returns whether packet link is realized or not. | ||
| 133 | - * | ||
| 134 | - * @return true if packet link is realized. false if not. | ||
| 135 | - */ | ||
| 136 | - public boolean isEstablished() { | ||
| 137 | - return established; | ||
| 138 | - } | ||
| 139 | - | ||
| 140 | - /** | ||
| 141 | - * Sets packet link to be established. | ||
| 142 | - * | ||
| 143 | - * @param established status of packet link | ||
| 144 | - */ | ||
| 145 | - public void setEstablished(boolean established) { | ||
| 146 | - this.established = established; | ||
| 147 | - } | ||
| 148 | - | ||
| 149 | - /** | ||
| 150 | * Check if packet link is between specified two connect points. | 128 | * Check if packet link is between specified two connect points. |
| 151 | * | 129 | * |
| 152 | * @param src source connect point | 130 | * @param src source connect point |
| ... | @@ -157,4 +135,36 @@ public class PacketLinkRealizedByOptical { | ... | @@ -157,4 +135,36 @@ public class PacketLinkRealizedByOptical { |
| 157 | return (this.src.equals(src) && this.dst.equals(dst)); | 135 | return (this.src.equals(src) && this.dst.equals(dst)); |
| 158 | } | 136 | } |
| 159 | 137 | ||
| 138 | + @Override | ||
| 139 | + public boolean equals(Object o) { | ||
| 140 | + if (this == o) { | ||
| 141 | + return true; | ||
| 142 | + } | ||
| 143 | + if (o == null || getClass() != o.getClass()) { | ||
| 144 | + return false; | ||
| 145 | + } | ||
| 146 | + | ||
| 147 | + PacketLinkRealizedByOptical that = (PacketLinkRealizedByOptical) o; | ||
| 148 | + | ||
| 149 | + if (!src.equals(that.src)) { | ||
| 150 | + return false; | ||
| 151 | + } | ||
| 152 | + if (!dst.equals(that.dst)) { | ||
| 153 | + return false; | ||
| 154 | + } | ||
| 155 | + if (!bandwidth.equals(that.bandwidth)) { | ||
| 156 | + return false; | ||
| 157 | + } | ||
| 158 | + return realizingIntentKey.equals(that.realizingIntentKey); | ||
| 159 | + | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + @Override | ||
| 163 | + public int hashCode() { | ||
| 164 | + int result = src.hashCode(); | ||
| 165 | + result = 31 * result + dst.hashCode(); | ||
| 166 | + result = 31 * result + bandwidth.hashCode(); | ||
| 167 | + result = 31 * result + realizingIntentKey.hashCode(); | ||
| 168 | + return result; | ||
| 169 | + } | ||
| 160 | } | 170 | } | ... | ... |
| ... | @@ -33,7 +33,7 @@ import java.util.Optional; | ... | @@ -33,7 +33,7 @@ import java.util.Optional; |
| 33 | public interface OpticalPathService extends ListenerService<OpticalPathEvent, OpticalPathListener> { | 33 | public interface OpticalPathService extends ListenerService<OpticalPathEvent, OpticalPathListener> { |
| 34 | 34 | ||
| 35 | /** | 35 | /** |
| 36 | - * Calculates optical path between connect points and sets up connectivity. | 36 | + * Calculates multi-layer path between connect points and sets up connectivity. |
| 37 | * | 37 | * |
| 38 | * @param ingress ingress port | 38 | * @param ingress ingress port |
| 39 | * @param egress egress port | 39 | * @param egress egress port |
| ... | @@ -45,9 +45,9 @@ public interface OpticalPathService extends ListenerService<OpticalPathEvent, Op | ... | @@ -45,9 +45,9 @@ public interface OpticalPathService extends ListenerService<OpticalPathEvent, Op |
| 45 | Bandwidth bandwidth, Duration latency); | 45 | Bandwidth bandwidth, Duration latency); |
| 46 | 46 | ||
| 47 | /** | 47 | /** |
| 48 | - * Sets up connectivity along given optical path. | 48 | + * Sets up connectivity along given multi-layer path including cross-connect links. |
| 49 | * | 49 | * |
| 50 | - * @param path path along which connectivity will be set up | 50 | + * @param path multi-layer path along which connectivity will be set up |
| 51 | * @param bandwidth required bandwidth. No bandwidth is assured if null. | 51 | * @param bandwidth required bandwidth. No bandwidth is assured if null. |
| 52 | * @param latency required latency. No latency is assured if null. | 52 | * @param latency required latency. No latency is assured if null. |
| 53 | * @return true if successful. false otherwise. | 53 | * @return true if successful. false otherwise. | ... | ... |
| ... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
| 16 | 16 | ||
| 17 | package org.onosproject.newoptical; | 17 | package org.onosproject.newoptical; |
| 18 | 18 | ||
| 19 | +import com.google.common.collect.ImmutableSet; | ||
| 19 | import org.junit.After; | 20 | import org.junit.After; |
| 20 | import org.junit.Before; | 21 | import org.junit.Before; |
| 21 | import org.junit.Test; | 22 | import org.junit.Test; |
| ... | @@ -39,7 +40,9 @@ import org.onosproject.net.provider.ProviderId; | ... | @@ -39,7 +40,9 @@ import org.onosproject.net.provider.ProviderId; |
| 39 | import org.onosproject.newoptical.api.OpticalConnectivityId; | 40 | import org.onosproject.newoptical.api.OpticalConnectivityId; |
| 40 | 41 | ||
| 41 | import java.time.Duration; | 42 | import java.time.Duration; |
| 43 | +import java.util.Collections; | ||
| 42 | import java.util.List; | 44 | import java.util.List; |
| 45 | +import java.util.Set; | ||
| 43 | import java.util.stream.Collectors; | 46 | import java.util.stream.Collectors; |
| 44 | import java.util.stream.Stream; | 47 | import java.util.stream.Stream; |
| 45 | 48 | ||
| ... | @@ -94,10 +97,9 @@ public class OpticalConnectivityTest { | ... | @@ -94,10 +97,9 @@ public class OpticalConnectivityTest { |
| 94 | Link link2 = createLink(cp22, cp31); | 97 | Link link2 = createLink(cp22, cp31); |
| 95 | List<Link> links = Stream.of(link1, link2).collect(Collectors.toList()); | 98 | List<Link> links = Stream.of(link1, link2).collect(Collectors.toList()); |
| 96 | 99 | ||
| 97 | - Path path = new MockPath(cp12, cp31, links); | ||
| 98 | - | ||
| 99 | OpticalConnectivityId cid = OpticalConnectivityId.of(1L); | 100 | OpticalConnectivityId cid = OpticalConnectivityId.of(1L); |
| 100 | - OpticalConnectivity oc = new OpticalConnectivity(cid, path, bandwidth, latency); | 101 | + OpticalConnectivity oc = new OpticalConnectivity(cid, links, bandwidth, latency, |
| 102 | + Collections.emptySet(), Collections.emptySet()); | ||
| 101 | 103 | ||
| 102 | assertNotNull(oc); | 104 | assertNotNull(oc); |
| 103 | assertEquals(oc.id(), cid); | 105 | assertEquals(oc.id(), cid); |
| ... | @@ -133,8 +135,6 @@ public class OpticalConnectivityTest { | ... | @@ -133,8 +135,6 @@ public class OpticalConnectivityTest { |
| 133 | Link link6 = createLink(cp62, cp71); | 135 | Link link6 = createLink(cp62, cp71); |
| 134 | List<Link> links = Stream.of(link1, link2, link3, link4, link5, link6).collect(Collectors.toList()); | 136 | List<Link> links = Stream.of(link1, link2, link3, link4, link5, link6).collect(Collectors.toList()); |
| 135 | 137 | ||
| 136 | - Path path = new MockPath(cp12, cp71, links); | ||
| 137 | - | ||
| 138 | // Mocks 2 intents to create OduCtl connectivity | 138 | // Mocks 2 intents to create OduCtl connectivity |
| 139 | OpticalConnectivityIntent connIntent1 = createConnectivityIntent(cp21, cp32); | 139 | OpticalConnectivityIntent connIntent1 = createConnectivityIntent(cp21, cp32); |
| 140 | PacketLinkRealizedByOptical oduLink1 = PacketLinkRealizedByOptical.create(cp12, cp41, | 140 | PacketLinkRealizedByOptical oduLink1 = PacketLinkRealizedByOptical.create(cp12, cp41, |
| ... | @@ -144,29 +144,29 @@ public class OpticalConnectivityTest { | ... | @@ -144,29 +144,29 @@ public class OpticalConnectivityTest { |
| 144 | PacketLinkRealizedByOptical oduLink2 = PacketLinkRealizedByOptical.create(cp42, cp71, | 144 | PacketLinkRealizedByOptical oduLink2 = PacketLinkRealizedByOptical.create(cp42, cp71, |
| 145 | connIntent2); | 145 | connIntent2); |
| 146 | 146 | ||
| 147 | + Set<PacketLinkRealizedByOptical> plinks = ImmutableSet.of(oduLink1, oduLink2); | ||
| 148 | + | ||
| 147 | Bandwidth bandwidth = Bandwidth.bps(100); | 149 | Bandwidth bandwidth = Bandwidth.bps(100); |
| 148 | Duration latency = Duration.ofMillis(10); | 150 | Duration latency = Duration.ofMillis(10); |
| 149 | 151 | ||
| 150 | OpticalConnectivityId cid = OpticalConnectivityId.of(1L); | 152 | OpticalConnectivityId cid = OpticalConnectivityId.of(1L); |
| 151 | - OpticalConnectivity oc = new OpticalConnectivity(cid, path, bandwidth, latency); | 153 | + OpticalConnectivity oc1 = new OpticalConnectivity(cid, links, bandwidth, latency, |
| 152 | - | 154 | + plinks, Collections.emptySet()); |
| 153 | - oc.addRealizingLink(oduLink1); | ||
| 154 | - oc.addRealizingLink(oduLink2); | ||
| 155 | 155 | ||
| 156 | - assertTrue(oc.isAllRealizingLinkNotEstablished()); | 156 | + assertTrue(oc1.isAllRealizingLinkNotEstablished()); |
| 157 | - assertFalse(oc.isAllRealizingLinkEstablished()); | 157 | + assertFalse(oc1.isAllRealizingLinkEstablished()); |
| 158 | 158 | ||
| 159 | // Sets link realized by connIntent1 to be established | 159 | // Sets link realized by connIntent1 to be established |
| 160 | - oc.setLinkEstablished(cp12, cp41); | 160 | + OpticalConnectivity oc2 = oc1.setLinkEstablished(cp12, cp41, true); |
| 161 | 161 | ||
| 162 | - assertFalse(oc.isAllRealizingLinkNotEstablished()); | 162 | + assertFalse(oc2.isAllRealizingLinkNotEstablished()); |
| 163 | - assertFalse(oc.isAllRealizingLinkEstablished()); | 163 | + assertFalse(oc2.isAllRealizingLinkEstablished()); |
| 164 | 164 | ||
| 165 | // Sets link realized by connIntent2 to be established | 165 | // Sets link realized by connIntent2 to be established |
| 166 | - oc.setLinkEstablished(cp42, cp71); | 166 | + OpticalConnectivity oc3 = oc2.setLinkEstablished(cp42, cp71, true); |
| 167 | 167 | ||
| 168 | - assertFalse(oc.isAllRealizingLinkNotEstablished()); | 168 | + assertFalse(oc3.isAllRealizingLinkNotEstablished()); |
| 169 | - assertTrue(oc.isAllRealizingLinkEstablished()); | 169 | + assertTrue(oc3.isAllRealizingLinkEstablished()); |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | /** | 172 | /** |
| ... | @@ -196,8 +196,6 @@ public class OpticalConnectivityTest { | ... | @@ -196,8 +196,6 @@ public class OpticalConnectivityTest { |
| 196 | Link link6 = createLink(cp62, cp71); | 196 | Link link6 = createLink(cp62, cp71); |
| 197 | List<Link> links = Stream.of(link1, link2, link3, link4, link5, link6).collect(Collectors.toList()); | 197 | List<Link> links = Stream.of(link1, link2, link3, link4, link5, link6).collect(Collectors.toList()); |
| 198 | 198 | ||
| 199 | - Path path = new MockPath(cp12, cp71, links); | ||
| 200 | - | ||
| 201 | // Mocks 2 intents to create Och connectivity | 199 | // Mocks 2 intents to create Och connectivity |
| 202 | OpticalCircuitIntent circuitIntent1 = createCircuitIntent(cp21, cp32); | 200 | OpticalCircuitIntent circuitIntent1 = createCircuitIntent(cp21, cp32); |
| 203 | PacketLinkRealizedByOptical ochLink1 = PacketLinkRealizedByOptical.create(cp12, cp41, | 201 | PacketLinkRealizedByOptical ochLink1 = PacketLinkRealizedByOptical.create(cp12, cp41, |
| ... | @@ -207,29 +205,29 @@ public class OpticalConnectivityTest { | ... | @@ -207,29 +205,29 @@ public class OpticalConnectivityTest { |
| 207 | PacketLinkRealizedByOptical ochLink2 = PacketLinkRealizedByOptical.create(cp42, cp71, | 205 | PacketLinkRealizedByOptical ochLink2 = PacketLinkRealizedByOptical.create(cp42, cp71, |
| 208 | circuitIntent2); | 206 | circuitIntent2); |
| 209 | 207 | ||
| 208 | + Set<PacketLinkRealizedByOptical> plinks = ImmutableSet.of(ochLink1, ochLink2); | ||
| 209 | + | ||
| 210 | Bandwidth bandwidth = Bandwidth.bps(100); | 210 | Bandwidth bandwidth = Bandwidth.bps(100); |
| 211 | Duration latency = Duration.ofMillis(10); | 211 | Duration latency = Duration.ofMillis(10); |
| 212 | 212 | ||
| 213 | OpticalConnectivityId cid = OpticalConnectivityId.of(1L); | 213 | OpticalConnectivityId cid = OpticalConnectivityId.of(1L); |
| 214 | - OpticalConnectivity oc = new OpticalConnectivity(cid, path, bandwidth, latency); | 214 | + OpticalConnectivity oc1 = new OpticalConnectivity(cid, links, bandwidth, latency, |
| 215 | - | 215 | + plinks, Collections.emptySet()); |
| 216 | - oc.addRealizingLink(ochLink1); | ||
| 217 | - oc.addRealizingLink(ochLink2); | ||
| 218 | 216 | ||
| 219 | - assertTrue(oc.isAllRealizingLinkNotEstablished()); | 217 | + assertTrue(oc1.isAllRealizingLinkNotEstablished()); |
| 220 | - assertFalse(oc.isAllRealizingLinkEstablished()); | 218 | + assertFalse(oc1.isAllRealizingLinkEstablished()); |
| 221 | 219 | ||
| 222 | // Sets link realized by circuitIntent1 to be established | 220 | // Sets link realized by circuitIntent1 to be established |
| 223 | - oc.setLinkEstablished(cp12, cp41); | 221 | + OpticalConnectivity oc2 = oc1.setLinkEstablished(cp12, cp41, true); |
| 224 | 222 | ||
| 225 | - assertFalse(oc.isAllRealizingLinkNotEstablished()); | 223 | + assertFalse(oc2.isAllRealizingLinkNotEstablished()); |
| 226 | - assertFalse(oc.isAllRealizingLinkEstablished()); | 224 | + assertFalse(oc2.isAllRealizingLinkEstablished()); |
| 227 | 225 | ||
| 228 | // Sets link realized by circuitIntent2 to be established | 226 | // Sets link realized by circuitIntent2 to be established |
| 229 | - oc.setLinkEstablished(cp42, cp71); | 227 | + OpticalConnectivity oc3 = oc2.setLinkEstablished(cp42, cp71, true); |
| 230 | 228 | ||
| 231 | - assertFalse(oc.isAllRealizingLinkNotEstablished()); | 229 | + assertFalse(oc3.isAllRealizingLinkNotEstablished()); |
| 232 | - assertTrue(oc.isAllRealizingLinkEstablished()); | 230 | + assertTrue(oc3.isAllRealizingLinkEstablished()); |
| 233 | } | 231 | } |
| 234 | 232 | ||
| 235 | private ConnectPoint createConnectPoint(long devIdNum, long portIdNum) { | 233 | private ConnectPoint createConnectPoint(long devIdNum, long portIdNum) { | ... | ... |
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment