Showing
6 changed files
with
82 additions
and
0 deletions
1 | +package org.onlab.onos.store; | ||
2 | + | ||
3 | +import com.hazelcast.core.HazelcastInstance; | ||
4 | + | ||
5 | +/** | ||
6 | + * Bootstrap service to get a handle on a share Hazelcast instance. | ||
7 | + */ | ||
8 | +public interface StoreService { | ||
9 | + | ||
10 | + /** | ||
11 | + * Returns the shared Hazelcast instance for use as a distributed store | ||
12 | + * backing. | ||
13 | + * | ||
14 | + * @return shared Hazelcast instance | ||
15 | + */ | ||
16 | + HazelcastInstance getHazelcastInstance(); | ||
17 | + | ||
18 | +} |
... | @@ -40,6 +40,7 @@ import org.onlab.onos.net.device.DeviceEvent; | ... | @@ -40,6 +40,7 @@ import org.onlab.onos.net.device.DeviceEvent; |
40 | import org.onlab.onos.net.device.DeviceStore; | 40 | import org.onlab.onos.net.device.DeviceStore; |
41 | import org.onlab.onos.net.device.PortDescription; | 41 | import org.onlab.onos.net.device.PortDescription; |
42 | import org.onlab.onos.net.provider.ProviderId; | 42 | import org.onlab.onos.net.provider.ProviderId; |
43 | +import org.onlab.onos.store.StoreService; | ||
43 | import org.onlab.util.KryoPool; | 44 | import org.onlab.util.KryoPool; |
44 | import org.slf4j.Logger; | 45 | import org.slf4j.Logger; |
45 | 46 | ||
... | @@ -187,12 +188,15 @@ public class DistributedDeviceStore implements DeviceStore { | ... | @@ -187,12 +188,15 @@ public class DistributedDeviceStore implements DeviceStore { |
187 | 188 | ||
188 | // FIXME change to protected once we remove DistributedDeviceManagerTest. | 189 | // FIXME change to protected once we remove DistributedDeviceManagerTest. |
189 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 190 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
191 | + protected StoreService storeService; | ||
192 | + | ||
190 | /*protected*/public HazelcastInstance theInstance; | 193 | /*protected*/public HazelcastInstance theInstance; |
191 | 194 | ||
192 | 195 | ||
193 | @Activate | 196 | @Activate |
194 | public void activate() { | 197 | public void activate() { |
195 | log.info("Started"); | 198 | log.info("Started"); |
199 | + theInstance = storeService.getHazelcastInstance(); | ||
196 | 200 | ||
197 | // IMap event handler needs value | 201 | // IMap event handler needs value |
198 | final boolean includeValue = true; | 202 | final boolean includeValue = true; | ... | ... |
1 | +package org.onlab.onos.store.impl; | ||
2 | + | ||
3 | +import com.hazelcast.core.Hazelcast; | ||
4 | +import com.hazelcast.core.HazelcastInstance; | ||
5 | +import org.apache.felix.scr.annotations.Activate; | ||
6 | +import org.apache.felix.scr.annotations.Component; | ||
7 | +import org.apache.felix.scr.annotations.Deactivate; | ||
8 | +import org.apache.felix.scr.annotations.Service; | ||
9 | +import org.onlab.onos.store.StoreService; | ||
10 | +import org.slf4j.Logger; | ||
11 | +import org.slf4j.LoggerFactory; | ||
12 | + | ||
13 | +/** | ||
14 | + * Auxiliary bootstrap of distributed store. | ||
15 | + */ | ||
16 | +@Component(immediate = true) | ||
17 | +@Service | ||
18 | +public class StoreManager implements StoreService { | ||
19 | + | ||
20 | + private final Logger log = LoggerFactory.getLogger(getClass()); | ||
21 | + | ||
22 | + private HazelcastInstance instance; | ||
23 | + | ||
24 | + @Activate | ||
25 | + public void activate() { | ||
26 | + instance = Hazelcast.newHazelcastInstance(); | ||
27 | + log.info("Started"); | ||
28 | + } | ||
29 | + | ||
30 | + @Deactivate | ||
31 | + public void deactivate() { | ||
32 | + log.info("Stopped"); | ||
33 | + } | ||
34 | + | ||
35 | + @Override | ||
36 | + public HazelcastInstance getHazelcastInstance() { | ||
37 | + return instance; | ||
38 | + } | ||
39 | +} |
... | @@ -10,9 +10,13 @@ | ... | @@ -10,9 +10,13 @@ |
10 | <bundle>mvn:com.google.guava/guava/18.0</bundle> | 10 | <bundle>mvn:com.google.guava/guava/18.0</bundle> |
11 | <bundle>mvn:io.netty/netty/3.9.2.Final</bundle> | 11 | <bundle>mvn:io.netty/netty/3.9.2.Final</bundle> |
12 | 12 | ||
13 | + <bundle>mvn:com.hazelcast/hazelcast/3.3</bundle> | ||
14 | + <bundle>mvn:com.eclipsesource.minimal-json/minimal-json/0.9.1</bundle> | ||
15 | + | ||
13 | <bundle>mvn:com.esotericsoftware.kryo/kryo/2.24.0</bundle> | 16 | <bundle>mvn:com.esotericsoftware.kryo/kryo/2.24.0</bundle> |
14 | <bundle>mvn:com.esotericsoftware/minlog/1.3.0</bundle> | 17 | <bundle>mvn:com.esotericsoftware/minlog/1.3.0</bundle> |
15 | <bundle>mvn:org.objenesis/objenesis/2.1</bundle> | 18 | <bundle>mvn:org.objenesis/objenesis/2.1</bundle> |
19 | + <bundle>mvn:de.javakaffee/kryo-serializers/0.27</bundle> | ||
16 | </feature> | 20 | </feature> |
17 | 21 | ||
18 | <feature name="onos-thirdparty-web" version="1.0.0" | 22 | <feature name="onos-thirdparty-web" version="1.0.0" |
... | @@ -42,6 +46,13 @@ | ... | @@ -42,6 +46,13 @@ |
42 | description="ONOS core components"> | 46 | description="ONOS core components"> |
43 | <feature>onos-api</feature> | 47 | <feature>onos-api</feature> |
44 | <bundle>mvn:org.onlab.onos/onos-core-net/1.0.0-SNAPSHOT</bundle> | 48 | <bundle>mvn:org.onlab.onos/onos-core-net/1.0.0-SNAPSHOT</bundle> |
49 | + <bundle>mvn:org.onlab.onos/onos-core-store/1.0.0-SNAPSHOT</bundle> | ||
50 | + </feature> | ||
51 | + | ||
52 | + <feature name="onos-core-trivial" version="1.0.0" | ||
53 | + description="ONOS core components"> | ||
54 | + <feature>onos-api</feature> | ||
55 | + <bundle>mvn:org.onlab.onos/onos-core-net/1.0.0-SNAPSHOT</bundle> | ||
45 | <bundle>mvn:org.onlab.onos/onos-core-trivial/1.0.0-SNAPSHOT</bundle> | 56 | <bundle>mvn:org.onlab.onos/onos-core-trivial/1.0.0-SNAPSHOT</bundle> |
46 | </feature> | 57 | </feature> |
47 | 58 | ... | ... |
... | @@ -139,6 +139,11 @@ | ... | @@ -139,6 +139,11 @@ |
139 | <version>3.3</version> | 139 | <version>3.3</version> |
140 | </dependency> | 140 | </dependency> |
141 | <dependency> | 141 | <dependency> |
142 | + <groupId>com.eclipsesource.minimal-json</groupId> | ||
143 | + <artifactId>minimal-json</artifactId> | ||
144 | + <version>0.9.1</version> | ||
145 | + </dependency> | ||
146 | + <dependency> | ||
142 | <groupId>com.esotericsoftware.kryo</groupId> | 147 | <groupId>com.esotericsoftware.kryo</groupId> |
143 | <artifactId>kryo</artifactId> | 148 | <artifactId>kryo</artifactId> |
144 | <version>2.24.0</version> | 149 | <version>2.24.0</version> | ... | ... |
... | @@ -35,6 +35,11 @@ | ... | @@ -35,6 +35,11 @@ |
35 | <artifactId>commons-lang3</artifactId> | 35 | <artifactId>commons-lang3</artifactId> |
36 | </dependency> | 36 | </dependency> |
37 | 37 | ||
38 | + <!-- TODO: do we still need this here? --> | ||
39 | + <dependency> | ||
40 | + <groupId>com.eclipsesource.minimal-json</groupId> | ||
41 | + <artifactId>minimal-json</artifactId> | ||
42 | + </dependency> | ||
38 | <dependency> | 43 | <dependency> |
39 | <groupId>com.esotericsoftware.kryo</groupId> | 44 | <groupId>com.esotericsoftware.kryo</groupId> |
40 | <artifactId>kryo</artifactId> | 45 | <artifactId>kryo</artifactId> | ... | ... |
-
Please register or login to post a comment