Charles Chan
Committed by Gerrit Code Review

[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
...@@ -183,21 +183,34 @@ public class GossipApplicationStore extends ApplicationArchive ...@@ -183,21 +183,34 @@ public class GossipApplicationStore extends ApplicationArchive
183 * they are marked to be active. 183 * they are marked to be active.
184 */ 184 */
185 private void loadFromDisk() { 185 private void loadFromDisk() {
186 - for (String name : getApplicationNames()) { 186 + getApplicationNames().forEach(appName -> {
187 - for (int i = 0; i < MAX_LOAD_RETRIES; i++) { 187 + Application app = loadFromDisk(appName);
188 - try { 188 + if (app != null && isActive(app.id().name())) {
189 - Application app = create(getApplicationDescription(name), false); 189 + activate(app.id(), false);
190 - if (app != null && isActive(app.id().name())) { 190 + // TODO Load app permissions
191 - requiredBy.put(app.id(), coreAppId); 191 + }
192 - activate(app.id(), false); 192 + });
193 - // load app permissions 193 + }
194 - } 194 +
195 - } catch (Exception e) { 195 + private Application loadFromDisk(String appName) {
196 - log.warn("Unable to load application {} from disk; retrying", name); 196 + for (int i = 0; i < MAX_LOAD_RETRIES; i++) {
197 - randomDelay(RETRY_DELAY_MS); // FIXME: This is a deliberate hack; fix in Drake 197 + try {
198 + // Directly return if app already exists
199 + ApplicationId appId = getId(appName);
200 + if (appId != null) {
201 + return getApplication(appId);
198 } 202 }
203 +
204 + ApplicationDescription appDesc = getApplicationDescription(appName);
205 + boolean success = appDesc.requiredApps().stream()
206 + .noneMatch(requiredApp -> loadFromDisk(requiredApp) == null);
207 + return success ? create(appDesc, false) : null;
208 + } catch (Exception e) {
209 + log.warn("Unable to load application {} from disk; retrying", appName);
210 + randomDelay(RETRY_DELAY_MS); //FIXME: This is a deliberate hack; fix in Falcon
199 } 211 }
200 } 212 }
213 + return null;
201 } 214 }
202 215
203 @Deactivate 216 @Deactivate
......
...@@ -29,7 +29,11 @@ ...@@ -29,7 +29,11 @@
29 <artifactId>onos-host-provider</artifactId> 29 <artifactId>onos-host-provider</artifactId>
30 <packaging>bundle</packaging> 30 <packaging>bundle</packaging>
31 31
32 - <description>ONOS host tracking provider</description> 32 + <properties>
33 + <onos.app.name>org.onosproject.hostprovider</onos.app.name>
34 + </properties>
35 +
36 + <description>ONOS host location provider</description>
33 <dependencies> 37 <dependencies>
34 <dependency> 38 <dependency>
35 <groupId>org.onosproject</groupId> 39 <groupId>org.onosproject</groupId>
......
...@@ -30,7 +30,11 @@ ...@@ -30,7 +30,11 @@
30 <artifactId>onos-lldp-provider</artifactId> 30 <artifactId>onos-lldp-provider</artifactId>
31 <packaging>bundle</packaging> 31 <packaging>bundle</packaging>
32 32
33 - <description>ONOS LLDP Link Discovery</description> 33 + <properties>
34 + <onos.app.name>org.onosproject.lldpprovider</onos.app.name>
35 + </properties>
36 +
37 + <description>ONOS LLDP link provider</description>
34 38
35 <dependencies> 39 <dependencies>
36 <dependency> 40 <dependency>
......
...@@ -27,55 +27,23 @@ ...@@ -27,55 +27,23 @@
27 </parent> 27 </parent>
28 28
29 <artifactId>onos-openflow</artifactId> 29 <artifactId>onos-openflow</artifactId>
30 - <packaging>pom</packaging> 30 + <packaging>bundle</packaging>
31 31
32 - <description>OpenFlow protocol southbound providers</description> 32 + <properties>
33 + <onos.app.name>org.onosproject.openflow</onos.app.name>
34 + <onos.app.requires>
35 + org.onosproject.openflow-base,
36 + org.onosproject.hostprovider,
37 + org.onosproject.lldpprovider
38 + </onos.app.requires>
39 + </properties>
40 +
41 + <description>OpenFlow southbound meta application</description>
33 42
34 <dependencies> 43 <dependencies>
35 - <dependency> 44 + <dependency>
36 - <groupId>org.onosproject</groupId> 45 + <groupId>org.onosproject</groupId>
37 - <artifactId>onos-of-api</artifactId> 46 + <artifactId>onos-of-api</artifactId>
38 - </dependency> 47 + </dependency>
39 - <dependency>
40 - <groupId>org.onosproject</groupId>
41 - <artifactId>onos-of-ctl</artifactId>
42 - <version>${project.version}</version>
43 - </dependency>
44 - <dependency>
45 - <groupId>org.onosproject</groupId>
46 - <artifactId>onos-drivers</artifactId>
47 - <version>${project.version}</version>
48 - </dependency>
49 - <dependency>
50 - <groupId>org.onosproject</groupId>
51 - <artifactId>onos-of-provider-device</artifactId>
52 - <version>${project.version}</version>
53 - </dependency>
54 - <dependency>
55 - <groupId>org.onosproject</groupId>
56 - <artifactId>onos-of-provider-packet</artifactId>
57 - <version>${project.version}</version>
58 - </dependency>
59 - <dependency>
60 - <groupId>org.onosproject</groupId>
61 - <artifactId>onos-of-provider-flow</artifactId>
62 - <version>${project.version}</version>
63 - </dependency>
64 - <dependency>
65 - <groupId>org.onosproject</groupId>
66 - <artifactId>onos-of-provider-group</artifactId>
67 - <version>${project.version}</version>
68 - </dependency>
69 - <dependency>
70 - <groupId>org.onosproject</groupId>
71 - <artifactId>onos-lldp-provider</artifactId>
72 - <version>${project.version}</version>
73 - </dependency>
74 - <dependency>
75 - <groupId>org.onosproject</groupId>
76 - <artifactId>onos-host-provider</artifactId>
77 - <version>${project.version}</version>
78 - </dependency>
79 </dependencies> 48 </dependencies>
80 -
81 </project> 49 </project>
......
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <!-- 2 <!--
3 - ~ Copyright 2015 Open Networking Laboratory 3 + ~ Copyright 2014-2015 Open Networking Laboratory
4 ~ 4 ~
5 ~ Licensed under the Apache License, Version 2.0 (the "License"); 5 ~ Licensed under the Apache License, Version 2.0 (the "License");
6 ~ you may not use this file except in compliance with the License. 6 ~ you may not use this file except in compliance with the License.
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
14 ~ See the License for the specific language governing permissions and 14 ~ See the License for the specific language governing permissions and
15 ~ limitations under the License. 15 ~ limitations under the License.
16 --> 16 -->
17 -<app name="org.onosproject.openflow" origin="ON.Lab" version="${project.version}" 17 +<app name="org.onosproject.openflow-base" origin="ON.Lab" version="${project.version}"
18 featuresRepo="mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features" 18 featuresRepo="mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features"
19 features="${project.artifactId}"> 19 features="${project.artifactId}">
20 <description>${project.description}</description> 20 <description>${project.description}</description>
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
23 <artifact>mvn:${project.groupId}/onos-of-ctl/${project.version}</artifact> 23 <artifact>mvn:${project.groupId}/onos-of-ctl/${project.version}</artifact>
24 <artifact>mvn:${project.groupId}/onos-drivers/${project.version}</artifact> 24 <artifact>mvn:${project.groupId}/onos-drivers/${project.version}</artifact>
25 25
26 - <artifact>mvn:${project.groupId}/onos-lldp-provider/${project.version}</artifact>
27 - <artifact>mvn:${project.groupId}/onos-host-provider/${project.version}</artifact>
28 <artifact>mvn:${project.groupId}/onos-of-provider-device/${project.version}</artifact> 26 <artifact>mvn:${project.groupId}/onos-of-provider-device/${project.version}</artifact>
29 <artifact>mvn:${project.groupId}/onos-of-provider-packet/${project.version}</artifact> 27 <artifact>mvn:${project.groupId}/onos-of-provider-packet/${project.version}</artifact>
30 <artifact>mvn:${project.groupId}/onos-of-provider-flow/${project.version}</artifact> 28 <artifact>mvn:${project.groupId}/onos-of-provider-flow/${project.version}</artifact>
......
1 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> 1 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2 <!-- 2 <!--
3 - ~ Copyright 2015 Open Networking Laboratory 3 + ~ Copyright 2014-2015 Open Networking Laboratory
4 ~ 4 ~
5 ~ Licensed under the Apache License, Version 2.0 (the "License"); 5 ~ Licensed under the Apache License, Version 2.0 (the "License");
6 ~ you may not use this file except in compliance with the License. 6 ~ you may not use this file except in compliance with the License.
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
23 <bundle>mvn:${project.groupId}/onos-of-api/${project.version}</bundle> 23 <bundle>mvn:${project.groupId}/onos-of-api/${project.version}</bundle>
24 <bundle>mvn:${project.groupId}/onos-of-ctl/${project.version}</bundle> 24 <bundle>mvn:${project.groupId}/onos-of-ctl/${project.version}</bundle>
25 25
26 - <bundle>mvn:${project.groupId}/onos-lldp-provider/${project.version}</bundle>
27 - <bundle>mvn:${project.groupId}/onos-host-provider/${project.version}</bundle>
28 <bundle>mvn:${project.groupId}/onos-of-provider-device/${project.version}</bundle> 26 <bundle>mvn:${project.groupId}/onos-of-provider-device/${project.version}</bundle>
29 <bundle>mvn:${project.groupId}/onos-of-provider-packet/${project.version}</bundle> 27 <bundle>mvn:${project.groupId}/onos-of-provider-packet/${project.version}</bundle>
30 <bundle>mvn:${project.groupId}/onos-of-provider-flow/${project.version}</bundle> 28 <bundle>mvn:${project.groupId}/onos-of-provider-flow/${project.version}</bundle>
......
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2014-2015 Open Networking Laboratory
4 + ~
5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 + ~ you may not use this file except in compliance with the License.
7 + ~ You may obtain a copy of the License at
8 + ~
9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 + ~
11 + ~ Unless required by applicable law or agreed to in writing, software
12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + ~ See the License for the specific language governing permissions and
15 + ~ limitations under the License.
16 + -->
17 +<project xmlns="http://maven.apache.org/POM/4.0.0"
18 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
20 + <modelVersion>4.0.0</modelVersion>
21 +
22 + <parent>
23 + <groupId>org.onosproject</groupId>
24 + <artifactId>onos-of-providers</artifactId>
25 + <version>1.4.0-SNAPSHOT</version>
26 + <relativePath>../pom.xml</relativePath>
27 + </parent>
28 +
29 + <artifactId>onos-openflow-base</artifactId>
30 + <packaging>pom</packaging>
31 +
32 + <description>OpenFlow protocol southbound providers</description>
33 +
34 + <dependencies>
35 + <dependency>
36 + <groupId>org.onosproject</groupId>
37 + <artifactId>onos-of-api</artifactId>
38 + </dependency>
39 + <dependency>
40 + <groupId>org.onosproject</groupId>
41 + <artifactId>onos-of-ctl</artifactId>
42 + <version>${project.version}</version>
43 + </dependency>
44 + <dependency>
45 + <groupId>org.onosproject</groupId>
46 + <artifactId>onos-drivers</artifactId>
47 + <version>${project.version}</version>
48 + </dependency>
49 + <dependency>
50 + <groupId>org.onosproject</groupId>
51 + <artifactId>onos-of-provider-device</artifactId>
52 + <version>${project.version}</version>
53 + </dependency>
54 + <dependency>
55 + <groupId>org.onosproject</groupId>
56 + <artifactId>onos-of-provider-packet</artifactId>
57 + <version>${project.version}</version>
58 + </dependency>
59 + <dependency>
60 + <groupId>org.onosproject</groupId>
61 + <artifactId>onos-of-provider-flow</artifactId>
62 + <version>${project.version}</version>
63 + </dependency>
64 + <dependency>
65 + <groupId>org.onosproject</groupId>
66 + <artifactId>onos-of-provider-group</artifactId>
67 + <version>${project.version}</version>
68 + </dependency>
69 + </dependencies>
70 +
71 +</project>
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
37 <module>flow</module> 37 <module>flow</module>
38 <module>group</module> 38 <module>group</module>
39 <module>meter</module> 39 <module>meter</module>
40 + <module>base</module>
40 <module>app</module> 41 <module>app</module>
41 </modules> 42 </modules>
42 43
......