Package org.glassfish.grizzly.utils
Class IdleTimeoutFilter
- java.lang.Object
-
- org.glassfish.grizzly.filterchain.BaseFilter
-
- org.glassfish.grizzly.utils.IdleTimeoutFilter
-
- All Implemented Interfaces:
Filter
public class IdleTimeoutFilter extends BaseFilter
The Filter is responsible for trackingConnectionactivity and closingConnectiononce it becomes idle for certain amount of time. UnlikeActivityCheckFilter, this Filter assumesConnectionis idle, when no event is being executed on it. But if some event processing was suspended - this Filter still assumesConnectionis active.- Author:
- Alexey Stashok
- See Also:
ActivityCheckFilter
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceIdleTimeoutFilter.TimeoutHandlerstatic interfaceIdleTimeoutFilter.TimeoutResolver
-
Field Summary
Fields Modifier and Type Field Description static LongFOREVERstatic LongFOREVER_SPECIALstatic StringIDLE_ATTRIBUTE_NAME
-
Constructor Summary
Constructors Modifier Constructor Description IdleTimeoutFilter(DelayedExecutor executor, long timeout, TimeUnit timeoutUnit)IdleTimeoutFilter(DelayedExecutor executor, long timeout, TimeUnit timeUnit, IdleTimeoutFilter.TimeoutHandler handler)protectedIdleTimeoutFilter(DelayedExecutor executor, DelayedExecutor.Worker<Connection> worker, IdleTimeoutFilter.TimeoutResolver timeoutResolver)IdleTimeoutFilter(DelayedExecutor executor, IdleTimeoutFilter.TimeoutResolver timeoutResolver)IdleTimeoutFilter(DelayedExecutor executor, IdleTimeoutFilter.TimeoutResolver timeoutResolver, IdleTimeoutFilter.TimeoutHandler handler)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DelayedExecutorcreateDefaultIdleDelayedExecutor()static DelayedExecutorcreateDefaultIdleDelayedExecutor(long checkInterval, TimeUnit checkIntervalUnit)DelayedExecutor.Resolver<Connection>getResolver()NextActionhandleAccept(FilterChainContext ctx)Execute a unit of processing work to be performed, when server channel has accepted the client connection.NextActionhandleClose(FilterChainContext ctx)Execute a unit of processing work to be performed, when connection has been closed.NextActionhandleConnect(FilterChainContext ctx)Execute a unit of processing work to be performed, when channel gets connected.NextActionhandleRead(FilterChainContext ctx)Execute a unit of processing work to be performed, when channel will become available for reading.NextActionhandleWrite(FilterChainContext ctx)Execute a unit of processing work to be performed, when some data should be written on channel.protected voidqueueAction(FilterChainContext ctx)static voidsetCustomTimeout(Connection connection, long timeout, TimeUnit timeunit)Provides an override mechanism for the default timeout.-
Methods inherited from class org.glassfish.grizzly.filterchain.BaseFilter
createContext, exceptionOccurred, handleEvent, onAdded, onFilterChainChanged, onRemoved, toString
-
-
-
-
Field Detail
-
FOREVER
public static final Long FOREVER
-
FOREVER_SPECIAL
public static final Long FOREVER_SPECIAL
-
IDLE_ATTRIBUTE_NAME
public static final String IDLE_ATTRIBUTE_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
IdleTimeoutFilter
public IdleTimeoutFilter(DelayedExecutor executor, long timeout, TimeUnit timeoutUnit)
-
IdleTimeoutFilter
public IdleTimeoutFilter(DelayedExecutor executor, IdleTimeoutFilter.TimeoutResolver timeoutResolver)
-
IdleTimeoutFilter
public IdleTimeoutFilter(DelayedExecutor executor, long timeout, TimeUnit timeUnit, IdleTimeoutFilter.TimeoutHandler handler)
-
IdleTimeoutFilter
public IdleTimeoutFilter(DelayedExecutor executor, IdleTimeoutFilter.TimeoutResolver timeoutResolver, IdleTimeoutFilter.TimeoutHandler handler)
-
IdleTimeoutFilter
protected IdleTimeoutFilter(DelayedExecutor executor, DelayedExecutor.Worker<Connection> worker, IdleTimeoutFilter.TimeoutResolver timeoutResolver)
-
-
Method Detail
-
handleAccept
public NextAction handleAccept(FilterChainContext ctx) throws IOException
Description copied from class:BaseFilterExecute a unit of processing work to be performed, when server channel has accepted the client connection. ThisFiltermay either complete the required processing and return false, or delegate remaining processing to the nextFilterin aFilterChaincontaining thisFilterby returning true.- Specified by:
handleAcceptin interfaceFilter- Overrides:
handleAcceptin classBaseFilter- Parameters:
ctx-FilterChainContext- Returns:
NextActioninstruction forFilterChain, how it should continue the execution- Throws:
IOException
-
handleConnect
public NextAction handleConnect(FilterChainContext ctx) throws IOException
Description copied from class:BaseFilterExecute a unit of processing work to be performed, when channel gets connected. ThisFiltermay either complete the required processing and return false, or delegate remaining processing to the nextFilterin aFilterChaincontaining thisFilterby returning true.- Specified by:
handleConnectin interfaceFilter- Overrides:
handleConnectin classBaseFilter- Parameters:
ctx-FilterChainContext- Returns:
NextActioninstruction forFilterChain, how it should continue the execution- Throws:
IOException
-
handleRead
public NextAction handleRead(FilterChainContext ctx) throws IOException
Description copied from class:BaseFilterExecute a unit of processing work to be performed, when channel will become available for reading. ThisFiltermay either complete the required processing and return false, or delegate remaining processing to the nextFilterin aFilterChaincontaining thisFilterby returning true.- Specified by:
handleReadin interfaceFilter- Overrides:
handleReadin classBaseFilter- Parameters:
ctx-FilterChainContext- Returns:
NextActioninstruction forFilterChain, how it should continue the execution- Throws:
IOException
-
handleWrite
public NextAction handleWrite(FilterChainContext ctx) throws IOException
Description copied from class:BaseFilterExecute a unit of processing work to be performed, when some data should be written on channel. ThisFiltermay either complete the required processing and return false, or delegate remaining processing to the nextFilterin aFilterChaincontaining thisFilterby returning true.- Specified by:
handleWritein interfaceFilter- Overrides:
handleWritein classBaseFilter- Parameters:
ctx-FilterChainContext- Returns:
NextActioninstruction forFilterChain, how it should continue the execution- Throws:
IOException
-
handleClose
public NextAction handleClose(FilterChainContext ctx) throws IOException
Description copied from class:BaseFilterExecute a unit of processing work to be performed, when connection has been closed. ThisFiltermay either complete the required processing and return false, or delegate remaining processing to the nextFilterin aFilterChaincontaining thisFilterby returning true.- Specified by:
handleClosein interfaceFilter- Overrides:
handleClosein classBaseFilter- Parameters:
ctx-FilterChainContext- Returns:
NextActioninstruction forFilterChain, how it should continue the execution- Throws:
IOException
-
getResolver
public DelayedExecutor.Resolver<Connection> getResolver()
-
createDefaultIdleDelayedExecutor
public static DelayedExecutor createDefaultIdleDelayedExecutor()
-
createDefaultIdleDelayedExecutor
public static DelayedExecutor createDefaultIdleDelayedExecutor(long checkInterval, TimeUnit checkIntervalUnit)
-
setCustomTimeout
public static void setCustomTimeout(Connection connection, long timeout, TimeUnit timeunit)
Provides an override mechanism for the default timeout.- Parameters:
connection- TheConnectionwhich is having the idle detection adjusted.timeout- the new idle timeout.timeunit-TimeUnit.
-
queueAction
protected void queueAction(FilterChainContext ctx)
-
-