org.kth.dks
Class DKSImpl

java.lang.Object
  extended by org.kth.dks.DKSImpl
All Implemented Interfaces:
DKSCallbackInterface, DKSInterface

public class DKSImpl
extends java.lang.Object
implements DKSInterface, DKSCallbackInterface


Field Summary
protected  ConnectionManager cm
           
protected  DKSNode myDKSNode
           
protected  DKSRef myDKSRef
           
 
Constructor Summary
DKSImpl(ConnectionManager _cm, DKSOverlayAddress over)
           
DKSImpl(ConnectionManager _cm, long nodeId, long gId, long GUID)
           
DKSImpl(ConnectionManager _cm, long nodeId, java.net.URL nodeAddress)
           
 
Method Summary
 boolean addMsgHandler(DKSMessage msg, java.lang.Object handlerObject, java.lang.String methodName)
          Registers a handler for a DKSMessage.
 long addressSpace()
           
 void broadcast(DKSObject message)
          Broadcasts the given message.
 void broadcastRestricted(DKSObject message, long startId, long endId)
          Broadcasts to nodes with identifiers within the rand startId and endId []
 void create()
          first node should call this
 DKSRef findResponsible(long identifier)
          Finds the responsible node for a certain identifier
 ConnectionManager getCM()
           
 CommunicationInfo getComInfo()
           
 java.io.Serializable getDebugInfo()
           
 DKSMarshal getDKSMarshal()
           
 DKSRef getDKSRef()
          Returns the DKSRef associated to this DKS node
 java.lang.String getDKSURL()
          Returns the DKSURL (stringified DKSRef) used by this DKS node
 MessageInfo[] getMessageInfo()
           
 DKSNode getMyDKSNode()
           
 NodeInfo getNodeInfo()
           
 void join(DKSRef existingnodeAddress)
          Adds a new node to the network managed by the local DKS implementation.
 void join(long existingnodeId, java.net.URL existingnodeAddress)
           
 void joinCallbackReturn()
          INVARIANT: should be called by DKSAppInterface every time DKSAppInterface.joinCallback() is called
 void leave()
          Disconnect the local node from the network.
 void leaveCallbackReturn()
          INVARIANT: should be called by DKSAppInterface every time DKSAppInterface.leaveCallback() is called
 void logLevel(int level)
          Set the logging level
 DKSObject route(long identifier, DKSObject payload)
          Will route a message the DKS node that is responsible for the given identifier and give it the payload, upon which the responsible node will respond with a payload which is returned
 void routeAsync(long identifier, DKSObject payload)
          Will route a message to the DKS node that is responsible for the given identifier and give it the payload, upon which the responsible node will respond with a payload which is returned
 void routeAsyncFrom(long identifier, DKSObject payload, DKSRef firstNode)
          Will route a message from firstNode to the DKS node that is responsible for the given identifier and give it the payload, upon which the responsible node will respond with a payload which is returned
 void send(DKSRef target, DKSMessage message)
          Send the message to the specified recipient node.
 DKSCallbackInterface setCallbackHandler(DKSAppInterface appHandler)
          Instructs the DKS system to pass on all received messages to the specified DKSMessageReceiver.
 void unregisterNode()
          Every object implementing this interface gets registered in a ConnectionManager, this method this method unregisters the object in the ConnectionManager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myDKSNode

protected DKSNode myDKSNode

cm

protected ConnectionManager cm

myDKSRef

protected DKSRef myDKSRef
Constructor Detail

DKSImpl

public DKSImpl(ConnectionManager _cm,
               long nodeId,
               java.net.URL nodeAddress)
        throws DKSNodeAlreadyRegistered
Throws:
DKSNodeAlreadyRegistered

DKSImpl

public DKSImpl(ConnectionManager _cm,
               DKSOverlayAddress over)
        throws DKSNodeAlreadyRegistered
Throws:
DKSNodeAlreadyRegistered

DKSImpl

public DKSImpl(ConnectionManager _cm,
               long nodeId,
               long gId,
               long GUID)
        throws DKSNodeAlreadyRegistered
Throws:
DKSNodeAlreadyRegistered
Method Detail

getDKSURL

public java.lang.String getDKSURL()
Description copied from interface: DKSInterface
Returns the DKSURL (stringified DKSRef) used by this DKS node

Specified by:
getDKSURL in interface DKSInterface
Returns:
String
See Also:
DKSRef

join

public void join(long existingnodeId,
                 java.net.URL existingnodeAddress)
          throws DKSTooManyRestartJoins,
                 DKSIdentifierAlreadyTaken
Throws:
DKSTooManyRestartJoins
DKSIdentifierAlreadyTaken

create

public void create()
first node should call this

Specified by:
create in interface DKSInterface

join

public void join(DKSRef existingnodeAddress)
          throws DKSTooManyRestartJoins,
                 DKSIdentifierAlreadyTaken,
                 DKSRefNoResponse
Description copied from interface: DKSInterface
Adds a new node to the network managed by the local DKS implementation.

Specified by:
join in interface DKSInterface
Throws:
DKSTooManyRestartJoins
DKSIdentifierAlreadyTaken
DKSRefNoResponse

logLevel

public void logLevel(int level)
Description copied from interface: DKSInterface
Set the logging level

Specified by:
logLevel in interface DKSInterface
Parameters:
level - int, 0 means no logging, 1 means debug prints, 2 means XML dumps

