anon.client
Class SequentialChannelDataChain

java.lang.Object
  extended by anon.client.AbstractDataChain
      extended by anon.client.SequentialChannelDataChain
All Implemented Interfaces:
AnonChannel, java.lang.Runnable, java.util.Observer

public class SequentialChannelDataChain
extends AbstractDataChain

Author:
Stefan Lieske

Nested Class Summary
private  class SequentialChannelDataChain.ChainCell
           
private  class SequentialChannelDataChain.InvalidChainCellException
           
private  class SequentialChannelDataChain.SendOrderProtocolData
           
 
Field Summary
private static int CHAIN_ID_LENGTH
           
private static short FLAG_CONNECTION_ERROR
           
private static short FLAG_FAST_RESPONSE
           
private static short FLAG_NEW_CHAIN
           
private static short FLAG_STREAM_CLOSED
           
private static short FLAG_UNKNOWN_CHAIN_ID
           
private  java.util.Vector m_associatedChannels
           
private  boolean m_chainClosed
           
private  byte[] m_chainId
           
private  long m_chainTimeout
           
private  boolean m_firstDownstreamPacket
           
private  int m_maximumOutputBlocksize
           
private  java.lang.Object m_sendSynchronization
           
 
Fields inherited from interface anon.AnonChannel
HTTP, SMTP, SOCKS
 
Constructor Summary
SequentialChannelDataChain(IDataChannelCreator a_channelCreator, DataChainErrorListener a_errorListener, long a_chainTimeout)
           
 
Method Summary
protected  void closeDataChain()
           
 void createPacketPayload(DataChainSendOrderStructure a_order)
           
 int getOutputBlockSize()
          Returns a value that indicates the current optimum size of data to write..
protected  void orderPacket(DataChainSendOrderStructure a_order)
           
private  void orderPacketInternal(DataChainSendOrderStructure a_order, boolean a_sendUpstreamClose, boolean a_enforceFastResponse)
           
protected  void outputStreamClosed()
           
 void run()
           
 
Methods inherited from class anon.client.AbstractDataChain
addInputStreamQueueEntry, close, createDataChannel, getInputStream, getMessageQueuesNotificationsList, getOutputStream, interruptDownstreamThread, isClosed, propagateConnectionError, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHAIN_ID_LENGTH

private static final int CHAIN_ID_LENGTH
See Also:
Constant Field Values

FLAG_UNKNOWN_CHAIN_ID

private static final short FLAG_UNKNOWN_CHAIN_ID
See Also:
Constant Field Values

FLAG_CONNECTION_ERROR

private static final short FLAG_CONNECTION_ERROR
See Also:
Constant Field Values

FLAG_NEW_CHAIN

private static final short FLAG_NEW_CHAIN
See Also:
Constant Field Values

FLAG_FAST_RESPONSE

private static final short FLAG_FAST_RESPONSE
See Also:
Constant Field Values

FLAG_STREAM_CLOSED

private static final short FLAG_STREAM_CLOSED
See Also:
Constant Field Values

m_associatedChannels

private java.util.Vector m_associatedChannels

m_firstDownstreamPacket

private boolean m_firstDownstreamPacket

m_chainId

private volatile byte[] m_chainId

m_maximumOutputBlocksize

private int m_maximumOutputBlocksize

m_sendSynchronization

private java.lang.Object m_sendSynchronization

m_chainClosed

private volatile boolean m_chainClosed

m_chainTimeout

private long m_chainTimeout
Constructor Detail

SequentialChannelDataChain

public SequentialChannelDataChain(IDataChannelCreator a_channelCreator,
                                  DataChainErrorListener a_errorListener,
                                  long a_chainTimeout)
Method Detail

getOutputBlockSize

public int getOutputBlockSize()
Description copied from interface: AnonChannel
Returns a value that indicates the current optimum size of data to write.. Because often anon services transport the data splited into packets for optimum performance it may be good to send data according to the packet size to avoid unneccessary overheads.

Specified by:
getOutputBlockSize in interface AnonChannel
Specified by:
getOutputBlockSize in class AbstractDataChain
Returns:
the current optimum size for output data. If 1 is returned the size does not matter.

createPacketPayload

public void createPacketPayload(DataChainSendOrderStructure a_order)
Specified by:
createPacketPayload in class AbstractDataChain

run

public void run()
Specified by:
run in interface java.lang.Runnable
Specified by:
run in class AbstractDataChain

orderPacket

protected void orderPacket(DataChainSendOrderStructure a_order)
Specified by:
orderPacket in class AbstractDataChain

orderPacketInternal

private void orderPacketInternal(DataChainSendOrderStructure a_order,
                                 boolean a_sendUpstreamClose,
                                 boolean a_enforceFastResponse)

outputStreamClosed

protected void outputStreamClosed()
                           throws java.io.IOException
Specified by:
outputStreamClosed in class AbstractDataChain
Throws:
java.io.IOException

closeDataChain

protected void closeDataChain()
Specified by:
closeDataChain in class AbstractDataChain