1 package org.onosproject.store.cluster.messaging.impl;
3 import com.google.common.base.Strings;
4 import org.apache.felix.scr.annotations.Activate;
5 import org.apache.felix.scr.annotations.Component;
6 import org.apache.felix.scr.annotations.Deactivate;
7 import org.apache.felix.scr.annotations.Reference;
8 import org.apache.felix.scr.annotations.ReferenceCardinality;
9 import org.apache.felix.scr.annotations.Service;
10 import org.onlab.netty.NettyMessaging;
11 import org.onosproject.cluster.ClusterDefinitionService;
12 import org.onosproject.cluster.ControllerNode;
13 import org.onosproject.store.cluster.messaging.Endpoint;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
18 * Netty based MessagingService.
20 @Component(immediate = true, enabled = true)
22 public class NettyMessagingManager extends NettyMessaging {
24 private final Logger log = LoggerFactory.getLogger(getClass());
26 private static final short MIN_KS_LENGTH = 6;
28 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
29 protected ClusterDefinitionService clusterDefinitionService;
32 public void activate() throws Exception {
33 ControllerNode localNode = clusterDefinitionService.localNode();
35 super.start(new Endpoint(localNode.ip(), localNode.tcpPort()));
40 public void deactivate() throws Exception {
45 private void getTLSParameters() {
46 String tempString = System.getProperty("enableNettyTLS");
47 enableNettyTLS = Strings.isNullOrEmpty(tempString) ? TLS_DISABLED : Boolean.parseBoolean(tempString);
48 log.info("enableNettyTLS = {}", enableNettyTLS);
50 ksLocation = System.getProperty("javax.net.ssl.keyStore");
51 if (Strings.isNullOrEmpty(ksLocation)) {
52 enableNettyTLS = TLS_DISABLED;
55 tsLocation = System.getProperty("javax.net.ssl.trustStore");
56 if (Strings.isNullOrEmpty(tsLocation)) {
57 enableNettyTLS = TLS_DISABLED;
60 ksPwd = System.getProperty("javax.net.ssl.keyStorePassword").toCharArray();
61 if (MIN_KS_LENGTH > ksPwd.length) {
62 enableNettyTLS = TLS_DISABLED;
65 tsPwd = System.getProperty("javax.net.ssl.trustStorePassword").toCharArray();
66 if (MIN_KS_LENGTH > tsPwd.length) {
67 enableNettyTLS = TLS_DISABLED;