org.hypergraphdb.peer.replication
Class CatchUpTaskServer

java.lang.Object
  extended by org.hypergraphdb.peer.workflow.AbstractActivity<StateType>
      extended by org.hypergraphdb.peer.workflow.TaskActivity<org.hypergraphdb.peer.replication.CatchUpTaskServer.State>
          extended by org.hypergraphdb.peer.replication.CatchUpTaskServer
All Implemented Interfaces:
java.lang.Runnable, ActivityStateListener

public class CatchUpTaskServer
extends TaskActivity<org.hypergraphdb.peer.replication.CatchUpTaskServer.State>

Author:
ciprian.costa This task manages a catchup request from another peer. It will determine the required Remember tasks and execute them.

Nested Class Summary
static class CatchUpTaskServer.CatchUpTaskServerFactory
           
 
Constructor Summary
CatchUpTaskServer(HyperGraphPeer thisPeer, java.util.UUID taskId)
           
 
Method Summary
 void handleMessage(Message msg)
           Called by the peer interface when a message arrives for this task.
 
Methods inherited from class org.hypergraphdb.peer.workflow.TaskActivity
getPeerInterface, getTaskId, getThisPeer, setTaskId, stateChanged
 
Methods inherited from class org.hypergraphdb.peer.workflow.AbstractActivity
getEndState, getStartState, run, setStateListener
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CatchUpTaskServer

public CatchUpTaskServer(HyperGraphPeer thisPeer,
                         java.util.UUID taskId)
Method Detail

handleMessage

public void handleMessage(Message msg)
Description copied from class: TaskActivity

Called by the peer interface when a message arrives for this task. Can be overridden by derived TaskActivity implementations. The default implementation delegates to the conversation identified by the CONVERSATION_ID attribute of the message (if any). If there's no conversation associated with this message, an attempt to create a new one is made by calling createNewConversation which can be overridden also. If createNewConversation returns a non-null Conversation instance, the conversation is assigned an ID and registered with this task.

So a task implementation can chose to implement handleMessage and respond to messages directly on it own or it can just implement createNewConversation to delegate the work to conversation implementations. Or it can have a combination of both like the following pattern:


 public void handleMessage(Object msg)
 {
          if msg should trigger a new conversation between this peer and
       the sending peer then
       
       super.handleMessage(msg);
    else
       respond to msg directly here...
 }
 
 public void createNewConversation(Object msg)
 {
    // handleMessage determined that a new conversation must be started
    // so based on the content of the message, create and return
    // an appropriate conversation here.
 }
 

Overrides:
handleMessage in class TaskActivity<org.hypergraphdb.peer.replication.CatchUpTaskServer.State>
Parameters:
msg - The message just received.