leave

public void leave()
Disconnect the local node from the network.

Specified by:
leave in interface DKSInterface

findResponsible

public DKSRef findResponsible(long identifier)
Finds the responsible node for a certain identifier

Specified by:
findResponsible in interface DKSInterface
Parameters:
identifier - long describing the target identifier whose responsible is to be found
Returns:
DKSRef reference containing contact information to the responsible node

route

public DKSObject route(long identifier,
                       DKSObject payload)
Will route a message the DKS node that is responsible for the given identifier and give it the payload, upon which the responsible node will respond with a payload which is returned

Specified by:
route in interface DKSInterface
Parameters:
identifier - whose responsible node being routed to
payload - to be sent to the responsible node
Returns:
DKSOBject payload sent back by the responsible node
See Also:
DKSAppInterface

routeAsync

public void routeAsync(long identifier,
                       DKSObject payload)
Will route a message to the DKS node that is responsible for the given identifier and give it the payload, upon which the responsible node will respond with a payload which is returned

Specified by:
routeAsync in interface DKSInterface
Parameters:
identifier - whose responsible node being routed to
payload - to be sent to the responsible node
See Also:
DKSAppInterface

routeAsyncFrom

public void routeAsyncFrom(long identifier,
                           DKSObject payload,
                           DKSRef firstNode)
Will route a message from firstNode to the DKS node that is responsible for the given identifier and give it the payload, upon which the responsible node will respond with a payload which is returned

Specified by:
routeAsyncFrom in interface DKSInterface
Parameters:
identifier - long
payload - DKSObject
firstNode - DKSRef

send

public void send(DKSRef target,
                 DKSMessage message)
Send the message to the specified recipient node.

Specified by:
send in interface DKSInterface
Parameters:
target - a DKSRef to a node in the system
message - a DKSMessage

broadcast

public void broadcast(DKSObject message)
Broadcasts the given message.

Specified by:
broadcast in interface DKSInterface

broadcastRestricted

public void broadcastRestricted(DKSObject message,
                                long startId,
                                long endId)
Broadcasts to nodes with identifiers within the rand startId and endId []

Specified by:
broadcastRestricted in interface DKSInterface
Parameters:
message - DKSObject message to be sent
startId - long beginning of the interval
endId - long end of the interval

setCallbackHandler

public DKSCallbackInterface setCallbackHandler(DKSAppInterface appHandler)
Instructs the DKS system to pass on all received messages to the specified DKSMessageReceiver.

Specified by:
setCallbackHandler in interface DKSCallbackInterface
Parameters:
appHandler - DKSAppInterface interface to the application for callbacks
Returns:
DKSCallbackInterface an interface for DKS callbacks, which the application will invoke
See Also:
DKSCallBackInterface, DKSAppInterface

getNodeInfo

public NodeInfo getNodeInfo()

getDebugInfo

public java.io.Serializable getDebugInfo()

getComInfo

public CommunicationInfo getComInfo()

getMessageInfo

public MessageInfo[] getMessageInfo()

getDKSMarshal

public DKSMarshal getDKSMarshal()

addressSpace

public long addressSpace()

getMyDKSNode

public DKSNode getMyDKSNode()

unregisterNode

public void unregisterNode()
Description copied from interface: DKSInterface
Every object implementing this interface gets registered in a ConnectionManager, this method this method unregisters the object in the ConnectionManager. This method needs to be called especially if another object of this type is to be instantiated with the same DKSNetAddress (overlay identity)

Specified by:
unregisterNode in interface DKSInterface

joinCallbackReturn

public void joinCallbackReturn()
Description copied from interface: DKSCallbackInterface
INVARIANT: should be called by DKSAppInterface every time DKSAppInterface.joinCallback() is called

Specified by:
joinCallbackReturn in interface DKSCallbackInterface
See Also:
DKSAppInterface

leaveCallbackReturn

public void leaveCallbackReturn()
INVARIANT: should be called by DKSAppInterface every time DKSAppInterface.leaveCallback() is called

Specified by:
leaveCallbackReturn in interface DKSCallbackInterface
See Also:
DKSAppInterface

getCM

public ConnectionManager getCM()

addMsgHandler

public boolean addMsgHandler(DKSMessage msg,
                             java.lang.Object handlerObject,
                             java.lang.String methodName)
Description copied from interface: DKSInterface
Registers a handler for a DKSMessage. DKS will invoke the handler whenever a DKSMessage of that type is received.

Specified by:
addMsgHandler in interface DKSInterface
Parameters:
msg - Some object which is a subclass of DKSMessage
handlerObject - Object whose method will be invoked upon receipt of a message of type DKSMessage
methodName - full case sensitive of the method to be invoked(without paranthesis). The method has a predefined signature as described in the following example. Example: if the method name is "handleStore", there should a method in handlerObject with the signature
public void handleStore(DKSRef sender, msgClass msg)
, where msgClass is the tye of the parameter msg.
Returns:
true if registration succeeded, or false if it failed (which can occur if a DKSMessage with the same internal string exists).
See Also:
DKSInterface.addMsgHandler()

getDKSRef

public DKSRef getDKSRef()
Description copied from interface: DKSInterface
Returns the DKSRef associated to this DKS node

Specified by:
getDKSRef in interface DKSInterface
Returns:
DKSRef
See Also:
DKSRef


Copyright © 2010. All Rights Reserved.