blob: 8b966ed0d8c272e8bab7f70531ebfdacbc41aedf [file] [log] [blame]
tom1d416c52014-09-29 20:55:24 -07001package org.onlab.onos.store.cluster.messaging;
2
Madan Jampani890bc352014-10-01 22:35:29 -07003import java.io.IOException;
tom1d416c52014-09-29 20:55:24 -07004import java.util.Set;
5
Madan Jampani890bc352014-10-01 22:35:29 -07006import org.onlab.onos.cluster.NodeId;
7
Yuta HIGUCHI6e501732014-10-12 12:00:27 -07008// TODO: remove IOExceptions?
tom1d416c52014-09-29 20:55:24 -07009/**
10 * Service for assisting communications between controller cluster nodes.
11 */
12public interface ClusterCommunicationService {
13
14 /**
Madan Jampani890bc352014-10-01 22:35:29 -070015 * Broadcast a message to all controller nodes.
tomd33e6402014-09-30 03:14:43 -070016 *
17 * @param message message to send
Madan Jampani890bc352014-10-01 22:35:29 -070018 * @return true if the message was sent successfully to all nodes; false otherwise.
tomd33e6402014-09-30 03:14:43 -070019 */
Madan Jampani890bc352014-10-01 22:35:29 -070020 boolean broadcast(ClusterMessage message) throws IOException;
tomd33e6402014-09-30 03:14:43 -070021
22 /**
tom1d416c52014-09-29 20:55:24 -070023 * Sends a message to the specified controller node.
24 *
25 * @param message message to send
26 * @param toNodeId node identifier
Madan Jampani890bc352014-10-01 22:35:29 -070027 * @return true if the message was sent successfully; false otherwise.
tom1d416c52014-09-29 20:55:24 -070028 */
Madan Jampani890bc352014-10-01 22:35:29 -070029 boolean unicast(ClusterMessage message, NodeId toNodeId) throws IOException;
30
31 /**
32 * Multicast a message to a set of controller nodes.
33 *
34 * @param message message to send
35 * @return true if the message was sent successfully to all nodes in the group; false otherwise.
36 */
37 boolean multicast(ClusterMessage message, Set<NodeId> nodeIds) throws IOException;
tom1d416c52014-09-29 20:55:24 -070038
39 /**
40 * Adds a new subscriber for the specified message subject.
41 *
42 * @param subject message subject
43 * @param subscriber message subscriber
44 */
Madan Jampani890bc352014-10-01 22:35:29 -070045 void addSubscriber(MessageSubject subject, ClusterMessageHandler subscriber);
tom1d416c52014-09-29 20:55:24 -070046}