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;
import org.onlab.packet.IpAddress;
import org.onlab.util.KryoNamespace;
import org.onlab.util.Tools;
import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.cluster.ClusterEvent;
import org.onosproject.cluster.ClusterMetadataService;
import org.onosproject.cluster.ClusterStore;
......@@ -118,8 +119,15 @@ public class DistributedClusterStore
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected MessagingService messagingService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected ComponentConfigService cfgService;
@Activate
public void activate() {
public void activate(ComponentContext context) {
cfgService.registerProperties(getClass());
modified(context);
localNode = clusterMetadataService.getLocalNode();
messagingService.registerHandler(HEARTBEAT_MESSAGE,
......@@ -135,6 +143,7 @@ public class DistributedClusterStore
@Deactivate
public void deactivate() {
cfgService.unregisterProperties(getClass(), false);
messagingService.unregisterHandler(HEARTBEAT_MESSAGE);
heartBeatSender.shutdownNow();
heartBeatMessageHandler.shutdownNow();
......
......@@ -26,6 +26,7 @@ import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.cluster.ClusterService;
import org.onosproject.cluster.NodeId;
import org.onosproject.mastership.MastershipService;
......@@ -88,6 +89,9 @@ public class DistributedPacketStore
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected StorageService storageService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected ComponentConfigService cfgService;
private PacketRequestTracker tracker;
private static final MessageSubject PACKET_OUT_SUBJECT =
......@@ -105,7 +109,11 @@ public class DistributedPacketStore
private static final int MAX_BACKOFF = 50;
@Activate
public void activate() {
public void activate(ComponentContext context) {
cfgService.registerProperties(getClass());
modified(context);
messageHandlingExecutor = Executors.newFixedThreadPool(
messageHandlerThreadPoolSize,
groupedThreads("onos/store/packet", "message-handlers", log));
......@@ -122,6 +130,7 @@ public class DistributedPacketStore
@Deactivate
public void deactivate() {
cfgService.unregisterProperties(getClass(), false);
communicationService.removeSubscriber(PACKET_OUT_SUBJECT);
messageHandlingExecutor.shutdown();
tracker = null;
......
......@@ -27,6 +27,7 @@ import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onlab.util.Tools;
import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.cluster.ClusterService;
import org.onosproject.cluster.NodeId;
import org.onosproject.mastership.MastershipService;
......@@ -84,6 +85,9 @@ public class DistributedFlowStatisticStore implements FlowStatisticStore {
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected ClusterService clusterService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected ComponentConfigService cfgService;
private Map<ConnectPoint, Set<FlowEntry>> previous =
new ConcurrentHashMap<>();
......@@ -107,7 +111,11 @@ public class DistributedFlowStatisticStore implements FlowStatisticStore {
private static final long STATISTIC_STORE_TIMEOUT_MILLIS = 3000;
@Activate
public void activate() {
public void activate(ComponentContext context) {
cfgService.registerProperties(getClass());
modified(context);
local = clusterService.getLocalNode().id();
messageHandlingExecutor = Executors.newFixedThreadPool(
......@@ -127,6 +135,7 @@ public class DistributedFlowStatisticStore implements FlowStatisticStore {
@Deactivate
public void deactivate() {
cfgService.unregisterProperties(getClass(), false);
clusterCommunicator.removeSubscriber(GET_PREVIOUS);
clusterCommunicator.removeSubscriber(GET_CURRENT);
messageHandlingExecutor.shutdown();
......
......@@ -26,6 +26,7 @@ import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onlab.util.Tools;
import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.cluster.ClusterService;
import org.onosproject.cluster.NodeId;
import org.onosproject.mastership.MastershipService;
......@@ -85,6 +86,9 @@ public class DistributedStatisticStore implements StatisticStore {
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected ClusterService clusterService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected ComponentConfigService cfgService;
public static final MessageSubject GET_CURRENT = new MessageSubject("peer-return-current");
public static final MessageSubject GET_PREVIOUS = new MessageSubject("peer-return-previous");
......@@ -109,7 +113,10 @@ public class DistributedStatisticStore implements StatisticStore {
private static final long STATISTIC_STORE_TIMEOUT_MILLIS = 3000;
@Activate
public void activate() {
public void activate(ComponentContext context) {
cfgService.registerProperties(getClass());
modified(context);
messageHandlingExecutor = Executors.newFixedThreadPool(
messageHandlerThreadPoolSize,
......@@ -132,6 +139,7 @@ public class DistributedStatisticStore implements StatisticStore {
@Deactivate
public void deactivate() {
cfgService.unregisterProperties(getClass(), false);
clusterCommunicator.removeSubscriber(GET_PREVIOUS);
clusterCommunicator.removeSubscriber(GET_CURRENT);
messageHandlingExecutor.shutdown();
......
......@@ -29,7 +29,7 @@ public class DistributedClusterStoreTest {
@Before
public void setUp() throws Exception {
distributedClusterStore = new DistributedClusterStore();
distributedClusterStore.activate();
distributedClusterStore.activate(null);
}
@After
......