[ONOS-3370] Extract hostprovider and lldpprovider from openflow
There are three independent apps:
- openflow-base
- hostprovider
- lldpprovider
And there is also one meta-application called openflow that
contains all three of them.
Also fix the dependency issue when the apps are loaded from disk
Change-Id: I6da584e03593db9094b3a57976b28291f207c3c6
diff --git a/core/store/dist/src/main/java/org/onosproject/store/app/GossipApplicationStore.java b/core/store/dist/src/main/java/org/onosproject/store/app/GossipApplicationStore.java
index dda820a..fe4aa0b 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/app/GossipApplicationStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/app/GossipApplicationStore.java
@@ -183,21 +183,34 @@
* they are marked to be active.
*/
private void loadFromDisk() {
- for (String name : getApplicationNames()) {
- for (int i = 0; i < MAX_LOAD_RETRIES; i++) {
- try {
- Application app = create(getApplicationDescription(name), false);
- if (app != null && isActive(app.id().name())) {
- requiredBy.put(app.id(), coreAppId);
- activate(app.id(), false);
- // load app permissions
- }
- } catch (Exception e) {
- log.warn("Unable to load application {} from disk; retrying", name);
- randomDelay(RETRY_DELAY_MS); // FIXME: This is a deliberate hack; fix in Drake
+ getApplicationNames().forEach(appName -> {
+ Application app = loadFromDisk(appName);
+ if (app != null && isActive(app.id().name())) {
+ activate(app.id(), false);
+ // TODO Load app permissions
+ }
+ });
+ }
+
+ private Application loadFromDisk(String appName) {
+ for (int i = 0; i < MAX_LOAD_RETRIES; i++) {
+ try {
+ // Directly return if app already exists
+ ApplicationId appId = getId(appName);
+ if (appId != null) {
+ return getApplication(appId);
}
+
+ ApplicationDescription appDesc = getApplicationDescription(appName);
+ boolean success = appDesc.requiredApps().stream()
+ .noneMatch(requiredApp -> loadFromDisk(requiredApp) == null);
+ return success ? create(appDesc, false) : null;
+ } catch (Exception e) {
+ log.warn("Unable to load application {} from disk; retrying", appName);
+ randomDelay(RETRY_DELAY_MS); //FIXME: This is a deliberate hack; fix in Falcon
}
}
+ return null;
}
@Deactivate
diff --git a/providers/host/pom.xml b/providers/host/pom.xml
index e8f32ca..ddbdbfc 100644
--- a/providers/host/pom.xml
+++ b/providers/host/pom.xml
@@ -29,7 +29,11 @@
<artifactId>onos-host-provider</artifactId>
<packaging>bundle</packaging>
- <description>ONOS host tracking provider</description>
+ <properties>
+ <onos.app.name>org.onosproject.hostprovider</onos.app.name>
+ </properties>
+
+ <description>ONOS host location provider</description>
<dependencies>
<dependency>
<groupId>org.onosproject</groupId>
diff --git a/providers/lldp/pom.xml b/providers/lldp/pom.xml
index e47d26c..7bf92ed 100644
--- a/providers/lldp/pom.xml
+++ b/providers/lldp/pom.xml
@@ -30,7 +30,11 @@
<artifactId>onos-lldp-provider</artifactId>
<packaging>bundle</packaging>
- <description>ONOS LLDP Link Discovery</description>
+ <properties>
+ <onos.app.name>org.onosproject.lldpprovider</onos.app.name>
+ </properties>
+
+ <description>ONOS LLDP link provider</description>
<dependencies>
<dependency>
diff --git a/providers/openflow/app/pom.xml b/providers/openflow/app/pom.xml
index cb55463..ac5f6ee 100644
--- a/providers/openflow/app/pom.xml
+++ b/providers/openflow/app/pom.xml
@@ -27,55 +27,23 @@
</parent>
<artifactId>onos-openflow</artifactId>
- <packaging>pom</packaging>
+ <packaging>bundle</packaging>
- <description>OpenFlow protocol southbound providers</description>
+ <properties>
+ <onos.app.name>org.onosproject.openflow</onos.app.name>
+ <onos.app.requires>
+ org.onosproject.openflow-base,
+ org.onosproject.hostprovider,
+ org.onosproject.lldpprovider
+ </onos.app.requires>
+ </properties>
+
+ <description>OpenFlow southbound meta application</description>
<dependencies>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-of-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-of-ctl</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-drivers</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-of-provider-device</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-of-provider-packet</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-of-provider-flow</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-of-provider-group</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-lldp-provider</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-host-provider</artifactId>
- <version>${project.version}</version>
- </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-of-api</artifactId>
+ </dependency>
</dependencies>
-
</project>
diff --git a/providers/openflow/app/app.xml b/providers/openflow/base/app.xml
similarity index 83%
rename from providers/openflow/app/app.xml
rename to providers/openflow/base/app.xml
index e54d1a8..34e6b15 100644
--- a/providers/openflow/app/app.xml
+++ b/providers/openflow/base/app.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- ~ Copyright 2015 Open Networking Laboratory
+ ~ Copyright 2014-2015 Open Networking Laboratory
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<app name="org.onosproject.openflow" origin="ON.Lab" version="${project.version}"
+<app name="org.onosproject.openflow-base" origin="ON.Lab" version="${project.version}"
featuresRepo="mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features"
features="${project.artifactId}">
<description>${project.description}</description>
@@ -23,8 +23,6 @@
<artifact>mvn:${project.groupId}/onos-of-ctl/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-drivers/${project.version}</artifact>
- <artifact>mvn:${project.groupId}/onos-lldp-provider/${project.version}</artifact>
- <artifact>mvn:${project.groupId}/onos-host-provider/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-of-provider-device/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-of-provider-packet/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-of-provider-flow/${project.version}</artifact>
diff --git a/providers/openflow/app/features.xml b/providers/openflow/base/features.xml
similarity index 88%
rename from providers/openflow/app/features.xml
rename to providers/openflow/base/features.xml
index 9dbae8a..ed6b938 100644
--- a/providers/openflow/app/features.xml
+++ b/providers/openflow/base/features.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
- ~ Copyright 2015 Open Networking Laboratory
+ ~ Copyright 2014-2015 Open Networking Laboratory
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
@@ -23,8 +23,6 @@
<bundle>mvn:${project.groupId}/onos-of-api/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-of-ctl/${project.version}</bundle>
- <bundle>mvn:${project.groupId}/onos-lldp-provider/${project.version}</bundle>
- <bundle>mvn:${project.groupId}/onos-host-provider/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-of-provider-device/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-of-provider-packet/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-of-provider-flow/${project.version}</bundle>
diff --git a/providers/openflow/base/pom.xml b/providers/openflow/base/pom.xml
new file mode 100644
index 0000000..9eb170c
--- /dev/null
+++ b/providers/openflow/base/pom.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2014-2015 Open Networking Laboratory
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-of-providers</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>onos-openflow-base</artifactId>
+ <packaging>pom</packaging>
+
+ <description>OpenFlow protocol southbound providers</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-of-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-of-ctl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-drivers</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-of-provider-device</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-of-provider-packet</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-of-provider-flow</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-of-provider-group</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/providers/openflow/pom.xml b/providers/openflow/pom.xml
index c098a60..1250af6 100644
--- a/providers/openflow/pom.xml
+++ b/providers/openflow/pom.xml
@@ -37,6 +37,7 @@
<module>flow</module>
<module>group</module>
<module>meter</module>
+ <module>base</module>
<module>app</module>
</modules>