|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.ac.ic.doc.automed.p2p.AutoMedMessagingHelper
public class AutoMedMessagingHelper
Field Summary | |
---|---|
private static java.util.Map |
_clients
|
private AutoMedPeer |
_mainPeer
|
private AbstractServer |
_peerDaemon
|
private TimedThread |
_peerDaemonThread
The companion peer daemon attached to every peer for handling other peer's request |
private static java.util.Map |
_servers
|
private SimpleMessageHandler |
_simpleHandler
|
private static java.util.Map |
_threads
|
private static java.lang.String |
TEMP_CLIENT
|
Constructor Summary | |
---|---|
AutoMedMessagingHelper(AutoMedPeer mainPeer)
Creates a new instance of AutoMedMessagingHelper |
Method Summary | |
---|---|
void |
clear()
|
static TimedThread |
createDaemon(java.lang.String id,
java.lang.String protocol,
int port,
RequestListener requestHandler,
boolean reuse)
Initiates a network daemon for an AutoMedPeer to listen to other peers' requests. |
void |
doCustomRequest(java.lang.String requestType,
java.lang.String protocol,
java.lang.String remoteAddress,
int remotePort,
int sleepTime,
boolean asynchronous)
Create a custom keep-alive messaging helper for an AutoMedPeer . |
void |
doRequest(java.lang.String requestType)
Utility method for performing specific P2P requests See Constants for a list of
OPT_* request types |
static void |
doRequest(java.lang.String id,
java.lang.String type,
AbstractMessage requestMessage,
java.lang.String protocol,
java.lang.String remoteAddress,
int remotePort,
RequestListener responseHandler,
int sleepTime,
boolean reuse,
boolean asynchronous,
boolean ackExpected)
Perform a network request on behalf of the client. |
static void |
doRequest(java.lang.String id,
java.lang.String type,
AbstractMessage requestMessage,
java.lang.String protocol,
java.lang.String remoteAddress,
int remotePort,
RequestListener responseHandler,
int sleepTime,
boolean reuse,
boolean asynchronous,
boolean ackExpected,
java.util.Properties props)
Perform a network request on behalf of the client. |
AbstractMessage |
doSimpleAnonymousRequest(AbstractMessage requestMessage,
PeerProcessDescription peerDesc)
Overloading method that accepts a PeerDescription object and finds
the destination port of this peer |
AbstractMessage |
doSimpleAnonymousRequest(AbstractMessage requestMessage,
java.lang.String remoteAddress,
int remotePort)
This overiding method works the same as {@link doSimpleAnonymousRequest( AbstractMessage requestMessage, String protocol, String remoteAddress, int remotePort) in that it uses the default protocol in the peer's configuration file |
AbstractMessage |
doSimpleAnonymousRequest(AbstractMessage requestMessage,
java.lang.String protocol,
java.lang.String remoteAddress,
int remotePort)
This overiding method is used for executing switched, synchronousrequests that expects a response. |
void |
doSimpleRequest(AbstractMessage requestMessage,
java.lang.String protocol,
java.lang.String remoteAddress,
int remotePort,
boolean asynchronous)
This overiding method is used for executing switched, synchronous/asynchronousrequests that does NOT expect a response . |
void |
doSimpleRequest(AbstractMessage requestMessage,
java.lang.String protocol,
java.lang.String remoteAddress,
int remotePort,
RequestListener responseHandler,
boolean asynchronous)
This overiding method is used for executing switched, synchronous/asynchronousrequests that expects a response . |
static void |
doSimpleRequest(java.lang.String id,
AbstractMessage requestMessage,
java.lang.String protocol,
java.lang.String remoteAddress,
int remotePort,
boolean reuse,
boolean asynchronous)
This overiding method is used for executing switched, synchronous/asynchronousrequests that does NOT expect a response . |
int |
getDaemonPort()
Get the daemon port as created by the system |
int |
getKeepAliveStatus()
Check keep-alive status |
void |
initMulticastDaemon(RequestListener handler)
Initiate a multicast daemon |
private void |
initPeerDaemon()
Initiate the main peer daemon |
void |
stopAll()
|
void |
terminateMsgProcess(java.lang.String id,
java.lang.String type)
Terminate an active messaging process |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private TimedThread _peerDaemonThread
private AbstractServer _peerDaemon
private static java.util.Map _clients
private static java.util.Map _threads
private static java.util.Map _servers
private AutoMedPeer _mainPeer
private static final java.lang.String TEMP_CLIENT
private SimpleMessageHandler _simpleHandler
Constructor Detail |
---|
public AutoMedMessagingHelper(AutoMedPeer mainPeer) throws AutoMedException
AutoMedException
Method Detail |
---|
private void initPeerDaemon() throws CommunicationException, AutoMedException
CommunicationException
AutoMedException
public void initMulticastDaemon(RequestListener handler) throws CommunicationException, AutoMedException
CommunicationException
AutoMedException
public int getDaemonPort() throws CommunicationException
CommunicationException
public AbstractMessage doSimpleAnonymousRequest(AbstractMessage requestMessage, PeerProcessDescription peerDesc) throws CommunicationException, AutoMedException
PeerDescription
object and finds
the destination port of this peer
CommunicationException
AutoMedException
public AbstractMessage doSimpleAnonymousRequest(AbstractMessage requestMessage, java.lang.String remoteAddress, int remotePort) throws CommunicationException, AutoMedException
CommunicationException
AutoMedException
public AbstractMessage doSimpleAnonymousRequest(AbstractMessage requestMessage, java.lang.String protocol, java.lang.String remoteAddress, int remotePort) throws CommunicationException, AutoMedException
#doSimpleRequest()
in that RequestListener
object is passed AbstractMessage
CommunicationException
AutoMedException
public void doSimpleRequest(AbstractMessage requestMessage, java.lang.String protocol, java.lang.String remoteAddress, int remotePort, RequestListener responseHandler, boolean asynchronous) throws CommunicationException, AutoMedException
CommunicationException
AutoMedException
public void doSimpleRequest(AbstractMessage requestMessage, java.lang.String protocol, java.lang.String remoteAddress, int remotePort, boolean asynchronous) throws CommunicationException, AutoMedException
CommunicationException
AutoMedException
public static void doSimpleRequest(java.lang.String id, AbstractMessage requestMessage, java.lang.String protocol, java.lang.String remoteAddress, int remotePort, boolean reuse, boolean asynchronous) throws CommunicationException, AutoMedException
CommunicationException
AutoMedException
public static void doRequest(java.lang.String id, java.lang.String type, AbstractMessage requestMessage, java.lang.String protocol, java.lang.String remoteAddress, int remotePort, RequestListener responseHandler, int sleepTime, boolean reuse, boolean asynchronous, boolean ackExpected) throws CommunicationException, AutoMedException
AutoMedPeer
and the network. It requires an instance of RequestListener
A request client can use either TCP or UDP protocol as specified by protocol
.
See Constants
for a list of network protocols.
There are two types of client as specified by type
(see
Constants
):
asynchcronous
is set to true then This method through the reuse
parameter also offers
the flexibility of reusing an existing switched client if one is available.
Not only does this save resources but also allow a degree of parallelism which allows multiple
requests to be sent and processed at the same time
id
- a unique name/id for the operationtype
- type of network client used for this operation (see note above)requestMessage
- an AbstractMessage
object representing the message to sendprotocol
- network protocol used (see note above)remoteAddress
- destination address to send toremotePort
- destination port to send toresponseHandler
- a RequestListener
object to handle responsessleepTime
- sleep time between two successive runs for dedicated client requestreuse
- whether reuse an existing network client if one exists? (see note)asynchronous
- whether to perform an asynchronous communication (see note)ackExpected
- whether or not to expect an acknowledgement response CommunicationException
AutoMedException
public static void doRequest(java.lang.String id, java.lang.String type, AbstractMessage requestMessage, java.lang.String protocol, java.lang.String remoteAddress, int remotePort, RequestListener responseHandler, int sleepTime, boolean reuse, boolean asynchronous, boolean ackExpected, java.util.Properties props) throws CommunicationException, AutoMedException
AutoMedPeer
and the network. It requires an instance of RequestListener
A request client can use either TCP or UDP protocol as specified by protocol
.
See Constants
for a list of network protocols.
There are two types of client as specified by type
(see
Constants
):
asynchcronous
is set to true then This method through the reuse
parameter also offers
the flexibility of reusing an existing switched client if one is available.
Not only does this save resources but also allow a degree of parallelism which allows multiple
requests to be sent and processed at the same time
id
- a unique name/id for the operationtype
- type of network client used for this operation (see note above)requestMessage
- an AbstractMessage
object representing the message to sendprotocol
- network protocol used (see note above)remoteAddress
- destination address to send toremotePort
- destination port to send toresponseHandler
- a RequestListener
object to handle responsessleepTime
- sleep time between two successive runs for dedicated client requestreuse
- whether reuse an existing network client if one exists? (see note)asynchronous
- whether to perform an asynchronous communication (see note)ackExpected
- whether or not to expect an acknowledgement response CommunicationException
AutoMedException
public void terminateMsgProcess(java.lang.String id, java.lang.String type)
public static TimedThread createDaemon(java.lang.String id, java.lang.String protocol, int port, RequestListener requestHandler, boolean reuse) throws CommunicationException, AutoMedException
AutoMedPeer
to listen to other peers' requestsRequestListener
objectAutoMedPeer
is typically associated with
CommunicationException
AutoMedException
public void doRequest(java.lang.String requestType) throws CommunicationException, AutoMedException
Constants
for a list of
OPT_* request types
CommunicationException
AutoMedException
public void doCustomRequest(java.lang.String requestType, java.lang.String protocol, java.lang.String remoteAddress, int remotePort, int sleepTime, boolean asynchronous) throws CommunicationException, AutoMedException
AutoMedPeer
. doRequest(String requestType)
instead.
CommunicationException
AutoMedException
public int getKeepAliveStatus()
public void stopAll()
public void clear()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |