blob: fe7fcd30d511011b898e11a704394e496c5d085a [file] [log] [blame]
tom1d416c52014-09-29 20:55:24 -07001package org.onlab.onos.store.cluster.messaging;
2
3import org.onlab.onos.cluster.NodeId;
4
5import java.util.Set;
6
7/**
8 * Service for assisting communications between controller cluster nodes.
9 */
10public interface ClusterCommunicationService {
11
12 /**
tomd33e6402014-09-30 03:14:43 -070013 * Sends a message to all controller nodes.
14 *
15 * @param message message to send
16 * @return true if the message was sent sucessfully to all nodes; false
17 * if there is no stream or if there was an error for some node
18 */
19 boolean send(ClusterMessage message);
20
21 /**
tom1d416c52014-09-29 20:55:24 -070022 * Sends a message to the specified controller node.
23 *
24 * @param message message to send
25 * @param toNodeId node identifier
26 * @return true if the message was sent sucessfully; false if there is
27 * no stream or if there was an error
28 */
29 boolean send(ClusterMessage message, NodeId toNodeId);
30
31 /**
32 * Adds a new subscriber for the specified message subject.
33 *
34 * @param subject message subject
35 * @param subscriber message subscriber
36 */
37 void addSubscriber(MessageSubject subject, MessageSubscriber subscriber);
38
39 /**
40 * Removes the specified subscriber from the given message subject.
41 *
42 * @param subject message subject
43 * @param subscriber message subscriber
44 */
45 void removeSubscriber(MessageSubject subject, MessageSubscriber subscriber);
46
47 /**
48 * Returns the set of subscribers for the specified message subject.
49 *
50 * @param subject message subject
51 * @return set of message subscribers
52 */
53 Set<MessageSubscriber> getSubscribers(MessageSubject subject);
54
55}