Madan Jampani | afeebbd | 2015-05-19 15:26:01 -0700 | [diff] [blame^] | 1 | package org.onosproject.store.cluster.messaging.impl; |
| 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.apache.felix.scr.annotations.Service; |
| 9 | import org.onlab.netty.NettyMessaging; |
| 10 | import org.onosproject.cluster.ClusterDefinitionService; |
| 11 | import org.onosproject.cluster.ControllerNode; |
| 12 | import org.onosproject.store.cluster.messaging.Endpoint; |
| 13 | import org.slf4j.Logger; |
| 14 | import org.slf4j.LoggerFactory; |
| 15 | |
| 16 | /** |
| 17 | * Netty based MessagingService. |
| 18 | */ |
| 19 | @Component(immediate = true, enabled = true) |
| 20 | @Service |
| 21 | public class NettyMessagingManager extends NettyMessaging { |
| 22 | |
| 23 | private final Logger log = LoggerFactory.getLogger(getClass()); |
| 24 | |
| 25 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 26 | protected ClusterDefinitionService clusterDefinitionService; |
| 27 | |
| 28 | @Activate |
| 29 | public void activate() throws Exception { |
| 30 | ControllerNode localNode = clusterDefinitionService.localNode(); |
| 31 | super.start(new Endpoint(localNode.ip(), localNode.tcpPort())); |
| 32 | log.info("Started"); |
| 33 | } |
| 34 | |
| 35 | @Deactivate |
| 36 | public void deactivate() throws Exception { |
| 37 | super.stop(); |
| 38 | log.info("Stopped"); |
| 39 | } |
| 40 | } |