uk.ac.ic.doc.rodex.p2p
Class Peer

java.lang.Object
  extended by uk.ac.ic.doc.automed.p2p.communication.AbstractRequestListener
      extended by uk.ac.ic.doc.automed.p2p.AutoMedPeer
          extended by uk.ac.ic.doc.rodex.p2p.Peer
All Implemented Interfaces:
RequestListener, StateChangedListener
Direct Known Subclasses:
DirectoryServicePeer

public class Peer
extends AutoMedPeer

Peer.java Represents a functional peer on the network

Author:
Duc M Le dmle@doc.ic.ac.uk Created on 20 April 2006 Department of Computing, Imperial College

Nested Class Summary
 
Nested classes/interfaces inherited from class uk.ac.ic.doc.automed.p2p.AutoMedPeer
AutoMedPeer.PeerProcessDescription
 
Field Summary
protected  SICP _sicp
           
 
Fields inherited from class uk.ac.ic.doc.automed.p2p.AutoMedPeer
config, peerAddress, role, ROLE_AUTOMED_PEER, ROLE_DSP, ROLE_PEER, thePeer
 
Constructor Summary
protected Peer(java.lang.String name, PeerStateHandler stateHandler)
           
 
Method Summary
 void finalize()
           
 java.util.Set get(ow.id.ID key)
          Get a set of values from the overlay network for ID
 java.util.Set get(ow.id.ID key, ASG query)
          Get a set of values from the overlay network for ID
 java.util.Set get(java.lang.String keyStr)
          Get a set of values from the overlay network for a String ID
 java.lang.String getIDString()
          Overlay ID string
 java.lang.String getLastKeyString()
           
 java.lang.String getLastRouteString()
           
 java.util.Set getMyKeys()
           
 java.util.Set getMyValues(ow.id.ID key)
           
 java.util.Set getMyValues(java.lang.String key)
           
static OverlayController getOverlayController()
          Return the OverlayController for further tasks
 QEP getQEP()
          Return reference to QEP protocol instance
 IQueryAggregator getQueryAggregator()
          Return a different instance of IQueryAggregator
 java.lang.String getRoutingTableString()
           
 java.lang.String getSelfIDAddressPair()
           
 void initHelloProtocol()
          Initialise the hello protocol based on the role of this peer on the network.
static void initOverlay(int numHosts)
          One overlay controller is shared among all peers
static void initOverlay(int startNum, int numHosts)
          One overlay controller is shared among all peers
 void initSICP()
          Initialises SICP protocol
 java.lang.String joinOverlay(ow.id.ID key, java.lang.String joinHost, java.lang.String selfHost)
          Initialise an instance of the overlay controller and start a DHT process for this peer
static Peer newPeer(java.lang.String name, PeerStateHandler stateHandler)
          Creates a new instance of Peer
static Peer newPeerProcess(java.lang.String name, PeerStateHandler stateHandler, java.lang.String dsrConfigFile)
          Create a new peer with a different configuration
 void outputQuery(AbstractMessage request, ResponseHandler output)
          Execute query using QEP protocol
 void put(ow.id.ID key, java.io.Serializable value, long ttl)
          Put a real (key, value) pair to the overlay
 void put(java.lang.String keyStr, java.lang.String value, long ttl)
          Put a (key, value) pair to the overlay
 java.util.List requestAbstractPathToSource(java.lang.String schemaName)
          Request abstract pathway to source from directory service
 AbstractMessage requestQuery(java.lang.String host, java.lang.String peerName, java.lang.String schema, java.lang.String query)
          Override request query method
 
Methods inherited from class uk.ac.ic.doc.automed.p2p.AutoMedPeer
addRequestListener, authenticate, close, getAutoMedPeer, getCache, getDaemonPort, getDirectory, getMessageHandler, getMessagingHelper, getName, getPeerAddress, getPeerConfig, getPeerHost, getPeerPort, getPeerState, getQueryMediator, getReplyForRequest, getRole, getStateHandler, handleRequest, initAuthentication, initDirectory, initDirectoryRepository, initMessagingPeer, initRegistry, initRepository, isJoinedNetwork, newAutoMedPeer, outputPathway, outputPathwayToSource, outputSchema, outputSourcePathways, performStateAction, register, requestPathToSource, requestPathway, requestSchema, sendRequest, setName, setPeerAddress, setPeerState, unregister
 
