sangyun-han
Committed by Gerrit Code Review

Add ComponentConfigService for @Modified

- DistributedClusterStore
- DistributedPacketStore
- DistributedFlowStatisticStore
- DistributedStatisticStore

Change-Id: Ibacd569ba509616ea3000ddfd83d501bd0b8b4ff
...@@ -31,6 +31,7 @@ import org.joda.time.DateTime; ...@@ -31,6 +31,7 @@ import org.joda.time.DateTime;
31 import org.onlab.packet.IpAddress; 31 import org.onlab.packet.IpAddress;
32 import org.onlab.util.KryoNamespace; 32 import org.onlab.util.KryoNamespace;
33 import org.onlab.util.Tools; 33 import org.onlab.util.Tools;
34 +import org.onosproject.cfg.ComponentConfigService;
34 import org.onosproject.cluster.ClusterEvent; 35 import org.onosproject.cluster.ClusterEvent;
35 import org.onosproject.cluster.ClusterMetadataService; 36 import org.onosproject.cluster.ClusterMetadataService;
36 import org.onosproject.cluster.ClusterStore; 37 import org.onosproject.cluster.ClusterStore;
...@@ -118,8 +119,15 @@ public class DistributedClusterStore ...@@ -118,8 +119,15 @@ public class DistributedClusterStore
118 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 119 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
119 protected MessagingService messagingService; 120 protected MessagingService messagingService;
120 121
122 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
123 + protected ComponentConfigService cfgService;
124 +
121 @Activate 125 @Activate
122 - public void activate() { 126 + public void activate(ComponentContext context) {
127 + cfgService.registerProperties(getClass());
128 +
129 + modified(context);
130 +
123 localNode = clusterMetadataService.getLocalNode(); 131 localNode = clusterMetadataService.getLocalNode();
124 132
125 messagingService.registerHandler(HEARTBEAT_MESSAGE, 133 messagingService.registerHandler(HEARTBEAT_MESSAGE,
...@@ -135,6 +143,7 @@ public class DistributedClusterStore ...@@ -135,6 +143,7 @@ public class DistributedClusterStore
135 143
136 @Deactivate 144 @Deactivate
137 public void deactivate() { 145 public void deactivate() {
146 + cfgService.unregisterProperties(getClass(), false);
138 messagingService.unregisterHandler(HEARTBEAT_MESSAGE); 147 messagingService.unregisterHandler(HEARTBEAT_MESSAGE);
139 heartBeatSender.shutdownNow(); 148 heartBeatSender.shutdownNow();
140 heartBeatMessageHandler.shutdownNow(); 149 heartBeatMessageHandler.shutdownNow();
......
...@@ -26,6 +26,7 @@ import org.apache.felix.scr.annotations.Property; ...@@ -26,6 +26,7 @@ import org.apache.felix.scr.annotations.Property;
26 import org.apache.felix.scr.annotations.Reference; 26 import org.apache.felix.scr.annotations.Reference;
27 import org.apache.felix.scr.annotations.ReferenceCardinality; 27 import org.apache.felix.scr.annotations.ReferenceCardinality;
28 import org.apache.felix.scr.annotations.Service; 28 import org.apache.felix.scr.annotations.Service;
29 +import org.onosproject.cfg.ComponentConfigService;
29 import org.onosproject.cluster.ClusterService; 30 import org.onosproject.cluster.ClusterService;
30 import org.onosproject.cluster.NodeId; 31 import org.onosproject.cluster.NodeId;
31 import org.onosproject.mastership.MastershipService; 32 import org.onosproject.mastership.MastershipService;
...@@ -88,6 +89,9 @@ public class DistributedPacketStore ...@@ -88,6 +89,9 @@ public class DistributedPacketStore
88 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 89 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
89 protected StorageService storageService; 90 protected StorageService storageService;
90 91
92 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
93 + protected ComponentConfigService cfgService;
94 +
91 private PacketRequestTracker tracker; 95 private PacketRequestTracker tracker;
92 96
93 private static final MessageSubject PACKET_OUT_SUBJECT = 97 private static final MessageSubject PACKET_OUT_SUBJECT =
...@@ -105,7 +109,11 @@ public class DistributedPacketStore ...@@ -105,7 +109,11 @@ public class DistributedPacketStore
105 private static final int MAX_BACKOFF = 50; 109 private static final int MAX_BACKOFF = 50;
106 110
107 @Activate 111 @Activate
108 - public void activate() { 112 + public void activate(ComponentContext context) {
113 + cfgService.registerProperties(getClass());
114 +
115 + modified(context);
116 +
109 messageHandlingExecutor = Executors.newFixedThreadPool( 117 messageHandlingExecutor = Executors.newFixedThreadPool(
110 messageHandlerThreadPoolSize, 118 messageHandlerThreadPoolSize,
111 groupedThreads("onos/store/packet", "message-handlers", log)); 119 groupedThreads("onos/store/packet", "message-handlers", log));
...@@ -122,6 +130,7 @@ public class DistributedPacketStore ...@@ -122,6 +130,7 @@ public class DistributedPacketStore
122 130
123 @Deactivate 131 @Deactivate
124 public void deactivate() { 132 public void deactivate() {
133 + cfgService.unregisterProperties(getClass(), false);
125 communicationService.removeSubscriber(PACKET_OUT_SUBJECT); 134 communicationService.removeSubscriber(PACKET_OUT_SUBJECT);
126 messageHandlingExecutor.shutdown(); 135 messageHandlingExecutor.shutdown();
127 tracker = null; 136 tracker = null;
......
...@@ -27,6 +27,7 @@ import org.apache.felix.scr.annotations.Reference; ...@@ -27,6 +27,7 @@ import org.apache.felix.scr.annotations.Reference;
27 import org.apache.felix.scr.annotations.ReferenceCardinality; 27 import org.apache.felix.scr.annotations.ReferenceCardinality;
28 import org.apache.felix.scr.annotations.Service; 28 import org.apache.felix.scr.annotations.Service;
29 import org.onlab.util.Tools; 29 import org.onlab.util.Tools;
30 +import org.onosproject.cfg.ComponentConfigService;
30 import org.onosproject.cluster.ClusterService; 31 import org.onosproject.cluster.ClusterService;
31 import org.onosproject.cluster.NodeId; 32 import org.onosproject.cluster.NodeId;
32 import org.onosproject.mastership.MastershipService; 33 import org.onosproject.mastership.MastershipService;
...@@ -84,6 +85,9 @@ public class DistributedFlowStatisticStore implements FlowStatisticStore { ...@@ -84,6 +85,9 @@ public class DistributedFlowStatisticStore implements FlowStatisticStore {
84 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 85 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
85 protected ClusterService clusterService; 86 protected ClusterService clusterService;
86 87
88 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
89 + protected ComponentConfigService cfgService;
90 +
87 private Map<ConnectPoint, Set<FlowEntry>> previous = 91 private Map<ConnectPoint, Set<FlowEntry>> previous =
88 new ConcurrentHashMap<>(); 92 new ConcurrentHashMap<>();
89 93
...@@ -107,7 +111,11 @@ public class DistributedFlowStatisticStore implements FlowStatisticStore { ...@@ -107,7 +111,11 @@ public class DistributedFlowStatisticStore implements FlowStatisticStore {
107 private static final long STATISTIC_STORE_TIMEOUT_MILLIS = 3000; 111 private static final long STATISTIC_STORE_TIMEOUT_MILLIS = 3000;
108 112
109 @Activate 113 @Activate
110 - public void activate() { 114 + public void activate(ComponentContext context) {
115 + cfgService.registerProperties(getClass());
116 +
117 + modified(context);
118 +
111 local = clusterService.getLocalNode().id(); 119 local = clusterService.getLocalNode().id();
112 120
113 messageHandlingExecutor = Executors.newFixedThreadPool( 121 messageHandlingExecutor = Executors.newFixedThreadPool(
...@@ -127,6 +135,7 @@ public class DistributedFlowStatisticStore implements FlowStatisticStore { ...@@ -127,6 +135,7 @@ public class DistributedFlowStatisticStore implements FlowStatisticStore {
127 135
128 @Deactivate 136 @Deactivate
129 public void deactivate() { 137 public void deactivate() {
138 + cfgService.unregisterProperties(getClass(), false);
130 clusterCommunicator.removeSubscriber(GET_PREVIOUS); 139 clusterCommunicator.removeSubscriber(GET_PREVIOUS);
131 clusterCommunicator.removeSubscriber(GET_CURRENT); 140 clusterCommunicator.removeSubscriber(GET_CURRENT);
132 messageHandlingExecutor.shutdown(); 141 messageHandlingExecutor.shutdown();
......
...@@ -26,6 +26,7 @@ import org.apache.felix.scr.annotations.Reference; ...@@ -26,6 +26,7 @@ import org.apache.felix.scr.annotations.Reference;
26 import org.apache.felix.scr.annotations.ReferenceCardinality; 26 import org.apache.felix.scr.annotations.ReferenceCardinality;
27 import org.apache.felix.scr.annotations.Service; 27 import org.apache.felix.scr.annotations.Service;
28 import org.onlab.util.Tools; 28 import org.onlab.util.Tools;
29 +import org.onosproject.cfg.ComponentConfigService;
29 import org.onosproject.cluster.ClusterService; 30 import org.onosproject.cluster.ClusterService;
30 import org.onosproject.cluster.NodeId; 31 import org.onosproject.cluster.NodeId;
31 import org.onosproject.mastership.MastershipService; 32 import org.onosproject.mastership.MastershipService;
...@@ -85,6 +86,9 @@ public class DistributedStatisticStore implements StatisticStore { ...@@ -85,6 +86,9 @@ public class DistributedStatisticStore implements StatisticStore {
85 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 86 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
86 protected ClusterService clusterService; 87 protected ClusterService clusterService;
87 88
89 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
90 + protected ComponentConfigService cfgService;
91 +
88 public static final MessageSubject GET_CURRENT = new MessageSubject("peer-return-current"); 92 public static final MessageSubject GET_CURRENT = new MessageSubject("peer-return-current");
89 public static final MessageSubject GET_PREVIOUS = new MessageSubject("peer-return-previous"); 93 public static final MessageSubject GET_PREVIOUS = new MessageSubject("peer-return-previous");
90 94
...@@ -109,7 +113,10 @@ public class DistributedStatisticStore implements StatisticStore { ...@@ -109,7 +113,10 @@ public class DistributedStatisticStore implements StatisticStore {
109 private static final long STATISTIC_STORE_TIMEOUT_MILLIS = 3000; 113 private static final long STATISTIC_STORE_TIMEOUT_MILLIS = 3000;
110 114
111 @Activate 115 @Activate
112 - public void activate() { 116 + public void activate(ComponentContext context) {
117 + cfgService.registerProperties(getClass());
118 +
119 + modified(context);
113 120
114 messageHandlingExecutor = Executors.newFixedThreadPool( 121 messageHandlingExecutor = Executors.newFixedThreadPool(
115 messageHandlerThreadPoolSize, 122 messageHandlerThreadPoolSize,
...@@ -132,6 +139,7 @@ public class DistributedStatisticStore implements StatisticStore { ...@@ -132,6 +139,7 @@ public class DistributedStatisticStore implements StatisticStore {
132 139
133 @Deactivate 140 @Deactivate
134 public void deactivate() { 141 public void deactivate() {
142 + cfgService.unregisterProperties(getClass(), false);
135 clusterCommunicator.removeSubscriber(GET_PREVIOUS); 143 clusterCommunicator.removeSubscriber(GET_PREVIOUS);
136 clusterCommunicator.removeSubscriber(GET_CURRENT); 144 clusterCommunicator.removeSubscriber(GET_CURRENT);
137 messageHandlingExecutor.shutdown(); 145 messageHandlingExecutor.shutdown();
......
...@@ -29,7 +29,7 @@ public class DistributedClusterStoreTest { ...@@ -29,7 +29,7 @@ public class DistributedClusterStoreTest {
29 @Before 29 @Before
30 public void setUp() throws Exception { 30 public void setUp() throws Exception {
31 distributedClusterStore = new DistributedClusterStore(); 31 distributedClusterStore = new DistributedClusterStore();
32 - distributedClusterStore.activate(); 32 + distributedClusterStore.activate(null);
33 } 33 }
34 34
35 @After 35 @After
......