Top Description Inners Fields Constructors Methods
org.glassfish.grizzly.http.server.util

public Class HttpPipelineOptAddOn

extends Object
implements AddOn
Class Inheritance
All Implemented Interfaces
org.glassfish.grizzly.http.server.AddOn
Imports
java.io.IOException, java.util.Arrays, org.glassfish.grizzly.Buffer, .CompletionHandler, .Connection, .Context, .IOEventLifeCycleListener, .ThreadCache, org.glassfish.grizzly.asyncqueue.MessageCloner, .WritableMessage, org.glassfish.grizzly.attributes.Attribute, .AttributeBuilder, org.glassfish.grizzly.filterchain.BaseFilter, .FilterChainBuilder, .FilterChainContext, .NextAction, .TransportFilter, org.glassfish.grizzly.http.server.AddOn, .NetworkListener, org.glassfish.grizzly.memory.CompositeBuffer

The plugin, that optimizes processing of pipelined HTTP requests by buffering HTTP responses and then writing them as one operation. Please note, this addon is not thread-safe, so it can't be used with HTTP requests, that require asynchronous processing.
Author
Alexey Stashok

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
HttpPipelineOptAddOn.PlugFilter

The filter, that works as a plug in the FilterChain, and buffers output data before passing it down to a transport filter, which will write the data to network.

Field Summary

Modifier and TypeField and Description
private static final int
private final int
maxBufferSize

max number of response bytes to buffer before flush

Constructor Summary

AccessConstructor and Description
public
HttpPipelineOptAddOn()

Constructs HttpPipelineOptAddOn.

public
HttpPipelineOptAddOn(final int
the max number of response bytes to buffer before flush
maxBufferSize
)

Constructs HttpPipelineOptAddOn.

Method Summary

Modifier and TypeMethod and Description
public void
setup(final NetworkListener networkListener, final FilterChainBuilder builder)

Implements org.glassfish.grizzly.http.server.AddOn.setup.

The method, which will be invoked by HttpServer in order to initialize the AddOn on the passed NetworkListener.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_MAX_BUFFER_SIZEback to summary
private static final int DEFAULT_MAX_BUFFER_SIZE
maxBufferSizeback to summary
private final int maxBufferSize

max number of response bytes to buffer before flush

Constructor Detail

HttpPipelineOptAddOnback to summary
public HttpPipelineOptAddOn()

Constructs HttpPipelineOptAddOn.

HttpPipelineOptAddOnback to summary
public HttpPipelineOptAddOn(final int maxBufferSize)

Constructs HttpPipelineOptAddOn.

Parameters
maxBufferSize:int

the max number of response bytes to buffer before flush

Method Detail

setupback to summary
public void setup(final NetworkListener networkListener, final FilterChainBuilder builder)

Implements org.glassfish.grizzly.http.server.AddOn.setup.

Doc from org.glassfish.grizzly.http.server.AddOn.setup.

The method, which will be invoked by HttpServer in order to initialize the AddOn on the passed NetworkListener. Most of the time the AddOn implementation will update the passed NetworkListener's FilterChainBuilder by adding custom org.glassfish.grizzly.filterchain.Filter(s), which implement AddOn's logic.

Annotations
@Override
org.glassfish.grizzly.http.server.util back to summary

private Class HttpPipelineOptAddOn.PlugFilter

extends BaseFilter
Class Inheritance

The filter, that works as a plug in the FilterChain, and buffers output data before passing it down to a transport filter, which will write the data to network.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class

Field Summary

Modifier and TypeField and Description
private final int
private final Attribute<HttpPipelineOptAddOn.PlugFilter.Plug>

Constructor Summary

AccessConstructor and Description
public
PlugFilter(final int maxBufferSize, final AttributeBuilder builder)

Method Summary

Modifier and TypeMethod and Description
public NextAction
handleRead(final FilterChainContext ctx)

Overrides org.glassfish.grizzly.filterchain.BaseFilter.handleRead.

Implements org.glassfish.grizzly.filterchain.Filter.handleRead.

Execute a unit of processing work to be performed, when channel will become available for reading.

public NextAction
handleWrite(final FilterChainContext ctx)

Overrides org.glassfish.grizzly.filterchain.BaseFilter.handleWrite.

Implements org.glassfish.grizzly.filterchain.Filter.handleWrite.

Execute a unit of processing work to be performed, when some data should be written on channel.

