${header}

meteor.dht.can
Class CANServiceImpl

java.lang.Object
  extended byjava.lang.Thread
      extended bymeteor.dht.can.CANServiceImpl
All Implemented Interfaces:
CANService, DHTService, net.jxta.discovery.DiscoveryListener, java.util.EventListener, net.jxta.platform.Module, java.lang.Runnable, net.jxta.service.Service

public class CANServiceImpl
extends java.lang.Thread
implements CANService, net.jxta.discovery.DiscoveryListener

The implementation of the CAN DHT service providing an implementation for the DHT querying

Author:
Vincent Matossian November 2004

Field Summary
 java.lang.String handlerName
           
 net.jxta.peergroup.PeerGroup peergroup
           
static java.lang.String refModuleSpecID
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface meteor.dht.can.CANService
refModuleClassID
 
Fields inherited from interface net.jxta.platform.Module
START_AGAIN_PROGRESS, START_AGAIN_STALLED, START_OK
 
Constructor Summary
CANServiceImpl()
          Constructor for the DHT service implementation
 
Method Summary
 void addListener(DHTListener listener)
          Add a listener to this class.
 void blockOnSend()
          Synchronization for the Messaging between peers
 void bootstrap(java.lang.String peerID)
          Start the bootstrapping
 void discoveryEvent(net.jxta.discovery.DiscoveryEvent e)
          Is called when a discovery message is received Used ONLY during the bootstrap protocol
 void get(java.lang.String key)
          Hashtable primitive to retrieve an entry from the table
 int getDimension()
          Returns the dimension of the cartesian space
 net.jxta.document.Advertisement getImplAdvertisement()
          Get the Implemetation advertisement
 net.jxta.service.Service getInterface()
           
 java.math.BigInteger getNodeID(java.lang.String id)
          Hashes the JXTA peer id into an overlay node id
 java.math.BigInteger getTopologySize()
          Returns the size of the topoloy as an Integer In the case of a ring, the size of the ring, In the case of a mesh, the width ot th mesh
 void init(net.jxta.peergroup.PeerGroup group, net.jxta.id.ID assignedID, net.jxta.document.Advertisement implAdv)
          Invoked when the service is added to the peergroup in the Loader class.
 boolean inMyZone(QueryMessage qm)
          Determines if an identifier belongs to this node's zone
 void join(java.math.BigInteger bi)
           
 void join(java.lang.String bootstrap)
          The JOIN protocol If the target is identical to the local ID i.e.
 void lookup(java.math.BigInteger target, int owner, int mode)
          Lookup the successor of an identifier
 java.math.BigInteger[] mapNodeToCoord(java.math.BigInteger nid)
          Returns coordinates of the node ID in d dimensional space
 void notifyReceived()
          Invoked in messageHandler's processResponse to notify the lookup Service that a response for its blocking query has just been received, and the response identifier of the query set as successor ID.
 void notifyReceived(Zone z)
          Invoked in messageHandler's processResponse to notify the lookup Service that a response for its blocking query has just been received, and the response identifier of the query set as successor ID.
 void put(java.lang.String key, java.lang.String value)
          Hashtable primitive to insert an element in the table
 void receivedDHTEntry(QueryMessage query)
          Received a DHT Entry
 void removeListener(DHTListener listener)
          Remove a listener
 void routeTo(QueryMessage qm)
          Routes to this node
 void setDimension(int d)
          Set the dimension
 void setTopologySize(int s)
          Set the size of the topology For a mesh, the width of the mesh
 Zone splitZone(QueryMessage qm)
          Splits the zone of this node
 int startApp(java.lang.String[] args)
          Invoked when calling peergroup.startApps in Loader class.
 void stopApp()
          Invoked when application stops
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

refModuleSpecID

public static final java.lang.String refModuleSpecID

peergroup

public net.jxta.peergroup.PeerGroup peergroup

handlerName

public java.lang.String handlerName
Constructor Detail

CANServiceImpl

public CANServiceImpl()
Constructor for the DHT service implementation

Method Detail

getImplAdvertisement

public net.jxta.document.Advertisement getImplAdvertisement()
Get the Implemetation advertisement

Specified by:
getImplAdvertisement in interface net.jxta.service.Service
Returns:
the advertisement associated to this implementation

getInterface

