Pavlin Radoslavov

Added Hazelcast-based Leadership implementation that is needed/used by SDN-IP.

This is a drop-in replacement until the generic ONOS Leadership service
is robust enough.

Change-Id: I72a84331dd948f98707eb59844dab425aa9d5c08
...@@ -85,6 +85,12 @@ ...@@ -85,6 +85,12 @@
85 </dependency> 85 </dependency>
86 86
87 <dependency> 87 <dependency>
88 + <groupId>org.onlab.onos</groupId>
89 + <artifactId>onos-core-dist</artifactId>
90 + <version>${project.version}</version>
91 + </dependency>
92 +
93 + <dependency>
88 <groupId>org.apache.karaf.shell</groupId> 94 <groupId>org.apache.karaf.shell</groupId>
89 <artifactId>org.apache.karaf.shell.console</artifactId> 95 <artifactId>org.apache.karaf.shell.console</artifactId>
90 </dependency> 96 </dependency>
......
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2014 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.onlab.onos</groupId>
24 + <artifactId>onos-apps</artifactId>
25 + <version>1.0.0-SNAPSHOT</version>
26 + <relativePath>../pom.xml</relativePath>
27 + </parent>
28 +
29 + <artifactId>onos-app-sdnip</artifactId>
30 + <packaging>bundle</packaging>
31 +
32 + <description>SDN-IP peering application</description>
33 +
34 + <dependencies>
35 + <dependency>
36 + <groupId>com.fasterxml.jackson.core</groupId>
37 + <artifactId>jackson-databind</artifactId>
38 + </dependency>
39 + <dependency>
40 + <groupId>com.fasterxml.jackson.core</groupId>
41 + <artifactId>jackson-annotations</artifactId>
42 + <version>2.4.2</version>
43 + <scope>provided</scope>
44 + </dependency>
45 +
46 + <dependency>
47 + <groupId>com.google.guava</groupId>
48 + <artifactId>guava</artifactId>
49 + </dependency>
50 +
51 + <dependency>
52 + <groupId>org.apache.commons</groupId>
53 + <artifactId>commons-collections4</artifactId>
54 + <version>4.0</version>
55 + </dependency>
56 +
57 + <dependency>
58 + <groupId>org.onlab.onos</groupId>
59 + <artifactId>onlab-thirdparty</artifactId>
60 + </dependency>
61 +
62 + <dependency>
63 + <groupId>org.onlab.onos</groupId>
64 + <artifactId>onlab-misc</artifactId>
65 + </dependency>
66 +
67 + <dependency>
68 + <groupId>org.onlab.onos</groupId>
69 + <artifactId>onlab-junit</artifactId>
70 + <scope>test</scope>
71 + </dependency>
72 +
73 + <dependency>
74 + <groupId>org.onlab.onos</groupId>
75 + <artifactId>onos-api</artifactId>
76 + <version>${project.version}</version>
77 + <scope>test</scope>
78 + <classifier>tests</classifier>
79 + </dependency>
80 +
81 + <dependency>
82 + <groupId>org.onlab.onos</groupId>
83 + <artifactId>onos-cli</artifactId>
84 + <version>${project.version}</version>
85 + </dependency>
86 +
87 + <dependency>
88 + <groupId>org.apache.karaf.shell</groupId>
89 + <artifactId>org.apache.karaf.shell.console</artifactId>
90 + </dependency>
91 +
92 + <dependency>
93 + <groupId>org.osgi</groupId>
94 + <artifactId>org.osgi.core</artifactId>
95 + </dependency>
96 +
97 + <dependency>
98 + <groupId>org.easymock</groupId>
99 + <artifactId>easymock</artifactId>
100 + <scope>test</scope>
101 + </dependency>
102 + </dependencies>
103 +
104 +</project>
...@@ -29,15 +29,17 @@ import org.onlab.onos.cluster.ClusterService; ...@@ -29,15 +29,17 @@ import org.onlab.onos.cluster.ClusterService;
29 import org.onlab.onos.cluster.ControllerNode; 29 import org.onlab.onos.cluster.ControllerNode;
30 import org.onlab.onos.cluster.LeadershipEvent; 30 import org.onlab.onos.cluster.LeadershipEvent;
31 import org.onlab.onos.cluster.LeadershipEventListener; 31 import org.onlab.onos.cluster.LeadershipEventListener;
32 -import org.onlab.onos.cluster.LeadershipService; 32 +// import org.onlab.onos.cluster.LeadershipService;
33 import org.onlab.onos.core.ApplicationId; 33 import org.onlab.onos.core.ApplicationId;
34 import org.onlab.onos.core.CoreService; 34 import org.onlab.onos.core.CoreService;
35 +import org.onlab.onos.event.EventDeliveryService;
35 import org.onlab.onos.net.host.HostService; 36 import org.onlab.onos.net.host.HostService;
36 import org.onlab.onos.net.intent.IntentService; 37 import org.onlab.onos.net.intent.IntentService;
37 import org.onlab.onos.sdnip.bgp.BgpRouteEntry; 38 import org.onlab.onos.sdnip.bgp.BgpRouteEntry;
38 import org.onlab.onos.sdnip.bgp.BgpSession; 39 import org.onlab.onos.sdnip.bgp.BgpSession;
39 import org.onlab.onos.sdnip.bgp.BgpSessionManager; 40 import org.onlab.onos.sdnip.bgp.BgpSessionManager;
40 import org.onlab.onos.sdnip.config.SdnIpConfigReader; 41 import org.onlab.onos.sdnip.config.SdnIpConfigReader;
42 +import org.onlab.onos.store.hz.StoreService;
41 43
42 import org.slf4j.Logger; 44 import org.slf4j.Logger;
43 45
...@@ -68,7 +70,13 @@ public class SdnIp implements SdnIpService { ...@@ -68,7 +70,13 @@ public class SdnIp implements SdnIpService {
68 protected ClusterService clusterService; 70 protected ClusterService clusterService;
69 71
70 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 72 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
71 - protected LeadershipService leadershipService; 73 + protected StoreService storeService;
74 +
75 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
76 + protected EventDeliveryService eventDispatcher;
77 +
78 + // @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
79 + protected SdnIpLeadershipService leadershipService;
72 80
73 private IntentSynchronizer intentSynchronizer; 81 private IntentSynchronizer intentSynchronizer;
74 private SdnIpConfigReader config; 82 private SdnIpConfigReader config;
...@@ -77,7 +85,7 @@ public class SdnIp implements SdnIpService { ...@@ -77,7 +85,7 @@ public class SdnIp implements SdnIpService {
77 private BgpSessionManager bgpSessionManager; 85 private BgpSessionManager bgpSessionManager;
78 private LeadershipEventListener leadershipEventListener = 86 private LeadershipEventListener leadershipEventListener =
79 new InnerLeadershipEventListener(); 87 new InnerLeadershipEventListener();
80 - ApplicationId appId; 88 + private ApplicationId appId;
81 private ControllerNode localControllerNode; 89 private ControllerNode localControllerNode;
82 90
83 @Activate 91 @Activate
...@@ -106,6 +114,10 @@ public class SdnIp implements SdnIpService { ...@@ -106,6 +114,10 @@ public class SdnIp implements SdnIpService {
106 interfaceService, hostService); 114 interfaceService, hostService);
107 router.start(); 115 router.start();
108 116
117 + leadershipService = new SdnIpLeadershipService(clusterService,
118 + storeService,
119 + eventDispatcher);
120 + leadershipService.start();
109 leadershipService.addListener(leadershipEventListener); 121 leadershipService.addListener(leadershipEventListener);
110 leadershipService.runForLeadership(appId.name()); 122 leadershipService.runForLeadership(appId.name());
111 123
...@@ -126,6 +138,7 @@ public class SdnIp implements SdnIpService { ...@@ -126,6 +138,7 @@ public class SdnIp implements SdnIpService {
126 138
127 leadershipService.withdraw(appId.name()); 139 leadershipService.withdraw(appId.name());
128 leadershipService.removeListener(leadershipEventListener); 140 leadershipService.removeListener(leadershipEventListener);
141 + leadershipService.stop();
129 142
130 log.info("SDN-IP Stopped"); 143 log.info("SDN-IP Stopped");
131 } 144 }
......