Package net.i2p.client.streaming.impl
Class MessageOutputStream
- java.lang.Object
- 
- java.io.OutputStream
- 
- net.i2p.client.streaming.impl.MessageOutputStream
 
 
- 
- All Implemented Interfaces:
- Closeable,- Flushable,- AutoCloseable
 
 class MessageOutputStream extends OutputStream A stream that we can shove data into that fires off those bytes on flush or when the buffer is full. It also blocks according to the data receiver's needs.MessageOutputStream -> ConnectionDataReceiver -> Connection -> PacketQueue -> I2PSession 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static interfaceMessageOutputStream.DataReceiverDefine a component to receive data flushed from this streamstatic interfaceMessageOutputStream.WriteStatusDefine a way to detect the status of a write
 - 
Constructor SummaryConstructors Constructor Description MessageOutputStream(I2PAppContext ctx, SimpleTimer2 timer, MessageOutputStream.DataReceiver receiver, int bufSize, int initBufSize)MessageOutputStream(I2PAppContext ctx, SimpleTimer2 timer, MessageOutputStream.DataReceiver receiver, int bufSize, int initBufSize, int passiveFlushDelay)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()This does a flush, and BLOCKS until the CLOSE packet is acked.voidcloseInternal()nonblocking close - Only for use inside package(package private) voiddestroy()voidflush()Flush the data already queued up, blocking only if the outbound window is full.(package private) voidflushAvailable(MessageOutputStream.DataReceiver target)called whenever the engine wants to push more data to the peer(package private) voidflushAvailable(MessageOutputStream.DataReceiver target, boolean blocking)booleangetClosed()intgetWriteTimeout()voidsetBufferSize(int size)Caller should enforce a sane minimum.voidsetWriteTimeout(int ms)(package private) voidstreamErrorOccurred(IOException ioe)voidwrite(byte[] b)voidwrite(byte[] b, int off, int len)voidwrite(int b)- 
Methods inherited from class java.io.OutputStreamnullOutputStream
 
- 
 
- 
- 
- 
Constructor Detail- 
MessageOutputStreampublic MessageOutputStream(I2PAppContext ctx, SimpleTimer2 timer, MessageOutputStream.DataReceiver receiver, int bufSize, int initBufSize) 
 - 
MessageOutputStreampublic MessageOutputStream(I2PAppContext ctx, SimpleTimer2 timer, MessageOutputStream.DataReceiver receiver, int bufSize, int initBufSize, int passiveFlushDelay) 
 
- 
 - 
Method Detail- 
setWriteTimeoutpublic void setWriteTimeout(int ms) 
 - 
getWriteTimeoutpublic int getWriteTimeout() 
 - 
setBufferSizepublic void setBufferSize(int size) Caller should enforce a sane minimum.- Parameters:
- size- must be greater than 0, and smaller than or equal to bufSize in constructor
 
 - 
writepublic void write(byte[] b) throws IOException- Overrides:
- writein class- OutputStream
- Throws:
- IOException
 
 - 
writepublic void write(byte[] b, int off, int len) throws IOException- Overrides:
- writein class- OutputStream
- Throws:
- IOException
 
 - 
writepublic void write(int b) throws IOException- Specified by:
- writein class- OutputStream
- Throws:
- IOException
 
 - 
flushpublic void flush() throws IOExceptionFlush the data already queued up, blocking only if the outbound window is full. Prior to 0.8.1, this blocked until "delivered". "Delivered" meant "received an ACK from the far end", which is not the commom implementation of flush(), and really hurt the performance of i2psnark, which flush()ed frequently. Calling flush() would cause a complete window stall. As of 0.8.1, only wait for accept into the streaming output queue. This will speed up snark significantly, and allow us to flush() the initial data in I2PTunnelRunner, saving 250 ms.- Specified by:
- flushin interface- Flushable
- Overrides:
- flushin class- OutputStream
- Throws:
- IOException- if the write fails
 
 - 
closepublic void close() throws IOExceptionThis does a flush, and BLOCKS until the CLOSE packet is acked.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Overrides:
- closein class- OutputStream
- Throws:
- IOException
 
 - 
closeInternalpublic void closeInternal() nonblocking close - Only for use inside package
 - 
getClosedpublic boolean getClosed() 
 - 
streamErrorOccurredvoid streamErrorOccurred(IOException ioe) 
 - 
flushAvailablevoid flushAvailable(MessageOutputStream.DataReceiver target) throws IOException called whenever the engine wants to push more data to the peer- Throws:
- IOException
 
 - 
flushAvailablevoid flushAvailable(MessageOutputStream.DataReceiver target, boolean blocking) throws IOException - Throws:
- IOException
 
 - 
destroyvoid destroy() 
 
- 
 
-