blob: 2cff64ac4989d4936103213f06182986f786f1a3 [file] [log] [blame]
package org.onlab.onos.store.cluster.messaging;
import java.io.IOException;
import java.util.Set;
import org.onlab.onos.cluster.NodeId;
import com.google.common.util.concurrent.ListenableFuture;
// TODO: remove IOExceptions?
/**
* Service for assisting communications between controller cluster nodes.
*/
public interface ClusterCommunicationService {
/**
* Broadcast a message to all controller nodes.
*
* @param message message to send
* @return true if the message was sent successfully to all nodes; false otherwise.
*/
boolean broadcast(ClusterMessage message) throws IOException;
/**
* Sends a message to the specified controller node.
*
* @param message message to send
* @param toNodeId node identifier
* @return true if the message was sent successfully; false otherwise.
*/
boolean unicast(ClusterMessage message, NodeId toNodeId) throws IOException;
/**
* Multicast a message to a set of controller nodes.
*
* @param message message to send
* @return true if the message was sent successfully to all nodes in the group; false otherwise.
*/
boolean multicast(ClusterMessage message, Set<NodeId> nodeIds) throws IOException;
/**
* Sends a message synchronously.
* @param message message to send
* @param toNodeId recipient node identifier
* @return reply future.
* @throws IOException
*/
ListenableFuture<byte[]> sendAndReceive(ClusterMessage message, NodeId toNodeId) throws IOException;
/**
* Adds a new subscriber for the specified message subject.
*
* @param subject message subject
* @param subscriber message subscriber
*/
void addSubscriber(MessageSubject subject, ClusterMessageHandler subscriber);
}