Package io.undertow.server.protocol.http
Class PipeliningBufferingStreamSinkConduit
- java.lang.Object
-
- org.xnio.conduits.AbstractConduit<D>
-
- org.xnio.conduits.AbstractSinkConduit<D>
-
- org.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>
-
- io.undertow.server.protocol.http.PipeliningBufferingStreamSinkConduit
-
- All Implemented Interfaces:
org.xnio.conduits.Conduit
,org.xnio.conduits.SinkConduit
,org.xnio.conduits.StreamSinkConduit
public class PipeliningBufferingStreamSinkConduit extends org.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>
A buffer that is used when processing pipelined requests, that allows the server to buffer multiple responses into a single write() call.This can improve performance when pipelining requests.
- Author:
- Stuart Douglas
-
-
Constructor Summary
Constructors Constructor Description PipeliningBufferingStreamSinkConduit(org.xnio.conduits.StreamSinkConduit next, ByteBufferPool pool)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
awaitWritable()
void
awaitWritable(long time, java.util.concurrent.TimeUnit timeUnit)
void
exchangeComplete(HttpServerExchange exchange)
boolean
flush()
boolean
flushPipelinedData()
Flushes the cached data.void
setupPipelineBuffer(HttpServerExchange exchange)
Gets the channel wrapper that implements the bufferingvoid
terminateWrites()
long
transferFrom(java.nio.channels.FileChannel src, long position, long count)
long
transferFrom(org.xnio.channels.StreamSourceChannel source, long count, java.nio.ByteBuffer throughBuffer)
void
truncateWrites()
int
write(java.nio.ByteBuffer src)
long
write(java.nio.ByteBuffer[] srcs, int offset, int length)
int
writeFinal(java.nio.ByteBuffer src)
long
writeFinal(java.nio.ByteBuffer[] srcs, int offset, int length)
-
Methods inherited from class org.xnio.conduits.AbstractSinkConduit
getWriteThread, isWriteResumed, isWriteShutdown, resumeWrites, setWriteReadyHandler, suspendWrites, wakeupWrites
-
-
-
-
Constructor Detail
-
PipeliningBufferingStreamSinkConduit
public PipeliningBufferingStreamSinkConduit(org.xnio.conduits.StreamSinkConduit next, ByteBufferPool pool)
-
-
Method Detail
-
transferFrom
public long transferFrom(java.nio.channels.FileChannel src, long position, long count) throws java.io.IOException
- Specified by:
transferFrom
in interfaceorg.xnio.conduits.StreamSinkConduit
- Overrides:
transferFrom
in classorg.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>
- Throws:
java.io.IOException
-
transferFrom
public long transferFrom(org.xnio.channels.StreamSourceChannel source, long count, java.nio.ByteBuffer throughBuffer) throws java.io.IOException
- Specified by:
transferFrom
in interfaceorg.xnio.conduits.StreamSinkConduit
- Overrides:
transferFrom
in classorg.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>
- Throws:
java.io.IOException
-
write
public long write(java.nio.ByteBuffer[] srcs, int offset, int length) throws java.io.IOException
- Specified by:
write
in interfaceorg.xnio.conduits.StreamSinkConduit
- Overrides:
write
in classorg.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>
- Throws:
java.io.IOException
-
write
public int write(java.nio.ByteBuffer src) throws java.io.IOException
- Specified by:
write
in interfaceorg.xnio.conduits.StreamSinkConduit
- Overrides:
write
in classorg.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>
- Throws:
java.io.IOException
-
writeFinal
public int writeFinal(java.nio.ByteBuffer src) throws java.io.IOException
- Specified by:
writeFinal
in interfaceorg.xnio.conduits.StreamSinkConduit
- Overrides:
writeFinal
in classorg.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>
- Throws:
java.io.IOException
-
writeFinal
public long writeFinal(java.nio.ByteBuffer[] srcs, int offset, int length) throws java.io.IOException
- Specified by:
writeFinal
in interfaceorg.xnio.conduits.StreamSinkConduit
- Overrides:
writeFinal
in classorg.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>
- Throws:
java.io.IOException
-
flushPipelinedData
public boolean flushPipelinedData() throws java.io.IOException
Flushes the cached data.This should be called when a read thread fails to read any more request data, to make sure that any buffered data is flushed after the last pipelined request.
If this returns false the read thread should suspend reads and resume writes
- Returns:
true
If the flush succeeded, false otherwise- Throws:
java.io.IOException
-
setupPipelineBuffer
public void setupPipelineBuffer(HttpServerExchange exchange)
Gets the channel wrapper that implements the buffering
-
awaitWritable
public void awaitWritable(long time, java.util.concurrent.TimeUnit timeUnit) throws java.io.IOException
- Specified by:
awaitWritable
in interfaceorg.xnio.conduits.SinkConduit
- Overrides:
awaitWritable
in classorg.xnio.conduits.AbstractSinkConduit<org.xnio.conduits.StreamSinkConduit>
- Throws:
java.io.IOException
-
awaitWritable
public void awaitWritable() throws java.io.IOException
- Specified by:
awaitWritable
in interfaceorg.xnio.conduits.SinkConduit
- Overrides:
awaitWritable
in classorg.xnio.conduits.AbstractSinkConduit<org.xnio.conduits.StreamSinkConduit>
- Throws:
java.io.IOException
-
flush
public boolean flush() throws java.io.IOException
- Specified by:
flush
in interfaceorg.xnio.conduits.SinkConduit
- Overrides:
flush
in classorg.xnio.conduits.AbstractSinkConduit<org.xnio.conduits.StreamSinkConduit>
- Throws:
java.io.IOException
-
terminateWrites
public void terminateWrites() throws java.io.IOException
- Specified by:
terminateWrites
in interfaceorg.xnio.conduits.SinkConduit
- Overrides:
terminateWrites
in classorg.xnio.conduits.AbstractSinkConduit<org.xnio.conduits.StreamSinkConduit>
- Throws:
java.io.IOException
-
truncateWrites
public void truncateWrites() throws java.io.IOException
- Specified by:
truncateWrites
in interfaceorg.xnio.conduits.SinkConduit
- Overrides:
truncateWrites
in classorg.xnio.conduits.AbstractSinkConduit<org.xnio.conduits.StreamSinkConduit>
- Throws:
java.io.IOException
-
exchangeComplete
public void exchangeComplete(HttpServerExchange exchange)
-
-