public net.jxta.service.Service getInterface()
Specified by:
getInterface in interface net.jxta.service.Service
Returns:
this implementation of the DHT service interface

addListener

public void addListener(DHTListener listener)
Add a listener to this class. All registered listeners will be notified when a receivedQuerry and receivedSuccessor event occurs. (See MessageHandler)

Specified by:
addListener in interface CANService

removeListener

public void removeListener(DHTListener listener)
Remove a listener

Specified by:
removeListener in interface CANService

init

public void init(net.jxta.peergroup.PeerGroup group,
                 net.jxta.id.ID assignedID,
                 net.jxta.document.Advertisement implAdv)
          throws net.jxta.exception.PeerGroupException
Invoked when the service is added to the peergroup in the Loader class. Init obtains a reference to the peergroup

Specified by:
init in interface net.jxta.platform.Module
Parameters:
group - the peergroup to which this implementaiton belongs
implAdv - the implementaiton advertisement for this module
Throws:
net.jxta.exception.PeerGroupException

startApp

public int startApp(java.lang.String[] args)
Invoked when calling peergroup.startApps in Loader class. Gets the services from the peergroup and defines the credentials.

Specified by:
startApp in interface net.jxta.platform.Module

stopApp

public void stopApp()
Invoked when application stops

Specified by:
stopApp in interface net.jxta.platform.Module

setDimension

public void setDimension(int d)
Set the dimension

Specified by:
setDimension in interface CANService

getDimension

public int getDimension()
Returns the dimension of the cartesian space

Specified by:
getDimension in interface CANService

setTopologySize

public void setTopologySize(int s)
Set the size of the topology For a mesh, the width of the mesh

Specified by:
setTopologySize in interface DHTService

getTopologySize

public java.math.BigInteger getTopologySize()
Description copied from interface: DHTService
Returns the size of the topoloy as an Integer In the case of a ring, the size of the ring, In the case of a mesh, the width ot th mesh

Specified by:
getTopologySize in interface DHTService
Returns:
the size of the topology

getNodeID

public java.math.BigInteger getNodeID(java.lang.String id)
Description copied from interface: DHTService
Hashes the JXTA peer id into an overlay node id

Specified by:
getNodeID in interface DHTService
Returns:
the Node ID on the ring

mapNodeToCoord

public java.math.BigInteger[] mapNodeToCoord(java.math.BigInteger nid)
Returns coordinates of the node ID in d dimensional space


bootstrap

public void bootstrap(java.lang.String peerID)
Start the bootstrapping

Specified by:
bootstrap in interface DHTService

discoveryEvent

public void discoveryEvent(net.jxta.discovery.DiscoveryEvent e)
Is called when a discovery message is received Used ONLY during the bootstrap protocol

Specified by:
discoveryEvent in interface net.jxta.discovery.DiscoveryListener

join

public void join(java.math.BigInteger bi)

join

public void join(java.lang.String bootstrap)
The JOIN protocol If the target is identical to the local ID i.e. this is the bootstrap node If not ask bootstrap node to find this node's successor

Specified by:
join in interface DHTService

blockOnSend

public void blockOnSend()
Synchronization for the Messaging between peers


notifyReceived

public void notifyReceived(Zone z)
Invoked in messageHandler's processResponse to notify the lookup Service that a response for its blocking query has just been received, and the response identifier of the query set as successor ID.


notifyReceived

public void notifyReceived()
Invoked in messageHandler's processResponse to notify the lookup Service that a response for its blocking query has just been received, and the response identifier of the query set as successor ID.


inMyZone

public boolean inMyZone(QueryMessage qm)
Determines if an identifier belongs to this node's zone

Specified by:
inMyZone in interface CANService

splitZone

public Zone splitZone(QueryMessage qm)
Splits the zone of this node


lookup

public void lookup(java.math.BigInteger target,
                   int owner,
                   int mode)
Lookup the successor of an identifier

Specified by:
lookup in interface DHTService

routeTo

public void routeTo(QueryMessage qm)
Routes to this node


put

public void put(java.lang.String key,
                java.lang.String value)
Hashtable primitive to insert an element in the table

Specified by:
put in interface DHTService

get

public void get(java.lang.String key)
Hashtable primitive to retrieve an entry from the table

Specified by:
get in interface DHTService

receivedDHTEntry

public void receivedDHTEntry(QueryMessage query)
Received a DHT Entry


${header}