|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectuk.ac.ic.doc.automed.p2p.communication.AbstractRequestListener
uk.ac.ic.doc.automed.p2p.AutoMedPeer
public class AutoMedPeer
Represent the AutoMed Repository in this Java Virtual Machine (JVM)
as a peer on a peer-to-peer (P2P) network. Thus there should never
be more than one instance of this class in any JVM. For this to
function correctly, there must be a P2PRegistry running
on the local machine, and a directory.P2PDirectory running
on some host accesible by this peer.
4/2006: AutoMedPeer has been designed to act as both a peer and a directory service peer
| Nested Class Summary | |
|---|---|
static class |
AutoMedPeer.PeerProcessDescription
|
| Field Summary | |
|---|---|
protected AppToolKit.NodeConfig |
config
|
protected java.net.InetAddress |
peerAddress
|
protected int |
role
|
static int |
ROLE_AUTOMED_PEER
|
static int |
ROLE_DSP
|
static int |
ROLE_PEER
|
protected static AutoMedPeer |
thePeer
|
| Constructor Summary | |
|---|---|
protected |
AutoMedPeer(java.lang.String name,
PeerStateHandler stateHandler)
Create the one AutoMedPeer that is allowed in any JVM: to
prevent more than one being created, this is a private method, and
you must call #newAutoMedPeer() to create the peer. |
| Method Summary | |
|---|---|
void |
addRequestListener(RequestListener listener)
Register a RequestListener object for client requests |
void |
authenticate()
Authenticate using the authentication helper |
void |
close()
Close down the peer and its message handler, allowing another instance of this class to be created. |
static AutoMedPeer |
getAutoMedPeer()
Return the AutoMedPeer that represents the repository
in the JVM on the P2P network. |
PeerCache |
getCache()
Return the PeerCache that this AutoMedPeer keeps, containing
data fetched form the P2PDirectory of other peers and public
schemas. |
int |
getDaemonPort()
public boolean isRegistered() { return this.registered; } |
P2PDirectory |
getDirectory()
Return directory service object |
MessageHandler |
getMessageHandler()
|
AutoMedMessagingHelper |
getMessagingHelper()
Return reference to the AutoMedMessagingHelper object |
java.lang.String |
getName()
|
java.lang.String |
getPeerAddress()
Added by dmle 27/10/2005 to get a peer's IP address |
AppToolKit.NodeConfig |
getPeerConfig()
Return the configuration of the peer |
java.lang.String |
getPeerHost()
Added by dmle 27/10/2005 to get a peer's host name |
int |
getPeerPort(AutoMedPeer.PeerProcessDescription peerProcess,
boolean useCache)
|
int |
getPeerState()
Return the current state of the peer as managed by PeerStateHandler |
IQueryAggregator |
getQueryAggregator()
Return an instance of IQueryAggregator |
IQueryMediator |
getQueryMediator()
Return query mediator instance |
AbstractMessage |
getReplyForRequest(AbstractMessage request,
java.lang.String address,
int port)
|
int |
getRole()
Return this peer's role |
PeerStateHandler |
getStateHandler()
Return reference to state handler |
byte[] |
handleRequest(byte[] dataReceived,
ResponseHandler output)
Implements the method for handling network requests from other peers. |
void |
initAuthentication()
Initialise the authentication module |
P2PDirectory |
initDirectory()
This special method offers the flexibility of starting a P2PDirectoryobject for and 'attaching' it to a peer. |
void |
initDirectoryRepository()
This method allows a peer to indirectly re-initialises the directory repository used by the peer's P2PDirectory instance |
void |
initMessagingPeer()
Start the messaging clients in the background |
P2PRegistry |
initRegistry()
This special method offers the flexibility of starting a P2PRegistryobject for and 'attaching' it to a peer. |
static void |
initRepository()
Initialise the AutoMedPeer repository based on the default configuration fileloaded at a previous stage |
boolean |
isJoinedNetwork()
|
static AutoMedPeer |
newAutoMedPeer(java.lang.String name,
PeerStateHandler stateHandler)
Create a new AutoMedPeer if one does not already exist. |
void |
outputPathway(AbstractMessage message,
ResponseHandler output)
|
void |
outputPathwayToSource(AbstractMessage request,
ResponseHandler output)
Deprecated. use #outputSourcePathways(AbstractMessage request, OutputStream output)
to get multiple pathways |
void |
outputQuery(AbstractMessage request,
ResponseHandler output)
Use QEP protocol to execute the query |
void |
outputSchema(AbstractMessage request,
ResponseHandler output)
|
void |
outputSourcePathways(AbstractMessage request,
ResponseHandler output)
Output all possible pathways to all data sources attached to a given public schema |
void |
performStateAction(int newState)
Implements interface PeerStateListener |
void |
register()
|
AbstractMessage |
requestPathToSource(java.lang.String host,
java.lang.String peerName,
java.lang.String schemaName)
|
AbstractMessage |
requestPathway(java.lang.String host,
java.lang.String peerName,
java.lang.String fromSchema,
java.lang.String toSchema)
|
AbstractMessage |
requestQuery(java.lang.String host,
java.lang.String peerName,
java.lang.String schema,
java.lang.String query)
|
AbstractMessage |
requestSchema(java.lang.String host,
java.lang.String peerName,
java.lang.String schemaName)
|
AbstractMessage |
sendRequest(java.lang.String host,
java.lang.String peerName,
AbstractMessage message)
|
void |
setName(java.lang.String name)
Set a new name for peer |
void |
setPeerAddress(java.net.InetAddress address)
|
void |
setPeerState(int newState)
Return reference to PeerStateHandler object |
void |
unregister()
Notify directory server that this peer is logged out |
| 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, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static AutoMedPeer thePeer
protected java.net.InetAddress peerAddress
protected AppToolKit.NodeConfig config
protected int role
public static final int ROLE_AUTOMED_PEER
public static final int ROLE_DSP
public static final int ROLE_PEER
| Constructor Detail |
|---|
protected AutoMedPeer(java.lang.String name,
PeerStateHandler stateHandler)
throws StateChangedException,
AutoMedException
AutoMedPeer that is allowed in any JVM: to
prevent more than one being created, this is a private method, and
you must call #newAutoMedPeer() to create the peer.
StateChangedException
AutoMedException| Method Detail |
|---|
public void addRequestListener(RequestListener listener)
RequestListener object for client requests
public P2PRegistry initRegistry()
throws AutoMedException
P2PRegistryAutoMedPeer instance
AutoMedException
public P2PDirectory initDirectory()
throws AutoMedException
P2PDirectoryAutoMedPeer instance
AutoMedExceptionpublic P2PDirectory getDirectory()
public void initDirectoryRepository()
throws AutoMedException
P2PDirectory instance
AutoMedException
public void initAuthentication()
throws AutoMedException
AutoMedException
public static void initRepository()
throws AutoMedException
AutoMedPeer repository based on the default configuration file
AutoMedException
public void authenticate()
throws AuthenticationException
AuthenticationExceptionpublic void close()
public void unregister()
public static AutoMedPeer newAutoMedPeer(java.lang.String name,
PeerStateHandler stateHandler)
throws P2PException,
AutoMedException
AutoMedPeer if one does not already exist.
AutoMedPeer with the given name
P2PException - if an AutoMedPeer already exists for this JVM
java.io.IOException - if unable to connect the P2PRegistry
AutoMedExceptionpublic static AutoMedPeer getAutoMedPeer()
AutoMedPeer that represents the repository
in the JVM on the P2P network.
public MessageHandler getMessageHandler()
public AutoMedMessagingHelper getMessagingHelper()
AutoMedMessagingHelper object
public void setPeerState(int newState)
throws StateChangedException
PeerStateHandler object
StateChangedExceptionpublic int getPeerState()
PeerStateHandler
public PeerStateHandler getStateHandler()
public AppToolKit.NodeConfig getPeerConfig()
public void initMessagingPeer()
throws AutoMedException
AutoMedExceptionpublic void setName(java.lang.String name)
name - the new peer name
public AbstractMessage sendRequest(java.lang.String host,
java.lang.String peerName,
AbstractMessage message)
throws AutoMedException
host - peerName - message -
java.io.IOException
CommunicationException
AutoMedException
public AbstractMessage requestSchema(java.lang.String host,
java.lang.String peerName,
java.lang.String schemaName)
throws AutoMedException
AutoMedException
public AbstractMessage requestPathToSource(java.lang.String host,
java.lang.String peerName,
java.lang.String schemaName)
throws AutoMedException
AutoMedException
public AbstractMessage requestQuery(java.lang.String host,
java.lang.String peerName,
java.lang.String schema,
java.lang.String query)
throws AutoMedException
AutoMedException
public AbstractMessage requestPathway(java.lang.String host,
java.lang.String peerName,
java.lang.String fromSchema,
java.lang.String toSchema)
throws AutoMedException
AutoMedException
public AbstractMessage getReplyForRequest(AbstractMessage request,
java.lang.String address,
int port)
throws AutoMedException
AutoMedException
public int getPeerPort(AutoMedPeer.PeerProcessDescription peerProcess,
boolean useCache)
throws AutoMedException
AutoMedException
public void register()
throws AutoMedException
AutoMedException
public byte[] handleRequest(byte[] dataReceived,
ResponseHandler output)
throws CommunicationException
AbstractRequestListener abstract class.This handler is for server functions.
handleRequest in interface RequestListenerhandleRequest in class AbstractRequestListenerCommunicationException
public void outputPathway(AbstractMessage message,
ResponseHandler output)
throws CommunicationException
CommunicationException
public void outputSchema(AbstractMessage request,
ResponseHandler output)
throws CommunicationException
CommunicationException
public void outputSourcePathways(AbstractMessage request,
ResponseHandler output)
throws CommunicationException
CommunicationException
public void outputPathwayToSource(AbstractMessage request,
ResponseHandler output)
throws CommunicationException
#outputSourcePathways(AbstractMessage request, OutputStream output)
CommunicationException
public void outputQuery(AbstractMessage request,
ResponseHandler output)
throws CommunicationException
QEP protocol to execute the query
CommunicationExceptionpublic java.lang.String getName()
public int getRole()
public IQueryMediator getQueryMediator()
public IQueryAggregator getQueryAggregator()
IQueryAggregator
public int getDaemonPort()
public PeerCache getCache()
PeerCache that this AutoMedPeer keeps, containing
data fetched form the P2PDirectory of other peers and public
schemas.
public void setPeerAddress(java.net.InetAddress address)
public java.lang.String getPeerAddress()
public java.lang.String getPeerHost()
public boolean isJoinedNetwork()
public void performStateAction(int newState)
PeerStateListener
performStateAction in interface StateChangedListener
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||