org.kth.dks.dks_node
Class DefaultAppHandler

java.lang.Object
  extended by org.kth.dks.dks_node.DefaultAppHandler
All Implemented Interfaces:
DKSAppInterface

public class DefaultAppHandler
extends java.lang.Object
implements DKSAppInterface

This is a default class implementing placeholders for every callback that an application should implement

Title: DKS

Description: DKS Middleware

Copyright: Copyright (c) 2004

Company: KTH-IMIT/SICS

Version:
1.0
Author:
not attributable

Field Summary
protected  DKSCallbackInterface dks
           
 
Constructor Summary
DefaultAppHandler()
           
DefaultAppHandler(DKSCallbackInterface dksImpl)
           
 
Method Summary
 void broadcastCallback(DKSObject payload)
          This callback routine is called when the node recieves a broadcast message.
 void failCallback(DKSRef failed, DKSRef failedPred)
          This callback routine is called at the successor of a filed node, when it detects its predecessor has failed.
 void joinCallback(DKSRef pred, DKSRef succ)
          This callback routine is called at the joining node, when the node is about to join INVARIANT: this method must make a callback to DKSCallbacks.joinCallbackReturn
 void leaveCallback(DKSRef pred, DKSRef succ)
          This callback routine is called at the leaving node, when the node is about to leave INVARIANT: this method must make a callback to DKSCallbacks.joinCallbackReturn
 DKSObject routeCallback(long identifier, DKSObject payload)
          Is set in DKSInterface through setCallbackHandler().
 void routeCallbackAsync(long identifier, DKSObject payload)
          Is set in DKSInterface through setCallbackHandler().
 void setDKSCallbackInterface(DKSCallbackInterface d)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dks

protected DKSCallbackInterface dks
Constructor Detail

DefaultAppHandler

public DefaultAppHandler(DKSCallbackInterface dksImpl)

DefaultAppHandler

public DefaultAppHandler()
Method Detail

setDKSCallbackInterface

public void setDKSCallbackInterface(DKSCallbackInterface d)

routeCallback

public DKSObject routeCallback(long identifier,
                               DKSObject payload)
Description copied from interface: DKSAppInterface
Is set in DKSInterface through setCallbackHandler(). It is called at the responsible node when a route() message reaches its destination. It receives a DKSObject, and returns a possibly new DKSObject INVARIANT: the implementor of this method SHOULD immediately return, as otherwise the underlying DKSNode cannot process new messagesl, and consequently the method cannot recursively call other methods in the DKSInterface as the DKSNode will not be able to receive response messages. Consider using routeAsync() in DKSInterface.

Specified by:
routeCallback in interface DKSAppInterface
Parameters:
identifier - long, the identifier searched for in route, maybe not interesting for the app in many cases.
payload - DKSObject, the actual payload sent by the source
Returns:
DKSObject the payload to be routed back

routeCallbackAsync

public void routeCallbackAsync(long identifier,
                               DKSObject payload)
Description copied from interface: DKSAppInterface
Is set in DKSInterface through setCallbackHandler(). It is called at the responsible node when a route() message reaches its destination. as the DKSNode will not be able to receive response messages. Consider using routeAsync() in DKSInterface.

Specified by:
routeCallbackAsync in interface DKSAppInterface
Parameters:
identifier - long, the identifier searched for in route, maybe not interesting for the app in many cases.
payload - DKSObject, the actual payload sent by the source

broadcastCallback

public void broadcastCallback(DKSObject payload)
Description copied from interface: DKSAppInterface
This callback routine is called when the node recieves a broadcast message. Note that the sender of a broadcast also recieves a broadcast msg.

Specified by:
broadcastCallback in interface DKSAppInterface
Parameters:
payload - DKSObject, the actual payload sent by the source

joinCallback

public void joinCallback(DKSRef pred,
                         DKSRef succ)
Description copied from interface: DKSAppInterface
This callback routine is called at the joining node, when the node is about to join INVARIANT: this method must make a callback to DKSCallbacks.joinCallbackReturn

Specified by:
joinCallback in interface DKSAppInterface
Parameters:
pred - DKSRef predecessor reference, containing the identifier of the predecessor (useful for DHT impl)
succ - DKSRef successor, containing the identifier of the successor (useful for DHT impl)

leaveCallback

public void leaveCallback(DKSRef pred,
                          DKSRef succ)
Description copied from interface: DKSAppInterface
This callback routine is called at the leaving node, when the node is about to leave INVARIANT: this method must make a callback to DKSCallbacks.joinCallbackReturn

Specified by:
leaveCallback in interface DKSAppInterface
Parameters:
pred - DKSRef predecessor reference, containing the identifier of the predecessor (useful for DHT impl)
succ - DKSRef successor, containing the identifier of the successor (useful for DHT impl)

failCallback

public void failCallback(DKSRef failed,
                         DKSRef failedPred)
Description copied from interface: DKSAppInterface
This callback routine is called at the successor of a filed node, when it detects its predecessor has failed.

Specified by:
failCallback in interface DKSAppInterface
Parameters:
failed - DKSRef to the failed node (useful for DHT impl)
failedPred - DKSRef to the failed nodes predecessor (useful for DHT impl)


Copyright © 2010. All Rights Reserved.