Jonathan Hart

Remove "throws IOException" from ClusterCommunicationService APIs

that never throw IOExceptions. These APIs already return boolean to indicate
if sending failed.

Change-Id: I339949fe59f3b8b18a117aabc8d67402dc66c2a3
...@@ -15,12 +15,11 @@ ...@@ -15,12 +15,11 @@
15 */ 15 */
16 package org.onosproject.store.cluster.messaging; 16 package org.onosproject.store.cluster.messaging;
17 17
18 -import java.io.IOException; 18 +import com.google.common.util.concurrent.ListenableFuture;
19 -import java.util.Set;
20 -
21 import org.onosproject.cluster.NodeId; 19 import org.onosproject.cluster.NodeId;
22 20
23 -import com.google.common.util.concurrent.ListenableFuture; 21 +import java.io.IOException;
22 +import java.util.Set;
24 23
25 // TODO: remove IOExceptions? 24 // TODO: remove IOExceptions?
26 /** 25 /**
...@@ -33,18 +32,16 @@ public interface ClusterCommunicationService { ...@@ -33,18 +32,16 @@ public interface ClusterCommunicationService {
33 * 32 *
34 * @param message message to send 33 * @param message message to send
35 * @return true if the message was sent successfully to all nodes; false otherwise. 34 * @return true if the message was sent successfully to all nodes; false otherwise.
36 - * @throws IOException when I/O exception of some sort has occurred
37 */ 35 */
38 - boolean broadcast(ClusterMessage message) throws IOException; 36 + boolean broadcast(ClusterMessage message);
39 37
40 /** 38 /**
41 * Broadcast a message to all controller nodes including self. 39 * Broadcast a message to all controller nodes including self.
42 * 40 *
43 * @param message message to send 41 * @param message message to send
44 * @return true if the message was sent successfully to all nodes; false otherwise. 42 * @return true if the message was sent successfully to all nodes; false otherwise.
45 - * @throws IOException when I/O exception of some sort has occurred
46 */ 43 */
47 - boolean broadcastIncludeSelf(ClusterMessage message) throws IOException; 44 + boolean broadcastIncludeSelf(ClusterMessage message);
48 45
49 /** 46 /**
50 * Sends a message to the specified controller node. 47 * Sends a message to the specified controller node.
...@@ -62,9 +59,8 @@ public interface ClusterCommunicationService { ...@@ -62,9 +59,8 @@ public interface ClusterCommunicationService {
62 * @param message message to send 59 * @param message message to send
63 * @param nodeIds recipient node identifiers 60 * @param nodeIds recipient node identifiers
64 * @return true if the message was sent successfully to all nodes in the group; false otherwise. 61 * @return true if the message was sent successfully to all nodes in the group; false otherwise.
65 - * @throws IOException when I/O exception of some sort has occurred
66 */ 62 */
67 - boolean multicast(ClusterMessage message, Set<NodeId> nodeIds) throws IOException; 63 + boolean multicast(ClusterMessage message, Set<NodeId> nodeIds);
68 64
69 /** 65 /**
70 * Sends a message synchronously. 66 * Sends a message synchronously.
......
...@@ -15,23 +15,16 @@ ...@@ -15,23 +15,16 @@
15 */ 15 */
16 package org.onosproject.store.cluster.impl; 16 package org.onosproject.store.cluster.impl;
17 17
18 -import static com.google.common.base.Preconditions.checkArgument; 18 +import com.google.common.collect.ImmutableMap;
19 -import static org.onlab.util.Tools.namedThreads; 19 +import com.google.common.collect.Maps;
20 -import static org.slf4j.LoggerFactory.getLogger; 20 +import com.google.common.collect.Sets;
21 -
22 -import java.io.IOException;
23 -import java.util.Map;
24 -import java.util.Set;
25 -import java.util.concurrent.Executors;
26 -import java.util.concurrent.ScheduledExecutorService;
27 -import java.util.concurrent.TimeUnit;
28 -
29 import org.apache.felix.scr.annotations.Activate; 21 import org.apache.felix.scr.annotations.Activate;
30 import org.apache.felix.scr.annotations.Component; 22 import org.apache.felix.scr.annotations.Component;
31 import org.apache.felix.scr.annotations.Deactivate; 23 import org.apache.felix.scr.annotations.Deactivate;
32 import org.apache.felix.scr.annotations.Reference; 24 import org.apache.felix.scr.annotations.Reference;
33 import org.apache.felix.scr.annotations.ReferenceCardinality; 25 import org.apache.felix.scr.annotations.ReferenceCardinality;
34 import org.apache.felix.scr.annotations.Service; 26 import org.apache.felix.scr.annotations.Service;
27 +import org.onlab.util.KryoNamespace;
35 import org.onosproject.cluster.ClusterService; 28 import org.onosproject.cluster.ClusterService;
36 import org.onosproject.cluster.Leadership; 29 import org.onosproject.cluster.Leadership;
37 import org.onosproject.cluster.LeadershipEvent; 30 import org.onosproject.cluster.LeadershipEvent;
...@@ -47,12 +40,17 @@ import org.onosproject.store.serializers.KryoSerializer; ...@@ -47,12 +40,17 @@ import org.onosproject.store.serializers.KryoSerializer;
47 import org.onosproject.store.service.Lock; 40 import org.onosproject.store.service.Lock;
48 import org.onosproject.store.service.LockService; 41 import org.onosproject.store.service.LockService;
49 import org.onosproject.store.service.impl.DistributedLockManager; 42 import org.onosproject.store.service.impl.DistributedLockManager;
50 -import org.onlab.util.KryoNamespace;
51 import org.slf4j.Logger; 43 import org.slf4j.Logger;
52 44
53 -import com.google.common.collect.ImmutableMap; 45 +import java.util.Map;
54 -import com.google.common.collect.Maps; 46 +import java.util.Set;
55 -import com.google.common.collect.Sets; 47 +import java.util.concurrent.Executors;
48 +import java.util.concurrent.ScheduledExecutorService;
49 +import java.util.concurrent.TimeUnit;
50 +
51 +import static com.google.common.base.Preconditions.checkArgument;
52 +import static org.onlab.util.Tools.namedThreads;
53 +import static org.slf4j.LoggerFactory.getLogger;
56 54
57 /** 55 /**
58 * Distributed implementation of LeadershipService that is based on the primitives exposed by 56 * Distributed implementation of LeadershipService that is based on the primitives exposed by
...@@ -286,15 +284,11 @@ public class LeadershipManager implements LeadershipService { ...@@ -286,15 +284,11 @@ public class LeadershipManager implements LeadershipService {
286 public void event(LeadershipEvent event) { 284 public void event(LeadershipEvent event) {
287 // publish events originating on this host. 285 // publish events originating on this host.
288 if (event.subject().leader().equals(localNodeId)) { 286 if (event.subject().leader().equals(localNodeId)) {
289 - try { 287 + clusterCommunicator.broadcast(
290 - clusterCommunicator.broadcast( 288 + new ClusterMessage(
291 - new ClusterMessage( 289 + localNodeId,
292 - localNodeId, 290 + LEADERSHIP_UPDATES,
293 - LEADERSHIP_UPDATES, 291 + SERIALIZER.encode(event)));
294 - SERIALIZER.encode(event)));
295 - } catch (IOException e) {
296 - log.error("Failed to broadcast leadership update message", e);
297 - }
298 } 292 }
299 } 293 }
300 } 294 }
......
...@@ -15,11 +15,7 @@ ...@@ -15,11 +15,7 @@
15 */ 15 */
16 package org.onosproject.store.cluster.messaging.impl; 16 package org.onosproject.store.cluster.messaging.impl;
17 17
18 -import static com.google.common.base.Preconditions.checkArgument; 18 +import com.google.common.util.concurrent.ListenableFuture;
19 -
20 -import java.io.IOException;
21 -import java.util.Set;
22 -
23 import org.apache.felix.scr.annotations.Activate; 19 import org.apache.felix.scr.annotations.Activate;
24 import org.apache.felix.scr.annotations.Component; 20 import org.apache.felix.scr.annotations.Component;
25 import org.apache.felix.scr.annotations.Deactivate; 21 import org.apache.felix.scr.annotations.Deactivate;
...@@ -31,6 +27,7 @@ import org.onlab.netty.Message; ...@@ -31,6 +27,7 @@ import org.onlab.netty.Message;
31 import org.onlab.netty.MessageHandler; 27 import org.onlab.netty.MessageHandler;
32 import org.onlab.netty.MessagingService; 28 import org.onlab.netty.MessagingService;
33 import org.onlab.netty.NettyMessagingService; 29 import org.onlab.netty.NettyMessagingService;
30 +import org.onlab.util.KryoNamespace;
34 import org.onosproject.cluster.ClusterService; 31 import org.onosproject.cluster.ClusterService;
35 import org.onosproject.cluster.ControllerNode; 32 import org.onosproject.cluster.ControllerNode;
36 import org.onosproject.cluster.NodeId; 33 import org.onosproject.cluster.NodeId;
...@@ -42,11 +39,13 @@ import org.onosproject.store.serializers.KryoNamespaces; ...@@ -42,11 +39,13 @@ import org.onosproject.store.serializers.KryoNamespaces;
42 import org.onosproject.store.serializers.KryoSerializer; 39 import org.onosproject.store.serializers.KryoSerializer;
43 import org.onosproject.store.serializers.impl.ClusterMessageSerializer; 40 import org.onosproject.store.serializers.impl.ClusterMessageSerializer;
44 import org.onosproject.store.serializers.impl.MessageSubjectSerializer; 41 import org.onosproject.store.serializers.impl.MessageSubjectSerializer;
45 -import org.onlab.util.KryoNamespace;
46 import org.slf4j.Logger; 42 import org.slf4j.Logger;
47 import org.slf4j.LoggerFactory; 43 import org.slf4j.LoggerFactory;
48 44
49 -import com.google.common.util.concurrent.ListenableFuture; 45 +import java.io.IOException;
46 +import java.util.Set;
47 +
48 +import static com.google.common.base.Preconditions.checkArgument;
50 49
51 @Component(immediate = true) 50 @Component(immediate = true)
52 @Service 51 @Service
...@@ -101,7 +100,7 @@ public class ClusterCommunicationManager ...@@ -101,7 +100,7 @@ public class ClusterCommunicationManager
101 } 100 }
102 101
103 @Override 102 @Override
104 - public boolean broadcast(ClusterMessage message) throws IOException { 103 + public boolean broadcast(ClusterMessage message) {
105 boolean ok = true; 104 boolean ok = true;
106 final ControllerNode localNode = clusterService.getLocalNode(); 105 final ControllerNode localNode = clusterService.getLocalNode();
107 for (ControllerNode node : clusterService.getNodes()) { 106 for (ControllerNode node : clusterService.getNodes()) {
...@@ -113,7 +112,7 @@ public class ClusterCommunicationManager ...@@ -113,7 +112,7 @@ public class ClusterCommunicationManager
113 } 112 }
114 113
115 @Override 114 @Override
116 - public boolean broadcastIncludeSelf(ClusterMessage message) throws IOException { 115 + public boolean broadcastIncludeSelf(ClusterMessage message) {
117 boolean ok = true; 116 boolean ok = true;
118 for (ControllerNode node : clusterService.getNodes()) { 117 for (ControllerNode node : clusterService.getNodes()) {
119 ok = unicastUnchecked(message, node.id()) && ok; 118 ok = unicastUnchecked(message, node.id()) && ok;
...@@ -122,7 +121,7 @@ public class ClusterCommunicationManager ...@@ -122,7 +121,7 @@ public class ClusterCommunicationManager
122 } 121 }
123 122
124 @Override 123 @Override
125 - public boolean multicast(ClusterMessage message, Set<NodeId> nodes) throws IOException { 124 + public boolean multicast(ClusterMessage message, Set<NodeId> nodes) {
126 boolean ok = true; 125 boolean ok = true;
127 final ControllerNode localNode = clusterService.getLocalNode(); 126 final ControllerNode localNode = clusterService.getLocalNode();
128 for (NodeId nodeId : nodes) { 127 for (NodeId nodeId : nodes) {
...@@ -148,7 +147,7 @@ public class ClusterCommunicationManager ...@@ -148,7 +147,7 @@ public class ClusterCommunicationManager
148 } 147 }
149 } 148 }
150 149
151 - private boolean unicastUnchecked(ClusterMessage message, NodeId toNodeId) throws IOException { 150 + private boolean unicastUnchecked(ClusterMessage message, NodeId toNodeId) {
152 try { 151 try {
153 return unicast(message, toNodeId); 152 return unicast(message, toNodeId);
154 } catch (IOException e) { 153 } catch (IOException e) {
......
...@@ -263,12 +263,7 @@ public class GossipDeviceStore ...@@ -263,12 +263,7 @@ public class GossipDeviceStore
263 if (event != null) { 263 if (event != null) {
264 log.info("Notifying peers of a device update topology event for providerId: {} and deviceId: {}", 264 log.info("Notifying peers of a device update topology event for providerId: {} and deviceId: {}",
265 providerId, deviceId); 265 providerId, deviceId);
266 - try { 266 + notifyPeers(new InternalDeviceEvent(providerId, deviceId, mergedDesc));
267 - notifyPeers(new InternalDeviceEvent(providerId, deviceId, mergedDesc));
268 - } catch (IOException e) {
269 - log.error("Failed to notify peers of a device update topology event for providerId: "
270 - + providerId + " and deviceId: " + deviceId, e);
271 - }
272 } 267 }
273 return event; 268 return event;
274 } 269 }
...@@ -376,12 +371,7 @@ public class GossipDeviceStore ...@@ -376,12 +371,7 @@ public class GossipDeviceStore
376 if (event != null) { 371 if (event != null) {
377 log.info("Notifying peers of a device offline topology event for deviceId: {} {}", 372 log.info("Notifying peers of a device offline topology event for deviceId: {} {}",
378 deviceId, timestamp); 373 deviceId, timestamp);
379 - try { 374 + notifyPeers(new InternalDeviceOfflineEvent(deviceId, timestamp));
380 - notifyPeers(new InternalDeviceOfflineEvent(deviceId, timestamp));
381 - } catch (IOException e) {
382 - log.error("Failed to notify peers of a device offline topology event for deviceId: {}",
383 - deviceId);
384 - }
385 } 375 }
386 return event; 376 return event;
387 } 377 }
...@@ -487,12 +477,7 @@ public class GossipDeviceStore ...@@ -487,12 +477,7 @@ public class GossipDeviceStore
487 if (!events.isEmpty()) { 477 if (!events.isEmpty()) {
488 log.info("Notifying peers of a ports update topology event for providerId: {} and deviceId: {}", 478 log.info("Notifying peers of a ports update topology event for providerId: {} and deviceId: {}",
489 providerId, deviceId); 479 providerId, deviceId);
490 - try { 480 + notifyPeers(new InternalPortEvent(providerId, deviceId, merged));
491 - notifyPeers(new InternalPortEvent(providerId, deviceId, merged));
492 - } catch (IOException e) {
493 - log.error("Failed to notify peers of a port update topology event or providerId: "
494 - + providerId + " and deviceId: " + deviceId, e);
495 - }
496 } 481 }
497 return events; 482 return events;
498 } 483 }
...@@ -667,12 +652,7 @@ public class GossipDeviceStore ...@@ -667,12 +652,7 @@ public class GossipDeviceStore
667 if (event != null) { 652 if (event != null) {
668 log.info("Notifying peers of a port status update topology event for providerId: {} and deviceId: {}", 653 log.info("Notifying peers of a port status update topology event for providerId: {} and deviceId: {}",
669 providerId, deviceId); 654 providerId, deviceId);
670 - try { 655 + notifyPeers(new InternalPortStatusEvent(providerId, deviceId, mergedDesc));
671 - notifyPeers(new InternalPortStatusEvent(providerId, deviceId, mergedDesc));
672 - } catch (IOException e) {
673 - log.error("Failed to notify peers of a port status update topology event or providerId: "
674 - + providerId + " and deviceId: " + deviceId, e);
675 - }
676 } 656 }
677 return event; 657 return event;
678 } 658 }
...@@ -793,12 +773,7 @@ public class GossipDeviceStore ...@@ -793,12 +773,7 @@ public class GossipDeviceStore
793 if (event != null) { 773 if (event != null) {
794 log.debug("Notifying peers of a device removed topology event for deviceId: {}", 774 log.debug("Notifying peers of a device removed topology event for deviceId: {}",
795 deviceId); 775 deviceId);
796 - try { 776 + notifyPeers(new InternalDeviceRemovedEvent(deviceId, timestamp));
797 - notifyPeers(new InternalDeviceRemovedEvent(deviceId, timestamp));
798 - } catch (IOException e) {
799 - log.error("Failed to notify peers of a device removed topology event for deviceId: {}",
800 - deviceId);
801 - }
802 } 777 }
803 if (relinquishAtEnd) { 778 if (relinquishAtEnd) {
804 log.debug("Relinquishing temporary role acquired for {}", deviceId); 779 log.debug("Relinquishing temporary role acquired for {}", deviceId);
...@@ -973,7 +948,7 @@ public class GossipDeviceStore ...@@ -973,7 +948,7 @@ public class GossipDeviceStore
973 clusterCommunicator.unicast(message, recipient); 948 clusterCommunicator.unicast(message, recipient);
974 } 949 }
975 950
976 - private void broadcastMessage(MessageSubject subject, Object event) throws IOException { 951 + private void broadcastMessage(MessageSubject subject, Object event) {
977 ClusterMessage message = new ClusterMessage( 952 ClusterMessage message = new ClusterMessage(
978 clusterService.getLocalNode().id(), 953 clusterService.getLocalNode().id(),
979 subject, 954 subject,
...@@ -981,23 +956,23 @@ public class GossipDeviceStore ...@@ -981,23 +956,23 @@ public class GossipDeviceStore
981 clusterCommunicator.broadcast(message); 956 clusterCommunicator.broadcast(message);
982 } 957 }
983 958
984 - private void notifyPeers(InternalDeviceEvent event) throws IOException { 959 + private void notifyPeers(InternalDeviceEvent event) {
985 broadcastMessage(GossipDeviceStoreMessageSubjects.DEVICE_UPDATE, event); 960 broadcastMessage(GossipDeviceStoreMessageSubjects.DEVICE_UPDATE, event);
986 } 961 }
987 962
988 - private void notifyPeers(InternalDeviceOfflineEvent event) throws IOException { 963 + private void notifyPeers(InternalDeviceOfflineEvent event) {
989 broadcastMessage(GossipDeviceStoreMessageSubjects.DEVICE_OFFLINE, event); 964 broadcastMessage(GossipDeviceStoreMessageSubjects.DEVICE_OFFLINE, event);
990 } 965 }
991 966
992 - private void notifyPeers(InternalDeviceRemovedEvent event) throws IOException { 967 + private void notifyPeers(InternalDeviceRemovedEvent event) {
993 broadcastMessage(GossipDeviceStoreMessageSubjects.DEVICE_REMOVED, event); 968 broadcastMessage(GossipDeviceStoreMessageSubjects.DEVICE_REMOVED, event);
994 } 969 }
995 970
996 - private void notifyPeers(InternalPortEvent event) throws IOException { 971 + private void notifyPeers(InternalPortEvent event) {
997 broadcastMessage(GossipDeviceStoreMessageSubjects.PORT_UPDATE, event); 972 broadcastMessage(GossipDeviceStoreMessageSubjects.PORT_UPDATE, event);
998 } 973 }
999 974
1000 - private void notifyPeers(InternalPortStatusEvent event) throws IOException { 975 + private void notifyPeers(InternalPortStatusEvent event) {
1001 broadcastMessage(GossipDeviceStoreMessageSubjects.PORT_STATUS_UPDATE, event); 976 broadcastMessage(GossipDeviceStoreMessageSubjects.PORT_STATUS_UPDATE, event);
1002 } 977 }
1003 978
......
...@@ -15,33 +15,13 @@ ...@@ -15,33 +15,13 @@
15 */ 15 */
16 package org.onosproject.store.host.impl; 16 package org.onosproject.store.host.impl;
17 17
18 -import static com.google.common.base.Preconditions.checkNotNull; 18 +import com.google.common.collect.FluentIterable;
19 -import static com.google.common.collect.Multimaps.synchronizedSetMultimap; 19 +import com.google.common.collect.HashMultimap;
20 -import static com.google.common.collect.Multimaps.newSetMultimap; 20 +import com.google.common.collect.ImmutableList;
21 -import static com.google.common.collect.Sets.newConcurrentHashSet; 21 +import com.google.common.collect.ImmutableSet;
22 -import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor; 22 +import com.google.common.collect.Multimap;
23 -import static org.onosproject.cluster.ControllerNodeToNodeId.toNodeId; 23 +import com.google.common.collect.Multimaps;
24 -import static org.onosproject.net.DefaultAnnotations.merge; 24 +import com.google.common.collect.SetMultimap;
25 -import static org.onosproject.net.host.HostEvent.Type.HOST_ADDED;
26 -import static org.onosproject.net.host.HostEvent.Type.HOST_REMOVED;
27 -import static org.onosproject.store.host.impl.GossipHostStoreMessageSubjects.*;
28 -import static org.onlab.util.Tools.namedThreads;
29 -import static org.onlab.util.Tools.minPriority;
30 -import static org.slf4j.LoggerFactory.getLogger;
31 -
32 -import java.io.IOException;
33 -import java.util.Collections;
34 -import java.util.HashMap;
35 -import java.util.HashSet;
36 -import java.util.Map;
37 -import java.util.Map.Entry;
38 -import java.util.Set;
39 -import java.util.concurrent.ConcurrentHashMap;
40 -import java.util.concurrent.ExecutorService;
41 -import java.util.concurrent.Executors;
42 -import java.util.concurrent.ScheduledExecutorService;
43 -import java.util.concurrent.TimeUnit;
44 -
45 import org.apache.commons.lang3.RandomUtils; 25 import org.apache.commons.lang3.RandomUtils;
46 import org.apache.felix.scr.annotations.Activate; 26 import org.apache.felix.scr.annotations.Activate;
47 import org.apache.felix.scr.annotations.Component; 27 import org.apache.felix.scr.annotations.Component;
...@@ -49,6 +29,10 @@ import org.apache.felix.scr.annotations.Deactivate; ...@@ -49,6 +29,10 @@ import org.apache.felix.scr.annotations.Deactivate;
49 import org.apache.felix.scr.annotations.Reference; 29 import org.apache.felix.scr.annotations.Reference;
50 import org.apache.felix.scr.annotations.ReferenceCardinality; 30 import org.apache.felix.scr.annotations.ReferenceCardinality;
51 import org.apache.felix.scr.annotations.Service; 31 import org.apache.felix.scr.annotations.Service;
32 +import org.onlab.packet.IpAddress;
33 +import org.onlab.packet.MacAddress;
34 +import org.onlab.packet.VlanId;
35 +import org.onlab.util.KryoNamespace;
52 import org.onosproject.cluster.ClusterService; 36 import org.onosproject.cluster.ClusterService;
53 import org.onosproject.cluster.ControllerNode; 37 import org.onosproject.cluster.ControllerNode;
54 import org.onosproject.cluster.NodeId; 38 import org.onosproject.cluster.NodeId;
...@@ -79,19 +63,36 @@ import org.onosproject.store.cluster.messaging.MessageSubject; ...@@ -79,19 +63,36 @@ import org.onosproject.store.cluster.messaging.MessageSubject;
79 import org.onosproject.store.impl.Timestamped; 63 import org.onosproject.store.impl.Timestamped;
80 import org.onosproject.store.serializers.KryoSerializer; 64 import org.onosproject.store.serializers.KryoSerializer;
81 import org.onosproject.store.serializers.impl.DistributedStoreSerializers; 65 import org.onosproject.store.serializers.impl.DistributedStoreSerializers;
82 -import org.onlab.packet.IpAddress;
83 -import org.onlab.packet.MacAddress;
84 -import org.onlab.packet.VlanId;
85 -import org.onlab.util.KryoNamespace;
86 import org.slf4j.Logger; 66 import org.slf4j.Logger;
87 67
88 -import com.google.common.collect.FluentIterable; 68 +import java.io.IOException;
89 -import com.google.common.collect.HashMultimap; 69 +import java.util.Collections;
90 -import com.google.common.collect.ImmutableList; 70 +import java.util.HashMap;
91 -import com.google.common.collect.ImmutableSet; 71 +import java.util.HashSet;
92 -import com.google.common.collect.Multimap; 72 +import java.util.Map;
93 -import com.google.common.collect.Multimaps; 73 +import java.util.Map.Entry;
94 -import com.google.common.collect.SetMultimap; 74 +import java.util.Set;
75 +import java.util.concurrent.ConcurrentHashMap;
76 +import java.util.concurrent.ExecutorService;
77 +import java.util.concurrent.Executors;
78 +import java.util.concurrent.ScheduledExecutorService;
79 +import java.util.concurrent.TimeUnit;
80 +
81 +import static com.google.common.base.Preconditions.checkNotNull;
82 +import static com.google.common.collect.Multimaps.newSetMultimap;
83 +import static com.google.common.collect.Multimaps.synchronizedSetMultimap;
84 +import static com.google.common.collect.Sets.newConcurrentHashSet;
85 +import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
86 +import static org.onlab.util.Tools.minPriority;
87 +import static org.onlab.util.Tools.namedThreads;
88 +import static org.onosproject.cluster.ControllerNodeToNodeId.toNodeId;
89 +import static org.onosproject.net.DefaultAnnotations.merge;
90 +import static org.onosproject.net.host.HostEvent.Type.HOST_ADDED;
91 +import static org.onosproject.net.host.HostEvent.Type.HOST_REMOVED;
92 +import static org.onosproject.store.host.impl.GossipHostStoreMessageSubjects.HOST_ANTI_ENTROPY_ADVERTISEMENT;
93 +import static org.onosproject.store.host.impl.GossipHostStoreMessageSubjects.HOST_REMOVED_MSG;
94 +import static org.onosproject.store.host.impl.GossipHostStoreMessageSubjects.HOST_UPDATED_MSG;
95 +import static org.slf4j.LoggerFactory.getLogger;
95 96
96 /** 97 /**
97 * Manages inventory of end-station hosts in distributed data store 98 * Manages inventory of end-station hosts in distributed data store
...@@ -205,12 +206,7 @@ public class GossipHostStore ...@@ -205,12 +206,7 @@ public class GossipHostStore
205 if (event != null) { 206 if (event != null) {
206 log.debug("Notifying peers of a host topology event for providerId: " 207 log.debug("Notifying peers of a host topology event for providerId: "
207 + "{}; hostId: {}; hostDescription: {}", providerId, hostId, hostDescription); 208 + "{}; hostId: {}; hostDescription: {}", providerId, hostId, hostDescription);
208 - try { 209 + notifyPeers(new InternalHostEvent(providerId, hostId, hostDescription, timestamp));
209 - notifyPeers(new InternalHostEvent(providerId, hostId, hostDescription, timestamp));
210 - } catch (IOException e) {
211 - log.error("Failed to notify peers of a host topology event for providerId: "
212 - + "{}; hostId: {}; hostDescription: {}", providerId, hostId, hostDescription);
213 - }
214 } 210 }
215 return event; 211 return event;
216 } 212 }
...@@ -331,11 +327,7 @@ public class GossipHostStore ...@@ -331,11 +327,7 @@ public class GossipHostStore
331 HostEvent event = removeHostInternal(hostId, timestamp); 327 HostEvent event = removeHostInternal(hostId, timestamp);
332 if (event != null) { 328 if (event != null) {
333 log.debug("Notifying peers of a host removed topology event for hostId: {}", hostId); 329 log.debug("Notifying peers of a host removed topology event for hostId: {}", hostId);
334 - try { 330 + notifyPeers(new InternalHostRemovedEvent(hostId, timestamp));
335 - notifyPeers(new InternalHostRemovedEvent(hostId, timestamp));
336 - } catch (IOException e) {
337 - log.info("Failed to notify peers of a host removed topology event for hostId: {}", hostId);
338 - }
339 } 331 }
340 return event; 332 return event;
341 } 333 }
...@@ -477,15 +469,15 @@ public class GossipHostStore ...@@ -477,15 +469,15 @@ public class GossipHostStore
477 } 469 }
478 } 470 }
479 471
480 - private void notifyPeers(InternalHostRemovedEvent event) throws IOException { 472 + private void notifyPeers(InternalHostRemovedEvent event) {
481 broadcastMessage(HOST_REMOVED_MSG, event); 473 broadcastMessage(HOST_REMOVED_MSG, event);
482 } 474 }
483 475
484 - private void notifyPeers(InternalHostEvent event) throws IOException { 476 + private void notifyPeers(InternalHostEvent event) {
485 broadcastMessage(HOST_UPDATED_MSG, event); 477 broadcastMessage(HOST_UPDATED_MSG, event);
486 } 478 }
487 479
488 - private void broadcastMessage(MessageSubject subject, Object event) throws IOException { 480 + private void broadcastMessage(MessageSubject subject, Object event) {
489 ClusterMessage message = new ClusterMessage( 481 ClusterMessage message = new ClusterMessage(
490 clusterService.getLocalNode().id(), 482 clusterService.getLocalNode().id(),
491 subject, 483 subject,
......
...@@ -366,26 +366,14 @@ public class EventuallyConsistentMapImpl<K, V> ...@@ -366,26 +366,14 @@ public class EventuallyConsistentMapImpl<K, V>
366 } 366 }
367 367
368 private void notifyPeers(InternalPutEvent event) { 368 private void notifyPeers(InternalPutEvent event) {
369 - try { 369 + broadcastMessage(updateMessageSubject, event);
370 - log.debug("sending put {}", event);
371 - broadcastMessage(updateMessageSubject, event);
372 - } catch (IOException e) {
373 - // TODO this won't happen; remove from API
374 - log.debug("IOException broadcasting update", e);
375 - }
376 } 370 }
377 371
378 private void notifyPeers(InternalRemoveEvent event) { 372 private void notifyPeers(InternalRemoveEvent event) {
379 - try { 373 + broadcastMessage(removeMessageSubject, event);
380 - broadcastMessage(removeMessageSubject, event);
381 - } catch (IOException e) {
382 - // TODO this won't happen; remove from API
383 - log.debug("IOException broadcasting update", e);
384 - }
385 } 374 }
386 375
387 - private void broadcastMessage(MessageSubject subject, Object event) throws 376 + private void broadcastMessage(MessageSubject subject, Object event) {
388 - IOException {
389 ClusterMessage message = new ClusterMessage( 377 ClusterMessage message = new ClusterMessage(
390 clusterService.getLocalNode().id(), 378 clusterService.getLocalNode().id(),
391 subject, 379 subject,
......
...@@ -327,25 +327,14 @@ public class GossipIntentStore ...@@ -327,25 +327,14 @@ public class GossipIntentStore
327 } 327 }
328 328
329 private void notifyPeers(InternalIntentEvent event) { 329 private void notifyPeers(InternalIntentEvent event) {
330 - try { 330 + broadcastMessage(INTENT_UPDATED_MSG, event);
331 - broadcastMessage(INTENT_UPDATED_MSG, event);
332 - } catch (IOException e) {
333 - // TODO this won't happen; remove from API
334 - log.debug("IOException broadcasting update", e);
335 - }
336 } 331 }
337 332
338 private void notifyPeers(InternalSetInstallablesEvent event) { 333 private void notifyPeers(InternalSetInstallablesEvent event) {
339 - try { 334 + broadcastMessage(INTENT_SET_INSTALLABLES_MSG, event);
340 - broadcastMessage(INTENT_SET_INSTALLABLES_MSG, event);
341 - } catch (IOException e) {
342 - // TODO this won't happen; remove from API
343 - log.debug("IOException broadcasting update", e);
344 - }
345 } 335 }
346 336
347 - private void broadcastMessage(MessageSubject subject, Object event) throws 337 + private void broadcastMessage(MessageSubject subject, Object event) {
348 - IOException {
349 ClusterMessage message = new ClusterMessage( 338 ClusterMessage message = new ClusterMessage(
350 clusterService.getLocalNode().id(), 339 clusterService.getLocalNode().id(),
351 subject, 340 subject,
......
...@@ -15,22 +15,12 @@ ...@@ -15,22 +15,12 @@
15 */ 15 */
16 package org.onosproject.store.link.impl; 16 package org.onosproject.store.link.impl;
17 17
18 -import java.io.IOException; 18 +import com.google.common.base.Function;
19 -import java.util.Collection; 19 +import com.google.common.collect.FluentIterable;
20 -import java.util.Collections; 20 +import com.google.common.collect.ImmutableList;
21 -import java.util.HashMap; 21 +import com.google.common.collect.Multimaps;
22 -import java.util.HashSet; 22 +import com.google.common.collect.SetMultimap;
23 -import java.util.Map; 23 +import com.google.common.collect.Sets;
24 -import java.util.Map.Entry;
25 -import java.util.Objects;
26 -import java.util.Set;
27 -import java.util.concurrent.ConcurrentHashMap;
28 -import java.util.concurrent.ConcurrentMap;
29 -import java.util.concurrent.ExecutorService;
30 -import java.util.concurrent.Executors;
31 -import java.util.concurrent.ScheduledExecutorService;
32 -import java.util.concurrent.TimeUnit;
33 -
34 import org.apache.commons.lang3.RandomUtils; 24 import org.apache.commons.lang3.RandomUtils;
35 import org.apache.felix.scr.annotations.Activate; 25 import org.apache.felix.scr.annotations.Activate;
36 import org.apache.felix.scr.annotations.Component; 26 import org.apache.felix.scr.annotations.Component;
...@@ -70,12 +60,21 @@ import org.onosproject.store.serializers.KryoSerializer; ...@@ -70,12 +60,21 @@ import org.onosproject.store.serializers.KryoSerializer;
70 import org.onosproject.store.serializers.impl.DistributedStoreSerializers; 60 import org.onosproject.store.serializers.impl.DistributedStoreSerializers;
71 import org.slf4j.Logger; 61 import org.slf4j.Logger;
72 62
73 -import com.google.common.base.Function; 63 +import java.io.IOException;
74 -import com.google.common.collect.FluentIterable; 64 +import java.util.Collection;
75 -import com.google.common.collect.ImmutableList; 65 +import java.util.Collections;
76 -import com.google.common.collect.Multimaps; 66 +import java.util.HashMap;
77 -import com.google.common.collect.SetMultimap; 67 +import java.util.HashSet;
78 -import com.google.common.collect.Sets; 68 +import java.util.Map;
69 +import java.util.Map.Entry;
70 +import java.util.Objects;
71 +import java.util.Set;
72 +import java.util.concurrent.ConcurrentHashMap;
73 +import java.util.concurrent.ConcurrentMap;
74 +import java.util.concurrent.ExecutorService;
75 +import java.util.concurrent.Executors;
76 +import java.util.concurrent.ScheduledExecutorService;
77 +import java.util.concurrent.TimeUnit;
79 78
80 import static com.google.common.base.Preconditions.checkNotNull; 79 import static com.google.common.base.Preconditions.checkNotNull;
81 import static com.google.common.base.Predicates.notNull; 80 import static com.google.common.base.Predicates.notNull;
...@@ -289,13 +288,7 @@ public class GossipLinkStore ...@@ -289,13 +288,7 @@ public class GossipLinkStore
289 log.info("Notifying peers of a link update topology event from providerId: " 288 log.info("Notifying peers of a link update topology event from providerId: "
290 + "{} between src: {} and dst: {}", 289 + "{} between src: {} and dst: {}",
291 providerId, linkDescription.src(), linkDescription.dst()); 290 providerId, linkDescription.src(), linkDescription.dst());
292 - try { 291 + notifyPeers(new InternalLinkEvent(providerId, mergedDesc));
293 - notifyPeers(new InternalLinkEvent(providerId, mergedDesc));
294 - } catch (IOException e) {
295 - log.debug("Failed to notify peers of a link update topology event from providerId: "
296 - + "{} between src: {} and dst: {}",
297 - providerId, linkDescription.src(), linkDescription.dst());
298 - }
299 } 292 }
300 return event; 293 return event;
301 } 294 }
...@@ -432,12 +425,7 @@ public class GossipLinkStore ...@@ -432,12 +425,7 @@ public class GossipLinkStore
432 if (event != null) { 425 if (event != null) {
433 log.info("Notifying peers of a link removed topology event for a link " 426 log.info("Notifying peers of a link removed topology event for a link "
434 + "between src: {} and dst: {}", src, dst); 427 + "between src: {} and dst: {}", src, dst);
435 - try { 428 + notifyPeers(new InternalLinkRemovedEvent(key, timestamp));
436 - notifyPeers(new InternalLinkRemovedEvent(key, timestamp));
437 - } catch (IOException e) {
438 - log.error("Failed to notify peers of a link removed topology event for a link "
439 - + "between src: {} and dst: {}", src, dst);
440 - }
441 } 429 }
442 return event; 430 return event;
443 } 431 }
...@@ -607,7 +595,7 @@ public class GossipLinkStore ...@@ -607,7 +595,7 @@ public class GossipLinkStore
607 } 595 }
608 } 596 }
609 597
610 - private void broadcastMessage(MessageSubject subject, Object event) throws IOException { 598 + private void broadcastMessage(MessageSubject subject, Object event) {
611 ClusterMessage message = new ClusterMessage( 599 ClusterMessage message = new ClusterMessage(
612 clusterService.getLocalNode().id(), 600 clusterService.getLocalNode().id(),
613 subject, 601 subject,
...@@ -623,11 +611,11 @@ public class GossipLinkStore ...@@ -623,11 +611,11 @@ public class GossipLinkStore
623 clusterCommunicator.unicast(message, recipient); 611 clusterCommunicator.unicast(message, recipient);
624 } 612 }
625 613
626 - private void notifyPeers(InternalLinkEvent event) throws IOException { 614 + private void notifyPeers(InternalLinkEvent event) {
627 broadcastMessage(GossipLinkStoreMessageSubjects.LINK_UPDATE, event); 615 broadcastMessage(GossipLinkStoreMessageSubjects.LINK_UPDATE, event);
628 } 616 }
629 617
630 - private void notifyPeers(InternalLinkRemovedEvent event) throws IOException { 618 + private void notifyPeers(InternalLinkRemovedEvent event) {
631 broadcastMessage(GossipLinkStoreMessageSubjects.LINK_REMOVED, event); 619 broadcastMessage(GossipLinkStoreMessageSubjects.LINK_REMOVED, event);
632 } 620 }
633 621
......
...@@ -16,24 +16,13 @@ ...@@ -16,24 +16,13 @@
16 16
17 package org.onosproject.store.service.impl; 17 package org.onosproject.store.service.impl;
18 18
19 -import static org.onlab.util.Tools.namedThreads; 19 +import com.google.common.base.MoreObjects;
20 -
21 -import java.io.IOException;
22 -import java.util.HashMap;
23 -import java.util.Map;
24 -import java.util.Objects;
25 -import java.util.concurrent.ExecutorService;
26 -import java.util.concurrent.Executors;
27 -import java.util.concurrent.TimeUnit;
28 -import java.util.concurrent.atomic.AtomicBoolean;
29 -
30 import net.jodah.expiringmap.ExpiringMap; 20 import net.jodah.expiringmap.ExpiringMap;
31 import net.jodah.expiringmap.ExpiringMap.ExpirationListener; 21 import net.jodah.expiringmap.ExpiringMap.ExpirationListener;
32 import net.jodah.expiringmap.ExpiringMap.ExpirationPolicy; 22 import net.jodah.expiringmap.ExpiringMap.ExpirationPolicy;
33 import net.kuujo.copycat.cluster.Member; 23 import net.kuujo.copycat.cluster.Member;
34 import net.kuujo.copycat.event.EventHandler; 24 import net.kuujo.copycat.event.EventHandler;
35 import net.kuujo.copycat.event.LeaderElectEvent; 25 import net.kuujo.copycat.event.LeaderElectEvent;
36 -
37 import org.onosproject.cluster.ControllerNode; 26 import org.onosproject.cluster.ControllerNode;
38 import org.onosproject.store.cluster.messaging.ClusterCommunicationService; 27 import org.onosproject.store.cluster.messaging.ClusterCommunicationService;
39 import org.onosproject.store.cluster.messaging.ClusterMessage; 28 import org.onosproject.store.cluster.messaging.ClusterMessage;
...@@ -44,7 +33,15 @@ import org.onosproject.store.service.impl.DatabaseStateMachine.TableMetadata; ...@@ -44,7 +33,15 @@ import org.onosproject.store.service.impl.DatabaseStateMachine.TableMetadata;
44 import org.slf4j.Logger; 33 import org.slf4j.Logger;
45 import org.slf4j.LoggerFactory; 34 import org.slf4j.LoggerFactory;
46 35
47 -import com.google.common.base.MoreObjects; 36 +import java.util.HashMap;
37 +import java.util.Map;
38 +import java.util.Objects;
39 +import java.util.concurrent.ExecutorService;
40 +import java.util.concurrent.Executors;
41 +import java.util.concurrent.TimeUnit;
42 +import java.util.concurrent.atomic.AtomicBoolean;
43 +
44 +import static org.onlab.util.Tools.namedThreads;
48 45
49 /** 46 /**
50 * Plugs into the database update stream and track the TTL of entries added to 47 * Plugs into the database update stream and track the TTL of entries added to
...@@ -97,14 +94,10 @@ public class DatabaseEntryExpirationTracker implements ...@@ -97,14 +94,10 @@ public class DatabaseEntryExpirationTracker implements
97 case ROW_DELETED: 94 case ROW_DELETED:
98 map.remove(row, eventVersion); 95 map.remove(row, eventVersion);
99 if (isLocalMemberLeader.get()) { 96 if (isLocalMemberLeader.get()) {
100 - try { 97 + log.debug("Broadcasting {} to the entire cluster", event);
101 - log.debug("Broadcasting {} to the entire cluster", event); 98 + clusterCommunicator.broadcastIncludeSelf(new ClusterMessage(
102 - clusterCommunicator.broadcastIncludeSelf(new ClusterMessage( 99 + localNode.id(), DatabaseStateMachine.DATABASE_UPDATE_EVENTS,
103 - localNode.id(), DatabaseStateMachine.DATABASE_UPDATE_EVENTS, 100 + ClusterMessagingProtocol.DB_SERIALIZER.encode(event)));
104 - ClusterMessagingProtocol.DB_SERIALIZER.encode(event)));
105 - } catch (IOException e) {
106 - log.error("Failed to broadcast a database row deleted event.", e);
107 - }
108 } 101 }
109 break; 102 break;
110 case ROW_ADDED: 103 case ROW_ADDED:
......
...@@ -15,23 +15,7 @@ ...@@ -15,23 +15,7 @@
15 */ 15 */
16 package org.onosproject.store.service.impl; 16 package org.onosproject.store.service.impl;
17 17
18 -import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor; 18 +import com.google.common.collect.ImmutableList;
19 -import static org.onlab.util.Tools.namedThreads;
20 -import static org.slf4j.LoggerFactory.getLogger;
21 -
22 -import java.io.File;
23 -import java.io.IOException;
24 -import java.util.Collection;
25 -import java.util.Collections;
26 -import java.util.HashSet;
27 -import java.util.Map;
28 -import java.util.Optional;
29 -import java.util.Set;
30 -import java.util.concurrent.CountDownLatch;
31 -import java.util.concurrent.ExecutionException;
32 -import java.util.concurrent.ScheduledExecutorService;
33 -import java.util.concurrent.TimeUnit;
34 -
35 import net.kuujo.copycat.Copycat; 19 import net.kuujo.copycat.Copycat;
36 import net.kuujo.copycat.CopycatConfig; 20 import net.kuujo.copycat.CopycatConfig;
37 import net.kuujo.copycat.cluster.ClusterConfig; 21 import net.kuujo.copycat.cluster.ClusterConfig;
...@@ -42,13 +26,13 @@ import net.kuujo.copycat.cluster.TcpMember; ...@@ -42,13 +26,13 @@ import net.kuujo.copycat.cluster.TcpMember;
42 import net.kuujo.copycat.event.EventHandler; 26 import net.kuujo.copycat.event.EventHandler;
43 import net.kuujo.copycat.event.LeaderElectEvent; 27 import net.kuujo.copycat.event.LeaderElectEvent;
44 import net.kuujo.copycat.log.Log; 28 import net.kuujo.copycat.log.Log;
45 -
46 import org.apache.felix.scr.annotations.Activate; 29 import org.apache.felix.scr.annotations.Activate;
47 import org.apache.felix.scr.annotations.Component; 30 import org.apache.felix.scr.annotations.Component;
48 import org.apache.felix.scr.annotations.Deactivate; 31 import org.apache.felix.scr.annotations.Deactivate;
49 import org.apache.felix.scr.annotations.Reference; 32 import org.apache.felix.scr.annotations.Reference;
50 import org.apache.felix.scr.annotations.ReferenceCardinality; 33 import org.apache.felix.scr.annotations.ReferenceCardinality;
51 import org.apache.felix.scr.annotations.Service; 34 import org.apache.felix.scr.annotations.Service;
35 +import org.onlab.packet.IpAddress;
52 import org.onosproject.cluster.ClusterEvent; 36 import org.onosproject.cluster.ClusterEvent;
53 import org.onosproject.cluster.ClusterEventListener; 37 import org.onosproject.cluster.ClusterEventListener;
54 import org.onosproject.cluster.ClusterService; 38 import org.onosproject.cluster.ClusterService;
...@@ -69,10 +53,24 @@ import org.onosproject.store.service.ReadStatus; ...@@ -69,10 +53,24 @@ import org.onosproject.store.service.ReadStatus;
69 import org.onosproject.store.service.VersionedValue; 53 import org.onosproject.store.service.VersionedValue;
70 import org.onosproject.store.service.WriteResult; 54 import org.onosproject.store.service.WriteResult;
71 import org.onosproject.store.service.WriteStatus; 55 import org.onosproject.store.service.WriteStatus;
72 -import org.onlab.packet.IpAddress;
73 import org.slf4j.Logger; 56 import org.slf4j.Logger;
74 57
75 -import com.google.common.collect.ImmutableList; 58 +import java.io.File;
59 +import java.io.IOException;
60 +import java.util.Collection;
61 +import java.util.Collections;
62 +import java.util.HashSet;
63 +import java.util.Map;
64 +import java.util.Optional;
65 +import java.util.Set;
66 +import java.util.concurrent.CountDownLatch;
67 +import java.util.concurrent.ExecutionException;
68 +import java.util.concurrent.ScheduledExecutorService;
69 +import java.util.concurrent.TimeUnit;
70 +
71 +import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
72 +import static org.onlab.util.Tools.namedThreads;
73 +import static org.slf4j.LoggerFactory.getLogger;
76 74
77 /** 75 /**
78 * Strongly consistent and durable state management service based on 76 * Strongly consistent and durable state management service based on
...@@ -488,25 +486,21 @@ public class DatabaseManager implements DatabaseService, DatabaseAdminService { ...@@ -488,25 +486,21 @@ public class DatabaseManager implements DatabaseService, DatabaseAdminService {
488 private final class RaftLeaderElectionMonitor implements EventHandler<LeaderElectEvent> { 486 private final class RaftLeaderElectionMonitor implements EventHandler<LeaderElectEvent> {
489 @Override 487 @Override
490 public void handle(LeaderElectEvent event) { 488 public void handle(LeaderElectEvent event) {
491 - try { 489 + log.debug("Received LeaderElectEvent: {}", event);
492 - log.debug("Received LeaderElectEvent: {}", event); 490 + if (clusterConfig.getLocalMember() != null && event.leader().equals(clusterConfig.getLocalMember())) {
493 - if (clusterConfig.getLocalMember() != null && event.leader().equals(clusterConfig.getLocalMember())) { 491 + log.debug("Broadcasting RAFT_LEADER_ELECTION_EVENT");
494 - log.debug("Broadcasting RAFT_LEADER_ELECTION_EVENT"); 492 + myLeaderEvent = event;
495 - myLeaderEvent = event; 493 + // This node just became the leader.
496 - // This node just became the leader. 494 + clusterCommunicator.broadcastIncludeSelf(
497 - clusterCommunicator.broadcastIncludeSelf( 495 + new ClusterMessage(
498 - new ClusterMessage( 496 + clusterService.getLocalNode().id(),
499 - clusterService.getLocalNode().id(), 497 + RAFT_LEADER_ELECTION_EVENT,
500 - RAFT_LEADER_ELECTION_EVENT, 498 + ClusterMessagingProtocol.DB_SERIALIZER.encode(event)));
501 - ClusterMessagingProtocol.DB_SERIALIZER.encode(event))); 499 + } else {
502 - } else { 500 + if (myLeaderEvent != null) {
503 - if (myLeaderEvent != null) { 501 + log.debug("This node is no longer the Leader");
504 - log.debug("This node is no longer the Leader");
505 - }
506 - myLeaderEvent = null;
507 } 502 }
508 - } catch (IOException e) { 503 + myLeaderEvent = null;
509 - log.error("Failed to broadcast raft leadership change event", e);
510 } 504 }
511 } 505 }
512 } 506 }
......
...@@ -15,25 +15,8 @@ ...@@ -15,25 +15,8 @@
15 */ 15 */
16 package org.onosproject.store.device.impl; 16 package org.onosproject.store.device.impl;
17 17
18 -import static org.easymock.EasyMock.*; 18 +import com.google.common.collect.Iterables;
19 -import static org.junit.Assert.*; 19 +import com.google.common.collect.Sets;
20 -import static org.onosproject.net.Device.Type.SWITCH;
21 -import static org.onosproject.net.DeviceId.deviceId;
22 -import static org.onosproject.net.device.DeviceEvent.Type.*;
23 -import static org.onosproject.cluster.ControllerNode.State.*;
24 -import static org.onosproject.net.DefaultAnnotations.union;
25 -import static java.util.Arrays.asList;
26 -
27 -import java.io.IOException;
28 -import java.util.Arrays;
29 -import java.util.Collections;
30 -import java.util.HashMap;
31 -import java.util.List;
32 -import java.util.Map;
33 -import java.util.Set;
34 -import java.util.concurrent.CountDownLatch;
35 -import java.util.concurrent.TimeUnit;
36 -
37 import org.easymock.Capture; 20 import org.easymock.Capture;
38 import org.junit.After; 21 import org.junit.After;
39 import org.junit.AfterClass; 22 import org.junit.AfterClass;
...@@ -41,6 +24,8 @@ import org.junit.Before; ...@@ -41,6 +24,8 @@ import org.junit.Before;
41 import org.junit.BeforeClass; 24 import org.junit.BeforeClass;
42 import org.junit.Ignore; 25 import org.junit.Ignore;
43 import org.junit.Test; 26 import org.junit.Test;
27 +import org.onlab.packet.ChassisId;
28 +import org.onlab.packet.IpAddress;
44 import org.onosproject.cluster.ClusterService; 29 import org.onosproject.cluster.ClusterService;
45 import org.onosproject.cluster.ControllerNode; 30 import org.onosproject.cluster.ControllerNode;
46 import org.onosproject.cluster.DefaultControllerNode; 31 import org.onosproject.cluster.DefaultControllerNode;
...@@ -68,11 +53,25 @@ import org.onosproject.store.cluster.messaging.ClusterCommunicationService; ...@@ -68,11 +53,25 @@ import org.onosproject.store.cluster.messaging.ClusterCommunicationService;
68 import org.onosproject.store.cluster.messaging.ClusterMessage; 53 import org.onosproject.store.cluster.messaging.ClusterMessage;
69 import org.onosproject.store.cluster.messaging.ClusterMessageHandler; 54 import org.onosproject.store.cluster.messaging.ClusterMessageHandler;
70 import org.onosproject.store.cluster.messaging.MessageSubject; 55 import org.onosproject.store.cluster.messaging.MessageSubject;
71 -import org.onlab.packet.ChassisId;
72 -import org.onlab.packet.IpAddress;
73 56
74 -import com.google.common.collect.Iterables; 57 +import java.io.IOException;
75 -import com.google.common.collect.Sets; 58 +import java.util.Arrays;
59 +import java.util.Collections;
60 +import java.util.HashMap;
61 +import java.util.List;
62 +import java.util.Map;
63 +import java.util.Set;
64 +import java.util.concurrent.CountDownLatch;
65 +import java.util.concurrent.TimeUnit;
66 +
67 +import static java.util.Arrays.asList;
68 +import static org.easymock.EasyMock.*;
69 +import static org.junit.Assert.*;
70 +import static org.onosproject.cluster.ControllerNode.State.ACTIVE;
71 +import static org.onosproject.net.DefaultAnnotations.union;
72 +import static org.onosproject.net.Device.Type.SWITCH;
73 +import static org.onosproject.net.DeviceId.deviceId;
74 +import static org.onosproject.net.device.DeviceEvent.Type.*;
76 75
77 76
78 // TODO add tests for remote replication 77 // TODO add tests for remote replication
...@@ -180,12 +179,8 @@ public class GossipDeviceStoreTest { ...@@ -180,12 +179,8 @@ public class GossipDeviceStoreTest {
180 new DefaultDeviceDescription(deviceId.uri(), SWITCH, MFR, 179 new DefaultDeviceDescription(deviceId.uri(), SWITCH, MFR,
181 HW, swVersion, SN, CID, annotations); 180 HW, swVersion, SN, CID, annotations);
182 reset(clusterCommunicator); 181 reset(clusterCommunicator);
183 - try { 182 + expect(clusterCommunicator.broadcast(anyObject(ClusterMessage.class)))
184 - expect(clusterCommunicator.broadcast(anyObject(ClusterMessage.class))) 183 + .andReturn(true).anyTimes();
185 - .andReturn(true).anyTimes();
186 - } catch (IOException e) {
187 - fail("Should never reach here");
188 - }
189 replay(clusterCommunicator); 184 replay(clusterCommunicator);
190 deviceStore.createOrUpdateDevice(PID, deviceId, description); 185 deviceStore.createOrUpdateDevice(PID, deviceId, description);
191 verify(clusterCommunicator); 186 verify(clusterCommunicator);
...@@ -664,11 +659,7 @@ public class GossipDeviceStoreTest { ...@@ -664,11 +659,7 @@ public class GossipDeviceStoreTest {
664 659
665 bcast.reset(); 660 bcast.reset();
666 reset(clusterCommunicator); 661 reset(clusterCommunicator);
667 - try { 662 + expect(clusterCommunicator.broadcast(capture(bcast))).andReturn(true).once();
668 - expect(clusterCommunicator.broadcast(capture(bcast))).andReturn(true).once();
669 - } catch (IOException e) {
670 - fail("Should never reach here");
671 - }
672 replay(clusterCommunicator); 663 replay(clusterCommunicator);
673 } 664 }
674 665
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
16 package org.onosproject.store.link.impl; 16 package org.onosproject.store.link.impl;
17 17
18 import com.google.common.collect.Iterables; 18 import com.google.common.collect.Iterables;
19 -
20 import org.easymock.Capture; 19 import org.easymock.Capture;
21 import org.junit.After; 20 import org.junit.After;
22 import org.junit.AfterClass; 21 import org.junit.AfterClass;
...@@ -24,6 +23,7 @@ import org.junit.Before; ...@@ -24,6 +23,7 @@ import org.junit.Before;
24 import org.junit.BeforeClass; 23 import org.junit.BeforeClass;
25 import org.junit.Ignore; 24 import org.junit.Ignore;
26 import org.junit.Test; 25 import org.junit.Test;
26 +import org.onlab.packet.IpAddress;
27 import org.onosproject.cluster.ControllerNode; 27 import org.onosproject.cluster.ControllerNode;
28 import org.onosproject.cluster.DefaultControllerNode; 28 import org.onosproject.cluster.DefaultControllerNode;
29 import org.onosproject.cluster.NodeId; 29 import org.onosproject.cluster.NodeId;
...@@ -49,29 +49,24 @@ import org.onosproject.store.cluster.messaging.ClusterMessage; ...@@ -49,29 +49,24 @@ import org.onosproject.store.cluster.messaging.ClusterMessage;
49 import org.onosproject.store.cluster.messaging.ClusterMessageHandler; 49 import org.onosproject.store.cluster.messaging.ClusterMessageHandler;
50 import org.onosproject.store.cluster.messaging.MessageSubject; 50 import org.onosproject.store.cluster.messaging.MessageSubject;
51 import org.onosproject.store.device.impl.DeviceClockManager; 51 import org.onosproject.store.device.impl.DeviceClockManager;
52 -import org.onlab.packet.IpAddress;
53 52
54 -import java.io.IOException;
55 import java.util.HashMap; 53 import java.util.HashMap;
56 import java.util.Map; 54 import java.util.Map;
57 import java.util.Set; 55 import java.util.Set;
58 import java.util.concurrent.CountDownLatch; 56 import java.util.concurrent.CountDownLatch;
59 import java.util.concurrent.TimeUnit; 57 import java.util.concurrent.TimeUnit;
60 58
61 -import static org.easymock.EasyMock.anyObject; 59 +import static org.easymock.EasyMock.*;
62 -import static org.easymock.EasyMock.capture;
63 -import static org.easymock.EasyMock.createNiceMock;
64 -import static org.easymock.EasyMock.expect;
65 -import static org.easymock.EasyMock.expectLastCall;
66 -import static org.easymock.EasyMock.replay;
67 -import static org.easymock.EasyMock.reset;
68 -import static org.easymock.EasyMock.verify;
69 import static org.junit.Assert.*; 60 import static org.junit.Assert.*;
70 import static org.onosproject.cluster.ControllerNode.State.ACTIVE; 61 import static org.onosproject.cluster.ControllerNode.State.ACTIVE;
71 import static org.onosproject.net.DeviceId.deviceId; 62 import static org.onosproject.net.DeviceId.deviceId;
72 -import static org.onosproject.net.Link.Type.*; 63 +import static org.onosproject.net.Link.Type.DIRECT;
73 -import static org.onosproject.net.link.LinkEvent.Type.*; 64 +import static org.onosproject.net.Link.Type.EDGE;
65 +import static org.onosproject.net.Link.Type.INDIRECT;
74 import static org.onosproject.net.NetTestTools.assertAnnotationsEquals; 66 import static org.onosproject.net.NetTestTools.assertAnnotationsEquals;
67 +import static org.onosproject.net.link.LinkEvent.Type.LINK_ADDED;
68 +import static org.onosproject.net.link.LinkEvent.Type.LINK_REMOVED;
69 +import static org.onosproject.net.link.LinkEvent.Type.LINK_UPDATED;
75 70
76 /** 71 /**
77 * Test of the GossipLinkStoreTest implementation. 72 * Test of the GossipLinkStoreTest implementation.
...@@ -169,12 +164,8 @@ public class GossipLinkStoreTest { ...@@ -169,12 +164,8 @@ public class GossipLinkStoreTest {
169 ConnectPoint src = new ConnectPoint(srcId, srcNum); 164 ConnectPoint src = new ConnectPoint(srcId, srcNum);
170 ConnectPoint dst = new ConnectPoint(dstId, dstNum); 165 ConnectPoint dst = new ConnectPoint(dstId, dstNum);
171 reset(clusterCommunicator); 166 reset(clusterCommunicator);
172 - try { 167 + expect(clusterCommunicator.broadcast(anyObject(ClusterMessage.class)))
173 - expect(clusterCommunicator.broadcast(anyObject(ClusterMessage.class))) 168 + .andReturn(true).anyTimes();
174 - .andReturn(true).anyTimes();
175 - } catch (IOException e) {
176 - fail("Should never reach here");
177 - }
178 replay(clusterCommunicator); 169 replay(clusterCommunicator);
179 linkStore.createOrUpdateLink(PID, new DefaultLinkDescription(src, dst, type, annotations)); 170 linkStore.createOrUpdateLink(PID, new DefaultLinkDescription(src, dst, type, annotations));
180 verify(clusterCommunicator); 171 verify(clusterCommunicator);
...@@ -192,11 +183,7 @@ public class GossipLinkStoreTest { ...@@ -192,11 +183,7 @@ public class GossipLinkStoreTest {
192 183
193 bcast.reset(); 184 bcast.reset();
194 reset(clusterCommunicator); 185 reset(clusterCommunicator);
195 - try { 186 + expect(clusterCommunicator.broadcast(capture(bcast))).andReturn(true).once();
196 - expect(clusterCommunicator.broadcast(capture(bcast))).andReturn(true).once();
197 - } catch (IOException e) {
198 - fail("Should never reach here");
199 - }
200 replay(clusterCommunicator); 187 replay(clusterCommunicator);
201 } 188 }
202 189
......