blob: 4236c8c1603528aa21e52b1c9585de8377077a82 [file] [log] [blame]
Thomas Vachuska58de4162015-09-10 16:15:33 -07001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Madan Jampaniafeebbd2015-05-19 15:26:01 -070016package org.onosproject.store.cluster.messaging.impl;
17
18import org.apache.felix.scr.annotations.Activate;
Madan Jampaniafeebbd2015-05-19 15:26:01 -070019import org.apache.felix.scr.annotations.Deactivate;
20import org.apache.felix.scr.annotations.Reference;
21import org.apache.felix.scr.annotations.ReferenceCardinality;
22import org.apache.felix.scr.annotations.Service;
23import org.onlab.nio.service.IOLoopMessaging;
Madan Jampaniec1df022015-10-13 21:23:03 -070024import org.onosproject.cluster.ClusterMetadataService;
Madan Jampaniafeebbd2015-05-19 15:26:01 -070025import org.onosproject.cluster.ControllerNode;
26import org.onosproject.store.cluster.messaging.Endpoint;
27import org.slf4j.Logger;
28import org.slf4j.LoggerFactory;
29
30/**
31 * IOLoop based MessagingService.
32 */
Jian Li11599162016-01-15 15:46:16 -080033//@Component(immediate = true, enabled = false)
Madan Jampaniafeebbd2015-05-19 15:26:01 -070034@Service
35public class IOLoopMessagingManager extends IOLoopMessaging {
36
37 private final Logger log = LoggerFactory.getLogger(getClass());
38
39 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Madan Jampaniec1df022015-10-13 21:23:03 -070040 protected ClusterMetadataService clusterMetadataService;
Madan Jampaniafeebbd2015-05-19 15:26:01 -070041
42 @Activate
43 public void activate() throws Exception {
Madan Jampaniec1df022015-10-13 21:23:03 -070044 ControllerNode localNode = clusterMetadataService.getLocalNode();
Madan Jampaniafeebbd2015-05-19 15:26:01 -070045 super.start(new Endpoint(localNode.ip(), localNode.tcpPort()));
46 log.info("Started");
47 }
48
49 @Deactivate
50 public void deactivate() throws Exception {
51 super.stop();
52 log.info("Stopped");
53 }
54}