diff options
Diffstat (limited to 'framework/src/onos/core/common')
9 files changed, 40 insertions, 24 deletions
diff --git a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/ApplicationCodec.java b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/ApplicationCodec.java index b2cab094..a09c0bdb 100644 --- a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/ApplicationCodec.java +++ b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/ApplicationCodec.java @@ -32,18 +32,18 @@ public final class ApplicationCodec extends JsonCodec<Application> { public ObjectNode encode(Application app, CodecContext context) { checkNotNull(app, "Application cannot be null"); ApplicationService service = context.getService(ApplicationService.class); - ObjectNode result = context.mapper().createObjectNode() + return context.mapper().createObjectNode() .put("name", app.id().name()) .put("id", app.id().id()) .put("version", app.version().toString()) .put("description", app.description()) .put("origin", app.origin()) - .put("permissions", app.permissions().toString()) + .put("permissions", app.permissions().toString()) // FIXME: change to an array .put("featuresRepo", app.featuresRepo().isPresent() ? app.featuresRepo().get().toString() : "") - .put("features", app.features().toString()) + .put("features", app.features().toString()) // FIXME: change to an array + .put("requiredApps", app.requiredApps().toString()) // FIXME: change to an array .put("state", service.getState(app.id()).toString()); - return result; } } diff --git a/framework/src/onos/core/common/src/main/java/org/onosproject/common/DefaultTopology.java b/framework/src/onos/core/common/src/main/java/org/onosproject/common/DefaultTopology.java index 3c5c540d..84cde424 100644 --- a/framework/src/onos/core/common/src/main/java/org/onosproject/common/DefaultTopology.java +++ b/framework/src/onos/core/common/src/main/java/org/onosproject/common/DefaultTopology.java @@ -26,10 +26,10 @@ import org.onlab.graph.DijkstraGraphSearch; import org.onlab.graph.DisjointPathPair; import org.onlab.graph.GraphPathSearch; import org.onlab.graph.GraphPathSearch.Result; -import org.onlab.graph.SRLGGraphSearch; +import org.onlab.graph.SrlgGraphSearch; import org.onlab.graph.SuurballeGraphSearch; import org.onlab.graph.TarjanGraphSearch; -import org.onlab.graph.TarjanGraphSearch.SCCResult; +import org.onlab.graph.TarjanGraphSearch.SccResult; import org.onosproject.net.AbstractModel; import org.onosproject.net.ConnectPoint; import org.onosproject.net.DefaultDisjointPath; @@ -83,7 +83,7 @@ public class DefaultTopology extends AbstractModel implements Topology { private final TopologyGraph graph; private final LinkWeight weight; - private final Supplier<SCCResult<TopologyVertex, TopologyEdge>> clusterResults; + private final Supplier<SccResult<TopologyVertex, TopologyEdge>> clusterResults; private final Supplier<ImmutableMap<ClusterId, TopologyCluster>> clusters; private final Supplier<ImmutableSet<ConnectPoint>> infrastructurePoints; private final Supplier<ImmutableSetMultimap<ClusterId, ConnectPoint>> broadcastSets; @@ -385,7 +385,7 @@ public class DefaultTopology extends AbstractModel implements Topology { return ImmutableSet.of(); } - SRLGGraphSearch<TopologyVertex, TopologyEdge> srlg = new SRLGGraphSearch<>(riskProfile); + SrlgGraphSearch<TopologyVertex, TopologyEdge> srlg = new SrlgGraphSearch<>(riskProfile); GraphPathSearch.Result<TopologyVertex, TopologyEdge> result = srlg.search(graph, srcV, dstV, weight, ALL_PATHS); ImmutableSet.Builder<DisjointPath> builder = ImmutableSet.builder(); @@ -455,14 +455,14 @@ public class DefaultTopology extends AbstractModel implements Topology { // Searches for SCC clusters in the network topology graph using Tarjan // algorithm. - private SCCResult<TopologyVertex, TopologyEdge> searchForClusters() { + private SccResult<TopologyVertex, TopologyEdge> searchForClusters() { return TARJAN.search(graph, new NoIndirectLinksWeight()); } // Builds the topology clusters and returns the id-cluster bindings. private ImmutableMap<ClusterId, TopologyCluster> buildTopologyClusters() { ImmutableMap.Builder<ClusterId, TopologyCluster> clusterBuilder = ImmutableMap.builder(); - SCCResult<TopologyVertex, TopologyEdge> results = clusterResults.get(); + SccResult<TopologyVertex, TopologyEdge> results = clusterResults.get(); // Extract both vertexes and edges from the results; the lists form // pairs along the same index. diff --git a/framework/src/onos/core/common/src/main/java/org/onosproject/common/app/ApplicationArchive.java b/framework/src/onos/core/common/src/main/java/org/onosproject/common/app/ApplicationArchive.java index 54f0fb89..37cdbdfc 100644 --- a/framework/src/onos/core/common/src/main/java/org/onosproject/common/app/ApplicationArchive.java +++ b/framework/src/onos/core/common/src/main/java/org/onosproject/common/app/ApplicationArchive.java @@ -17,6 +17,7 @@ package org.onosproject.common.app; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; import com.google.common.io.ByteStreams; import com.google.common.io.Files; import org.apache.commons.configuration.ConfigurationException; @@ -33,7 +34,6 @@ import org.onosproject.core.Version; import org.onosproject.security.AppPermission; import org.onosproject.security.Permission; import org.onosproject.store.AbstractStore; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,7 +46,6 @@ import java.io.InputStream; import java.net.URI; import java.nio.charset.Charset; import java.nio.file.NoSuchFileException; -import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.Set; @@ -79,6 +78,7 @@ public class ApplicationArchive private static final String VERSION = "[@version]"; private static final String FEATURES_REPO = "[@featuresRepo]"; private static final String FEATURES = "[@features]"; + private static final String APPS = "[@apps]"; private static final String DESCRIPTION = "description"; private static final String ROLE = "security.role"; @@ -291,8 +291,13 @@ public class ApplicationArchive URI featuresRepo = featRepo != null ? URI.create(featRepo) : null; List<String> features = ImmutableList.copyOf(cfg.getString(FEATURES).split(",")); + String apps = cfg.getString(APPS, ""); + List<String> requiredApps = apps.isEmpty() ? + ImmutableList.of() : ImmutableList.copyOf(apps.split(",")); + return new DefaultApplicationDescription(name, version, desc, origin, role, - perms, featuresRepo, features); + perms, featuresRepo, features, + requiredApps); } // Expands the specified ZIP stream into app-specific directory. @@ -390,7 +395,7 @@ public class ApplicationArchive // Returns the set of Permissions specified in the app.xml file private ImmutableSet<Permission> getPermissions(XMLConfiguration cfg) { - List<Permission> permissionList = new ArrayList(); + List<Permission> permissionList = Lists.newArrayList(); for (Object o : cfg.getList(APP_PERMISSIONS)) { String name = (String) o; diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/IntentCodecTest.java b/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/IntentCodecTest.java index 7cbce4d1..2f933966 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/IntentCodecTest.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/codec/impl/IntentCodecTest.java @@ -217,7 +217,7 @@ public class IntentCodecTest extends AbstractIntentTest { * @throws IOException if processing the resource fails */ private Intent getIntent(String resourceName, JsonCodec intentCodec) throws IOException { - InputStream jsonStream = FlowRuleCodecTest.class + InputStream jsonStream = IntentCodecTest.class .getResourceAsStream(resourceName); JsonNode json = context.mapper().readTree(jsonStream); assertThat(json, notNullValue()); diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleApplicationStore.java b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleApplicationStore.java index ea9a773e..d9f5285c 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleApplicationStore.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleApplicationStore.java @@ -75,7 +75,8 @@ public class SimpleApplicationStore extends ApplicationArchive implements Applic new DefaultApplication(appId, appDesc.version(), appDesc.description(), appDesc.origin(), appDesc.role(), appDesc.permissions(), - appDesc.featuresRepo(), appDesc.features()); + appDesc.featuresRepo(), appDesc.features(), + appDesc.requiredApps()); apps.put(appId, app); states.put(appId, isActive(name) ? INSTALLED : ACTIVE); // load app permissions @@ -117,7 +118,8 @@ public class SimpleApplicationStore extends ApplicationArchive implements Applic DefaultApplication app = new DefaultApplication(appId, appDesc.version(), appDesc.description(), appDesc.origin(), appDesc.role(), appDesc.permissions(), - appDesc.featuresRepo(), appDesc.features()); + appDesc.featuresRepo(), appDesc.features(), + appDesc.requiredApps()); apps.put(appId, app); states.put(appId, INSTALLED); delegate.notify(new ApplicationEvent(APP_INSTALLED, app)); diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStore.java b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStore.java index 72fc1b05..11a12040 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStore.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStore.java @@ -532,7 +532,7 @@ public class SimpleDeviceStore checkArgument(!providerDescs.isEmpty(), "No Device descriptions supplied"); - ProviderId primary = pickPrimaryPID(providerDescs); + ProviderId primary = pickPrimaryPid(providerDescs); DeviceDescriptions desc = providerDescs.get(primary); @@ -575,7 +575,7 @@ public class SimpleDeviceStore private Port composePort(Device device, PortNumber number, Map<ProviderId, DeviceDescriptions> descsMap) { - ProviderId primary = pickPrimaryPID(descsMap); + ProviderId primary = pickPrimaryPid(descsMap); DeviceDescriptions primDescs = descsMap.get(primary); // if no primary, assume not enabled // TODO: revisit this default port enabled/disabled behavior @@ -613,7 +613,7 @@ public class SimpleDeviceStore /** * @return primary ProviderID, or randomly chosen one if none exists */ - private ProviderId pickPrimaryPID(Map<ProviderId, DeviceDescriptions> descsMap) { + private ProviderId pickPrimaryPid(Map<ProviderId, DeviceDescriptions> descsMap) { ProviderId fallBackPrimary = null; for (Entry<ProviderId, DeviceDescriptions> e : descsMap.entrySet()) { if (!e.getKey().isAncillary()) { diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleHostStore.java b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleHostStore.java index 72ec98ca..a56daab1 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleHostStore.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleHostStore.java @@ -88,10 +88,14 @@ public class SimpleHostStore boolean replaceIps) { //TODO We need a way to detect conflicting changes and abort update. StoredHost host = hosts.get(hostId); + HostEvent hostEvent; if (host == null) { - return createHost(providerId, hostId, hostDescription); + hostEvent = createHost(providerId, hostId, hostDescription); + } else { + hostEvent = updateHost(providerId, host, hostDescription, replaceIps); } - return updateHost(providerId, host, hostDescription, replaceIps); + notifyDelegate(hostEvent); + return hostEvent; } // creates a new host and sends HOST_ADDED @@ -153,7 +157,9 @@ public class SimpleHostStore Host host = hosts.remove(hostId); if (host != null) { locations.remove((host.location()), host); - return new HostEvent(HOST_REMOVED, host); + HostEvent hostEvent = new HostEvent(HOST_REMOVED, host); + notifyDelegate(hostEvent); + return hostEvent; } return null; } diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleLinkResourceStore.java b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleLinkResourceStore.java index 58b446cf..22df937b 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleLinkResourceStore.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SimpleLinkResourceStore.java @@ -52,7 +52,10 @@ import static org.slf4j.LoggerFactory.getLogger; /** * Manages link resources using trivial in-memory structures implementation. + * + * @deprecated in Emu Release */ +@Deprecated @Component(immediate = true) @Service public class SimpleLinkResourceStore implements LinkResourceStore { diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SystemClockTimestamp.java b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SystemClockTimestamp.java index 2ee41945..500a09c7 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SystemClockTimestamp.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SystemClockTimestamp.java @@ -51,7 +51,7 @@ public class SystemClockTimestamp implements Timestamp { } @Override public int hashCode() { - return Objects.hash(nanoTimestamp); + return Long.hashCode(nanoTimestamp); } @Override |