Inherited from org.glassfish.grizzly.filterchain.BaseFilter:
createContextexceptionOccurredhandleAccepthandleClosehandleConnecthandleEventonAddedonFilterChainChangedonRemovedtoString

Field Detail

maxBufferSizeback to summary
private final int maxBufferSize
plugAttrback to summary
private final Attribute<HttpPipelineOptAddOn.PlugFilter.Plug> plugAttr

Constructor Detail

PlugFilterback to summary
public PlugFilter(final int maxBufferSize, final AttributeBuilder builder)

Method Detail

handleReadback to summary
public NextAction handleRead(final FilterChainContext ctx) throws IOException

Overrides org.glassfish.grizzly.filterchain.BaseFilter.handleRead.

Implements org.glassfish.grizzly.filterchain.Filter.handleRead.

Doc from org.glassfish.grizzly.filterchain.BaseFilter.handleRead.

Execute a unit of processing work to be performed, when channel will become available for reading. This Filter may either complete the required processing and return false, or delegate remaining processing to the next Filter in a FilterChain containing this Filter by returning true.

Annotations
@Override
handleWriteback to summary
public NextAction handleWrite(final FilterChainContext ctx) throws IOException

Overrides org.glassfish.grizzly.filterchain.BaseFilter.handleWrite.

Implements org.glassfish.grizzly.filterchain.Filter.handleWrite.

Doc from org.glassfish.grizzly.filterchain.BaseFilter.handleWrite.

Execute a unit of processing work to be performed, when some data should be written on channel. This Filter may either complete the required processing and return false, or delegate remaining processing to the next Filter in a FilterChain containing this Filter by returning true.

Annotations
@Override
@SuppressWarnings:unchecked
org.glassfish.grizzly.http.server.util back to summary

public final Class HttpPipelineOptAddOn.PlugFilter.AggrCompletionHandler

extends Object
implements CompletionHandler
Class Inheritance
  • java.lang.Object
  • org.glassfish.grizzly.http.server.util.HttpPipelineOptAddOn.PlugFilter.AggrCompletionHandler
All Implemented Interfaces
org.glassfish.grizzly.CompletionHandler

Field Summary

Modifier and TypeField and Description
private CompletionHandler<E>[]
private int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
add(final CompletionHandler<E> handler)

public void
cancelled()

Implements org.glassfish.grizzly.CompletionHandler.cancelled.

The operation was cancelled.

public void
public void
completed(final Object result)

Implements org.glassfish.grizzly.CompletionHandler.completed.

The operation was completed.

private void
public void
failed(final Throwable throwable)

Implements org.glassfish.grizzly.CompletionHandler.failed.

The operation was failed.

public void
updated(final Object result)

Implements org.glassfish.grizzly.CompletionHandler.updated.

The callback method may be called, when there is some progress in operation execution, but it is still not completed

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

handlersback to summary
private CompletionHandler<E>[] handlers
szback to summary
private int sz

Constructor Detail

AggrCompletionHandlerback to summary
public AggrCompletionHandler()

Method Detail

addback to summary
public void add(final CompletionHandler<E> handler)
cancelledback to summary
public void cancelled()

Implements org.glassfish.grizzly.CompletionHandler.cancelled.

Doc from org.glassfish.grizzly.CompletionHandler.cancelled.

The operation was cancelled.

Annotations
@Override
clearback to summary
public void clear()
completedback to summary
public void completed(final Object result)

Implements org.glassfish.grizzly.CompletionHandler.completed.

Doc from org.glassfish.grizzly.CompletionHandler.completed.

The operation was completed.

Annotations
@Override
@SuppressWarnings:unchecked
ensureSizeback to summary
private void ensureSize()
failedback to summary
public void failed(final Throwable throwable)

Implements org.glassfish.grizzly.CompletionHandler.failed.

Doc from org.glassfish.grizzly.CompletionHandler.failed.

The operation was failed.

Annotations
@Override
updatedback to summary
public void updated(final Object result)

Implements org.glassfish.grizzly.CompletionHandler.updated.

Doc from org.glassfish.grizzly.CompletionHandler.updated.

The callback method may be called, when there is some progress in operation execution, but it is still not completed

Annotations
@Override
@SuppressWarnings:unchecked
org.glassfish.grizzly.http.server.util back to summary

public Class HttpPipelineOptAddOn.PlugFilter.Plug

extends Adapter
Class Inheritance

Constructor Summary

AccessConstructor and Description
public
Plug()

Method Summary

