tom | 1d416c5 | 2014-09-29 20:55:24 -0700 | [diff] [blame] | 1 | package org.onlab.onos.store.cluster.messaging; |
| 2 | |
Madan Jampani | 890bc35 | 2014-10-01 22:35:29 -0700 | [diff] [blame] | 3 | import java.io.IOException; |
tom | 1d416c5 | 2014-09-29 20:55:24 -0700 | [diff] [blame] | 4 | import java.util.Set; |
| 5 | |
Madan Jampani | 890bc35 | 2014-10-01 22:35:29 -0700 | [diff] [blame] | 6 | import org.onlab.onos.cluster.NodeId; |
| 7 | |
Madan Jampani | 24f9efb | 2014-10-24 18:56:23 -0700 | [diff] [blame] | 8 | import com.google.common.util.concurrent.ListenableFuture; |
| 9 | |
Yuta HIGUCHI | 6e50173 | 2014-10-12 12:00:27 -0700 | [diff] [blame] | 10 | // TODO: remove IOExceptions? |
tom | 1d416c5 | 2014-09-29 20:55:24 -0700 | [diff] [blame] | 11 | /** |
| 12 | * Service for assisting communications between controller cluster nodes. |
| 13 | */ |
| 14 | public interface ClusterCommunicationService { |
| 15 | |
| 16 | /** |
Madan Jampani | 890bc35 | 2014-10-01 22:35:29 -0700 | [diff] [blame] | 17 | * Broadcast a message to all controller nodes. |
tom | d33e640 | 2014-09-30 03:14:43 -0700 | [diff] [blame] | 18 | * |
| 19 | * @param message message to send |
Madan Jampani | 890bc35 | 2014-10-01 22:35:29 -0700 | [diff] [blame] | 20 | * @return true if the message was sent successfully to all nodes; false otherwise. |
tom | d33e640 | 2014-09-30 03:14:43 -0700 | [diff] [blame] | 21 | */ |
Madan Jampani | 890bc35 | 2014-10-01 22:35:29 -0700 | [diff] [blame] | 22 | boolean broadcast(ClusterMessage message) throws IOException; |
tom | d33e640 | 2014-09-30 03:14:43 -0700 | [diff] [blame] | 23 | |
| 24 | /** |
tom | 1d416c5 | 2014-09-29 20:55:24 -0700 | [diff] [blame] | 25 | * Sends a message to the specified controller node. |
| 26 | * |
| 27 | * @param message message to send |
| 28 | * @param toNodeId node identifier |
Madan Jampani | 890bc35 | 2014-10-01 22:35:29 -0700 | [diff] [blame] | 29 | * @return true if the message was sent successfully; false otherwise. |
tom | 1d416c5 | 2014-09-29 20:55:24 -0700 | [diff] [blame] | 30 | */ |
Madan Jampani | 890bc35 | 2014-10-01 22:35:29 -0700 | [diff] [blame] | 31 | boolean unicast(ClusterMessage message, NodeId toNodeId) throws IOException; |
| 32 | |
| 33 | /** |
| 34 | * Multicast a message to a set of controller nodes. |
| 35 | * |
| 36 | * @param message message to send |
| 37 | * @return true if the message was sent successfully to all nodes in the group; false otherwise. |
| 38 | */ |
| 39 | boolean multicast(ClusterMessage message, Set<NodeId> nodeIds) throws IOException; |
tom | 1d416c5 | 2014-09-29 20:55:24 -0700 | [diff] [blame] | 40 | |
| 41 | /** |
Madan Jampani | 4a9cb6d | 2014-10-17 10:48:50 -0700 | [diff] [blame] | 42 | * Sends a message synchronously. |
| 43 | * @param message message to send |
| 44 | * @param toNodeId recipient node identifier |
Madan Jampani | 24f9efb | 2014-10-24 18:56:23 -0700 | [diff] [blame] | 45 | * @return reply future. |
Madan Jampani | 4a9cb6d | 2014-10-17 10:48:50 -0700 | [diff] [blame] | 46 | * @throws IOException |
| 47 | */ |
Madan Jampani | 24f9efb | 2014-10-24 18:56:23 -0700 | [diff] [blame] | 48 | ListenableFuture<byte[]> sendAndReceive(ClusterMessage message, NodeId toNodeId) throws IOException; |
Madan Jampani | 4a9cb6d | 2014-10-17 10:48:50 -0700 | [diff] [blame] | 49 | |
| 50 | /** |
tom | 1d416c5 | 2014-09-29 20:55:24 -0700 | [diff] [blame] | 51 | * Adds a new subscriber for the specified message subject. |
| 52 | * |
| 53 | * @param subject message subject |
| 54 | * @param subscriber message subscriber |
| 55 | */ |
Madan Jampani | 890bc35 | 2014-10-01 22:35:29 -0700 | [diff] [blame] | 56 | void addSubscriber(MessageSubject subject, ClusterMessageHandler subscriber); |
tom | 1d416c5 | 2014-09-29 20:55:24 -0700 | [diff] [blame] | 57 | } |