blob: ddb45f71435e0c0d7f641cdec62264209642a105 [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;
19import org.apache.felix.scr.annotations.Component;
20import org.apache.felix.scr.annotations.Deactivate;
21import org.apache.felix.scr.annotations.Reference;
22import org.apache.felix.scr.annotations.ReferenceCardinality;
23import org.apache.felix.scr.annotations.Service;
24import org.onlab.nio.service.IOLoopMessaging;
Madan Jampaniec1df022015-10-13 21:23:03 -070025import org.onosproject.cluster.ClusterMetadataService;
Madan Jampaniafeebbd2015-05-19 15:26:01 -070026import org.onosproject.cluster.ControllerNode;
27import org.onosproject.store.cluster.messaging.Endpoint;
28import org.slf4j.Logger;
29import org.slf4j.LoggerFactory;
30
31/**
32 * IOLoop based MessagingService.
33 */
34@Component(immediate = true, enabled = false)
35@Service
36public class IOLoopMessagingManager extends IOLoopMessaging {
37
38 private final Logger log = LoggerFactory.getLogger(getClass());
39
40 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Madan Jampaniec1df022015-10-13 21:23:03 -070041 protected ClusterMetadataService clusterMetadataService;
Madan Jampaniafeebbd2015-05-19 15:26:01 -070042
43 @Activate
44 public void activate() throws Exception {
Madan Jampaniec1df022015-10-13 21:23:03 -070045 ControllerNode localNode = clusterMetadataService.getLocalNode();
Madan Jampaniafeebbd2015-05-19 15:26:01 -070046 super.start(new Endpoint(localNode.ip(), localNode.tcpPort()));
47 log.info("Started");
48 }
49
50 @Deactivate
51 public void deactivate() throws Exception {
52 super.stop();
53 log.info("Stopped");
54 }
55}