Modifier and TypeMethod and Description
private boolean
append(final Buffer msg, final CompletionHandler<E> completionHandler)

Appends buffer to the queue.

public static HttpPipelineOptAddOn.PlugFilter.Plug
private void
flush()

flushes buffered data

pack-priv HttpPipelineOptAddOn.PlugFilter.Plug
private HttpPipelineOptAddOn.PlugFilter.AggrCompletionHandler
private CompositeBuffer
public void
public void
public void
private void
private int
size()

private void
unplug(final Context context)

Releases the plug, which means we have to flush all the data and remove the PlugFilter attr from the context.

Inherited from org.glassfish.grizzly.IOEventLifeCycleListener.Adapter:
onContextResumeonErroronLeaveonNotRunonReregisteronRerunonTerminate

Field Detail

aggrCompletionHandlerback to summary
private HttpPipelineOptAddOn.PlugFilter.AggrCompletionHandler aggrCompletionHandler
bufferback to summary
private CompositeBuffer buffer
CACHE_IDXback to summary
private static final ThreadCache.CachedTypeIndex<HttpPipelineOptAddOn.PlugFilter.Plug> CACHE_IDX
clonerback to summary
private final MessageCloner<Buffer> cloner
ctxback to summary
private FilterChainContext ctx
isPluggedback to summary
private boolean isPlugged
isWrittenInThisThreadback to summary
private boolean isWrittenInThisThread
plugFilterback to summary
private HttpPipelineOptAddOn.PlugFilter plugFilter

Constructor Detail

Plugback to summary
public Plug()

Method Detail

appendback to summary
private boolean append(final Buffer msg, final CompletionHandler<E> completionHandler)

Appends buffer to the queue.

createback to summary
public static HttpPipelineOptAddOn.PlugFilter.Plug create(final FilterChainContext ctx, final HttpPipelineOptAddOn.PlugFilter plugFilter)
flushback to summary
private void flush()

flushes buffered data

Annotations
@SuppressWarnings:unchecked
initback to summary
pack-priv HttpPipelineOptAddOn.PlugFilter.Plug init(final FilterChainContext ctx, final HttpPipelineOptAddOn.PlugFilter plugFilter)
obtainAggrCompletionHandlerback to summary
private HttpPipelineOptAddOn.PlugFilter.AggrCompletionHandler obtainAggrCompletionHandler()
obtainCompositeBufferback to summary
private CompositeBuffer obtainCompositeBuffer()
onCompleteback to summary
public void onComplete(final Context context, final Object data) throws IOException

Overrides org.glassfish.grizzly.IOEventLifeCycleListener.Adapter.onComplete.

Implements org.glassfish.grizzly.IOEventLifeCycleListener.onComplete.

Doc from org.glassfish.grizzly.IOEventLifeCycleListener.Adapter.onComplete.

IOEvent processing completed.

Annotations
@Override
Exceptions
IOException:

Doc from org.glassfish.grizzly.IOEventLifeCycleListener.onComplete.

on error

onContextManualIOEventControlback to summary
public void onContextManualIOEventControl(final Context context) throws IOException

Overrides org.glassfish.grizzly.IOEventLifeCycleListener.Adapter.onContextManualIOEventControl.

Implements org.glassfish.grizzly.IOEventLifeCycleListener.onContextManualIOEventControl.

Doc from org.glassfish.grizzly.IOEventLifeCycleListener.Adapter.onContextManualIOEventControl.

Processing switched to the manual IOEvent control. Connection#enableIOEvent(org.glassfish.grizzly.IOEvent) or Connection#disableIOEvent(org.glassfish.grizzly.IOEvent) might be explicitly called.

Annotations
@Override
onContextSuspendback to summary
public void onContextSuspend(final Context context) throws IOException

Overrides org.glassfish.grizzly.IOEventLifeCycleListener.Adapter.onContextSuspend.

Implements org.glassfish.grizzly.IOEventLifeCycleListener.onContextSuspend.

Doc from org.glassfish.grizzly.IOEventLifeCycleListener.Adapter.onContextSuspend.

IOEvent processing suspended.

Annotations
@Override
Exceptions
IOException:

Doc from org.glassfish.grizzly.IOEventLifeCycleListener.onContextSuspend.

on error

recycleback to summary
private void recycle()
sizeback to summary
private int size()
unplugback to summary
private void unplug(final Context context)

Releases the plug, which means we have to flush all the data and remove the PlugFilter attr from the context.