Merge branch 'master' of ssh://gerrit.onlab.us:29418/onos-next
Showing
16 changed files
with
273 additions
and
66 deletions
| 1 | package org.onlab.onos.net; | 1 | package org.onlab.onos.net; |
| 2 | 2 | ||
| 3 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
| 4 | + | ||
| 3 | import java.util.Objects; | 5 | import java.util.Objects; |
| 4 | 6 | ||
| 7 | +import org.onlab.onos.net.link.LinkDescription; | ||
| 8 | + | ||
| 5 | import com.google.common.base.MoreObjects; | 9 | import com.google.common.base.MoreObjects; |
| 6 | 10 | ||
| 7 | // TODO Consider renaming. | 11 | // TODO Consider renaming. |
| ... | @@ -10,7 +14,7 @@ import com.google.common.base.MoreObjects; | ... | @@ -10,7 +14,7 @@ import com.google.common.base.MoreObjects; |
| 10 | /** | 14 | /** |
| 11 | * Immutable representation of a link identity. | 15 | * Immutable representation of a link identity. |
| 12 | */ | 16 | */ |
| 13 | -public class LinkKey { | 17 | +public final class LinkKey { |
| 14 | 18 | ||
| 15 | private final ConnectPoint src; | 19 | private final ConnectPoint src; |
| 16 | private final ConnectPoint dst; | 20 | private final ConnectPoint dst; |
| ... | @@ -39,18 +43,40 @@ public class LinkKey { | ... | @@ -39,18 +43,40 @@ public class LinkKey { |
| 39 | * @param src source connection point | 43 | * @param src source connection point |
| 40 | * @param dst destination connection point | 44 | * @param dst destination connection point |
| 41 | */ | 45 | */ |
| 42 | - public LinkKey(ConnectPoint src, ConnectPoint dst) { | 46 | + private LinkKey(ConnectPoint src, ConnectPoint dst) { |
| 43 | - this.src = src; | 47 | + this.src = checkNotNull(src); |
| 44 | - this.dst = dst; | 48 | + this.dst = checkNotNull(dst); |
| 49 | + } | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * Creates a link identifier with source and destination connection point. | ||
| 53 | + * | ||
| 54 | + * @param src source connection point | ||
| 55 | + * @param dst destination connection point | ||
| 56 | + * @return a link identifier | ||
| 57 | + */ | ||
| 58 | + public static LinkKey linkKey(ConnectPoint src, ConnectPoint dst) { | ||
| 59 | + return new LinkKey(src, dst); | ||
| 45 | } | 60 | } |
| 46 | 61 | ||
| 47 | /** | 62 | /** |
| 48 | * Creates a link identifier for the specified link. | 63 | * Creates a link identifier for the specified link. |
| 49 | * | 64 | * |
| 50 | * @param link link descriptor | 65 | * @param link link descriptor |
| 66 | + * @return a link identifier | ||
| 67 | + */ | ||
| 68 | + public static LinkKey linkKey(Link link) { | ||
| 69 | + return new LinkKey(link.src(), link.dst()); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + /** | ||
| 73 | + * Creates a link identifier for the specified link. | ||
| 74 | + * | ||
| 75 | + * @param desc link description | ||
| 76 | + * @return a link identifier | ||
| 51 | */ | 77 | */ |
| 52 | - public LinkKey(Link link) { | 78 | + public static LinkKey linkKey(LinkDescription desc) { |
| 53 | - this(link.src(), link.dst()); | 79 | + return new LinkKey(desc.src(), desc.dst()); |
| 54 | } | 80 | } |
| 55 | 81 | ||
| 56 | @Override | 82 | @Override |
| ... | @@ -65,7 +91,7 @@ public class LinkKey { | ... | @@ -65,7 +91,7 @@ public class LinkKey { |
| 65 | } | 91 | } |
| 66 | if (obj instanceof LinkKey) { | 92 | if (obj instanceof LinkKey) { |
| 67 | final LinkKey other = (LinkKey) obj; | 93 | final LinkKey other = (LinkKey) obj; |
| 68 | - return Objects.equals(this.src(), other.src()) && | 94 | + return Objects.equals(this.src, other.src) && |
| 69 | Objects.equals(this.dst, other.dst); | 95 | Objects.equals(this.dst, other.dst); |
| 70 | } | 96 | } |
| 71 | return false; | 97 | return false; |
| ... | @@ -74,7 +100,7 @@ public class LinkKey { | ... | @@ -74,7 +100,7 @@ public class LinkKey { |
| 74 | @Override | 100 | @Override |
| 75 | public String toString() { | 101 | public String toString() { |
| 76 | return MoreObjects.toStringHelper(getClass()) | 102 | return MoreObjects.toStringHelper(getClass()) |
| 77 | - .add("src", src()) | 103 | + .add("src", src) |
| 78 | .add("dst", dst) | 104 | .add("dst", dst) |
| 79 | .toString(); | 105 | .toString(); |
| 80 | } | 106 | } | ... | ... |
| 1 | +package org.onlab.onos.net.host; | ||
| 2 | + | ||
| 3 | +import org.onlab.onos.store.Timestamp; | ||
| 4 | +import org.onlab.packet.MacAddress; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * Interface for a logical clock service that issues per host timestamps. | ||
| 8 | + */ | ||
| 9 | +public interface HostClockService { | ||
| 10 | + | ||
| 11 | + /** | ||
| 12 | + * Returns a new timestamp for the specified host mac address. | ||
| 13 | + * @param hostMac host MAC address. | ||
| 14 | + * @return timestamp. | ||
| 15 | + */ | ||
| 16 | + public Timestamp getTimestamp(MacAddress hostMac); | ||
| 17 | +} |
| ... | @@ -28,6 +28,7 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -28,6 +28,7 @@ import static com.google.common.base.Preconditions.checkNotNull; |
| 28 | import static com.google.common.collect.Multimaps.synchronizedSetMultimap; | 28 | import static com.google.common.collect.Multimaps.synchronizedSetMultimap; |
| 29 | import static java.util.concurrent.Executors.newSingleThreadExecutor; | 29 | import static java.util.concurrent.Executors.newSingleThreadExecutor; |
| 30 | import static org.onlab.onos.net.link.LinkEvent.Type.LINK_REMOVED; | 30 | import static org.onlab.onos.net.link.LinkEvent.Type.LINK_REMOVED; |
| 31 | +import static org.onlab.onos.net.LinkKey.linkKey; | ||
| 31 | import static org.onlab.util.Tools.namedThreads; | 32 | import static org.onlab.util.Tools.namedThreads; |
| 32 | import static org.slf4j.LoggerFactory.getLogger; | 33 | import static org.slf4j.LoggerFactory.getLogger; |
| 33 | 34 | ||
| ... | @@ -82,14 +83,14 @@ public class ObjectiveTracker implements ObjectiveTrackerService { | ... | @@ -82,14 +83,14 @@ public class ObjectiveTracker implements ObjectiveTrackerService { |
| 82 | @Override | 83 | @Override |
| 83 | public void addTrackedResources(IntentId intentId, Collection<Link> resources) { | 84 | public void addTrackedResources(IntentId intentId, Collection<Link> resources) { |
| 84 | for (Link link : resources) { | 85 | for (Link link : resources) { |
| 85 | - intentsByLink.put(new LinkKey(link), intentId); | 86 | + intentsByLink.put(linkKey(link), intentId); |
| 86 | } | 87 | } |
| 87 | } | 88 | } |
| 88 | 89 | ||
| 89 | @Override | 90 | @Override |
| 90 | public void removeTrackedResources(IntentId intentId, Collection<Link> resources) { | 91 | public void removeTrackedResources(IntentId intentId, Collection<Link> resources) { |
| 91 | for (Link link : resources) { | 92 | for (Link link : resources) { |
| 92 | - intentsByLink.remove(new LinkKey(link), intentId); | 93 | + intentsByLink.remove(linkKey(link), intentId); |
| 93 | } | 94 | } |
| 94 | } | 95 | } |
| 95 | 96 | ||
| ... | @@ -125,7 +126,7 @@ public class ObjectiveTracker implements ObjectiveTrackerService { | ... | @@ -125,7 +126,7 @@ public class ObjectiveTracker implements ObjectiveTrackerService { |
| 125 | if (reason instanceof LinkEvent) { | 126 | if (reason instanceof LinkEvent) { |
| 126 | LinkEvent linkEvent = (LinkEvent) reason; | 127 | LinkEvent linkEvent = (LinkEvent) reason; |
| 127 | if (linkEvent.type() == LINK_REMOVED) { | 128 | if (linkEvent.type() == LINK_REMOVED) { |
| 128 | - Set<IntentId> intentIds = intentsByLink.get(new LinkKey(linkEvent.subject())); | 129 | + Set<IntentId> intentIds = intentsByLink.get(linkKey(linkEvent.subject())); |
| 129 | toBeRecompiled.addAll(intentIds); | 130 | toBeRecompiled.addAll(intentIds); |
| 130 | } | 131 | } |
| 131 | recompileOnly = recompileOnly && linkEvent.type() == LINK_REMOVED; | 132 | recompileOnly = recompileOnly && linkEvent.type() == LINK_REMOVED; | ... | ... |
| ... | @@ -1090,7 +1090,7 @@ public class GossipDeviceStore | ... | @@ -1090,7 +1090,7 @@ public class GossipDeviceStore |
| 1090 | .toList(); | 1090 | .toList(); |
| 1091 | 1091 | ||
| 1092 | if (nodeIds.size() == 1 && nodeIds.get(0).equals(self)) { | 1092 | if (nodeIds.size() == 1 && nodeIds.get(0).equals(self)) { |
| 1093 | - log.info("No other peers in the cluster."); | 1093 | + log.debug("No other peers in the cluster."); |
| 1094 | return; | 1094 | return; |
| 1095 | } | 1095 | } |
| 1096 | 1096 | ... | ... |
| 1 | +package org.onlab.onos.store.host.impl; | ||
| 2 | + | ||
| 3 | +import static org.slf4j.LoggerFactory.getLogger; | ||
| 4 | + | ||
| 5 | +import org.apache.felix.scr.annotations.Activate; | ||
| 6 | +import org.apache.felix.scr.annotations.Component; | ||
| 7 | +import org.apache.felix.scr.annotations.Deactivate; | ||
| 8 | +import org.apache.felix.scr.annotations.Service; | ||
| 9 | +import org.onlab.onos.net.host.HostClockService; | ||
| 10 | +import org.onlab.onos.store.Timestamp; | ||
| 11 | +import org.onlab.onos.store.impl.WallClockTimestamp; | ||
| 12 | +import org.onlab.packet.MacAddress; | ||
| 13 | +import org.slf4j.Logger; | ||
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * HostClockService to issue Timestamps based on local wallclock time. | ||
| 17 | + */ | ||
| 18 | +@Component(immediate = true) | ||
| 19 | +@Service | ||
| 20 | +public class HostClockManager implements HostClockService { | ||
| 21 | + | ||
| 22 | + private final Logger log = getLogger(getClass()); | ||
| 23 | + | ||
| 24 | + @Activate | ||
| 25 | + public void activate() { | ||
| 26 | + log.info("Started"); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + @Deactivate | ||
| 30 | + public void deactivate() { | ||
| 31 | + log.info("Stopped"); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + @Override | ||
| 35 | + public Timestamp getTimestamp(MacAddress hostMac) { | ||
| 36 | + return new WallClockTimestamp(); | ||
| 37 | + } | ||
| 38 | +} |
| ... | @@ -10,8 +10,12 @@ import com.google.common.base.MoreObjects; | ... | @@ -10,8 +10,12 @@ import com.google.common.base.MoreObjects; |
| 10 | import com.google.common.collect.ComparisonChain; | 10 | import com.google.common.collect.ComparisonChain; |
| 11 | 11 | ||
| 12 | /** | 12 | /** |
| 13 | - * Default implementation of Timestamp. | 13 | + * A logical timestamp that derives its value from two things: |
| 14 | - * TODO: Better documentation. | 14 | + * <ul> |
| 15 | + * <li> The current mastership term of the device.</li> | ||
| 16 | + * <li> The value of the counter used for tracking topology events observed from | ||
| 17 | + * the device during that current time of a device. </li> | ||
| 18 | + * </ul> | ||
| 15 | */ | 19 | */ |
| 16 | public final class MastershipBasedTimestamp implements Timestamp { | 20 | public final class MastershipBasedTimestamp implements Timestamp { |
| 17 | 21 | ... | ... |
| 1 | +package org.onlab.onos.store.impl; | ||
| 2 | + | ||
| 3 | +import static com.google.common.base.Preconditions.checkArgument; | ||
| 4 | + | ||
| 5 | +import java.util.Objects; | ||
| 6 | + | ||
| 7 | +import org.onlab.onos.store.Timestamp; | ||
| 8 | + | ||
| 9 | +import com.google.common.base.MoreObjects; | ||
| 10 | +import com.google.common.collect.ComparisonChain; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * A Timestamp that derives its value from the prevailing | ||
| 14 | + * wallclock time on the controller where it is generated. | ||
| 15 | + */ | ||
| 16 | +public class WallClockTimestamp implements Timestamp { | ||
| 17 | + | ||
| 18 | + private final long unixTimestamp; | ||
| 19 | + | ||
| 20 | + public WallClockTimestamp() { | ||
| 21 | + unixTimestamp = System.currentTimeMillis(); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + @Override | ||
| 25 | + public int compareTo(Timestamp o) { | ||
| 26 | + checkArgument(o instanceof WallClockTimestamp, | ||
| 27 | + "Must be WallClockTimestamp", o); | ||
| 28 | + WallClockTimestamp that = (WallClockTimestamp) o; | ||
| 29 | + | ||
| 30 | + return ComparisonChain.start() | ||
| 31 | + .compare(this.unixTimestamp, that.unixTimestamp) | ||
| 32 | + .result(); | ||
| 33 | + } | ||
| 34 | + @Override | ||
| 35 | + public int hashCode() { | ||
| 36 | + return Objects.hash(unixTimestamp); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + @Override | ||
| 40 | + public boolean equals(Object obj) { | ||
| 41 | + if (this == obj) { | ||
| 42 | + return true; | ||
| 43 | + } | ||
| 44 | + if (!(obj instanceof WallClockTimestamp)) { | ||
| 45 | + return false; | ||
| 46 | + } | ||
| 47 | + WallClockTimestamp that = (WallClockTimestamp) obj; | ||
| 48 | + return Objects.equals(this.unixTimestamp, that.unixTimestamp); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + @Override | ||
| 52 | + public String toString() { | ||
| 53 | + return MoreObjects.toStringHelper(getClass()) | ||
| 54 | + .add("unixTimestamp", unixTimestamp) | ||
| 55 | + .toString(); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * Returns the unixTimestamp. | ||
| 60 | + * | ||
| 61 | + * @return unix timestamp | ||
| 62 | + */ | ||
| 63 | + public long unixTimestamp() { | ||
| 64 | + return unixTimestamp; | ||
| 65 | + } | ||
| 66 | +} |
| ... | @@ -67,6 +67,7 @@ import static org.onlab.onos.net.DefaultAnnotations.union; | ... | @@ -67,6 +67,7 @@ import static org.onlab.onos.net.DefaultAnnotations.union; |
| 67 | import static org.onlab.onos.net.DefaultAnnotations.merge; | 67 | import static org.onlab.onos.net.DefaultAnnotations.merge; |
| 68 | import static org.onlab.onos.net.Link.Type.DIRECT; | 68 | import static org.onlab.onos.net.Link.Type.DIRECT; |
| 69 | import static org.onlab.onos.net.Link.Type.INDIRECT; | 69 | import static org.onlab.onos.net.Link.Type.INDIRECT; |
| 70 | +import static org.onlab.onos.net.LinkKey.linkKey; | ||
| 70 | import static org.onlab.onos.net.link.LinkEvent.Type.*; | 71 | import static org.onlab.onos.net.link.LinkEvent.Type.*; |
| 71 | import static org.onlab.util.Tools.namedThreads; | 72 | import static org.onlab.util.Tools.namedThreads; |
| 72 | import static org.slf4j.LoggerFactory.getLogger; | 73 | import static org.slf4j.LoggerFactory.getLogger; |
| ... | @@ -203,7 +204,7 @@ public class GossipLinkStore | ... | @@ -203,7 +204,7 @@ public class GossipLinkStore |
| 203 | 204 | ||
| 204 | @Override | 205 | @Override |
| 205 | public Link getLink(ConnectPoint src, ConnectPoint dst) { | 206 | public Link getLink(ConnectPoint src, ConnectPoint dst) { |
| 206 | - return links.get(new LinkKey(src, dst)); | 207 | + return links.get(linkKey(src, dst)); |
| 207 | } | 208 | } |
| 208 | 209 | ||
| 209 | @Override | 210 | @Override |
| ... | @@ -237,14 +238,20 @@ public class GossipLinkStore | ... | @@ -237,14 +238,20 @@ public class GossipLinkStore |
| 237 | 238 | ||
| 238 | final Timestamped<LinkDescription> deltaDesc = new Timestamped<>(linkDescription, newTimestamp); | 239 | final Timestamped<LinkDescription> deltaDesc = new Timestamped<>(linkDescription, newTimestamp); |
| 239 | 240 | ||
| 240 | - LinkEvent event = createOrUpdateLinkInternal(providerId, deltaDesc); | 241 | + LinkKey key = linkKey(linkDescription); |
| 242 | + final LinkEvent event; | ||
| 243 | + final Timestamped<LinkDescription> mergedDesc; | ||
| 244 | + synchronized (getLinkDescriptions(key)) { | ||
| 245 | + event = createOrUpdateLinkInternal(providerId, deltaDesc); | ||
| 246 | + mergedDesc = getLinkDescriptions(key).get(providerId); | ||
| 247 | + } | ||
| 241 | 248 | ||
| 242 | if (event != null) { | 249 | if (event != null) { |
| 243 | log.info("Notifying peers of a link update topology event from providerId: " | 250 | log.info("Notifying peers of a link update topology event from providerId: " |
| 244 | + "{} between src: {} and dst: {}", | 251 | + "{} between src: {} and dst: {}", |
| 245 | providerId, linkDescription.src(), linkDescription.dst()); | 252 | providerId, linkDescription.src(), linkDescription.dst()); |
| 246 | try { | 253 | try { |
| 247 | - notifyPeers(new InternalLinkEvent(providerId, deltaDesc)); | 254 | + notifyPeers(new InternalLinkEvent(providerId, mergedDesc)); |
| 248 | } catch (IOException e) { | 255 | } catch (IOException e) { |
| 249 | log.info("Failed to notify peers of a link update topology event from providerId: " | 256 | log.info("Failed to notify peers of a link update topology event from providerId: " |
| 250 | + "{} between src: {} and dst: {}", | 257 | + "{} between src: {} and dst: {}", |
| ... | @@ -258,7 +265,7 @@ public class GossipLinkStore | ... | @@ -258,7 +265,7 @@ public class GossipLinkStore |
| 258 | ProviderId providerId, | 265 | ProviderId providerId, |
| 259 | Timestamped<LinkDescription> linkDescription) { | 266 | Timestamped<LinkDescription> linkDescription) { |
| 260 | 267 | ||
| 261 | - LinkKey key = new LinkKey(linkDescription.value().src(), linkDescription.value().dst()); | 268 | + LinkKey key = linkKey(linkDescription.value()); |
| 262 | ConcurrentMap<ProviderId, Timestamped<LinkDescription>> descs = getLinkDescriptions(key); | 269 | ConcurrentMap<ProviderId, Timestamped<LinkDescription>> descs = getLinkDescriptions(key); |
| 263 | 270 | ||
| 264 | synchronized (descs) { | 271 | synchronized (descs) { |
| ... | @@ -351,7 +358,7 @@ public class GossipLinkStore | ... | @@ -351,7 +358,7 @@ public class GossipLinkStore |
| 351 | 358 | ||
| 352 | @Override | 359 | @Override |
| 353 | public LinkEvent removeLink(ConnectPoint src, ConnectPoint dst) { | 360 | public LinkEvent removeLink(ConnectPoint src, ConnectPoint dst) { |
| 354 | - final LinkKey key = new LinkKey(src, dst); | 361 | + final LinkKey key = linkKey(src, dst); |
| 355 | 362 | ||
| 356 | DeviceId dstDeviceId = dst.deviceId(); | 363 | DeviceId dstDeviceId = dst.deviceId(); |
| 357 | Timestamp timestamp = deviceClockService.getTimestamp(dstDeviceId); | 364 | Timestamp timestamp = deviceClockService.getTimestamp(dstDeviceId); |
| ... | @@ -538,7 +545,7 @@ public class GossipLinkStore | ... | @@ -538,7 +545,7 @@ public class GossipLinkStore |
| 538 | .toList(); | 545 | .toList(); |
| 539 | 546 | ||
| 540 | if (nodeIds.size() == 1 && nodeIds.get(0).equals(self)) { | 547 | if (nodeIds.size() == 1 && nodeIds.get(0).equals(self)) { |
| 541 | - log.info("No other peers in the cluster."); | 548 | + log.debug("No other peers in the cluster."); |
| 542 | return; | 549 | return; |
| 543 | } | 550 | } |
| 544 | 551 | ... | ... |
| 1 | +package org.onlab.onos.store.impl; | ||
| 2 | + | ||
| 3 | +import static org.junit.Assert.assertTrue; | ||
| 4 | + | ||
| 5 | +import java.nio.ByteBuffer; | ||
| 6 | + | ||
| 7 | +import org.junit.Test; | ||
| 8 | +import org.onlab.onos.store.Timestamp; | ||
| 9 | +import org.onlab.util.KryoPool; | ||
| 10 | + | ||
| 11 | +import com.google.common.testing.EqualsTester; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * Tests for {@link WallClockTimestamp}. | ||
| 15 | + */ | ||
| 16 | +public class WallClockTimestampTest { | ||
| 17 | + | ||
| 18 | + @Test | ||
| 19 | + public final void testBasic() throws InterruptedException { | ||
| 20 | + WallClockTimestamp ts1 = new WallClockTimestamp(); | ||
| 21 | + Thread.sleep(50); | ||
| 22 | + WallClockTimestamp ts2 = new WallClockTimestamp(); | ||
| 23 | + | ||
| 24 | + assertTrue(ts1.compareTo(ts1) == 0); | ||
| 25 | + assertTrue(ts2.compareTo(ts1) > 0); | ||
| 26 | + assertTrue(ts1.compareTo(ts2) < 0); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + @Test | ||
| 30 | + public final void testKryoSerializable() { | ||
| 31 | + WallClockTimestamp ts1 = new WallClockTimestamp(); | ||
| 32 | + final ByteBuffer buffer = ByteBuffer.allocate(1 * 1024 * 1024); | ||
| 33 | + final KryoPool kryos = KryoPool.newBuilder() | ||
| 34 | + .register(WallClockTimestamp.class) | ||
| 35 | + .build(); | ||
| 36 | + | ||
| 37 | + kryos.serialize(ts1, buffer); | ||
| 38 | + buffer.flip(); | ||
| 39 | + Timestamp copy = kryos.deserialize(buffer); | ||
| 40 | + | ||
| 41 | + new EqualsTester() | ||
| 42 | + .addEqualityGroup(ts1, copy) | ||
| 43 | + .testEquals(); | ||
| 44 | + } | ||
| 45 | +} |
This diff is collapsed. Click to expand it.
| ... | @@ -3,6 +3,7 @@ package org.onlab.onos.store.link.impl; | ... | @@ -3,6 +3,7 @@ package org.onlab.onos.store.link.impl; |
| 3 | import static com.google.common.cache.CacheBuilder.newBuilder; | 3 | import static com.google.common.cache.CacheBuilder.newBuilder; |
| 4 | import static org.onlab.onos.net.Link.Type.DIRECT; | 4 | import static org.onlab.onos.net.Link.Type.DIRECT; |
| 5 | import static org.onlab.onos.net.Link.Type.INDIRECT; | 5 | import static org.onlab.onos.net.Link.Type.INDIRECT; |
| 6 | +import static org.onlab.onos.net.LinkKey.linkKey; | ||
| 6 | import static org.onlab.onos.net.link.LinkEvent.Type.LINK_ADDED; | 7 | import static org.onlab.onos.net.link.LinkEvent.Type.LINK_ADDED; |
| 7 | import static org.onlab.onos.net.link.LinkEvent.Type.LINK_REMOVED; | 8 | import static org.onlab.onos.net.link.LinkEvent.Type.LINK_REMOVED; |
| 8 | import static org.onlab.onos.net.link.LinkEvent.Type.LINK_UPDATED; | 9 | import static org.onlab.onos.net.link.LinkEvent.Type.LINK_UPDATED; |
| ... | @@ -122,7 +123,7 @@ public class DistributedLinkStore | ... | @@ -122,7 +123,7 @@ public class DistributedLinkStore |
| 122 | 123 | ||
| 123 | @Override | 124 | @Override |
| 124 | public Link getLink(ConnectPoint src, ConnectPoint dst) { | 125 | public Link getLink(ConnectPoint src, ConnectPoint dst) { |
| 125 | - return links.getUnchecked(new LinkKey(src, dst)).orNull(); | 126 | + return links.getUnchecked(linkKey(src, dst)).orNull(); |
| 126 | } | 127 | } |
| 127 | 128 | ||
| 128 | @Override | 129 | @Override |
| ... | @@ -150,7 +151,7 @@ public class DistributedLinkStore | ... | @@ -150,7 +151,7 @@ public class DistributedLinkStore |
| 150 | @Override | 151 | @Override |
| 151 | public LinkEvent createOrUpdateLink(ProviderId providerId, | 152 | public LinkEvent createOrUpdateLink(ProviderId providerId, |
| 152 | LinkDescription linkDescription) { | 153 | LinkDescription linkDescription) { |
| 153 | - LinkKey key = new LinkKey(linkDescription.src(), linkDescription.dst()); | 154 | + LinkKey key = linkKey(linkDescription); |
| 154 | Optional<DefaultLink> link = links.getUnchecked(key); | 155 | Optional<DefaultLink> link = links.getUnchecked(key); |
| 155 | if (!link.isPresent()) { | 156 | if (!link.isPresent()) { |
| 156 | return createLink(providerId, key, linkDescription); | 157 | return createLink(providerId, key, linkDescription); |
| ... | @@ -216,7 +217,7 @@ public class DistributedLinkStore | ... | @@ -216,7 +217,7 @@ public class DistributedLinkStore |
| 216 | @Override | 217 | @Override |
| 217 | public LinkEvent removeLink(ConnectPoint src, ConnectPoint dst) { | 218 | public LinkEvent removeLink(ConnectPoint src, ConnectPoint dst) { |
| 218 | synchronized (this) { | 219 | synchronized (this) { |
| 219 | - LinkKey key = new LinkKey(src, dst); | 220 | + LinkKey key = linkKey(src, dst); |
| 220 | byte[] keyBytes = serialize(key); | 221 | byte[] keyBytes = serialize(key); |
| 221 | Link link = deserialize(rawLinks.remove(keyBytes)); | 222 | Link link = deserialize(rawLinks.remove(keyBytes)); |
| 222 | links.invalidate(key); | 223 | links.invalidate(key); | ... | ... |
| ... | @@ -3,6 +3,7 @@ package org.onlab.onos.store.link.impl; | ... | @@ -3,6 +3,7 @@ package org.onlab.onos.store.link.impl; |
| 3 | import static org.junit.Assert.*; | 3 | import static org.junit.Assert.*; |
| 4 | import static org.onlab.onos.net.DeviceId.deviceId; | 4 | import static org.onlab.onos.net.DeviceId.deviceId; |
| 5 | import static org.onlab.onos.net.Link.Type.*; | 5 | import static org.onlab.onos.net.Link.Type.*; |
| 6 | +import static org.onlab.onos.net.LinkKey.linkKey; | ||
| 6 | import static org.onlab.onos.net.link.LinkEvent.Type.*; | 7 | import static org.onlab.onos.net.link.LinkEvent.Type.*; |
| 7 | 8 | ||
| 8 | import java.util.HashMap; | 9 | import java.util.HashMap; |
| ... | @@ -122,8 +123,8 @@ public class DistributedLinkStoreTest { | ... | @@ -122,8 +123,8 @@ public class DistributedLinkStoreTest { |
| 122 | assertEquals("initialy empty", 0, | 123 | assertEquals("initialy empty", 0, |
| 123 | Iterables.size(linkStore.getLinks())); | 124 | Iterables.size(linkStore.getLinks())); |
| 124 | 125 | ||
| 125 | - LinkKey linkId1 = new LinkKey(new ConnectPoint(DID1, P1), new ConnectPoint(DID2, P2)); | 126 | + LinkKey linkId1 = linkKey(new ConnectPoint(DID1, P1), new ConnectPoint(DID2, P2)); |
| 126 | - LinkKey linkId2 = new LinkKey(new ConnectPoint(DID2, P2), new ConnectPoint(DID1, P1)); | 127 | + LinkKey linkId2 = linkKey(new ConnectPoint(DID2, P2), new ConnectPoint(DID1, P1)); |
| 127 | 128 | ||
| 128 | putLink(linkId1, DIRECT); | 129 | putLink(linkId1, DIRECT); |
| 129 | putLink(linkId2, DIRECT); | 130 | putLink(linkId2, DIRECT); |
| ... | @@ -134,7 +135,7 @@ public class DistributedLinkStoreTest { | ... | @@ -134,7 +135,7 @@ public class DistributedLinkStoreTest { |
| 134 | 135 | ||
| 135 | Map<LinkKey, Link> links = new HashMap<>(); | 136 | Map<LinkKey, Link> links = new HashMap<>(); |
| 136 | for (Link link : linkStore.getLinks()) { | 137 | for (Link link : linkStore.getLinks()) { |
| 137 | - links.put(new LinkKey(link.src(), link.dst()), link); | 138 | + links.put(linkKey(link), link); |
| 138 | } | 139 | } |
| 139 | 140 | ||
| 140 | assertLink(linkId1, DIRECT, links.get(linkId1)); | 141 | assertLink(linkId1, DIRECT, links.get(linkId1)); |
| ... | @@ -143,9 +144,9 @@ public class DistributedLinkStoreTest { | ... | @@ -143,9 +144,9 @@ public class DistributedLinkStoreTest { |
| 143 | 144 | ||
| 144 | @Test | 145 | @Test |
| 145 | public final void testGetDeviceEgressLinks() { | 146 | public final void testGetDeviceEgressLinks() { |
| 146 | - LinkKey linkId1 = new LinkKey(new ConnectPoint(DID1, P1), new ConnectPoint(DID2, P2)); | 147 | + LinkKey linkId1 = linkKey(new ConnectPoint(DID1, P1), new ConnectPoint(DID2, P2)); |
| 147 | - LinkKey linkId2 = new LinkKey(new ConnectPoint(DID2, P2), new ConnectPoint(DID1, P1)); | 148 | + LinkKey linkId2 = linkKey(new ConnectPoint(DID2, P2), new ConnectPoint(DID1, P1)); |
| 148 | - LinkKey linkId3 = new LinkKey(new ConnectPoint(DID1, P2), new ConnectPoint(DID2, P3)); | 149 | + LinkKey linkId3 = linkKey(new ConnectPoint(DID1, P2), new ConnectPoint(DID2, P3)); |
| 149 | 150 | ||
| 150 | putLink(linkId1, DIRECT); | 151 | putLink(linkId1, DIRECT); |
| 151 | putLink(linkId2, DIRECT); | 152 | putLink(linkId2, DIRECT); |
| ... | @@ -166,9 +167,9 @@ public class DistributedLinkStoreTest { | ... | @@ -166,9 +167,9 @@ public class DistributedLinkStoreTest { |
| 166 | 167 | ||
| 167 | @Test | 168 | @Test |
| 168 | public final void testGetDeviceIngressLinks() { | 169 | public final void testGetDeviceIngressLinks() { |
| 169 | - LinkKey linkId1 = new LinkKey(new ConnectPoint(DID1, P1), new ConnectPoint(DID2, P2)); | 170 | + LinkKey linkId1 = linkKey(new ConnectPoint(DID1, P1), new ConnectPoint(DID2, P2)); |
| 170 | - LinkKey linkId2 = new LinkKey(new ConnectPoint(DID2, P2), new ConnectPoint(DID1, P1)); | 171 | + LinkKey linkId2 = linkKey(new ConnectPoint(DID2, P2), new ConnectPoint(DID1, P1)); |
| 171 | - LinkKey linkId3 = new LinkKey(new ConnectPoint(DID1, P2), new ConnectPoint(DID2, P3)); | 172 | + LinkKey linkId3 = linkKey(new ConnectPoint(DID1, P2), new ConnectPoint(DID2, P3)); |
| 172 | 173 | ||
| 173 | putLink(linkId1, DIRECT); | 174 | putLink(linkId1, DIRECT); |
| 174 | putLink(linkId2, DIRECT); | 175 | putLink(linkId2, DIRECT); |
| ... | @@ -191,7 +192,7 @@ public class DistributedLinkStoreTest { | ... | @@ -191,7 +192,7 @@ public class DistributedLinkStoreTest { |
| 191 | public final void testGetLink() { | 192 | public final void testGetLink() { |
| 192 | ConnectPoint src = new ConnectPoint(DID1, P1); | 193 | ConnectPoint src = new ConnectPoint(DID1, P1); |
| 193 | ConnectPoint dst = new ConnectPoint(DID2, P2); | 194 | ConnectPoint dst = new ConnectPoint(DID2, P2); |
| 194 | - LinkKey linkId1 = new LinkKey(src, dst); | 195 | + LinkKey linkId1 = linkKey(src, dst); |
| 195 | 196 | ||
| 196 | putLink(linkId1, DIRECT); | 197 | putLink(linkId1, DIRECT); |
| 197 | 198 | ||
| ... | @@ -206,9 +207,9 @@ public class DistributedLinkStoreTest { | ... | @@ -206,9 +207,9 @@ public class DistributedLinkStoreTest { |
| 206 | public final void testGetEgressLinks() { | 207 | public final void testGetEgressLinks() { |
| 207 | final ConnectPoint d1P1 = new ConnectPoint(DID1, P1); | 208 | final ConnectPoint d1P1 = new ConnectPoint(DID1, P1); |
| 208 | final ConnectPoint d2P2 = new ConnectPoint(DID2, P2); | 209 | final ConnectPoint d2P2 = new ConnectPoint(DID2, P2); |
| 209 | - LinkKey linkId1 = new LinkKey(d1P1, d2P2); | 210 | + LinkKey linkId1 = linkKey(d1P1, d2P2); |
| 210 | - LinkKey linkId2 = new LinkKey(d2P2, d1P1); | 211 | + LinkKey linkId2 = linkKey(d2P2, d1P1); |
| 211 | - LinkKey linkId3 = new LinkKey(new ConnectPoint(DID1, P2), new ConnectPoint(DID2, P3)); | 212 | + LinkKey linkId3 = linkKey(new ConnectPoint(DID1, P2), new ConnectPoint(DID2, P3)); |
| 212 | 213 | ||
| 213 | putLink(linkId1, DIRECT); | 214 | putLink(linkId1, DIRECT); |
| 214 | putLink(linkId2, DIRECT); | 215 | putLink(linkId2, DIRECT); |
| ... | @@ -231,9 +232,9 @@ public class DistributedLinkStoreTest { | ... | @@ -231,9 +232,9 @@ public class DistributedLinkStoreTest { |
| 231 | public final void testGetIngressLinks() { | 232 | public final void testGetIngressLinks() { |
| 232 | final ConnectPoint d1P1 = new ConnectPoint(DID1, P1); | 233 | final ConnectPoint d1P1 = new ConnectPoint(DID1, P1); |
| 233 | final ConnectPoint d2P2 = new ConnectPoint(DID2, P2); | 234 | final ConnectPoint d2P2 = new ConnectPoint(DID2, P2); |
| 234 | - LinkKey linkId1 = new LinkKey(d1P1, d2P2); | 235 | + LinkKey linkId1 = linkKey(d1P1, d2P2); |
| 235 | - LinkKey linkId2 = new LinkKey(d2P2, d1P1); | 236 | + LinkKey linkId2 = linkKey(d2P2, d1P1); |
| 236 | - LinkKey linkId3 = new LinkKey(new ConnectPoint(DID1, P2), new ConnectPoint(DID2, P3)); | 237 | + LinkKey linkId3 = linkKey(new ConnectPoint(DID1, P2), new ConnectPoint(DID2, P3)); |
| 237 | 238 | ||
| 238 | putLink(linkId1, DIRECT); | 239 | putLink(linkId1, DIRECT); |
| 239 | putLink(linkId2, DIRECT); | 240 | putLink(linkId2, DIRECT); |
| ... | @@ -282,8 +283,8 @@ public class DistributedLinkStoreTest { | ... | @@ -282,8 +283,8 @@ public class DistributedLinkStoreTest { |
| 282 | public final void testRemoveLink() { | 283 | public final void testRemoveLink() { |
| 283 | final ConnectPoint d1P1 = new ConnectPoint(DID1, P1); | 284 | final ConnectPoint d1P1 = new ConnectPoint(DID1, P1); |
| 284 | final ConnectPoint d2P2 = new ConnectPoint(DID2, P2); | 285 | final ConnectPoint d2P2 = new ConnectPoint(DID2, P2); |
| 285 | - LinkKey linkId1 = new LinkKey(d1P1, d2P2); | 286 | + LinkKey linkId1 = linkKey(d1P1, d2P2); |
| 286 | - LinkKey linkId2 = new LinkKey(d2P2, d1P1); | 287 | + LinkKey linkId2 = linkKey(d2P2, d1P1); |
| 287 | 288 | ||
| 288 | putLink(linkId1, DIRECT); | 289 | putLink(linkId1, DIRECT); |
| 289 | putLink(linkId2, DIRECT); | 290 | putLink(linkId2, DIRECT); |
| ... | @@ -306,7 +307,7 @@ public class DistributedLinkStoreTest { | ... | @@ -306,7 +307,7 @@ public class DistributedLinkStoreTest { |
| 306 | 307 | ||
| 307 | final ConnectPoint d1P1 = new ConnectPoint(DID1, P1); | 308 | final ConnectPoint d1P1 = new ConnectPoint(DID1, P1); |
| 308 | final ConnectPoint d2P2 = new ConnectPoint(DID2, P2); | 309 | final ConnectPoint d2P2 = new ConnectPoint(DID2, P2); |
| 309 | - final LinkKey linkId1 = new LinkKey(d1P1, d2P2); | 310 | + final LinkKey linkId1 = linkKey(d1P1, d2P2); |
| 310 | 311 | ||
| 311 | final CountDownLatch addLatch = new CountDownLatch(1); | 312 | final CountDownLatch addLatch = new CountDownLatch(1); |
| 312 | LinkStoreDelegate checkAdd = new LinkStoreDelegate() { | 313 | LinkStoreDelegate checkAdd = new LinkStoreDelegate() { | ... | ... |
| ... | @@ -31,6 +31,6 @@ public class LinkKeySerializer extends Serializer<LinkKey> { | ... | @@ -31,6 +31,6 @@ public class LinkKeySerializer extends Serializer<LinkKey> { |
| 31 | public LinkKey read(Kryo kryo, Input input, Class<LinkKey> type) { | 31 | public LinkKey read(Kryo kryo, Input input, Class<LinkKey> type) { |
| 32 | ConnectPoint src = (ConnectPoint) kryo.readClassAndObject(input); | 32 | ConnectPoint src = (ConnectPoint) kryo.readClassAndObject(input); |
| 33 | ConnectPoint dst = (ConnectPoint) kryo.readClassAndObject(input); | 33 | ConnectPoint dst = (ConnectPoint) kryo.readClassAndObject(input); |
| 34 | - return new LinkKey(src, dst); | 34 | + return LinkKey.linkKey(src, dst); |
| 35 | } | 35 | } |
| 36 | } | 36 | } | ... | ... |
| ... | @@ -108,7 +108,7 @@ public class KryoSerializerTest { | ... | @@ -108,7 +108,7 @@ public class KryoSerializerTest { |
| 108 | testSerialized(ImmutableSet.of()); | 108 | testSerialized(ImmutableSet.of()); |
| 109 | testSerialized(IpPrefix.valueOf("192.168.0.1/24")); | 109 | testSerialized(IpPrefix.valueOf("192.168.0.1/24")); |
| 110 | testSerialized(IpAddress.valueOf("192.168.0.1")); | 110 | testSerialized(IpAddress.valueOf("192.168.0.1")); |
| 111 | - testSerialized(new LinkKey(CP1, CP2)); | 111 | + testSerialized(LinkKey.linkKey(CP1, CP2)); |
| 112 | testSerialized(new NodeId("SomeNodeIdentifier")); | 112 | testSerialized(new NodeId("SomeNodeIdentifier")); |
| 113 | testSerialized(P1); | 113 | testSerialized(P1); |
| 114 | testSerialized(PID); | 114 | testSerialized(PID); | ... | ... |
| ... | @@ -42,6 +42,7 @@ import static org.onlab.onos.net.DefaultAnnotations.union; | ... | @@ -42,6 +42,7 @@ import static org.onlab.onos.net.DefaultAnnotations.union; |
| 42 | import static org.onlab.onos.net.DefaultAnnotations.merge; | 42 | import static org.onlab.onos.net.DefaultAnnotations.merge; |
| 43 | import static org.onlab.onos.net.Link.Type.DIRECT; | 43 | import static org.onlab.onos.net.Link.Type.DIRECT; |
| 44 | import static org.onlab.onos.net.Link.Type.INDIRECT; | 44 | import static org.onlab.onos.net.Link.Type.INDIRECT; |
| 45 | +import static org.onlab.onos.net.LinkKey.linkKey; | ||
| 45 | import static org.onlab.onos.net.link.LinkEvent.Type.*; | 46 | import static org.onlab.onos.net.link.LinkEvent.Type.*; |
| 46 | import static org.slf4j.LoggerFactory.getLogger; | 47 | import static org.slf4j.LoggerFactory.getLogger; |
| 47 | import static com.google.common.collect.Multimaps.synchronizedSetMultimap; | 48 | import static com.google.common.collect.Multimaps.synchronizedSetMultimap; |
| ... | @@ -120,7 +121,7 @@ public class SimpleLinkStore | ... | @@ -120,7 +121,7 @@ public class SimpleLinkStore |
| 120 | 121 | ||
| 121 | @Override | 122 | @Override |
| 122 | public Link getLink(ConnectPoint src, ConnectPoint dst) { | 123 | public Link getLink(ConnectPoint src, ConnectPoint dst) { |
| 123 | - return links.get(new LinkKey(src, dst)); | 124 | + return links.get(linkKey(src, dst)); |
| 124 | } | 125 | } |
| 125 | 126 | ||
| 126 | @Override | 127 | @Override |
| ... | @@ -148,7 +149,7 @@ public class SimpleLinkStore | ... | @@ -148,7 +149,7 @@ public class SimpleLinkStore |
| 148 | @Override | 149 | @Override |
| 149 | public LinkEvent createOrUpdateLink(ProviderId providerId, | 150 | public LinkEvent createOrUpdateLink(ProviderId providerId, |
| 150 | LinkDescription linkDescription) { | 151 | LinkDescription linkDescription) { |
| 151 | - LinkKey key = new LinkKey(linkDescription.src(), linkDescription.dst()); | 152 | + LinkKey key = linkKey(linkDescription); |
| 152 | 153 | ||
| 153 | ConcurrentMap<ProviderId, LinkDescription> descs = getLinkDescriptions(key); | 154 | ConcurrentMap<ProviderId, LinkDescription> descs = getLinkDescriptions(key); |
| 154 | synchronized (descs) { | 155 | synchronized (descs) { |
| ... | @@ -225,7 +226,7 @@ public class SimpleLinkStore | ... | @@ -225,7 +226,7 @@ public class SimpleLinkStore |
| 225 | 226 | ||
| 226 | @Override | 227 | @Override |
| 227 | public LinkEvent removeLink(ConnectPoint src, ConnectPoint dst) { | 228 | public LinkEvent removeLink(ConnectPoint src, ConnectPoint dst) { |
| 228 | - final LinkKey key = new LinkKey(src, dst); | 229 | + final LinkKey key = linkKey(src, dst); |
| 229 | ConcurrentMap<ProviderId, LinkDescription> descs = getLinkDescriptions(key); | 230 | ConcurrentMap<ProviderId, LinkDescription> descs = getLinkDescriptions(key); |
| 230 | synchronized (descs) { | 231 | synchronized (descs) { |
| 231 | Link link = links.remove(key); | 232 | Link link = links.remove(key); | ... | ... |
| ... | @@ -136,8 +136,8 @@ public class SimpleLinkStoreTest { | ... | @@ -136,8 +136,8 @@ public class SimpleLinkStoreTest { |
| 136 | assertEquals("initialy empty", 0, | 136 | assertEquals("initialy empty", 0, |
| 137 | Iterables.size(linkStore.getLinks())); | 137 | Iterables.size(linkStore.getLinks())); |
| 138 | 138 | ||
| 139 | - LinkKey linkId1 = new LinkKey(new ConnectPoint(DID1, P1), new ConnectPoint(DID2, P2)); | 139 | + LinkKey linkId1 = LinkKey.linkKey(new ConnectPoint(DID1, P1), new ConnectPoint(DID2, P2)); |
| 140 | - LinkKey linkId2 = new LinkKey(new ConnectPoint(DID2, P2), new ConnectPoint(DID1, P1)); | 140 | + LinkKey linkId2 = LinkKey.linkKey(new ConnectPoint(DID2, P2), new ConnectPoint(DID1, P1)); |
| 141 | 141 | ||
| 142 | putLink(linkId1, DIRECT); | 142 | putLink(linkId1, DIRECT); |
| 143 | putLink(linkId2, DIRECT); | 143 | putLink(linkId2, DIRECT); |
| ... | @@ -148,7 +148,7 @@ public class SimpleLinkStoreTest { | ... | @@ -148,7 +148,7 @@ public class SimpleLinkStoreTest { |
| 148 | 148 | ||
| 149 | Map<LinkKey, Link> links = new HashMap<>(); | 149 | Map<LinkKey, Link> links = new HashMap<>(); |
| 150 | for (Link link : linkStore.getLinks()) { | 150 | for (Link link : linkStore.getLinks()) { |
| 151 | - links.put(new LinkKey(link.src(), link.dst()), link); | 151 | + links.put(LinkKey.linkKey(link), link); |
| 152 | } | 152 | } |
| 153 | 153 | ||
| 154 | assertLink(linkId1, DIRECT, links.get(linkId1)); | 154 | assertLink(linkId1, DIRECT, links.get(linkId1)); |
| ... | @@ -157,9 +157,9 @@ public class SimpleLinkStoreTest { | ... | @@ -157,9 +157,9 @@ public class SimpleLinkStoreTest { |
| 157 | 157 | ||
| 158 | @Test | 158 | @Test |
| 159 | public final void testGetDeviceEgressLinks() { | 159 | public final void testGetDeviceEgressLinks() { |
| 160 | - LinkKey linkId1 = new LinkKey(new ConnectPoint(DID1, P1), new ConnectPoint(DID2, P2)); | 160 | + LinkKey linkId1 = LinkKey.linkKey(new ConnectPoint(DID1, P1), new ConnectPoint(DID2, P2)); |
| 161 | - LinkKey linkId2 = new LinkKey(new ConnectPoint(DID2, P2), new ConnectPoint(DID1, P1)); | 161 | + LinkKey linkId2 = LinkKey.linkKey(new ConnectPoint(DID2, P2), new ConnectPoint(DID1, P1)); |
| 162 | - LinkKey linkId3 = new LinkKey(new ConnectPoint(DID1, P2), new ConnectPoint(DID2, P3)); | 162 | + LinkKey linkId3 = LinkKey.linkKey(new ConnectPoint(DID1, P2), new ConnectPoint(DID2, P3)); |
| 163 | 163 | ||
| 164 | putLink(linkId1, DIRECT); | 164 | putLink(linkId1, DIRECT); |
| 165 | putLink(linkId2, DIRECT); | 165 | putLink(linkId2, DIRECT); |
| ... | @@ -180,9 +180,9 @@ public class SimpleLinkStoreTest { | ... | @@ -180,9 +180,9 @@ public class SimpleLinkStoreTest { |
| 180 | 180 | ||
| 181 | @Test | 181 | @Test |
| 182 | public final void testGetDeviceIngressLinks() { | 182 | public final void testGetDeviceIngressLinks() { |
| 183 | - LinkKey linkId1 = new LinkKey(new ConnectPoint(DID1, P1), new ConnectPoint(DID2, P2)); | 183 | + LinkKey linkId1 = LinkKey.linkKey(new ConnectPoint(DID1, P1), new ConnectPoint(DID2, P2)); |
| 184 | - LinkKey linkId2 = new LinkKey(new ConnectPoint(DID2, P2), new ConnectPoint(DID1, P1)); | 184 | + LinkKey linkId2 = LinkKey.linkKey(new ConnectPoint(DID2, P2), new ConnectPoint(DID1, P1)); |
| 185 | - LinkKey linkId3 = new LinkKey(new ConnectPoint(DID1, P2), new ConnectPoint(DID2, P3)); | 185 | + LinkKey linkId3 = LinkKey.linkKey(new ConnectPoint(DID1, P2), new ConnectPoint(DID2, P3)); |
| 186 | 186 | ||
| 187 | putLink(linkId1, DIRECT); | 187 | putLink(linkId1, DIRECT); |
| 188 | putLink(linkId2, DIRECT); | 188 | putLink(linkId2, DIRECT); |
| ... | @@ -205,7 +205,7 @@ public class SimpleLinkStoreTest { | ... | @@ -205,7 +205,7 @@ public class SimpleLinkStoreTest { |
| 205 | public final void testGetLink() { | 205 | public final void testGetLink() { |
| 206 | ConnectPoint src = new ConnectPoint(DID1, P1); | 206 | ConnectPoint src = new ConnectPoint(DID1, P1); |
| 207 | ConnectPoint dst = new ConnectPoint(DID2, P2); | 207 | ConnectPoint dst = new ConnectPoint(DID2, P2); |
| 208 | - LinkKey linkId1 = new LinkKey(src, dst); | 208 | + LinkKey linkId1 = LinkKey.linkKey(src, dst); |
| 209 | 209 | ||
| 210 | putLink(linkId1, DIRECT); | 210 | putLink(linkId1, DIRECT); |
| 211 | 211 | ||
| ... | @@ -220,9 +220,9 @@ public class SimpleLinkStoreTest { | ... | @@ -220,9 +220,9 @@ public class SimpleLinkStoreTest { |
| 220 | public final void testGetEgressLinks() { | 220 | public final void testGetEgressLinks() { |
| 221 | final ConnectPoint d1P1 = new ConnectPoint(DID1, P1); | 221 | final ConnectPoint d1P1 = new ConnectPoint(DID1, P1); |
| 222 | final ConnectPoint d2P2 = new ConnectPoint(DID2, P2); | 222 | final ConnectPoint d2P2 = new ConnectPoint(DID2, P2); |
| 223 | - LinkKey linkId1 = new LinkKey(d1P1, d2P2); | 223 | + LinkKey linkId1 = LinkKey.linkKey(d1P1, d2P2); |
| 224 | - LinkKey linkId2 = new LinkKey(d2P2, d1P1); | 224 | + LinkKey linkId2 = LinkKey.linkKey(d2P2, d1P1); |
| 225 | - LinkKey linkId3 = new LinkKey(new ConnectPoint(DID1, P2), new ConnectPoint(DID2, P3)); | 225 | + LinkKey linkId3 = LinkKey.linkKey(new ConnectPoint(DID1, P2), new ConnectPoint(DID2, P3)); |
| 226 | 226 | ||
| 227 | putLink(linkId1, DIRECT); | 227 | putLink(linkId1, DIRECT); |
| 228 | putLink(linkId2, DIRECT); | 228 | putLink(linkId2, DIRECT); |
| ... | @@ -245,9 +245,9 @@ public class SimpleLinkStoreTest { | ... | @@ -245,9 +245,9 @@ public class SimpleLinkStoreTest { |
| 245 | public final void testGetIngressLinks() { | 245 | public final void testGetIngressLinks() { |
| 246 | final ConnectPoint d1P1 = new ConnectPoint(DID1, P1); | 246 | final ConnectPoint d1P1 = new ConnectPoint(DID1, P1); |
| 247 | final ConnectPoint d2P2 = new ConnectPoint(DID2, P2); | 247 | final ConnectPoint d2P2 = new ConnectPoint(DID2, P2); |
| 248 | - LinkKey linkId1 = new LinkKey(d1P1, d2P2); | 248 | + LinkKey linkId1 = LinkKey.linkKey(d1P1, d2P2); |
| 249 | - LinkKey linkId2 = new LinkKey(d2P2, d1P1); | 249 | + LinkKey linkId2 = LinkKey.linkKey(d2P2, d1P1); |
| 250 | - LinkKey linkId3 = new LinkKey(new ConnectPoint(DID1, P2), new ConnectPoint(DID2, P3)); | 250 | + LinkKey linkId3 = LinkKey.linkKey(new ConnectPoint(DID1, P2), new ConnectPoint(DID2, P3)); |
| 251 | 251 | ||
| 252 | putLink(linkId1, DIRECT); | 252 | putLink(linkId1, DIRECT); |
| 253 | putLink(linkId2, DIRECT); | 253 | putLink(linkId2, DIRECT); |
| ... | @@ -349,8 +349,8 @@ public class SimpleLinkStoreTest { | ... | @@ -349,8 +349,8 @@ public class SimpleLinkStoreTest { |
| 349 | public final void testRemoveLink() { | 349 | public final void testRemoveLink() { |
| 350 | final ConnectPoint d1P1 = new ConnectPoint(DID1, P1); | 350 | final ConnectPoint d1P1 = new ConnectPoint(DID1, P1); |
| 351 | final ConnectPoint d2P2 = new ConnectPoint(DID2, P2); | 351 | final ConnectPoint d2P2 = new ConnectPoint(DID2, P2); |
| 352 | - LinkKey linkId1 = new LinkKey(d1P1, d2P2); | 352 | + LinkKey linkId1 = LinkKey.linkKey(d1P1, d2P2); |
| 353 | - LinkKey linkId2 = new LinkKey(d2P2, d1P1); | 353 | + LinkKey linkId2 = LinkKey.linkKey(d2P2, d1P1); |
| 354 | 354 | ||
| 355 | putLink(linkId1, DIRECT, A1); | 355 | putLink(linkId1, DIRECT, A1); |
| 356 | putLink(linkId2, DIRECT, A2); | 356 | putLink(linkId2, DIRECT, A2); |
| ... | @@ -406,7 +406,7 @@ public class SimpleLinkStoreTest { | ... | @@ -406,7 +406,7 @@ public class SimpleLinkStoreTest { |
| 406 | 406 | ||
| 407 | final ConnectPoint d1P1 = new ConnectPoint(DID1, P1); | 407 | final ConnectPoint d1P1 = new ConnectPoint(DID1, P1); |
| 408 | final ConnectPoint d2P2 = new ConnectPoint(DID2, P2); | 408 | final ConnectPoint d2P2 = new ConnectPoint(DID2, P2); |
| 409 | - final LinkKey linkId1 = new LinkKey(d1P1, d2P2); | 409 | + final LinkKey linkId1 = LinkKey.linkKey(d1P1, d2P2); |
| 410 | 410 | ||
| 411 | final CountDownLatch addLatch = new CountDownLatch(1); | 411 | final CountDownLatch addLatch = new CountDownLatch(1); |
| 412 | LinkStoreDelegate checkAdd = new LinkStoreDelegate() { | 412 | LinkStoreDelegate checkAdd = new LinkStoreDelegate() { | ... | ... |
-
Please register or login to post a comment