public class MemcachedClientFilter
extends org.glassfish.grizzly.filterchain.BaseFilter
Filter implementation for memcached
This filter has an unbounded BlockingQueue per a connection for storing user's request.
When the response will be received, the corresponding request will be removed in queue
and the filter will pass the complete result to original request and notify the waiting sender.
If the memcached's command is a kind of quiet's, it is possible for the server not to send the response to client.
Then the filter skips the quiet request with MemcachedClientFilter.ParsingStatus.NO_REPLY status and processes next request.
This filter has two options.
1) localParsingOptimizing:
the input buffer has more than 1 complete memcached message,
the filter will parse the input buffer continuously in the same thread and local loop
without going through filter chains and spliting up the input buffer if this flag is true.
2) onceAllocationOptimizing:
Before multi-command(bulk-command) like getMulti and setMulti will be sent to the server, individual packets should be allocated.
If this flag is true, the filter will calculate the total buffer size of individual requests in advance
and will allocate only a Buffer once.| Modifier and Type | Class and Description |
|---|---|
static class |
MemcachedClientFilter.ParsingStatus |
| Constructor and Description |
|---|
MemcachedClientFilter() |
MemcachedClientFilter(boolean localParsingOptimizing,
boolean onceAllocationOptimizing) |
| Modifier and Type | Method and Description |
|---|---|
<V> V |
getCorrelatedResponse(org.glassfish.grizzly.Connection connection,
MemcachedRequest request,
long timeoutInMillis) |
<K,V> Map<K,V> |
getMultiResponse(org.glassfish.grizzly.Connection connection,
MemcachedRequest[] requests,
long timeoutInMillis,
Map<K,V> result) |
org.glassfish.grizzly.filterchain.NextAction |
handleClose(org.glassfish.grizzly.filterchain.FilterChainContext ctx) |
org.glassfish.grizzly.filterchain.NextAction |
handleRead(org.glassfish.grizzly.filterchain.FilterChainContext ctx) |
org.glassfish.grizzly.filterchain.NextAction |
handleWrite(org.glassfish.grizzly.filterchain.FilterChainContext ctx) |
public MemcachedClientFilter()
public MemcachedClientFilter(boolean localParsingOptimizing,
boolean onceAllocationOptimizing)
public org.glassfish.grizzly.filterchain.NextAction handleRead(org.glassfish.grizzly.filterchain.FilterChainContext ctx)
throws IOException
handleRead in interface org.glassfish.grizzly.filterchain.FilterhandleRead in class org.glassfish.grizzly.filterchain.BaseFilterIOExceptionpublic org.glassfish.grizzly.filterchain.NextAction handleWrite(org.glassfish.grizzly.filterchain.FilterChainContext ctx)
throws IOException
handleWrite in interface org.glassfish.grizzly.filterchain.FilterhandleWrite in class org.glassfish.grizzly.filterchain.BaseFilterIOExceptionpublic org.glassfish.grizzly.filterchain.NextAction handleClose(org.glassfish.grizzly.filterchain.FilterChainContext ctx)
throws IOException
handleClose in interface org.glassfish.grizzly.filterchain.FilterhandleClose in class org.glassfish.grizzly.filterchain.BaseFilterIOExceptionpublic <K,V> Map<K,V> getMultiResponse(org.glassfish.grizzly.Connection connection, MemcachedRequest[] requests, long timeoutInMillis, Map<K,V> result) throws InterruptedException, TimeoutException
InterruptedExceptionTimeoutExceptionpublic <V> V getCorrelatedResponse(org.glassfish.grizzly.Connection connection,
MemcachedRequest request,
long timeoutInMillis)
throws InterruptedException,
TimeoutException
InterruptedExceptionTimeoutExceptionCopyright © 2015 Project Grizzly. All Rights Reserved.