Using ClusterService in ClusterCommunicationManager (NPE fix)
Showing
2 changed files
with
9 additions
and
1 deletions
... | @@ -8,7 +8,7 @@ import org.slf4j.LoggerFactory; | ... | @@ -8,7 +8,7 @@ import org.slf4j.LoggerFactory; |
8 | /** | 8 | /** |
9 | * Test to measure Messaging performance. | 9 | * Test to measure Messaging performance. |
10 | */ | 10 | */ |
11 | - public class SimpleNettyServer { | 11 | + public final class SimpleNettyServer { |
12 | private static Logger log = LoggerFactory.getLogger(IOLoopTestServer.class); | 12 | private static Logger log = LoggerFactory.getLogger(IOLoopTestServer.class); |
13 | 13 | ||
14 | private SimpleNettyServer() {} | 14 | private SimpleNettyServer() {} | ... | ... |
... | @@ -12,7 +12,10 @@ import java.util.TimerTask; | ... | @@ -12,7 +12,10 @@ import java.util.TimerTask; |
12 | import org.apache.felix.scr.annotations.Activate; | 12 | import org.apache.felix.scr.annotations.Activate; |
13 | import org.apache.felix.scr.annotations.Component; | 13 | import org.apache.felix.scr.annotations.Component; |
14 | import org.apache.felix.scr.annotations.Deactivate; | 14 | import org.apache.felix.scr.annotations.Deactivate; |
15 | +import org.apache.felix.scr.annotations.Reference; | ||
16 | +import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
15 | import org.apache.felix.scr.annotations.Service; | 17 | import org.apache.felix.scr.annotations.Service; |
18 | +import org.onlab.onos.cluster.ClusterService; | ||
16 | import org.onlab.onos.cluster.ControllerNode; | 19 | import org.onlab.onos.cluster.ControllerNode; |
17 | import org.onlab.onos.cluster.NodeId; | 20 | import org.onlab.onos.cluster.NodeId; |
18 | import org.onlab.onos.store.cluster.impl.ClusterMembershipEvent; | 21 | import org.onlab.onos.store.cluster.impl.ClusterMembershipEvent; |
... | @@ -42,6 +45,10 @@ public class ClusterCommunicationManager | ... | @@ -42,6 +45,10 @@ public class ClusterCommunicationManager |
42 | private final Logger log = LoggerFactory.getLogger(getClass()); | 45 | private final Logger log = LoggerFactory.getLogger(getClass()); |
43 | 46 | ||
44 | private ControllerNode localNode; | 47 | private ControllerNode localNode; |
48 | + | ||
49 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
50 | + private ClusterService clusterService; | ||
51 | + | ||
45 | private ClusterNodesDelegate nodesDelegate; | 52 | private ClusterNodesDelegate nodesDelegate; |
46 | // FIXME: `members` should go away and should be using ClusterService | 53 | // FIXME: `members` should go away and should be using ClusterService |
47 | private Map<NodeId, ControllerNode> members = new HashMap<>(); | 54 | private Map<NodeId, ControllerNode> members = new HashMap<>(); |
... | @@ -65,6 +72,7 @@ public class ClusterCommunicationManager | ... | @@ -65,6 +72,7 @@ public class ClusterCommunicationManager |
65 | 72 | ||
66 | @Activate | 73 | @Activate |
67 | public void activate() { | 74 | public void activate() { |
75 | + localNode = clusterService.getLocalNode(); | ||
68 | messagingService = new NettyMessagingService(localNode.tcpPort()); | 76 | messagingService = new NettyMessagingService(localNode.tcpPort()); |
69 | log.info("Started"); | 77 | log.info("Started"); |
70 | } | 78 | } | ... | ... |
-
Please register or login to post a comment