Package net.rubyeye.xmemcached.impl
Class Optimizer
java.lang.Object
net.rubyeye.xmemcached.impl.Optimizer
- All Implemented Interfaces:
OptimizerMBean,MemcachedOptimizer
Memcached command optimizer,merge single-get comands to multi-get command,
merge ByteBuffers to fit the socket's sendBufferSize etc.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static class(package private) static interface(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static ThreadLocal<Optimizer.BinaryGetQCollector> private static final ThreadLocal<Optimizer.BinarySetQCollector> static final intprivate static final org.slf4j.Loggerprivate static final intprivate intprivate booleanprivate booleanprivate final booleanprivate Protocolprivate static ThreadLocal<Optimizer.KeyStringCollector> private final ThreadLocal<List<Command>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate Optimizer.CommandCollectorintbooleanbooleanprivate final CommandmergeBuffer(Command firstCommand, Queue writeQueue, Queue<Command> executingCmds, int sendBufferSize) private final CommandmergeGetCommands(Command currentCmd, Queue writeQueue, Queue<Command> executingCmds, CommandType expectedCommandType) private final CommandmergeSetCommands(Command currentCmd, Queue writeQueue, Queue<Command> executingCmds, CommandType expectedCommandType, int sendBufferSize) private CommandnewMergedCommand(Map<Object, Command> mergeCommands, int mergeCount, Optimizer.CommandCollector commandCollector, CommandType commandType) final CommandoptimiezeGet(Queue writeQueue, Queue<Command> executingCmds, Command optimiezeCommand) Merge get operation to multi-get operationfinal CommandoptimiezeMergeBuffer(Command optimiezeCommand, Queue writeQueue, Queue<Command> executingCmds, int sendBufferSize) merge buffers to fit socket's send buffer sizefinal CommandoptimiezeSet(Queue writeQueue, Queue<Command> executingCmds, Command optimiezeCommand, int sendBufferSize) optimize(Command currentCommand, Queue writeQueue, Queue<Command> executingCmds, int sendBufferSize) voidsetBufferAllocator(BufferAllocator bufferAllocator) voidsetMergeFactor(int mergeFactor) voidsetOptimizeGet(boolean optimiezeGet) voidsetOptimizeMergeBuffer(boolean optimiezeMergeBuffer)
-
Field Details
-
MARGIN
private static final int MARGIN- See Also:
-
DEFAULT_MERGE_FACTOR
public static final int DEFAULT_MERGE_FACTOR- See Also:
-
mergeFactor
private int mergeFactor -
optimiezeGet
private boolean optimiezeGet -
optimiezeSet
private final boolean optimiezeSet- See Also:
-
optimiezeMergeBuffer
private boolean optimiezeMergeBuffer -
log
private static final org.slf4j.Logger log -
protocol
-
threadLocal
-
BIN_SET_CMD_COLLECTOR_THREAD_LOCAL
-
TEXT_GET_CMD_COLLECTOR_THREAD_LOCAL
-
BIN_GET_CMD_COLLECTOR_THREAD_LOCAL
-
-
Constructor Details
-
Optimizer
-
-
Method Details
-
setBufferAllocator
- Specified by:
setBufferAllocatorin interfaceMemcachedOptimizer
-
getMergeFactor
public int getMergeFactor()- Specified by:
getMergeFactorin interfaceOptimizerMBean
-
setMergeFactor
public void setMergeFactor(int mergeFactor) - Specified by:
setMergeFactorin interfaceOptimizerMBean
-
isOptimizeGet
public boolean isOptimizeGet()- Specified by:
isOptimizeGetin interfaceOptimizerMBean
-
setOptimizeGet
public void setOptimizeGet(boolean optimiezeGet) - Specified by:
setOptimizeGetin interfaceOptimizerMBean
-
isOptimizeMergeBuffer
public boolean isOptimizeMergeBuffer()- Specified by:
isOptimizeMergeBufferin interfaceOptimizerMBean
-
setOptimizeMergeBuffer
public void setOptimizeMergeBuffer(boolean optimiezeMergeBuffer) - Specified by:
setOptimizeMergeBufferin interfaceOptimizerMBean
-
optimize
public Command optimize(Command currentCommand, Queue writeQueue, Queue<Command> executingCmds, int sendBufferSize) - Specified by:
optimizein interfaceMemcachedOptimizer
-
optimiezeMergeBuffer
public final Command optimiezeMergeBuffer(Command optimiezeCommand, Queue writeQueue, Queue<Command> executingCmds, int sendBufferSize) merge buffers to fit socket's send buffer size- Parameters:
currentCommand-- Returns:
- Throws:
InterruptedException
-
optimiezeGet
public final Command optimiezeGet(Queue writeQueue, Queue<Command> executingCmds, Command optimiezeCommand) Merge get operation to multi-get operation- Parameters:
currentCmd-mergeCommands-- Returns:
- Throws:
InterruptedException
-
optimiezeSet
-
mergeBuffer
-
getLocalList
-
mergeGetCommands
-
mergeSetCommands
-
createGetCommandCollector
-
newMergedCommand
private Command newMergedCommand(Map<Object, Command> mergeCommands, int mergeCount, Optimizer.CommandCollector commandCollector, CommandType commandType)
-