From 8f92448e4f2f5d9c98036097bdabd1c40166908a Mon Sep 17 00:00:00 2001 From: Ashlee Young Date: Sat, 7 Nov 2015 09:43:53 -0800 Subject: Updated ONOS sources to commit ID 3f28c6803193d493b636dd3c43e08a3e6b35acca Change-Id: I08d1eb7ee31b38491b046933c502894d133b2a2d Signed-off-by: Ashlee Young --- .../cluster/impl/StaticClusterMetadataStore.java | 24 +++++++++++++++-- .../newresource/impl/ConsistentResourceStore.java | 30 +++++++++++++++++++--- .../resource/impl/ConsistentLinkResourceStore.java | 3 +++ 3 files changed, 52 insertions(+), 5 deletions(-) (limited to 'framework/src/onos/core/store') diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/impl/StaticClusterMetadataStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/impl/StaticClusterMetadataStore.java index 9f6c4130..e4a09cef 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/impl/StaticClusterMetadataStore.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/cluster/impl/StaticClusterMetadataStore.java @@ -55,6 +55,10 @@ public class StaticClusterMetadataStore implements ClusterMetadataStore { private final Logger log = getLogger(getClass()); + + private static final String ONOS_IP = "ONOS_IP"; + private static final String ONOS_INTERFACE = "ONOS_INTERFACE"; + private static final String DEFAULT_ONOS_INTERFACE = "eth0"; private static final String CLUSTER_METADATA_FILE = "../config/cluster.json"; private static final int DEFAULT_ONOS_PORT = 9876; private final File metadataFile = new File(CLUSTER_METADATA_FILE); @@ -194,6 +198,22 @@ public class StaticClusterMetadataStore private static String getSiteLocalAddress() { + + /* + * If the IP ONOS should use is set via the environment variable we will assume it is valid and should be used. + * Setting the IP address takes presidence over setting the interface via the environment. + */ + String useOnosIp = System.getenv(ONOS_IP); + if (useOnosIp != null) { + return useOnosIp; + } + + // Read environment variables for IP interface information or set to default + String useOnosInterface = System.getenv(ONOS_INTERFACE); + if (useOnosInterface == null) { + useOnosInterface = DEFAULT_ONOS_INTERFACE; + } + Function ipLookup = nif -> { for (InetAddress address : Collections.list(nif.getInetAddresses())) { if (address.isSiteLocalAddress()) { @@ -203,7 +223,7 @@ public class StaticClusterMetadataStore return null; }; try { - IpAddress ip = ipLookup.apply(NetworkInterface.getByName("eth0")); + IpAddress ip = ipLookup.apply(NetworkInterface.getByName(useOnosInterface)); if (ip != null) { return ip.toString(); } @@ -218,4 +238,4 @@ public class StaticClusterMetadataStore } return IpAddress.valueOf(InetAddress.getLoopbackAddress()).toString(); } -} \ No newline at end of file +} diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java index c9aaba5a..82dfe32f 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java @@ -16,14 +16,18 @@ package org.onosproject.store.newresource.impl; import com.google.common.annotations.Beta; +import com.google.common.collect.ImmutableList; import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Reference; import org.apache.felix.scr.annotations.ReferenceCardinality; import org.apache.felix.scr.annotations.Service; import org.onosproject.net.newresource.ResourceConsumer; +import org.onosproject.net.newresource.ResourceEvent; import org.onosproject.net.newresource.ResourcePath; import org.onosproject.net.newresource.ResourceStore; +import org.onosproject.net.newresource.ResourceStoreDelegate; +import org.onosproject.store.AbstractStore; import org.onosproject.store.serializers.KryoNamespaces; import org.onosproject.store.service.ConsistentMap; import org.onosproject.store.service.Serializer; @@ -47,6 +51,7 @@ import java.util.stream.Collectors; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; +import static org.onosproject.net.newresource.ResourceEvent.Type.*; /** * Implementation of ResourceStore using TransactionalMap. @@ -54,7 +59,8 @@ import static com.google.common.base.Preconditions.checkNotNull; @Component(immediate = true) @Service @Beta -public class ConsistentResourceStore implements ResourceStore { +public class ConsistentResourceStore extends AbstractStore + implements ResourceStore { private static final Logger log = LoggerFactory.getLogger(ConsistentResourceStore.class); private static final String CONSUMER_MAP = "onos-resource-consumers"; @@ -78,6 +84,8 @@ public class ConsistentResourceStore implements ResourceStore { .withName(CHILD_MAP) .withSerializer(SERIALIZER) .build(); + + childMap.put(ResourcePath.ROOT, ImmutableList.of()); } @Override @@ -116,7 +124,15 @@ public class ConsistentResourceStore implements ResourceStore { } } - return tx.commit(); + boolean success = tx.commit(); + if (success) { + List events = resources.stream() + .filter(x -> x.parent().isPresent()) + .map(x -> new ResourceEvent(RESOURCE_ADDED, x)) + .collect(Collectors.toList()); + notifyDelegate(events); + } + return success; } @Override @@ -147,7 +163,15 @@ public class ConsistentResourceStore implements ResourceStore { } } - return tx.commit(); + boolean success = tx.commit(); + if (success) { + List events = resources.stream() + .filter(x -> x.parent().isPresent()) + .map(x -> new ResourceEvent(RESOURCE_REMOVED, x)) + .collect(Collectors.toList()); + notifyDelegate(events); + } + return success; } @Override diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java index a38550e4..351c7a5f 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java @@ -72,7 +72,10 @@ import static org.onosproject.net.AnnotationKeys.BANDWIDTH; /** * Store that manages link resources using Copycat-backed TransactionalMaps. + * + * @deprecated in Emu Release */ +@Deprecated @Component(immediate = true, enabled = true) @Service public class ConsistentLinkResourceStore extends -- cgit 1.2.3-korg