org.apache.s4.core
Class Sender

java.lang.Object
  extended by org.apache.s4.core.Sender

public class Sender
extends java.lang.Object

The Sender and its counterpart Receiver are the top level classes of the communication layer.

Sender is responsible for sending an event to a ProcessingElement instance using a hashKey.

Details on how the cluster is partitioned and how events are serialized and transmitted to its destination are hidden from the application developer.


Constructor Summary
Sender(Emitter emitter, SerializerDeserializer serDeser, Hasher hasher, Assignment assignment)
           
 
Method Summary
 boolean checkAndSendIfNotLocal(java.lang.String hashKey, Event event)
          This method attempts to send an event to a remote partition.
 void sendToRemotePartitions(Event event)
          Send an event to all the remote partitions in the cluster.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sender

@Inject
public Sender(Emitter emitter,
                     SerializerDeserializer serDeser,
                     Hasher hasher,
                     Assignment assignment)
Parameters:
emitter - the emitter implements the low level communication layer.
serDeser - a serialization mechanism.
hasher - a hashing function to map keys to partition IDs.
Method Detail

checkAndSendIfNotLocal

public boolean checkAndSendIfNotLocal(java.lang.String hashKey,
                                      Event event)
This method attempts to send an event to a remote partition. If the destination is local, the method does not send the event and returns false. The caller is then expected to put the event in a local queue instead.

Parameters:
hashKey - the string used to map the value of a key to a specific partition.
event - the event to be delivered to a ProcessingElement instance.
Returns:
true if the event was sent because the destination is not local.

sendToRemotePartitions

public void sendToRemotePartitions(Event event)
Send an event to all the remote partitions in the cluster. The caller is expected to also put the event in a local queue.

Parameters:
event - the event to be delivered to ProcessingElement instances.