Methods inherited from class uk.ac.ic.doc.automed.p2p.communication.AbstractRequestListener
getRequestMessage, getResponseData, getType, handleRequest, handleRequest, handleRequest, handleUDPRequest, handleUDPRequest, handleUDPRequest
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_sicp

protected SICP _sicp
Constructor Detail

Peer

protected Peer(java.lang.String name,
               PeerStateHandler stateHandler)
        throws StateChangedException,
               AutoMedException
Throws:
StateChangedException
AutoMedException
Method Detail

newPeer

public static Peer newPeer(java.lang.String name,
                           PeerStateHandler stateHandler)
                    throws P2PException,
                           AutoMedException
Creates a new instance of Peer

Throws:
P2PException
AutoMedException

newPeerProcess

public static Peer newPeerProcess(java.lang.String name,
                                  PeerStateHandler stateHandler,
                                  java.lang.String dsrConfigFile)
                           throws P2PException,
                                  AutoMedException
Create a new peer with a different configuration

Throws:
P2PException
AutoMedException

getQueryAggregator

public IQueryAggregator getQueryAggregator()
Return a different instance of IQueryAggregator

Overrides:
getQueryAggregator in class AutoMedPeer

getQEP

public QEP getQEP()
Return reference to QEP protocol instance


initHelloProtocol

public void initHelloProtocol()
                       throws AutoMedException
Initialise the hello protocol based on the role of this peer on the network. If this peer acts as a directory service peer, it will need a multicast server process. Otherwise this peer only acts as a multicast client

Throws:
AutoMedException

requestQuery

public AbstractMessage requestQuery(java.lang.String host,
                                    java.lang.String peerName,
                                    java.lang.String schema,
                                    java.lang.String query)
                             throws AutoMedException
Override request query method

Overrides:
requestQuery in class AutoMedPeer
Throws:
AutoMedException

outputQuery

public void outputQuery(AbstractMessage request,
                        ResponseHandler output)
                 throws CommunicationException
Execute query using QEP protocol

Overrides:
outputQuery in class AutoMedPeer
Throws:
CommunicationException

requestAbstractPathToSource

public java.util.List requestAbstractPathToSource(java.lang.String schemaName)
                                           throws AutoMedException
Request abstract pathway to source from directory service

Returns:
List a list of PathwayDescription objects
Throws:
AutoMedException

initSICP

public void initSICP()
Initialises SICP protocol


initOverlay

public static void initOverlay(int numHosts)
One overlay controller is shared among all peers


initOverlay

public static void initOverlay(int startNum,
                               int numHosts)
One overlay controller is shared among all peers


joinOverlay

public java.lang.String joinOverlay(ow.id.ID key,
                                    java.lang.String joinHost,
                                    java.lang.String selfHost)
                             throws OverlayException
Initialise an instance of the overlay controller and start a DHT process for this peer

Returns:
the overlay ID
Throws:
OverlayException

getOverlayController

public static OverlayController getOverlayController()
Return the OverlayController for further tasks


getIDString

public java.lang.String getIDString()
Overlay ID string


put

public void put(java.lang.String keyStr,
                java.lang.String value,
                long ttl)
         throws OverlayException
Put a (key, value) pair to the overlay

Throws:
OverlayException

put

public void put(ow.id.ID key,
                java.io.Serializable value,
                long ttl)
         throws OverlayException
Put a real (key, value) pair to the overlay

Throws:
OverlayException

get

public java.util.Set get(ow.id.ID key)
Get a set of values from the overlay network for ID


get

public java.util.Set get(java.lang.String keyStr)
Get a set of values from the overlay network for a String ID


get

public java.util.Set get(ow.id.ID key,
                         ASG query)
Get a set of values from the overlay network for ID


getSelfIDAddressPair

public java.lang.String getSelfIDAddressPair()

getRoutingTableString

public java.lang.String getRoutingTableString()

getLastKeyString

public java.lang.String getLastKeyString()

getLastRouteString

public java.lang.String getLastRouteString()

getMyKeys

public java.util.Set getMyKeys()

getMyValues

public java.util.Set getMyValues(ow.id.ID key)

getMyValues

public java.util.Set getMyValues(java.lang.String key)

finalize

public void finalize()
Overrides:
finalize in class java.lang.Object