Ayaka Koshibe

Merge branch 'master' of ssh://gerrit.onlab.us:29418/onos-next

Showing 47 changed files with 434 additions and 52 deletions
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project xmlns="http://maven.apache.org/POM/4.0.0"
3 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5 + <modelVersion>4.0.0</modelVersion>
6 +
7 + <parent>
8 + <groupId>org.onlab.onos</groupId>
9 + <artifactId>onos-apps</artifactId>
10 + <version>1.0.0-SNAPSHOT</version>
11 + <relativePath>../pom.xml</relativePath>
12 + </parent>
13 +
14 + <artifactId>onos-app-foo</artifactId>
15 + <packaging>bundle</packaging>
16 +
17 + <description>ONOS application for miscellaneous experiments</description>
18 +
19 +</project>
1 +package org.onlab.onos.foo;
2 +
3 +import org.apache.felix.scr.annotations.Activate;
4 +import org.apache.felix.scr.annotations.Component;
5 +import org.apache.felix.scr.annotations.Deactivate;
6 +import org.apache.felix.scr.annotations.Reference;
7 +import org.apache.felix.scr.annotations.ReferenceCardinality;
8 +import org.onlab.onos.cluster.ClusterEvent;
9 +import org.onlab.onos.cluster.ClusterEventListener;
10 +import org.onlab.onos.cluster.ClusterService;
11 +import org.slf4j.Logger;
12 +
13 +import static org.slf4j.LoggerFactory.getLogger;
14 +
15 +/**
16 + * Playground app component.
17 + */
18 +@Component(immediate = true)
19 +public class FooComponent {
20 +
21 + private final Logger log = getLogger(getClass());
22 +
23 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
24 + protected ClusterService clusterService;
25 +
26 + private ClusterEventListener clusterListener = new InnerClusterListener();
27 +
28 + @Activate
29 + public void activate() {
30 + clusterService.addListener(clusterListener);
31 + log.info("Started");
32 + }
33 +
34 + @Deactivate
35 + public void deactivate() {
36 + clusterService.removeListener(clusterListener);
37 + log.info("Stopped");
38 + }
39 +
40 + private class InnerClusterListener implements ClusterEventListener {
41 + @Override
42 + public void event(ClusterEvent event) {
43 + log.info("WOOOOT! {}", event);
44 + }
45 + }
46 +}
47 +
48 +
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
19 <modules> 19 <modules>
20 <module>tvue</module> 20 <module>tvue</module>
21 <module>fwd</module> 21 <module>fwd</module>
22 + <module>foo</module>
22 </modules> 23 </modules>
23 24
24 <properties> 25 <properties>
......
1 package org.onlab.onos.cluster; 1 package org.onlab.onos.cluster;
2 2
3 +import org.onlab.onos.store.Store;
4 +
3 import java.util.Set; 5 import java.util.Set;
4 6
5 /** 7 /**
6 * Manages inventory of controller cluster nodes; not intended for direct use. 8 * Manages inventory of controller cluster nodes; not intended for direct use.
7 */ 9 */
8 -public interface ClusterStore { 10 +public interface ClusterStore extends Store<ClusterEvent, ClusterStoreDelegate> {
9 11
10 /** 12 /**
11 * Returns the local controller node. 13 * Returns the local controller node.
......
1 +package org.onlab.onos.cluster;
2 +
3 +import org.onlab.onos.store.StoreDelegate;
4 +
5 +/**
6 + * Cluster store delegate abstraction.
7 + */
8 +public interface ClusterStoreDelegate extends StoreDelegate<ClusterEvent> {
9 +}
...@@ -4,12 +4,13 @@ import java.util.Set; ...@@ -4,12 +4,13 @@ import java.util.Set;
4 4
5 import org.onlab.onos.net.DeviceId; 5 import org.onlab.onos.net.DeviceId;
6 import org.onlab.onos.net.MastershipRole; 6 import org.onlab.onos.net.MastershipRole;
7 +import org.onlab.onos.store.Store;
7 8
8 /** 9 /**
9 * Manages inventory of mastership roles for devices, across controller 10 * Manages inventory of mastership roles for devices, across controller
10 * instances; not intended for direct use. 11 * instances; not intended for direct use.
11 */ 12 */
12 -public interface MastershipStore { 13 +public interface MastershipStore extends Store<MastershipEvent, MastershipStoreDelegate> {
13 14
14 // three things to map: NodeId, DeviceId, MastershipRole 15 // three things to map: NodeId, DeviceId, MastershipRole
15 16
......
1 +package org.onlab.onos.cluster;
2 +
3 +import org.onlab.onos.store.StoreDelegate;
4 +
5 +/**
6 + * Mastership store delegate abstraction.
7 + */
8 +public interface MastershipStoreDelegate extends StoreDelegate<MastershipEvent> {
9 +}
1 package org.onlab.onos.net.device; 1 package org.onlab.onos.net.device;
2 2
3 import org.onlab.onos.net.DeviceId; 3 import org.onlab.onos.net.DeviceId;
4 +import org.onlab.onos.net.MastershipRole;
4 import org.onlab.onos.net.provider.ProviderService; 5 import org.onlab.onos.net.provider.ProviderService;
5 6
6 import java.util.List; 7 import java.util.List;
...@@ -45,4 +46,13 @@ public interface DeviceProviderService extends ProviderService<DeviceProvider> { ...@@ -45,4 +46,13 @@ public interface DeviceProviderService extends ProviderService<DeviceProvider> {
45 */ 46 */
46 void portStatusChanged(DeviceId deviceId, PortDescription portDescription); 47 void portStatusChanged(DeviceId deviceId, PortDescription portDescription);
47 48
49 + /**
50 + * Notifies the core about the providers inability to assert the specified
51 + * mastership role on the device.
52 + *
53 + * @param deviceId identity of the device
54 + * @param role mastership role being asserted
55 + */
56 + void unableToAssertRole(DeviceId deviceId, MastershipRole role);
57 +
48 } 58 }
......
...@@ -5,13 +5,14 @@ import org.onlab.onos.net.DeviceId; ...@@ -5,13 +5,14 @@ import org.onlab.onos.net.DeviceId;
5 import org.onlab.onos.net.Port; 5 import org.onlab.onos.net.Port;
6 import org.onlab.onos.net.PortNumber; 6 import org.onlab.onos.net.PortNumber;
7 import org.onlab.onos.net.provider.ProviderId; 7 import org.onlab.onos.net.provider.ProviderId;
8 +import org.onlab.onos.store.Store;
8 9
9 import java.util.List; 10 import java.util.List;
10 11
11 /** 12 /**
12 * Manages inventory of infrastructure devices; not intended for direct use. 13 * Manages inventory of infrastructure devices; not intended for direct use.
13 */ 14 */
14 -public interface DeviceStore { 15 +public interface DeviceStore extends Store<DeviceEvent, DeviceStoreDelegate> {
15 16
16 /** 17 /**
17 * Returns the number of devices known to the system. 18 * Returns the number of devices known to the system.
......
1 +package org.onlab.onos.net.device;
2 +
3 +import org.onlab.onos.store.StoreDelegate;
4 +
5 +/**
6 + * Infrastructure device store delegate abstraction.
7 + */
8 +public interface DeviceStoreDelegate extends StoreDelegate<DeviceEvent> {
9 +}
1 package org.onlab.onos.net.flow; 1 package org.onlab.onos.net.flow;
2 2
3 import org.onlab.onos.net.DeviceId; 3 import org.onlab.onos.net.DeviceId;
4 +import org.onlab.onos.store.Store;
4 5
5 /** 6 /**
6 * Manages inventory of flow rules; not intended for direct use. 7 * Manages inventory of flow rules; not intended for direct use.
7 */ 8 */
8 -public interface FlowRuleStore { 9 +public interface FlowRuleStore extends Store<FlowRuleEvent, FlowRuleStoreDelegate> {
9 10
10 /** 11 /**
11 * Returns the flow entries associated with a device. 12 * Returns the flow entries associated with a device.
......
1 +package org.onlab.onos.net.flow;
2 +
3 +import org.onlab.onos.store.StoreDelegate;
4 +
5 +/**
6 + * Flow rule store delegate abstraction.
7 + */
8 +public interface FlowRuleStoreDelegate extends StoreDelegate<FlowRuleEvent> {
9 +}
1 package org.onlab.onos.net.host; 1 package org.onlab.onos.net.host;
2 2
3 -import java.util.Set;
4 -
5 import org.onlab.onos.net.ConnectPoint; 3 import org.onlab.onos.net.ConnectPoint;
6 import org.onlab.onos.net.DeviceId; 4 import org.onlab.onos.net.DeviceId;
7 import org.onlab.onos.net.Host; 5 import org.onlab.onos.net.Host;
8 import org.onlab.onos.net.HostId; 6 import org.onlab.onos.net.HostId;
9 import org.onlab.onos.net.provider.ProviderId; 7 import org.onlab.onos.net.provider.ProviderId;
8 +import org.onlab.onos.store.Store;
10 import org.onlab.packet.IpPrefix; 9 import org.onlab.packet.IpPrefix;
11 import org.onlab.packet.MacAddress; 10 import org.onlab.packet.MacAddress;
12 import org.onlab.packet.VlanId; 11 import org.onlab.packet.VlanId;
13 12
13 +import java.util.Set;
14 +
14 /** 15 /**
15 * Manages inventory of end-station hosts; not intended for direct use. 16 * Manages inventory of end-station hosts; not intended for direct use.
16 */ 17 */
17 -public interface HostStore { 18 +public interface HostStore extends Store<HostEvent, HostStoreDelegate> {
18 19
19 /** 20 /**
20 * Creates a new host or updates the existing one based on the specified 21 * Creates a new host or updates the existing one based on the specified
...@@ -133,7 +134,7 @@ public interface HostStore { ...@@ -133,7 +134,7 @@ public interface HostStore {
133 * Returns the address bindings for a particular connection point. 134 * Returns the address bindings for a particular connection point.
134 * 135 *
135 * @param connectPoint the connection point to return address information 136 * @param connectPoint the connection point to return address information
136 - * for 137 + * for
137 * @return address information for the connection point 138 * @return address information for the connection point
138 */ 139 */
139 PortAddresses getAddressBindingsForPort(ConnectPoint connectPoint); 140 PortAddresses getAddressBindingsForPort(ConnectPoint connectPoint);
......
1 +package org.onlab.onos.net.host;
2 +
3 +import org.onlab.onos.store.StoreDelegate;
4 +
5 +/**
6 + * Infrastructure link store delegate abstraction.
7 + */
8 +public interface HostStoreDelegate extends StoreDelegate<HostEvent> {
9 +}
...@@ -4,13 +4,14 @@ import org.onlab.onos.net.ConnectPoint; ...@@ -4,13 +4,14 @@ import org.onlab.onos.net.ConnectPoint;
4 import org.onlab.onos.net.DeviceId; 4 import org.onlab.onos.net.DeviceId;
5 import org.onlab.onos.net.Link; 5 import org.onlab.onos.net.Link;
6 import org.onlab.onos.net.provider.ProviderId; 6 import org.onlab.onos.net.provider.ProviderId;
7 +import org.onlab.onos.store.Store;
7 8
8 import java.util.Set; 9 import java.util.Set;
9 10
10 /** 11 /**
11 * Manages inventory of infrastructure links; not intended for direct use. 12 * Manages inventory of infrastructure links; not intended for direct use.
12 */ 13 */
13 -public interface LinkStore { 14 +public interface LinkStore extends Store<LinkEvent, LinkStoreDelegate> {
14 15
15 /** 16 /**
16 * Returns the number of links in the store. 17 * Returns the number of links in the store.
......
1 +package org.onlab.onos.net.link;
2 +
3 +import org.onlab.onos.store.StoreDelegate;
4 +
5 +/**
6 + * Infrastructure link store delegate abstraction.
7 + */
8 +public interface LinkStoreDelegate extends StoreDelegate<LinkEvent> {
9 +}
...@@ -6,6 +6,7 @@ import org.onlab.onos.net.DeviceId; ...@@ -6,6 +6,7 @@ import org.onlab.onos.net.DeviceId;
6 import org.onlab.onos.net.Link; 6 import org.onlab.onos.net.Link;
7 import org.onlab.onos.net.Path; 7 import org.onlab.onos.net.Path;
8 import org.onlab.onos.net.provider.ProviderId; 8 import org.onlab.onos.net.provider.ProviderId;
9 +import org.onlab.onos.store.Store;
9 10
10 import java.util.List; 11 import java.util.List;
11 import java.util.Set; 12 import java.util.Set;
...@@ -13,7 +14,7 @@ import java.util.Set; ...@@ -13,7 +14,7 @@ import java.util.Set;
13 /** 14 /**
14 * Manages inventory of topology snapshots; not intended for direct use. 15 * Manages inventory of topology snapshots; not intended for direct use.
15 */ 16 */
16 -public interface TopologyStore { 17 +public interface TopologyStore extends Store<TopologyEvent, TopologyStoreDelegate> {
17 18
18 /** 19 /**
19 * Returns the current topology snapshot. 20 * Returns the current topology snapshot.
......
1 +package org.onlab.onos.net.topology;
2 +
3 +import org.onlab.onos.store.StoreDelegate;
4 +
5 +/**
6 + * Topology store delegate abstraction.
7 + */
8 +public interface TopologyStoreDelegate extends StoreDelegate<TopologyEvent> {
9 +}
1 +package org.onlab.onos.store;
2 +
3 +import org.onlab.onos.event.Event;
4 +
5 +import static com.google.common.base.Preconditions.checkState;
6 +
7 +/**
8 + * Base implementation of a store.
9 + */
10 +public class AbstractStore<E extends Event, D extends StoreDelegate<E>>
11 + implements Store<E, D> {
12 +
13 + protected D delegate;
14 +
15 + @Override
16 + public void setDelegate(D delegate) {
17 + checkState(this.delegate == null || this.delegate == delegate,
18 + "Store delegate already set");
19 + this.delegate = delegate;
20 + }
21 +
22 + @Override
23 + public void unsetDelegate(D delegate) {
24 + if (this.delegate == delegate) {
25 + this.delegate = null;
26 + }
27 + }
28 +
29 + @Override
30 + public boolean hasDelegate() {
31 + return delegate != null;
32 + }
33 +
34 + /**
35 + * Notifies the delegate with the specified event.
36 + *
37 + * @param event event to delegate
38 + */
39 + protected void notifyDelegate(E event) {
40 + if (delegate != null) {
41 + delegate.notify(event);
42 + }
43 + }
44 +}
1 +package org.onlab.onos.store;
2 +
3 +import org.onlab.onos.event.Event;
4 +
5 +/**
6 + * Abstraction of a entity capable of storing and/or distributing information
7 + * across a cluster.
8 + */
9 +public interface Store<E extends Event, D extends StoreDelegate<E>> {
10 +
11 + /**
12 + * Sets the delegate on the store.
13 + *
14 + * @param delegate new store delegate
15 + * @throws java.lang.IllegalStateException if a delegate is already
16 + * currently set on the store and is a different one that
17 + */
18 + void setDelegate(D delegate);
19 +
20 + /**
21 + * Withdraws the delegate from the store.
22 + *
23 + * @param delegate store delegate to withdraw
24 + * @throws java.lang.IllegalArgumentException if the delegate is not
25 + * currently set on the store
26 + */
27 + void unsetDelegate(D delegate);
28 +
29 + /**
30 + * Indicates whether the store has a delegate.
31 + *
32 + * @return true if delegate is set
33 + */
34 + boolean hasDelegate();
35 +
36 +}
1 +package org.onlab.onos.store;
2 +
3 +import org.onlab.onos.event.Event;
4 +
5 +/**
6 + * Entity associated with a store and capable of receiving notifications of
7 + * events within the store.
8 + */
9 +public interface StoreDelegate<E extends Event> {
10 +
11 + void notify(E event);
12 +
13 +}
1 +/**
2 + * Abstractions for creating and interacting with distributed stores.
3 + */
4 +package org.onlab.onos.store;
...\ No newline at end of file ...\ No newline at end of file
...@@ -11,6 +11,7 @@ import org.onlab.onos.cluster.ClusterEvent; ...@@ -11,6 +11,7 @@ import org.onlab.onos.cluster.ClusterEvent;
11 import org.onlab.onos.cluster.ClusterEventListener; 11 import org.onlab.onos.cluster.ClusterEventListener;
12 import org.onlab.onos.cluster.ClusterService; 12 import org.onlab.onos.cluster.ClusterService;
13 import org.onlab.onos.cluster.ClusterStore; 13 import org.onlab.onos.cluster.ClusterStore;
14 +import org.onlab.onos.cluster.ClusterStoreDelegate;
14 import org.onlab.onos.cluster.ControllerNode; 15 import org.onlab.onos.cluster.ControllerNode;
15 import org.onlab.onos.cluster.NodeId; 16 import org.onlab.onos.cluster.NodeId;
16 import org.onlab.onos.event.AbstractListenerRegistry; 17 import org.onlab.onos.event.AbstractListenerRegistry;
...@@ -32,6 +33,8 @@ public class ClusterManager implements ClusterService, ClusterAdminService { ...@@ -32,6 +33,8 @@ public class ClusterManager implements ClusterService, ClusterAdminService {
32 public static final String INSTANCE_ID_NULL = "Instance ID cannot be null"; 33 public static final String INSTANCE_ID_NULL = "Instance ID cannot be null";
33 private final Logger log = getLogger(getClass()); 34 private final Logger log = getLogger(getClass());
34 35
36 + private ClusterStoreDelegate delegate = new InternalStoreDelegate();
37 +
35 protected final AbstractListenerRegistry<ClusterEvent, ClusterEventListener> 38 protected final AbstractListenerRegistry<ClusterEvent, ClusterEventListener>
36 listenerRegistry = new AbstractListenerRegistry<>(); 39 listenerRegistry = new AbstractListenerRegistry<>();
37 40
...@@ -43,12 +46,14 @@ public class ClusterManager implements ClusterService, ClusterAdminService { ...@@ -43,12 +46,14 @@ public class ClusterManager implements ClusterService, ClusterAdminService {
43 46
44 @Activate 47 @Activate
45 public void activate() { 48 public void activate() {
49 + store.setDelegate(delegate);
46 eventDispatcher.addSink(ClusterEvent.class, listenerRegistry); 50 eventDispatcher.addSink(ClusterEvent.class, listenerRegistry);
47 log.info("Started"); 51 log.info("Started");
48 } 52 }
49 53
50 @Deactivate 54 @Deactivate
51 public void deactivate() { 55 public void deactivate() {
56 + store.unsetDelegate(delegate);
52 eventDispatcher.removeSink(ClusterEvent.class); 57 eventDispatcher.removeSink(ClusterEvent.class);
53 log.info("Stopped"); 58 log.info("Stopped");
54 } 59 }
...@@ -90,4 +95,13 @@ public class ClusterManager implements ClusterService, ClusterAdminService { ...@@ -90,4 +95,13 @@ public class ClusterManager implements ClusterService, ClusterAdminService {
90 public void removeListener(ClusterEventListener listener) { 95 public void removeListener(ClusterEventListener listener) {
91 listenerRegistry.removeListener(listener); 96 listenerRegistry.removeListener(listener);
92 } 97 }
98 +
99 + // Store delegate to re-post events emitted from the store.
100 + private class InternalStoreDelegate implements ClusterStoreDelegate {
101 + @Override
102 + public void notify(ClusterEvent event) {
103 + checkNotNull(event, "Event cannot be null");
104 + eventDispatcher.post(event);
105 + }
106 + }
93 } 107 }
......
...@@ -26,6 +26,7 @@ import org.onlab.onos.net.device.DeviceProviderRegistry; ...@@ -26,6 +26,7 @@ import org.onlab.onos.net.device.DeviceProviderRegistry;
26 import org.onlab.onos.net.device.DeviceProviderService; 26 import org.onlab.onos.net.device.DeviceProviderService;
27 import org.onlab.onos.net.device.DeviceService; 27 import org.onlab.onos.net.device.DeviceService;
28 import org.onlab.onos.net.device.DeviceStore; 28 import org.onlab.onos.net.device.DeviceStore;
29 +import org.onlab.onos.net.device.DeviceStoreDelegate;
29 import org.onlab.onos.net.device.PortDescription; 30 import org.onlab.onos.net.device.PortDescription;
30 import org.onlab.onos.net.provider.AbstractProviderRegistry; 31 import org.onlab.onos.net.provider.AbstractProviderRegistry;
31 import org.onlab.onos.net.provider.AbstractProviderService; 32 import org.onlab.onos.net.provider.AbstractProviderService;
...@@ -33,8 +34,8 @@ import org.slf4j.Logger; ...@@ -33,8 +34,8 @@ import org.slf4j.Logger;
33 34
34 import java.util.List; 35 import java.util.List;
35 36
36 -import static org.onlab.onos.net.device.DeviceEvent.Type.*;
37 import static com.google.common.base.Preconditions.checkNotNull; 37 import static com.google.common.base.Preconditions.checkNotNull;
38 +import static org.onlab.onos.net.device.DeviceEvent.Type.DEVICE_MASTERSHIP_CHANGED;
38 import static org.slf4j.LoggerFactory.getLogger; 39 import static org.slf4j.LoggerFactory.getLogger;
39 40
40 /** 41 /**
...@@ -57,7 +58,9 @@ public class DeviceManager ...@@ -57,7 +58,9 @@ public class DeviceManager
57 protected final AbstractListenerRegistry<DeviceEvent, DeviceListener> 58 protected final AbstractListenerRegistry<DeviceEvent, DeviceListener>
58 listenerRegistry = new AbstractListenerRegistry<>(); 59 listenerRegistry = new AbstractListenerRegistry<>();
59 60
60 - private final MastershipListener mastershipListener = new InnerMastershipListener(); 61 + private DeviceStoreDelegate delegate = new InternalStoreDelegate();
62 +
63 + private final MastershipListener mastershipListener = new InternalMastershipListener();
61 64
62 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 65 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
63 protected DeviceStore store; 66 protected DeviceStore store;
...@@ -73,6 +76,7 @@ public class DeviceManager ...@@ -73,6 +76,7 @@ public class DeviceManager
73 76
74 @Activate 77 @Activate
75 public void activate() { 78 public void activate() {
79 + store.setDelegate(delegate);
76 eventDispatcher.addSink(DeviceEvent.class, listenerRegistry); 80 eventDispatcher.addSink(DeviceEvent.class, listenerRegistry);
77 mastershipService.addListener(mastershipListener); 81 mastershipService.addListener(mastershipListener);
78 log.info("Started"); 82 log.info("Started");
...@@ -80,6 +84,7 @@ public class DeviceManager ...@@ -80,6 +84,7 @@ public class DeviceManager
80 84
81 @Deactivate 85 @Deactivate
82 public void deactivate() { 86 public void deactivate() {
87 + store.unsetDelegate(delegate);
83 mastershipService.removeListener(mastershipListener); 88 mastershipService.removeListener(mastershipListener);
84 eventDispatcher.removeSink(DeviceEvent.class); 89 eventDispatcher.removeSink(DeviceEvent.class);
85 log.info("Stopped"); 90 log.info("Stopped");
...@@ -224,6 +229,11 @@ public class DeviceManager ...@@ -224,6 +229,11 @@ public class DeviceManager
224 post(event); 229 post(event);
225 } 230 }
226 } 231 }
232 +
233 + @Override
234 + public void unableToAssertRole(DeviceId deviceId, MastershipRole role) {
235 + // FIXME: implement response to this notification
236 + }
227 } 237 }
228 238
229 // Posts the specified event to the local event dispatcher. 239 // Posts the specified event to the local event dispatcher.
...@@ -234,7 +244,7 @@ public class DeviceManager ...@@ -234,7 +244,7 @@ public class DeviceManager
234 } 244 }
235 245
236 // Intercepts mastership events 246 // Intercepts mastership events
237 - private class InnerMastershipListener implements MastershipListener { 247 + private class InternalMastershipListener implements MastershipListener {
238 @Override 248 @Override
239 public void event(MastershipEvent event) { 249 public void event(MastershipEvent event) {
240 // FIXME: for now we're taking action only on becoming master 250 // FIXME: for now we're taking action only on becoming master
...@@ -243,4 +253,12 @@ public class DeviceManager ...@@ -243,4 +253,12 @@ public class DeviceManager
243 } 253 }
244 } 254 }
245 } 255 }
256 +
257 + // Store delegate to re-post events emitted from the store.
258 + private class InternalStoreDelegate implements DeviceStoreDelegate {
259 + @Override
260 + public void notify(DeviceEvent event) {
261 + post(event);
262 + }
263 + }
246 } 264 }
......
1 package org.onlab.onos.net.flow.impl; 1 package org.onlab.onos.net.flow.impl;
2 2
3 -import static com.google.common.base.Preconditions.checkNotNull; 3 +import com.google.common.collect.Lists;
4 -import static org.slf4j.LoggerFactory.getLogger;
5 -
6 -import java.util.Iterator;
7 -import java.util.List;
8 -
9 import org.apache.felix.scr.annotations.Activate; 4 import org.apache.felix.scr.annotations.Activate;
10 import org.apache.felix.scr.annotations.Component; 5 import org.apache.felix.scr.annotations.Component;
11 import org.apache.felix.scr.annotations.Deactivate; 6 import org.apache.felix.scr.annotations.Deactivate;
...@@ -27,11 +22,16 @@ import org.onlab.onos.net.flow.FlowRuleProviderRegistry; ...@@ -27,11 +22,16 @@ import org.onlab.onos.net.flow.FlowRuleProviderRegistry;
27 import org.onlab.onos.net.flow.FlowRuleProviderService; 22 import org.onlab.onos.net.flow.FlowRuleProviderService;
28 import org.onlab.onos.net.flow.FlowRuleService; 23 import org.onlab.onos.net.flow.FlowRuleService;
29 import org.onlab.onos.net.flow.FlowRuleStore; 24 import org.onlab.onos.net.flow.FlowRuleStore;
25 +import org.onlab.onos.net.flow.FlowRuleStoreDelegate;
30 import org.onlab.onos.net.provider.AbstractProviderRegistry; 26 import org.onlab.onos.net.provider.AbstractProviderRegistry;
31 import org.onlab.onos.net.provider.AbstractProviderService; 27 import org.onlab.onos.net.provider.AbstractProviderService;
32 import org.slf4j.Logger; 28 import org.slf4j.Logger;
33 29
34 -import com.google.common.collect.Lists; 30 +import java.util.Iterator;
31 +import java.util.List;
32 +
33 +import static com.google.common.base.Preconditions.checkNotNull;
34 +import static org.slf4j.LoggerFactory.getLogger;
35 35
36 /** 36 /**
37 * Provides implementation of the flow NB &amp; SB APIs. 37 * Provides implementation of the flow NB &amp; SB APIs.
...@@ -48,6 +48,8 @@ implements FlowRuleService, FlowRuleProviderRegistry { ...@@ -48,6 +48,8 @@ implements FlowRuleService, FlowRuleProviderRegistry {
48 private final AbstractListenerRegistry<FlowRuleEvent, FlowRuleListener> 48 private final AbstractListenerRegistry<FlowRuleEvent, FlowRuleListener>
49 listenerRegistry = new AbstractListenerRegistry<>(); 49 listenerRegistry = new AbstractListenerRegistry<>();
50 50
51 + private FlowRuleStoreDelegate delegate = new InternalStoreDelegate();
52 +
51 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 53 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
52 protected FlowRuleStore store; 54 protected FlowRuleStore store;
53 55
...@@ -59,12 +61,14 @@ implements FlowRuleService, FlowRuleProviderRegistry { ...@@ -59,12 +61,14 @@ implements FlowRuleService, FlowRuleProviderRegistry {
59 61
60 @Activate 62 @Activate
61 public void activate() { 63 public void activate() {
64 + store.setDelegate(delegate);
62 eventDispatcher.addSink(FlowRuleEvent.class, listenerRegistry); 65 eventDispatcher.addSink(FlowRuleEvent.class, listenerRegistry);
63 log.info("Started"); 66 log.info("Started");
64 } 67 }
65 68
66 @Deactivate 69 @Deactivate
67 public void deactivate() { 70 public void deactivate() {
71 + store.unsetDelegate(delegate);
68 eventDispatcher.removeSink(FlowRuleEvent.class); 72 eventDispatcher.removeSink(FlowRuleEvent.class);
69 log.info("Stopped"); 73 log.info("Stopped");
70 } 74 }
...@@ -196,4 +200,11 @@ implements FlowRuleService, FlowRuleProviderRegistry { ...@@ -196,4 +200,11 @@ implements FlowRuleService, FlowRuleProviderRegistry {
196 } 200 }
197 } 201 }
198 202
203 + // Store delegate to re-post events emitted from the store.
204 + private class InternalStoreDelegate implements FlowRuleStoreDelegate {
205 + @Override
206 + public void notify(FlowRuleEvent event) {
207 + eventDispatcher.post(event);
208 + }
209 + }
199 } 210 }
......
1 package org.onlab.onos.net.host.impl; 1 package org.onlab.onos.net.host.impl;
2 2
3 -import static com.google.common.base.Preconditions.checkNotNull;
4 -import static org.slf4j.LoggerFactory.getLogger;
5 -
6 -import java.util.Set;
7 -
8 import org.apache.felix.scr.annotations.Activate; 3 import org.apache.felix.scr.annotations.Activate;
9 import org.apache.felix.scr.annotations.Component; 4 import org.apache.felix.scr.annotations.Component;
10 import org.apache.felix.scr.annotations.Deactivate; 5 import org.apache.felix.scr.annotations.Deactivate;
...@@ -26,6 +21,7 @@ import org.onlab.onos.net.host.HostProviderRegistry; ...@@ -26,6 +21,7 @@ import org.onlab.onos.net.host.HostProviderRegistry;
26 import org.onlab.onos.net.host.HostProviderService; 21 import org.onlab.onos.net.host.HostProviderService;
27 import org.onlab.onos.net.host.HostService; 22 import org.onlab.onos.net.host.HostService;
28 import org.onlab.onos.net.host.HostStore; 23 import org.onlab.onos.net.host.HostStore;
24 +import org.onlab.onos.net.host.HostStoreDelegate;
29 import org.onlab.onos.net.host.PortAddresses; 25 import org.onlab.onos.net.host.PortAddresses;
30 import org.onlab.onos.net.provider.AbstractProviderRegistry; 26 import org.onlab.onos.net.provider.AbstractProviderRegistry;
31 import org.onlab.onos.net.provider.AbstractProviderService; 27 import org.onlab.onos.net.provider.AbstractProviderService;
...@@ -35,6 +31,11 @@ import org.onlab.packet.MacAddress; ...@@ -35,6 +31,11 @@ import org.onlab.packet.MacAddress;
35 import org.onlab.packet.VlanId; 31 import org.onlab.packet.VlanId;
36 import org.slf4j.Logger; 32 import org.slf4j.Logger;
37 33
34 +import java.util.Set;
35 +
36 +import static com.google.common.base.Preconditions.checkNotNull;
37 +import static org.slf4j.LoggerFactory.getLogger;
38 +
38 /** 39 /**
39 * Provides basic implementation of the host SB &amp; NB APIs. 40 * Provides basic implementation of the host SB &amp; NB APIs.
40 */ 41 */
...@@ -50,6 +51,8 @@ public class HostManager ...@@ -50,6 +51,8 @@ public class HostManager
50 private final AbstractListenerRegistry<HostEvent, HostListener> 51 private final AbstractListenerRegistry<HostEvent, HostListener>
51 listenerRegistry = new AbstractListenerRegistry<>(); 52 listenerRegistry = new AbstractListenerRegistry<>();
52 53
54 + private HostStoreDelegate delegate = new InternalStoreDelegate();
55 +
53 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 56 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
54 protected HostStore store; 57 protected HostStore store;
55 58
...@@ -59,12 +62,14 @@ public class HostManager ...@@ -59,12 +62,14 @@ public class HostManager
59 62
60 @Activate 63 @Activate
61 public void activate() { 64 public void activate() {
65 + store.setDelegate(delegate);
62 eventDispatcher.addSink(HostEvent.class, listenerRegistry); 66 eventDispatcher.addSink(HostEvent.class, listenerRegistry);
63 log.info("Started"); 67 log.info("Started");
64 } 68 }
65 69
66 @Deactivate 70 @Deactivate
67 public void deactivate() { 71 public void deactivate() {
72 + store.unsetDelegate(delegate);
68 eventDispatcher.removeSink(HostEvent.class); 73 eventDispatcher.removeSink(HostEvent.class);
69 log.info("Stopped"); 74 log.info("Stopped");
70 } 75 }
...@@ -219,4 +224,11 @@ public class HostManager ...@@ -219,4 +224,11 @@ public class HostManager
219 } 224 }
220 } 225 }
221 226
227 + // Store delegate to re-post events emitted from the store.
228 + private class InternalStoreDelegate implements HostStoreDelegate {
229 + @Override
230 + public void notify(HostEvent event) {
231 + post(event);
232 + }
233 + }
222 } 234 }
......
...@@ -28,6 +28,7 @@ import org.onlab.onos.net.link.LinkProviderRegistry; ...@@ -28,6 +28,7 @@ import org.onlab.onos.net.link.LinkProviderRegistry;
28 import org.onlab.onos.net.link.LinkProviderService; 28 import org.onlab.onos.net.link.LinkProviderService;
29 import org.onlab.onos.net.link.LinkService; 29 import org.onlab.onos.net.link.LinkService;
30 import org.onlab.onos.net.link.LinkStore; 30 import org.onlab.onos.net.link.LinkStore;
31 +import org.onlab.onos.net.link.LinkStoreDelegate;
31 import org.onlab.onos.net.provider.AbstractProviderRegistry; 32 import org.onlab.onos.net.provider.AbstractProviderRegistry;
32 import org.onlab.onos.net.provider.AbstractProviderService; 33 import org.onlab.onos.net.provider.AbstractProviderService;
33 import org.slf4j.Logger; 34 import org.slf4j.Logger;
...@@ -52,7 +53,9 @@ public class LinkManager ...@@ -52,7 +53,9 @@ public class LinkManager
52 protected final AbstractListenerRegistry<LinkEvent, LinkListener> 53 protected final AbstractListenerRegistry<LinkEvent, LinkListener>
53 listenerRegistry = new AbstractListenerRegistry<>(); 54 listenerRegistry = new AbstractListenerRegistry<>();
54 55
55 - private final DeviceListener deviceListener = new InnerDeviceListener(); 56 + private LinkStoreDelegate delegate = new InternalStoreDelegate();
57 +
58 + private final DeviceListener deviceListener = new InternalDeviceListener();
56 59
57 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 60 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
58 protected LinkStore store; 61 protected LinkStore store;
...@@ -65,6 +68,7 @@ public class LinkManager ...@@ -65,6 +68,7 @@ public class LinkManager
65 68
66 @Activate 69 @Activate
67 public void activate() { 70 public void activate() {
71 + store.setDelegate(delegate);
68 eventDispatcher.addSink(LinkEvent.class, listenerRegistry); 72 eventDispatcher.addSink(LinkEvent.class, listenerRegistry);
69 deviceService.addListener(deviceListener); 73 deviceService.addListener(deviceListener);
70 log.info("Started"); 74 log.info("Started");
...@@ -72,6 +76,7 @@ public class LinkManager ...@@ -72,6 +76,7 @@ public class LinkManager
72 76
73 @Deactivate 77 @Deactivate
74 public void deactivate() { 78 public void deactivate() {
79 + store.unsetDelegate(delegate);
75 eventDispatcher.removeSink(LinkEvent.class); 80 eventDispatcher.removeSink(LinkEvent.class);
76 deviceService.removeListener(deviceListener); 81 deviceService.removeListener(deviceListener);
77 log.info("Stopped"); 82 log.info("Stopped");
...@@ -154,7 +159,7 @@ public class LinkManager ...@@ -154,7 +159,7 @@ public class LinkManager
154 159
155 // Auxiliary interceptor for device remove events to prune links that 160 // Auxiliary interceptor for device remove events to prune links that
156 // are associated with the removed device or its port. 161 // are associated with the removed device or its port.
157 - private class InnerDeviceListener implements DeviceListener { 162 + private class InternalDeviceListener implements DeviceListener {
158 @Override 163 @Override
159 public void event(DeviceEvent event) { 164 public void event(DeviceEvent event) {
160 if (event.type() == DeviceEvent.Type.DEVICE_REMOVED) { 165 if (event.type() == DeviceEvent.Type.DEVICE_REMOVED) {
...@@ -236,4 +241,11 @@ public class LinkManager ...@@ -236,4 +241,11 @@ public class LinkManager
236 } 241 }
237 } 242 }
238 243
244 + // Store delegate to re-post events emitted from the store.
245 + private class InternalStoreDelegate implements LinkStoreDelegate {
246 + @Override
247 + public void notify(LinkEvent event) {
248 + post(event);
249 + }
250 + }
239 } 251 }
......
...@@ -28,6 +28,7 @@ import org.onlab.onos.net.topology.TopologyProviderRegistry; ...@@ -28,6 +28,7 @@ import org.onlab.onos.net.topology.TopologyProviderRegistry;
28 import org.onlab.onos.net.topology.TopologyProviderService; 28 import org.onlab.onos.net.topology.TopologyProviderService;
29 import org.onlab.onos.net.topology.TopologyService; 29 import org.onlab.onos.net.topology.TopologyService;
30 import org.onlab.onos.net.topology.TopologyStore; 30 import org.onlab.onos.net.topology.TopologyStore;
31 +import org.onlab.onos.net.topology.TopologyStoreDelegate;
31 import org.slf4j.Logger; 32 import org.slf4j.Logger;
32 33
33 import java.util.List; 34 import java.util.List;
...@@ -56,6 +57,8 @@ public class TopologyManager ...@@ -56,6 +57,8 @@ public class TopologyManager
56 private final AbstractListenerRegistry<TopologyEvent, TopologyListener> 57 private final AbstractListenerRegistry<TopologyEvent, TopologyListener>
57 listenerRegistry = new AbstractListenerRegistry<>(); 58 listenerRegistry = new AbstractListenerRegistry<>();
58 59
60 + private TopologyStoreDelegate delegate = new InternalStoreDelegate();
61 +
59 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 62 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
60 protected TopologyStore store; 63 protected TopologyStore store;
61 64
...@@ -65,12 +68,14 @@ public class TopologyManager ...@@ -65,12 +68,14 @@ public class TopologyManager
65 68
66 @Activate 69 @Activate
67 public void activate() { 70 public void activate() {
71 + store.setDelegate(delegate);
68 eventDispatcher.addSink(TopologyEvent.class, listenerRegistry); 72 eventDispatcher.addSink(TopologyEvent.class, listenerRegistry);
69 log.info("Started"); 73 log.info("Started");
70 } 74 }
71 75
72 @Deactivate 76 @Deactivate
73 public void deactivate() { 77 public void deactivate() {
78 + store.unsetDelegate(delegate);
74 eventDispatcher.removeSink(TopologyEvent.class); 79 eventDispatcher.removeSink(TopologyEvent.class);
75 log.info("Stopped"); 80 log.info("Stopped");
76 } 81 }
...@@ -188,4 +193,11 @@ public class TopologyManager ...@@ -188,4 +193,11 @@ public class TopologyManager
188 } 193 }
189 } 194 }
190 195
196 + // Store delegate to re-post events emitted from the store.
197 + private class InternalStoreDelegate implements TopologyStoreDelegate {
198 + @Override
199 + public void notify(TopologyEvent event) {
200 + eventDispatcher.post(event);
201 + }
202 + }
191 } 203 }
......
...@@ -30,7 +30,7 @@ import org.onlab.onos.net.device.DeviceService; ...@@ -30,7 +30,7 @@ import org.onlab.onos.net.device.DeviceService;
30 import org.onlab.onos.net.device.PortDescription; 30 import org.onlab.onos.net.device.PortDescription;
31 import org.onlab.onos.net.provider.AbstractProvider; 31 import org.onlab.onos.net.provider.AbstractProvider;
32 import org.onlab.onos.net.provider.ProviderId; 32 import org.onlab.onos.net.provider.ProviderId;
33 -import org.onlab.onos.store.StoreService; 33 +import org.onlab.onos.store.common.StoreService;
34 import org.onlab.onos.store.device.impl.DistributedDeviceStore; 34 import org.onlab.onos.store.device.impl.DistributedDeviceStore;
35 import org.onlab.onos.store.impl.StoreManager; 35 import org.onlab.onos.store.impl.StoreManager;
36 36
......
...@@ -12,7 +12,9 @@ import org.apache.felix.scr.annotations.Activate; ...@@ -12,7 +12,9 @@ import org.apache.felix.scr.annotations.Activate;
12 import org.apache.felix.scr.annotations.Component; 12 import org.apache.felix.scr.annotations.Component;
13 import org.apache.felix.scr.annotations.Deactivate; 13 import org.apache.felix.scr.annotations.Deactivate;
14 import org.apache.felix.scr.annotations.Service; 14 import org.apache.felix.scr.annotations.Service;
15 +import org.onlab.onos.cluster.ClusterEvent;
15 import org.onlab.onos.cluster.ClusterStore; 16 import org.onlab.onos.cluster.ClusterStore;
17 +import org.onlab.onos.cluster.ClusterStoreDelegate;
16 import org.onlab.onos.cluster.ControllerNode; 18 import org.onlab.onos.cluster.ControllerNode;
17 import org.onlab.onos.cluster.DefaultControllerNode; 19 import org.onlab.onos.cluster.DefaultControllerNode;
18 import org.onlab.onos.cluster.NodeId; 20 import org.onlab.onos.cluster.NodeId;
...@@ -26,6 +28,8 @@ import java.util.Set; ...@@ -26,6 +28,8 @@ import java.util.Set;
26 import java.util.concurrent.ConcurrentHashMap; 28 import java.util.concurrent.ConcurrentHashMap;
27 29
28 import static com.google.common.cache.CacheBuilder.newBuilder; 30 import static com.google.common.cache.CacheBuilder.newBuilder;
31 +import static org.onlab.onos.cluster.ClusterEvent.Type.INSTANCE_ACTIVATED;
32 +import static org.onlab.onos.cluster.ClusterEvent.Type.INSTANCE_DEACTIVATED;
29 import static org.onlab.onos.cluster.ControllerNode.State; 33 import static org.onlab.onos.cluster.ControllerNode.State;
30 34
31 /** 35 /**
...@@ -33,14 +37,15 @@ import static org.onlab.onos.cluster.ControllerNode.State; ...@@ -33,14 +37,15 @@ import static org.onlab.onos.cluster.ControllerNode.State;
33 */ 37 */
34 @Component(immediate = true) 38 @Component(immediate = true)
35 @Service 39 @Service
36 -public class DistributedClusterStore extends AbstractDistributedStore 40 +public class DistributedClusterStore
41 + extends AbstractDistributedStore<ClusterEvent, ClusterStoreDelegate>
37 implements ClusterStore { 42 implements ClusterStore {
38 43
39 private IMap<byte[], byte[]> rawNodes; 44 private IMap<byte[], byte[]> rawNodes;
40 private LoadingCache<NodeId, Optional<DefaultControllerNode>> nodes; 45 private LoadingCache<NodeId, Optional<DefaultControllerNode>> nodes;
41 46
42 private String listenerId; 47 private String listenerId;
43 - private final MembershipListener listener = new InnerMembershipListener(); 48 + private final MembershipListener listener = new InternalMembershipListener();
44 private final Map<NodeId, State> states = new ConcurrentHashMap<>(); 49 private final Map<NodeId, State> states = new ConcurrentHashMap<>();
45 50
46 @Activate 51 @Activate
...@@ -106,11 +111,12 @@ public class DistributedClusterStore extends AbstractDistributedStore ...@@ -106,11 +111,12 @@ public class DistributedClusterStore extends AbstractDistributedStore
106 } 111 }
107 112
108 // Adds a new node based on the specified member 113 // Adds a new node based on the specified member
109 - private synchronized void addMember(Member member) { 114 + private synchronized ControllerNode addMember(Member member) {
110 DefaultControllerNode node = node(member); 115 DefaultControllerNode node = node(member);
111 rawNodes.put(serialize(node.id()), serialize(node)); 116 rawNodes.put(serialize(node.id()), serialize(node));
112 nodes.put(node.id(), Optional.of(node)); 117 nodes.put(node.id(), Optional.of(node));
113 states.put(node.id(), State.ACTIVE); 118 states.put(node.id(), State.ACTIVE);
119 + return node;
114 } 120 }
115 121
116 // Creates a controller node descriptor from the Hazelcast member. 122 // Creates a controller node descriptor from the Hazelcast member.
...@@ -125,18 +131,20 @@ public class DistributedClusterStore extends AbstractDistributedStore ...@@ -125,18 +131,20 @@ public class DistributedClusterStore extends AbstractDistributedStore
125 } 131 }
126 132
127 // Interceptor for membership events. 133 // Interceptor for membership events.
128 - private class InnerMembershipListener implements MembershipListener { 134 + private class InternalMembershipListener implements MembershipListener {
129 @Override 135 @Override
130 public void memberAdded(MembershipEvent membershipEvent) { 136 public void memberAdded(MembershipEvent membershipEvent) {
131 log.info("Member {} added", membershipEvent.getMember()); 137 log.info("Member {} added", membershipEvent.getMember());
132 - addMember(membershipEvent.getMember()); 138 + ControllerNode node = addMember(membershipEvent.getMember());
139 + notifyDelegate(new ClusterEvent(INSTANCE_ACTIVATED, node));
133 } 140 }
134 141
135 @Override 142 @Override
136 public void memberRemoved(MembershipEvent membershipEvent) { 143 public void memberRemoved(MembershipEvent membershipEvent) {
137 log.info("Member {} removed", membershipEvent.getMember()); 144 log.info("Member {} removed", membershipEvent.getMember());
138 - states.put(new NodeId(memberAddress(membershipEvent.getMember()).toString()), 145 + NodeId nodeId = new NodeId(memberAddress(membershipEvent.getMember()).toString());
139 - State.INACTIVE); 146 + states.put(nodeId, State.INACTIVE);
147 + notifyDelegate(new ClusterEvent(INSTANCE_DEACTIVATED, getNode(nodeId)));
140 } 148 }
141 149
142 @Override 150 @Override
......
...@@ -13,6 +13,7 @@ import org.apache.felix.scr.annotations.Service; ...@@ -13,6 +13,7 @@ import org.apache.felix.scr.annotations.Service;
13 import org.onlab.onos.cluster.ClusterService; 13 import org.onlab.onos.cluster.ClusterService;
14 import org.onlab.onos.cluster.MastershipEvent; 14 import org.onlab.onos.cluster.MastershipEvent;
15 import org.onlab.onos.cluster.MastershipStore; 15 import org.onlab.onos.cluster.MastershipStore;
16 +import org.onlab.onos.cluster.MastershipStoreDelegate;
16 import org.onlab.onos.cluster.NodeId; 17 import org.onlab.onos.cluster.NodeId;
17 import org.onlab.onos.net.DeviceId; 18 import org.onlab.onos.net.DeviceId;
18 import org.onlab.onos.net.MastershipRole; 19 import org.onlab.onos.net.MastershipRole;
...@@ -31,7 +32,8 @@ import static com.google.common.cache.CacheBuilder.newBuilder; ...@@ -31,7 +32,8 @@ import static com.google.common.cache.CacheBuilder.newBuilder;
31 */ 32 */
32 @Component(immediate = true) 33 @Component(immediate = true)
33 @Service 34 @Service
34 -public class DistributedMastershipStore extends AbstractDistributedStore 35 +public class DistributedMastershipStore
36 + extends AbstractDistributedStore<MastershipEvent, MastershipStoreDelegate>
35 implements MastershipStore { 37 implements MastershipStore {
36 38
37 private IMap<byte[], byte[]> rawMasters; 39 private IMap<byte[], byte[]> rawMasters;
......
1 -package org.onlab.onos.store; 1 +package org.onlab.onos.store.common;
2 2
3 import com.hazelcast.core.HazelcastInstance; 3 import com.hazelcast.core.HazelcastInstance;
4 4
......
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
2 * Common abstractions and facilities for implementing distributed store 2 * Common abstractions and facilities for implementing distributed store
3 * using Hazelcast. 3 * using Hazelcast.
4 */ 4 */
5 -package org.onlab.onos.store; 5 +package org.onlab.onos.store.common;
......
...@@ -21,6 +21,7 @@ import org.onlab.onos.net.PortNumber; ...@@ -21,6 +21,7 @@ import org.onlab.onos.net.PortNumber;
21 import org.onlab.onos.net.device.DeviceDescription; 21 import org.onlab.onos.net.device.DeviceDescription;
22 import org.onlab.onos.net.device.DeviceEvent; 22 import org.onlab.onos.net.device.DeviceEvent;
23 import org.onlab.onos.net.device.DeviceStore; 23 import org.onlab.onos.net.device.DeviceStore;
24 +import org.onlab.onos.net.device.DeviceStoreDelegate;
24 import org.onlab.onos.net.device.PortDescription; 25 import org.onlab.onos.net.device.PortDescription;
25 import org.onlab.onos.net.provider.ProviderId; 26 import org.onlab.onos.net.provider.ProviderId;
26 import org.onlab.onos.store.impl.AbsentInvalidatingLoadingCache; 27 import org.onlab.onos.store.impl.AbsentInvalidatingLoadingCache;
...@@ -48,7 +49,8 @@ import static org.slf4j.LoggerFactory.getLogger; ...@@ -48,7 +49,8 @@ import static org.slf4j.LoggerFactory.getLogger;
48 */ 49 */
49 @Component(immediate = true) 50 @Component(immediate = true)
50 @Service 51 @Service
51 -public class DistributedDeviceStore extends AbstractDistributedStore 52 +public class DistributedDeviceStore
53 + extends AbstractDistributedStore<DeviceEvent, DeviceStoreDelegate>
52 implements DeviceStore { 54 implements DeviceStore {
53 55
54 private final Logger log = getLogger(getClass()); 56 private final Logger log = getLogger(getClass());
......
...@@ -10,7 +10,10 @@ import org.apache.felix.scr.annotations.Activate; ...@@ -10,7 +10,10 @@ import org.apache.felix.scr.annotations.Activate;
10 import org.apache.felix.scr.annotations.Component; 10 import org.apache.felix.scr.annotations.Component;
11 import org.apache.felix.scr.annotations.Reference; 11 import org.apache.felix.scr.annotations.Reference;
12 import org.apache.felix.scr.annotations.ReferenceCardinality; 12 import org.apache.felix.scr.annotations.ReferenceCardinality;
13 -import org.onlab.onos.store.StoreService; 13 +import org.onlab.onos.event.Event;
14 +import org.onlab.onos.store.AbstractStore;
15 +import org.onlab.onos.store.StoreDelegate;
16 +import org.onlab.onos.store.common.StoreService;
14 import org.slf4j.Logger; 17 import org.slf4j.Logger;
15 18
16 import static com.google.common.base.Preconditions.checkNotNull; 19 import static com.google.common.base.Preconditions.checkNotNull;
...@@ -20,7 +23,8 @@ import static org.slf4j.LoggerFactory.getLogger; ...@@ -20,7 +23,8 @@ import static org.slf4j.LoggerFactory.getLogger;
20 * Abstraction of a distributed store based on Hazelcast. 23 * Abstraction of a distributed store based on Hazelcast.
21 */ 24 */
22 @Component(componentAbstract = true) 25 @Component(componentAbstract = true)
23 -public abstract class AbstractDistributedStore { 26 +public abstract class AbstractDistributedStore<E extends Event, D extends StoreDelegate<E>>
27 + extends AbstractStore<E, D> {
24 28
25 protected final Logger log = getLogger(getClass()); 29 protected final Logger log = getLogger(getClass());
26 30
......
...@@ -2,7 +2,7 @@ package org.onlab.onos.store.impl; ...@@ -2,7 +2,7 @@ package org.onlab.onos.store.impl;
2 2
3 import static com.google.common.base.Preconditions.checkNotNull; 3 import static com.google.common.base.Preconditions.checkNotNull;
4 4
5 -import org.onlab.onos.store.StoreService; 5 +import org.onlab.onos.store.common.StoreService;
6 6
7 import com.google.common.base.Optional; 7 import com.google.common.base.Optional;
8 import com.google.common.cache.CacheLoader; 8 import com.google.common.cache.CacheLoader;
......
...@@ -21,7 +21,7 @@ import org.onlab.onos.net.MastershipRole; ...@@ -21,7 +21,7 @@ import org.onlab.onos.net.MastershipRole;
21 import org.onlab.onos.net.Port; 21 import org.onlab.onos.net.Port;
22 import org.onlab.onos.net.PortNumber; 22 import org.onlab.onos.net.PortNumber;
23 import org.onlab.onos.net.provider.ProviderId; 23 import org.onlab.onos.net.provider.ProviderId;
24 -import org.onlab.onos.store.StoreService; 24 +import org.onlab.onos.store.common.StoreService;
25 import org.onlab.onos.store.serializers.DefaultPortSerializer; 25 import org.onlab.onos.store.serializers.DefaultPortSerializer;
26 import org.onlab.onos.store.serializers.DeviceIdSerializer; 26 import org.onlab.onos.store.serializers.DeviceIdSerializer;
27 import org.onlab.onos.store.serializers.IpPrefixSerializer; 27 import org.onlab.onos.store.serializers.IpPrefixSerializer;
......
...@@ -5,10 +5,13 @@ import org.apache.felix.scr.annotations.Activate; ...@@ -5,10 +5,13 @@ import org.apache.felix.scr.annotations.Activate;
5 import org.apache.felix.scr.annotations.Component; 5 import org.apache.felix.scr.annotations.Component;
6 import org.apache.felix.scr.annotations.Deactivate; 6 import org.apache.felix.scr.annotations.Deactivate;
7 import org.apache.felix.scr.annotations.Service; 7 import org.apache.felix.scr.annotations.Service;
8 +import org.onlab.onos.cluster.ClusterEvent;
8 import org.onlab.onos.cluster.ClusterStore; 9 import org.onlab.onos.cluster.ClusterStore;
10 +import org.onlab.onos.cluster.ClusterStoreDelegate;
9 import org.onlab.onos.cluster.ControllerNode; 11 import org.onlab.onos.cluster.ControllerNode;
10 import org.onlab.onos.cluster.DefaultControllerNode; 12 import org.onlab.onos.cluster.DefaultControllerNode;
11 import org.onlab.onos.cluster.NodeId; 13 import org.onlab.onos.cluster.NodeId;
14 +import org.onlab.onos.store.AbstractStore;
12 import org.onlab.packet.IpPrefix; 15 import org.onlab.packet.IpPrefix;
13 import org.slf4j.Logger; 16 import org.slf4j.Logger;
14 17
...@@ -22,7 +25,9 @@ import static org.slf4j.LoggerFactory.getLogger; ...@@ -22,7 +25,9 @@ import static org.slf4j.LoggerFactory.getLogger;
22 */ 25 */
23 @Component(immediate = true) 26 @Component(immediate = true)
24 @Service 27 @Service
25 -public class SimpleClusterStore implements ClusterStore { 28 +public class SimpleClusterStore
29 + extends AbstractStore<ClusterEvent, ClusterStoreDelegate>
30 + implements ClusterStore {
26 31
27 public static final IpPrefix LOCALHOST = IpPrefix.valueOf("127.0.0.1"); 32 public static final IpPrefix LOCALHOST = IpPrefix.valueOf("127.0.0.1");
28 33
......
...@@ -15,8 +15,10 @@ import org.onlab.onos.net.PortNumber; ...@@ -15,8 +15,10 @@ import org.onlab.onos.net.PortNumber;
15 import org.onlab.onos.net.device.DeviceDescription; 15 import org.onlab.onos.net.device.DeviceDescription;
16 import org.onlab.onos.net.device.DeviceEvent; 16 import org.onlab.onos.net.device.DeviceEvent;
17 import org.onlab.onos.net.device.DeviceStore; 17 import org.onlab.onos.net.device.DeviceStore;
18 +import org.onlab.onos.net.device.DeviceStoreDelegate;
18 import org.onlab.onos.net.device.PortDescription; 19 import org.onlab.onos.net.device.PortDescription;
19 import org.onlab.onos.net.provider.ProviderId; 20 import org.onlab.onos.net.provider.ProviderId;
21 +import org.onlab.onos.store.AbstractStore;
20 import org.slf4j.Logger; 22 import org.slf4j.Logger;
21 23
22 import java.util.ArrayList; 24 import java.util.ArrayList;
...@@ -40,7 +42,9 @@ import static org.slf4j.LoggerFactory.getLogger; ...@@ -40,7 +42,9 @@ import static org.slf4j.LoggerFactory.getLogger;
40 */ 42 */
41 @Component(immediate = true) 43 @Component(immediate = true)
42 @Service 44 @Service
43 -public class SimpleDeviceStore implements DeviceStore { 45 +public class SimpleDeviceStore
46 + extends AbstractStore<DeviceEvent, DeviceStoreDelegate>
47 + implements DeviceStore {
44 48
45 private final Logger log = getLogger(getClass()); 49 private final Logger log = getLogger(getClass());
46 50
......
...@@ -13,6 +13,8 @@ import org.onlab.onos.net.flow.FlowRule; ...@@ -13,6 +13,8 @@ import org.onlab.onos.net.flow.FlowRule;
13 import org.onlab.onos.net.flow.FlowRuleEvent; 13 import org.onlab.onos.net.flow.FlowRuleEvent;
14 import org.onlab.onos.net.flow.FlowRuleEvent.Type; 14 import org.onlab.onos.net.flow.FlowRuleEvent.Type;
15 import org.onlab.onos.net.flow.FlowRuleStore; 15 import org.onlab.onos.net.flow.FlowRuleStore;
16 +import org.onlab.onos.net.flow.FlowRuleStoreDelegate;
17 +import org.onlab.onos.store.AbstractStore;
16 import org.slf4j.Logger; 18 import org.slf4j.Logger;
17 19
18 import com.google.common.collect.ArrayListMultimap; 20 import com.google.common.collect.ArrayListMultimap;
...@@ -24,7 +26,9 @@ import com.google.common.collect.Multimap; ...@@ -24,7 +26,9 @@ import com.google.common.collect.Multimap;
24 */ 26 */
25 @Component(immediate = true) 27 @Component(immediate = true)
26 @Service 28 @Service
27 -public class SimpleFlowRuleStore implements FlowRuleStore { 29 +public class SimpleFlowRuleStore
30 + extends AbstractStore<FlowRuleEvent, FlowRuleStoreDelegate>
31 + implements FlowRuleStore {
28 32
29 private final Logger log = getLogger(getClass()); 33 private final Logger log = getLogger(getClass());
30 34
......
...@@ -24,8 +24,10 @@ import org.onlab.onos.net.HostId; ...@@ -24,8 +24,10 @@ import org.onlab.onos.net.HostId;
24 import org.onlab.onos.net.host.HostDescription; 24 import org.onlab.onos.net.host.HostDescription;
25 import org.onlab.onos.net.host.HostEvent; 25 import org.onlab.onos.net.host.HostEvent;
26 import org.onlab.onos.net.host.HostStore; 26 import org.onlab.onos.net.host.HostStore;
27 +import org.onlab.onos.net.host.HostStoreDelegate;
27 import org.onlab.onos.net.host.PortAddresses; 28 import org.onlab.onos.net.host.PortAddresses;
28 import org.onlab.onos.net.provider.ProviderId; 29 import org.onlab.onos.net.provider.ProviderId;
30 +import org.onlab.onos.store.AbstractStore;
29 import org.onlab.packet.IpPrefix; 31 import org.onlab.packet.IpPrefix;
30 import org.onlab.packet.MacAddress; 32 import org.onlab.packet.MacAddress;
31 import org.onlab.packet.VlanId; 33 import org.onlab.packet.VlanId;
...@@ -41,7 +43,9 @@ import com.google.common.collect.Multimap; ...@@ -41,7 +43,9 @@ import com.google.common.collect.Multimap;
41 */ 43 */
42 @Component(immediate = true) 44 @Component(immediate = true)
43 @Service 45 @Service
44 -public class SimpleHostStore implements HostStore { 46 +public class SimpleHostStore
47 + extends AbstractStore<HostEvent, HostStoreDelegate>
48 + implements HostStore {
45 49
46 private final Logger log = getLogger(getClass()); 50 private final Logger log = getLogger(getClass());
47 51
......
...@@ -14,7 +14,9 @@ import org.onlab.onos.net.Link; ...@@ -14,7 +14,9 @@ import org.onlab.onos.net.Link;
14 import org.onlab.onos.net.link.LinkDescription; 14 import org.onlab.onos.net.link.LinkDescription;
15 import org.onlab.onos.net.link.LinkEvent; 15 import org.onlab.onos.net.link.LinkEvent;
16 import org.onlab.onos.net.link.LinkStore; 16 import org.onlab.onos.net.link.LinkStore;
17 +import org.onlab.onos.net.link.LinkStoreDelegate;
17 import org.onlab.onos.net.provider.ProviderId; 18 import org.onlab.onos.net.provider.ProviderId;
19 +import org.onlab.onos.store.AbstractStore;
18 import org.slf4j.Logger; 20 import org.slf4j.Logger;
19 21
20 import java.util.Collections; 22 import java.util.Collections;
...@@ -35,7 +37,9 @@ import static org.slf4j.LoggerFactory.getLogger; ...@@ -35,7 +37,9 @@ import static org.slf4j.LoggerFactory.getLogger;
35 */ 37 */
36 @Component(immediate = true) 38 @Component(immediate = true)
37 @Service 39 @Service
38 -public class SimpleLinkStore implements LinkStore { 40 +public class SimpleLinkStore
41 + extends AbstractStore<LinkEvent, LinkStoreDelegate>
42 + implements LinkStore {
39 43
40 private final Logger log = getLogger(getClass()); 44 private final Logger log = getLogger(getClass());
41 45
......
...@@ -17,9 +17,11 @@ import org.onlab.onos.cluster.ControllerNode; ...@@ -17,9 +17,11 @@ import org.onlab.onos.cluster.ControllerNode;
17 import org.onlab.onos.cluster.DefaultControllerNode; 17 import org.onlab.onos.cluster.DefaultControllerNode;
18 import org.onlab.onos.cluster.MastershipEvent; 18 import org.onlab.onos.cluster.MastershipEvent;
19 import org.onlab.onos.cluster.MastershipStore; 19 import org.onlab.onos.cluster.MastershipStore;
20 +import org.onlab.onos.cluster.MastershipStoreDelegate;
20 import org.onlab.onos.cluster.NodeId; 21 import org.onlab.onos.cluster.NodeId;
21 import org.onlab.onos.net.DeviceId; 22 import org.onlab.onos.net.DeviceId;
22 import org.onlab.onos.net.MastershipRole; 23 import org.onlab.onos.net.MastershipRole;
24 +import org.onlab.onos.store.AbstractStore;
23 import org.onlab.packet.IpPrefix; 25 import org.onlab.packet.IpPrefix;
24 import org.slf4j.Logger; 26 import org.slf4j.Logger;
25 27
...@@ -31,7 +33,9 @@ import static org.onlab.onos.cluster.MastershipEvent.Type.*; ...@@ -31,7 +33,9 @@ import static org.onlab.onos.cluster.MastershipEvent.Type.*;
31 */ 33 */
32 @Component(immediate = true) 34 @Component(immediate = true)
33 @Service 35 @Service
34 -public class SimpleMastershipStore implements MastershipStore { 36 +public class SimpleMastershipStore
37 + extends AbstractStore<MastershipEvent, MastershipStoreDelegate>
38 + implements MastershipStore {
35 39
36 private final Logger log = getLogger(getClass()); 40 private final Logger log = getLogger(getClass());
37 41
......
...@@ -18,6 +18,8 @@ import org.onlab.onos.net.topology.TopologyCluster; ...@@ -18,6 +18,8 @@ import org.onlab.onos.net.topology.TopologyCluster;
18 import org.onlab.onos.net.topology.TopologyEvent; 18 import org.onlab.onos.net.topology.TopologyEvent;
19 import org.onlab.onos.net.topology.TopologyGraph; 19 import org.onlab.onos.net.topology.TopologyGraph;
20 import org.onlab.onos.net.topology.TopologyStore; 20 import org.onlab.onos.net.topology.TopologyStore;
21 +import org.onlab.onos.net.topology.TopologyStoreDelegate;
22 +import org.onlab.onos.store.AbstractStore;
21 import org.slf4j.Logger; 23 import org.slf4j.Logger;
22 24
23 import java.util.List; 25 import java.util.List;
...@@ -31,7 +33,9 @@ import static org.slf4j.LoggerFactory.getLogger; ...@@ -31,7 +33,9 @@ import static org.slf4j.LoggerFactory.getLogger;
31 */ 33 */
32 @Component(immediate = true) 34 @Component(immediate = true)
33 @Service 35 @Service
34 -public class SimpleTopologyStore implements TopologyStore { 36 +public class SimpleTopologyStore
37 + extends AbstractStore<TopologyEvent, TopologyStoreDelegate>
38 + implements TopologyStore {
35 39
36 private final Logger log = getLogger(getClass()); 40 private final Logger log = getLogger(getClass());
37 41
......
...@@ -97,11 +97,17 @@ ...@@ -97,11 +97,17 @@
97 <feature>onos-thirdparty-web</feature> 97 <feature>onos-thirdparty-web</feature>
98 <bundle>mvn:org.onlab.onos/onos-app-tvue/1.0.0-SNAPSHOT</bundle> 98 <bundle>mvn:org.onlab.onos/onos-app-tvue/1.0.0-SNAPSHOT</bundle>
99 </feature> 99 </feature>
100 - 100 +
101 <feature name="onos-app-fwd" version="1.0.0" 101 <feature name="onos-app-fwd" version="1.0.0"
102 description="ONOS sample forwarding application"> 102 description="ONOS sample forwarding application">
103 <feature>onos-api</feature> 103 <feature>onos-api</feature>
104 <bundle>mvn:org.onlab.onos/onos-app-fwd/1.0.0-SNAPSHOT</bundle> 104 <bundle>mvn:org.onlab.onos/onos-app-fwd/1.0.0-SNAPSHOT</bundle>
105 </feature> 105 </feature>
106 106
107 + <feature name="onos-app-foo" version="1.0.0"
108 + description="ONOS sample playground application">
109 + <feature>onos-api</feature>
110 + <bundle>mvn:org.onlab.onos/onos-app-foo/1.0.0-SNAPSHOT</bundle>
111 + </feature>
112 +
107 </features> 113 </features>
......
...@@ -20,6 +20,7 @@ import org.junit.Test; ...@@ -20,6 +20,7 @@ import org.junit.Test;
20 import org.onlab.onos.net.DefaultDevice; 20 import org.onlab.onos.net.DefaultDevice;
21 import org.onlab.onos.net.Device; 21 import org.onlab.onos.net.Device;
22 import org.onlab.onos.net.DeviceId; 22 import org.onlab.onos.net.DeviceId;
23 +import org.onlab.onos.net.MastershipRole;
23 import org.onlab.onos.net.device.DeviceDescription; 24 import org.onlab.onos.net.device.DeviceDescription;
24 import org.onlab.onos.net.device.DeviceProvider; 25 import org.onlab.onos.net.device.DeviceProvider;
25 import org.onlab.onos.net.device.DeviceProviderRegistry; 26 import org.onlab.onos.net.device.DeviceProviderRegistry;
...@@ -181,6 +182,11 @@ public class OpenFlowDeviceProviderTest { ...@@ -181,6 +182,11 @@ public class OpenFlowDeviceProviderTest {
181 descr = portDescription; 182 descr = portDescription;
182 } 183 }
183 184
185 + @Override
186 + public void unableToAssertRole(DeviceId deviceId, MastershipRole role) {
187 + // FIXME: add fixture core when tests are done on this
188 + }
189 +
184 } 190 }
185 } 191 }
186 192
......
...@@ -51,7 +51,7 @@ perl -pi.old -e "s|^(featuresRepositories=.*)|\1,mvn:org.onlab.onos/onos-feature ...@@ -51,7 +51,7 @@ perl -pi.old -e "s|^(featuresRepositories=.*)|\1,mvn:org.onlab.onos/onos-feature
51 $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg 51 $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg
52 52
53 # Patch the Apache Karaf distribution file to load ONOS features 53 # Patch the Apache Karaf distribution file to load ONOS features
54 -perl -pi.old -e 's|^(featuresBoot=.*)|\1,onos-api,onos-core,onos-cli,onos-rest,onos-gui,onos-openflow,onos-app-fwd|' \ 54 +perl -pi.old -e 's|^(featuresBoot=.*)|\1,webconsole,onos-api,onos-core,onos-cli,onos-rest,onos-gui,onos-openflow,onos-app-fwd,onos-app-foo|' \
55 $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg 55 $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg
56 56
57 # Patch the Apache Karaf distribution with ONOS branding bundle 57 # Patch the Apache Karaf distribution with ONOS branding bundle
......