|
Project JXTA | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.jxta.impl.pipe.NonBlockingOutputPipe
class NonBlockingOutputPipe
An implementation of Ouput Pipe which sends messages on the pipe
asynchronously. The send() method for this implementation will
never block.
| Nested Class Summary | |
|---|---|
(package private) static class |
NonBlockingOutputPipe.workerState
Tracks the state of our worker thread. |
| Constructor Summary | |
|---|---|
NonBlockingOutputPipe(PeerGroup g,
PipeResolver r,
PipeAdvertisement pAdv,
PeerID destPeer,
Set peers)
Create a new output pipe |
|
| Method Summary | |
|---|---|
void |
close()
|
protected void |
finalize()
|
PipeAdvertisement |
getAdvertisement()
|
String |
getName()
|
ID |
getPipeID()
|
String |
getType()
|
boolean |
isClosed()
|
protected EndpointAddress |
mkAddress(ID destPeer,
ID pipeID)
Convenience method for constructing a peer endpoint address from its peer id |
boolean |
pipeNAKEvent(PipeResolver.Event event)
A NAK Event was received for this pipe |
boolean |
pipeResolveEvent(PipeResolver.Event event)
Pipe Resolve Event |
void |
run()
Sends the messages. |
boolean |
send(Message msg)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public NonBlockingOutputPipe(PeerGroup g,
PipeResolver r,
PipeAdvertisement pAdv,
PeerID destPeer,
Set peers)
g - peergroup we are working in.r - the piperesolver this pipe is bound to.pAdv - advertisement for the pipe we are supporting.destPeer - the peer this pipe is currently bound to.peers - the set of peers we allow this pipe to be bound to.| Method Detail |
|---|
protected void finalize()
finalize in class Objectpublic void close()
close in interface OutputPipepublic boolean isClosed()
isClosed in interface OutputPipepublic final String getType()
getType in interface OutputPipepublic final ID getPipeID()
getPipeID in interface OutputPipepublic final String getName()
getName in interface OutputPipepublic final PipeAdvertisement getAdvertisement()
getAdvertisement in interface OutputPipe
public boolean send(Message msg)
throws IOException
send in interface OutputPipeIOExceptionpublic void run()
This method does a lot of things. It has several distinct states:
| STATE | Activity |
|---|---|
| ACQUIREMESSENGER | Acquire a messenger to the specified destination peer. If a messenger is acquired, then go to SENDMESSAGES state otherwise go to STARTMIGRATE.|
| SENDMESSAGES | Send messages until queue is closed and all messages have
been sent. Go to state CLOSED when done. If the messenger
becomes closed then go to ACQUIREMESSENGER. IDLEWORKERLINGER
millisecondsthen the worker thread will exit. It will only be
restarted if another message is eventually enqueued. |
| STARTVERIFY | Starts a verification query(s) to the destination peer. This
state is activated after
PipeServiceImpl.VERIFYINTERVAL milliseconds of
sending messages. The query responses will be tracked in the
PENDINGVERIFY state. |
| STARTMIGRATE | Starts a query(s) for peers listening on this pipe. The query responses will be tracked in the PENDINGMIGRATE state. |
| PENDINGVERIFY | Issues query messages to verify that the destination peer is
still listening on the pipe. Queries are issued every
QUERYINTERVAL milliseconds. If a positive response
is received, go to state ACQUIREMESSENGER. If no response
is received within QUERYTIMEOUT milliseconds or a
negative response is received then go to state
STARTMIGRATE. |
| PENDINGMIGRATE | Issues query messages to find a new destination peer.
Queries are issued every QUERYINTERVAL milliseconds.
If a positive response is received, go to state
ACQUIREMESSENGER. If no positive response from an
eligible peer is received within QUERYTIMEOUT
milliseconds go to state CLOSED. |
| CLOSED | Exit the worker thread. |
run in interface Runnable
protected EndpointAddress mkAddress(ID destPeer,
ID pipeID)
destPeer - the desitnation peerpipeID - the pipe to put in the param field.
public boolean pipeNAKEvent(PipeResolver.Event event)
pipeNAKEvent in interface PipeResolver.Listenerpublic boolean pipeResolveEvent(PipeResolver.Event event)
pipeResolveEvent in interface PipeResolver.Listener
|
JXTA J2SE | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||