Fixing ONOS-39 to allow configured links to be marked as durable.
Change-Id: I97b920bf5f597ddb8b64ecc5c4c3769527ad5260
Showing
5 changed files
with
145 additions
and
24 deletions
| ... | @@ -65,6 +65,7 @@ import java.util.Collections; | ... | @@ -65,6 +65,7 @@ import java.util.Collections; |
| 65 | import java.util.HashMap; | 65 | import java.util.HashMap; |
| 66 | import java.util.HashSet; | 66 | import java.util.HashSet; |
| 67 | import java.util.Map; | 67 | import java.util.Map; |
| 68 | +import java.util.Objects; | ||
| 68 | import java.util.Set; | 69 | import java.util.Set; |
| 69 | import java.util.Map.Entry; | 70 | import java.util.Map.Entry; |
| 70 | import java.util.concurrent.ConcurrentHashMap; | 71 | import java.util.concurrent.ConcurrentHashMap; |
| ... | @@ -448,8 +449,12 @@ public class GossipLinkStore | ... | @@ -448,8 +449,12 @@ public class GossipLinkStore |
| 448 | // outdated remove request, ignore | 449 | // outdated remove request, ignore |
| 449 | return null; | 450 | return null; |
| 450 | } | 451 | } |
| 452 | + Link link = links.get(key); | ||
| 453 | + if (isDurable(link)) { | ||
| 454 | + return null; | ||
| 455 | + } | ||
| 451 | removedLinks.put(key, timestamp); | 456 | removedLinks.put(key, timestamp); |
| 452 | - Link link = links.remove(key); | 457 | + links.remove(key); |
| 453 | linkDescriptions.clear(); | 458 | linkDescriptions.clear(); |
| 454 | if (link != null) { | 459 | if (link != null) { |
| 455 | srcLinks.remove(link.src().deviceId(), key); | 460 | srcLinks.remove(link.src().deviceId(), key); |
| ... | @@ -460,6 +465,11 @@ public class GossipLinkStore | ... | @@ -460,6 +465,11 @@ public class GossipLinkStore |
| 460 | } | 465 | } |
| 461 | } | 466 | } |
| 462 | 467 | ||
| 468 | + // Indicates if the link has been marked as durable via annotations. | ||
| 469 | + private boolean isDurable(Link link) { | ||
| 470 | + return link != null && Objects.equals(link.annotations().value("durable"), "true"); | ||
| 471 | + } | ||
| 472 | + | ||
| 463 | private static <K, V> SetMultimap<K, V> createSynchronizedHashMultiMap() { | 473 | private static <K, V> SetMultimap<K, V> createSynchronizedHashMultiMap() { |
| 464 | return synchronizedSetMultimap(HashMultimap.<K, V>create()); | 474 | return synchronizedSetMultimap(HashMultimap.<K, V>create()); |
| 465 | } | 475 | } | ... | ... |
| ... | @@ -46,6 +46,7 @@ import java.util.Collections; | ... | @@ -46,6 +46,7 @@ import java.util.Collections; |
| 46 | import java.util.HashMap; | 46 | import java.util.HashMap; |
| 47 | import java.util.HashSet; | 47 | import java.util.HashSet; |
| 48 | import java.util.Map; | 48 | import java.util.Map; |
| 49 | +import java.util.Objects; | ||
| 49 | import java.util.Set; | 50 | import java.util.Set; |
| 50 | import java.util.Map.Entry; | 51 | import java.util.Map.Entry; |
| 51 | import java.util.concurrent.ConcurrentHashMap; | 52 | import java.util.concurrent.ConcurrentHashMap; |
| ... | @@ -233,7 +234,11 @@ public class SimpleLinkStore | ... | @@ -233,7 +234,11 @@ public class SimpleLinkStore |
| 233 | final LinkKey key = linkKey(src, dst); | 234 | final LinkKey key = linkKey(src, dst); |
| 234 | Map<ProviderId, LinkDescription> descs = getOrCreateLinkDescriptions(key); | 235 | Map<ProviderId, LinkDescription> descs = getOrCreateLinkDescriptions(key); |
| 235 | synchronized (descs) { | 236 | synchronized (descs) { |
| 236 | - Link link = links.remove(key); | 237 | + Link link = links.get(key); |
| 238 | + if (isDurable(link)) { | ||
| 239 | + return null; | ||
| 240 | + } | ||
| 241 | + links.remove(key); | ||
| 237 | descs.clear(); | 242 | descs.clear(); |
| 238 | if (link != null) { | 243 | if (link != null) { |
| 239 | srcLinks.remove(link.src().deviceId(), key); | 244 | srcLinks.remove(link.src().deviceId(), key); |
| ... | @@ -244,6 +249,11 @@ public class SimpleLinkStore | ... | @@ -244,6 +249,11 @@ public class SimpleLinkStore |
| 244 | } | 249 | } |
| 245 | } | 250 | } |
| 246 | 251 | ||
| 252 | + // Indicates if the link has been marked as durable via annotations. | ||
| 253 | + private boolean isDurable(Link link) { | ||
| 254 | + return link != null && Objects.equals(link.annotations().value("durable"), "true"); | ||
| 255 | + } | ||
| 256 | + | ||
| 247 | private static <K, V> SetMultimap<K, V> createSynchronizedHashMultiMap() { | 257 | private static <K, V> SetMultimap<K, V> createSynchronizedHashMultiMap() { |
| 248 | return synchronizedSetMultimap(HashMultimap.<K, V>create()); | 258 | return synchronizedSetMultimap(HashMultimap.<K, V>create()); |
| 249 | } | 259 | } | ... | ... |
tools/package/etc/org.ops4j.pax.url.mvn.cfg
0 → 100644
| 1 | +################################################################################ | ||
| 2 | +# | ||
| 3 | +# Licensed to the Apache Software Foundation (ASF) under one or more | ||
| 4 | +# contributor license agreements. See the NOTICE file distributed with | ||
| 5 | +# this work for additional information regarding copyright ownership. | ||
| 6 | +# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| 7 | +# (the "License"); you may not use this file except in compliance with | ||
| 8 | +# the License. You may obtain a copy of the License at | ||
| 9 | +# | ||
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 | ||
| 11 | +# | ||
| 12 | +# Unless required by applicable law or agreed to in writing, software | ||
| 13 | +# distributed under the License is distributed on an "AS IS" BASIS, | ||
| 14 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 15 | +# See the License for the specific language governing permissions and | ||
| 16 | +# limitations under the License. | ||
| 17 | +# | ||
| 18 | +################################################################################ | ||
| 19 | + | ||
| 20 | +# | ||
| 21 | +# If set to true, the following property will not allow any certificate to be used | ||
| 22 | +# when accessing Maven repositories through SSL | ||
| 23 | +# | ||
| 24 | +#org.ops4j.pax.url.mvn.certificateCheck= | ||
| 25 | + | ||
| 26 | +# | ||
| 27 | +# Path to the local Maven settings file. | ||
| 28 | +# The repositories defined in this file will be automatically added to the list | ||
| 29 | +# of default repositories if the 'org.ops4j.pax.url.mvn.repositories' property | ||
| 30 | +# below is not set. | ||
| 31 | +# The following locations are checked for the existence of the settings.xml file | ||
| 32 | +# * 1. looks for the specified url | ||
| 33 | +# * 2. if not found looks for ${user.home}/.m2/settings.xml | ||
| 34 | +# * 3. if not found looks for ${maven.home}/conf/settings.xml | ||
| 35 | +# * 4. if not found looks for ${M2_HOME}/conf/settings.xml | ||
| 36 | +# | ||
| 37 | +#org.ops4j.pax.url.mvn.settings= | ||
| 38 | + | ||
| 39 | +# | ||
| 40 | +# Path to the local Maven repository which is used to avoid downloading | ||
| 41 | +# artifacts when they already exist locally. | ||
| 42 | +# The value of this property will be extracted from the settings.xml file | ||
| 43 | +# above, or defaulted to: | ||
| 44 | +# System.getProperty( "user.home" ) + "/.m2/repository" | ||
| 45 | +# | ||
| 46 | +#org.ops4j.pax.url.mvn.localRepository= | ||
| 47 | + | ||
| 48 | +# | ||
| 49 | +# Default this to false. It's just weird to use undocumented repos | ||
| 50 | +# | ||
| 51 | +org.ops4j.pax.url.mvn.useFallbackRepositories=false | ||
| 52 | + | ||
| 53 | +# | ||
| 54 | +# Uncomment if you don't wanna use the proxy settings | ||
| 55 | +# from the Maven conf/settings.xml file | ||
| 56 | +# | ||
| 57 | +# org.ops4j.pax.url.mvn.proxySupport=false | ||
| 58 | + | ||
| 59 | +# | ||
| 60 | +# Comma separated list of repositories scanned when resolving an artifact. | ||
| 61 | +# Those repositories will be checked before iterating through the | ||
| 62 | +# below list of repositories and even before the local repository | ||
| 63 | +# A repository url can be appended with zero or more of the following flags: | ||
| 64 | +# @snapshots : the repository contains snaphots | ||
| 65 | +# @noreleases : the repository does not contain any released artifacts | ||
| 66 | +# | ||
| 67 | +# The following property value will add the system folder as a repo. | ||
| 68 | +# | ||
| 69 | +org.ops4j.pax.url.mvn.defaultRepositories=\ | ||
| 70 | + file:${karaf.home}/${karaf.default.repository}@id=system.repository@snapshots,\ | ||
| 71 | + file:${karaf.data}/kar@id=kar.repository@multi@snapshots | ||
| 72 | + | ||
| 73 | +# Use the default local repo (e.g.~/.m2/repository) as a "remote" repo | ||
| 74 | +#org.ops4j.pax.url.mvn.defaultLocalRepoAsRemote=false | ||
| 75 | + | ||
| 76 | +# | ||
| 77 | +# Comma separated list of repositories scanned when resolving an artifact. | ||
| 78 | +# The default list includes the following repositories: | ||
| 79 | +# http://repo1.maven.org/maven2@id=central | ||
| 80 | +# http://repository.springsource.com/maven/bundles/release@id=spring.ebr | ||
| 81 | +# http://repository.springsource.com/maven/bundles/external@id=spring.ebr.external | ||
| 82 | +# http://zodiac.springsource.com/maven/bundles/release@id=gemini | ||
| 83 | +# http://repository.apache.org/content/groups/snapshots-group@id=apache@snapshots@noreleases | ||
| 84 | +# https://oss.sonatype.org/content/repositories/snapshots@id=sonatype.snapshots.deploy@snapshots@norelease | ||
| 85 | +# https://oss.sonatype.org/content/repositories/ops4j-snapshots@id=ops4j.sonatype.snapshots.deploy@snapshots@noreleases | ||
| 86 | +# To add repositories to the default ones, prepend '+' to the list of repositories | ||
| 87 | +# to add. | ||
| 88 | +# A repository url can be appended with zero or more of the following flags: | ||
| 89 | +# @snapshots : the repository contains snapshots | ||
| 90 | +# @noreleases : the repository does not contain any released artifacts | ||
| 91 | +# @id=repository.id : the id for the repository, just like in the settings.xml this is optional but recommended | ||
| 92 | +# | ||
| 93 | +org.ops4j.pax.url.mvn.repositories= \ | ||
| 94 | + ${org.ops4j.pax.url.mvn.defaultRepositories}, \ | ||
| 95 | + http://repo1.maven.org/maven2@id=central, \ | ||
| 96 | + http://repository.springsource.com/maven/bundles/release@id=spring.ebr.release, \ | ||
| 97 | + http://repository.springsource.com/maven/bundles/external@id=spring.ebr.external, \ | ||
| 98 | + http://zodiac.springsource.com/maven/bundles/release@id=gemini, \ | ||
| 99 | + http://repository.apache.org/content/groups/snapshots-group@id=apache@snapshots@noreleases, \ | ||
| 100 | + https://oss.sonatype.org/content/repositories/snapshots@id=sonatype.snapshots.deploy@snapshots@norelease, \ | ||
| 101 | + https://oss.sonatype.org/content/repositories/ops4j-snapshots@id=ops4j.sonatype.snapshots.deploy@snapshots@noreleases |
| ... | @@ -34,11 +34,11 @@ | ... | @@ -34,11 +34,11 @@ |
| 34 | ], | 34 | ], |
| 35 | 35 | ||
| 36 | "links" : [ | 36 | "links" : [ |
| 37 | - { "src": "of:0000ffffffffff01/20", "dst": "of:0000ffffffffff03/30", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM" } }, | 37 | + { "src": "of:0000ffffffffff01/20", "dst": "of:0000ffffffffff03/30", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM", "durable": "true" } }, |
| 38 | - { "src": "of:0000ffffffffff02/21", "dst": "of:0000ffffffffff03/31", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM" } }, | 38 | + { "src": "of:0000ffffffffff02/21", "dst": "of:0000ffffffffff03/31", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM", "durable": "true" } }, |
| 39 | 39 | ||
| 40 | - { "src": "of:0000ffffffff0001/2", "dst": "of:0000ffffffffff01/10", "type": "OPTICAL", "annotations": { "bandwidth": 100000, "optical.type": "cross-connect" } }, | 40 | + { "src": "of:0000ffffffff0001/2", "dst": "of:0000ffffffffff01/10", "type": "OPTICAL", "annotations": { "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" } }, |
| 41 | - { "src": "of:0000ffffffff0002/2", "dst": "of:0000ffffffffff02/11", "type": "OPTICAL", "annotations": { "bandwidth": 100000, "optical.type": "cross-connect" } } | 41 | + { "src": "of:0000ffffffff0002/2", "dst": "of:0000ffffffffff02/11", "type": "OPTICAL", "annotations": { "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" } } |
| 42 | ], | 42 | ], |
| 43 | 43 | ||
| 44 | "hosts" : [ | 44 | "hosts" : [ | ... | ... |
| ... | @@ -108,25 +108,25 @@ | ... | @@ -108,25 +108,25 @@ |
| 108 | ], | 108 | ], |
| 109 | 109 | ||
| 110 | "links" : [ | 110 | "links" : [ |
| 111 | - { "src": "of:0000ffffffffff01/10", "dst": "of:0000ffffffffff02/10", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000 } }, | 111 | + { "src": "of:0000ffffffffff01/10", "dst": "of:0000ffffffffff02/10", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" } }, |
| 112 | - { "src": "of:0000ffffffffff02/10", "dst": "of:0000ffffffffff03/10", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000 } }, | 112 | + { "src": "of:0000ffffffffff02/10", "dst": "of:0000ffffffffff03/10", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" } }, |
| 113 | - { "src": "of:0000ffffffffff03/30", "dst": "of:0000ffffffffff04/10", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000 } }, | 113 | + { "src": "of:0000ffffffffff03/30", "dst": "of:0000ffffffffff04/10", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" } }, |
| 114 | - { "src": "of:0000ffffffffff02/20", "dst": "of:0000ffffffffff05/10", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000 } }, | 114 | + { "src": "of:0000ffffffffff02/20", "dst": "of:0000ffffffffff05/10", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" } }, |
| 115 | - { "src": "of:0000ffffffffff03/20", "dst": "of:0000ffffffffff06/10", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000 } }, | 115 | + { "src": "of:0000ffffffffff03/20", "dst": "of:0000ffffffffff06/10", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" } }, |
| 116 | - { "src": "of:0000ffffffffff05/30", "dst": "of:0000ffffffffff06/20", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000 } }, | 116 | + { "src": "of:0000ffffffffff05/30", "dst": "of:0000ffffffffff06/20", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" } }, |
| 117 | - { "src": "of:0000ffffffffff05/20", "dst": "of:0000ffffffffff07/21", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000 } }, | 117 | + { "src": "of:0000ffffffffff05/20", "dst": "of:0000ffffffffff07/21", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" } }, |
| 118 | - { "src": "of:0000ffffffffff06/30", "dst": "of:0000ffffffffff08/10", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000 } }, | 118 | + { "src": "of:0000ffffffffff06/30", "dst": "of:0000ffffffffff08/10", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" } }, |
| 119 | - { "src": "of:0000ffffffffff07/30", "dst": "of:0000ffffffffff08/20", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000 } }, | 119 | + { "src": "of:0000ffffffffff07/30", "dst": "of:0000ffffffffff08/20", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" } }, |
| 120 | - { "src": "of:0000ffffffffff07/20", "dst": "of:0000ffffffffff09/10", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000 } }, | 120 | + { "src": "of:0000ffffffffff07/20", "dst": "of:0000ffffffffff09/10", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" } }, |
| 121 | - { "src": "of:0000ffffffffff08/30", "dst": "of:0000ffffffffff0A/10", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000 } }, | 121 | + { "src": "of:0000ffffffffff08/30", "dst": "of:0000ffffffffff0A/10", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" } }, |
| 122 | - { "src": "of:0000ffffffffff09/20", "dst": "of:0000ffffffffff0A/20", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000 } }, | 122 | + { "src": "of:0000ffffffffff09/20", "dst": "of:0000ffffffffff0A/20", "type": "OPTICAL", "annotations": { "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" } }, |
| 123 | 123 | ||
| 124 | - { "src": "of:0000ffffffff0001/2", "dst": "of:0000ffffffffff01/1", "type": "OPTICAL", "annotations": { "bandwidth": 100000, "optical.type": "cross-connect" } }, | 124 | + { "src": "of:0000ffffffff0001/2", "dst": "of:0000ffffffffff01/1", "type": "OPTICAL", "annotations": { "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" } }, |
| 125 | - { "src": "of:0000ffffffff0003/2", "dst": "of:0000ffffffffff03/1", "type": "OPTICAL", "annotations": { "bandwidth": 100000, "optical.type": "cross-connect" } }, | 125 | + { "src": "of:0000ffffffff0003/2", "dst": "of:0000ffffffffff03/1", "type": "OPTICAL", "annotations": { "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" } }, |
| 126 | - { "src": "of:0000ffffffff0004/2", "dst": "of:0000ffffffffff04/1", "type": "OPTICAL", "annotations": { "bandwidth": 100000, "optical.type": "cross-connect" } }, | 126 | + { "src": "of:0000ffffffff0004/2", "dst": "of:0000ffffffffff04/1", "type": "OPTICAL", "annotations": { "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" } }, |
| 127 | - { "src": "of:0000ffffffff0007/2", "dst": "of:0000ffffffffff07/1", "type": "OPTICAL", "annotations": { "bandwidth": 100000, "optical.type": "cross-connect" } }, | 127 | + { "src": "of:0000ffffffff0007/2", "dst": "of:0000ffffffffff07/1", "type": "OPTICAL", "annotations": { "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" } }, |
| 128 | - { "src": "of:0000ffffffff0009/2", "dst": "of:0000ffffffffff09/1", "type": "OPTICAL", "annotations": { "bandwidth": 100000, "optical.type": "cross-connect" } }, | 128 | + { "src": "of:0000ffffffff0009/2", "dst": "of:0000ffffffffff09/1", "type": "OPTICAL", "annotations": { "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" } }, |
| 129 | - { "src": "of:0000ffffffff000A/2", "dst": "of:0000ffffffffff0A/1", "type": "OPTICAL", "annotations": { "bandwidth": 100000, "optical.type": "cross-connect" } } | 129 | + { "src": "of:0000ffffffff000A/2", "dst": "of:0000ffffffffff0A/1", "type": "OPTICAL", "annotations": { "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" } } |
| 130 | ], | 130 | ], |
| 131 | 131 | ||
| 132 | "hosts" : [ | 132 | "hosts" : [ | ... | ... |
-
Please register or login to post a comment