Project JXTA

net.jxta.impl.pipe
Class SecureOutputPipe

java.lang.Object
  extended bynet.jxta.impl.pipe.NonBlockingOutputPipe
      extended bynet.jxta.impl.pipe.SecureOutputPipe
All Implemented Interfaces:
EventListener, OutputPipe, PipeResolver.Listener, Runnable

class SecureOutputPipe
extends NonBlockingOutputPipe

This class implements the Secure non blocking Output Pipe


Nested Class Summary
(package private) static class NonBlockingOutputPipe.workerState
          Tracks the state of our worker thread.
 
Constructor Summary
SecureOutputPipe(PeerGroup group, PipeResolver resolver, PipeAdvertisement pipeAdv, PeerID destPeer, Set peers)
           
 
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)
          

We can't fail to send a message.

 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecureOutputPipe

public SecureOutputPipe(PeerGroup group,
                        PipeResolver resolver,
                        PipeAdvertisement pipeAdv,
                        PeerID destPeer,
                        Set peers)
                 throws IOException
Method Detail

send

public boolean send(Message msg)
             throws IOException

We can't fail to send a message. Secure pipes are expected to be reliable and ordered.

Specified by:
send in interface OutputPipe
Overrides:
send in class NonBlockingOutputPipe
Throws:
IOException

mkAddress

protected EndpointAddress mkAddress(ID destPeer,
                                    ID pipeID)
Convenience method for constructing a peer endpoint address from its peer id

Overrides:
mkAddress in class NonBlockingOutputPipe
Parameters:
destPeer - the desitnation peer
pipeID - the pipe to put in the param field.
Returns:
the pipe endpoint address.

finalize

protected void finalize()


close

public void close()

Specified by:
close in interface OutputPipe

isClosed

public boolean isClosed()

Specified by:
isClosed in interface OutputPipe

getType

public final String getType()

Specified by:
getType in interface OutputPipe

getPipeID

public final ID getPipeID()

Specified by:
getPipeID in interface OutputPipe

getName

public final String getName()

Specified by:
getName in interface OutputPipe

getAdvertisement

public final PipeAdvertisement getAdvertisement()

Specified by:
getAdvertisement in interface OutputPipe

run

public void run()

Sends the messages.

This method does a lot of things. It has several distinct states:

Acquire a messenger to the specified destination peer. If a messenger is acquired, then go to SENDMESSAGES state otherwise go to STARTMIGRATE.
STATE Activity
ACQUIREMESSENGER
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. If there are no messages to send for 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.

Specified by:
run in interface Runnable

pipeNAKEvent

public boolean pipeNAKEvent(PipeResolver.Event event)
A NAK Event was received for this pipe

Specified by:
pipeNAKEvent in interface PipeResolver.Listener
Returns:
true if the event was handled otherwise false

pipeResolveEvent

public boolean pipeResolveEvent(PipeResolver.Event event)
Pipe Resolve Event

Specified by:
pipeResolveEvent in interface PipeResolver.Listener
Returns:
true if the event was handled otherwise false

JXTA J2SE