Map<Object, Command> mergeCommands = null; int mergeCount = 1; final CommandCollector commandCollector = this.createGetCommandCollector(); currentCmd.setStatus(OperationStatus.WRITING); log.debug("Merge optimieze:merge " + mergeCount + " get commands"); return this.newMergedCommand(mergeCommands, mergeCount, commandCollector, expectedCommandType);
/** * merge buffers to fit socket's send buffer size * * @param currentCommand * @return * @throws InterruptedException */ @SuppressWarnings("unchecked") public final Command optimiezeMergeBuffer(Command optimiezeCommand, final Queue writeQueue, final Queue<Command> executingCmds, int sendBufferSize) { if (log.isDebugEnabled()) { log.debug("Optimieze merge buffer:" + optimiezeCommand.toString()); } if (this.optimiezeMergeBuffer && optimiezeCommand.getIoBuffer().remaining() < sendBufferSize - 24) { optimiezeCommand = this.mergeBuffer(optimiezeCommand, writeQueue, executingCmds, sendBufferSize); } return optimiezeCommand; }
/** * Merge get operation to multi-get operation * * @param currentCmd * @param mergeCommands * @return * @throws InterruptedException */ @SuppressWarnings("unchecked") public final Command optimiezeGet(final Queue writeQueue, final Queue<Command> executingCmds, Command optimiezeCommand) { if (optimiezeCommand.getCommandType() == CommandType.GET_ONE || optimiezeCommand.getCommandType() == CommandType.GETS_ONE) { if (this.optimiezeGet) { optimiezeCommand = this.mergeGetCommands(optimiezeCommand, writeQueue, executingCmds, optimiezeCommand.getCommandType()); } } return optimiezeCommand; }
@SuppressWarnings("unchecked") public Command optimize(final Command currentCommand, final Queue writeQueue, final Queue<Command> executingCmds, int sendBufferSize) { Command optimiezeCommand = currentCommand; optimiezeCommand = this.optimiezeGet(writeQueue, executingCmds, optimiezeCommand); optimiezeCommand = this.optimiezeSet(writeQueue, executingCmds, optimiezeCommand, sendBufferSize); optimiezeCommand = this.optimiezeMergeBuffer(optimiezeCommand, writeQueue, executingCmds, sendBufferSize); return optimiezeCommand; }
final List<Command> commands = this.getLocalList(); final ByteBuffer firstBuffer = firstCommand.getIoBuffer().buf(); int totalBytes = firstBuffer.remaining(); || nextCmd.getCommandType() == CommandType.GETS_ONE) && this.optimiezeGet) { nextCmd = this.mergeGetCommands(nextCmd, writeQueue, executingCmds, nextCmd.getCommandType());
public final Command optimiezeSet(final Queue writeQueue, final Queue<Command> executingCmds, Command optimiezeCommand, int sendBufferSize) { if (this.optimiezeSet && optimiezeCommand.getCommandType() == CommandType.SET && !optimiezeCommand.isNoreply() && this.protocol == Protocol.Binary) { optimiezeCommand = this.mergeSetCommands(optimiezeCommand, writeQueue, executingCmds, optimiezeCommand.getCommandType(), sendBufferSize); } return optimiezeCommand; }
public MemcachedConnector(Configuration configuration, MemcachedSessionLocator locator, BufferAllocator allocator, CommandFactory commandFactory, int poolSize, int maxQueuedNoReplyOperations) { super(configuration, null); this.sessionLocator = locator; this.protocol = commandFactory.getProtocol(); this.addStateListener(new InnerControllerStateListener()); this.updateSessions(); this.bufferAllocator = allocator; this.optimiezer = new Optimizer(this.protocol); this.optimiezer.setBufferAllocator(this.bufferAllocator); this.connectionPoolSize = poolSize; this.soLingerOn = true; this.commandFactory = commandFactory; this.flowControl = new FlowControl(maxQueuedNoReplyOperations); this.setSelectorPoolSize(configuration.getSelectorPoolSize()); // setDispatchMessageThreadPoolSize(Runtime.getRuntime(). // availableProcessors()); }
@SuppressWarnings("unchecked") public Command optimize(final Command currentCommand, final Queue writeQueue, final Queue<Command> executingCmds, int sendBufferSize) { Command optimiezeCommand = currentCommand; optimiezeCommand = this.optimiezeGet(writeQueue, executingCmds, optimiezeCommand); optimiezeCommand = this.optimiezeSet(writeQueue, executingCmds, optimiezeCommand, sendBufferSize); optimiezeCommand = this.optimiezeMergeBuffer(optimiezeCommand, writeQueue, executingCmds, sendBufferSize); return optimiezeCommand; }
final List<Command> commands = this.getLocalList(); final ByteBuffer firstBuffer = firstCommand.getIoBuffer().buf(); int totalBytes = firstBuffer.remaining(); || nextCmd.getCommandType() == CommandType.GETS_ONE) && this.optimiezeGet) { nextCmd = this.mergeGetCommands(nextCmd, writeQueue, executingCmds, nextCmd.getCommandType());
public final Command optimiezeSet(final Queue writeQueue, final Queue<Command> executingCmds, Command optimiezeCommand, int sendBufferSize) { if (this.optimiezeSet && optimiezeCommand.getCommandType() == CommandType.SET && !optimiezeCommand.isNoreply() && this.protocol == Protocol.Binary) { optimiezeCommand = this.mergeSetCommands(optimiezeCommand, writeQueue, executingCmds, optimiezeCommand.getCommandType(), sendBufferSize); } return optimiezeCommand; }
public MemcachedConnector(Configuration configuration, MemcachedSessionLocator locator, BufferAllocator allocator, CommandFactory commandFactory, int poolSize, int maxQueuedNoReplyOperations) { super(configuration, null); this.sessionLocator = locator; this.protocol = commandFactory.getProtocol(); this.addStateListener(new InnerControllerStateListener()); this.updateSessions(); this.bufferAllocator = allocator; this.optimiezer = new Optimizer(this.protocol); this.optimiezer.setBufferAllocator(this.bufferAllocator); this.connectionPoolSize = poolSize; this.soLingerOn = true; this.commandFactory = commandFactory; this.flowControl = new FlowControl(maxQueuedNoReplyOperations); this.setSelectorPoolSize(configuration.getSelectorPoolSize()); // setDispatchMessageThreadPoolSize(Runtime.getRuntime(). // availableProcessors()); }
Map<Object, Command> mergeCommands = null; int mergeCount = 1; final CommandCollector commandCollector = this.createGetCommandCollector(); currentCmd.setStatus(OperationStatus.WRITING); log.debug("Merge optimieze:merge " + mergeCount + " get commands"); return this.newMergedCommand(mergeCommands, mergeCount, commandCollector, expectedCommandType);
/** * Merge get operation to multi-get operation * * @param currentCmd * @param mergeCommands * @return * @throws InterruptedException */ @SuppressWarnings("unchecked") public final Command optimiezeGet(final Queue writeQueue, final Queue<Command> executingCmds, Command optimiezeCommand) { if (optimiezeCommand.getCommandType() == CommandType.GET_ONE || optimiezeCommand.getCommandType() == CommandType.GETS_ONE) { if (this.optimiezeGet) { optimiezeCommand = this.mergeGetCommands(optimiezeCommand, writeQueue, executingCmds, optimiezeCommand.getCommandType()); } } return optimiezeCommand; }
/** * merge buffers to fit socket's send buffer size * * @param currentCommand * @return * @throws InterruptedException */ @SuppressWarnings("unchecked") public final Command optimiezeMergeBuffer(Command optimiezeCommand, final Queue writeQueue, final Queue<Command> executingCmds, int sendBufferSize) { if (log.isDebugEnabled()) { log.debug("Optimieze merge buffer:" + optimiezeCommand.toString()); } if (this.optimiezeMergeBuffer && optimiezeCommand.getIoBuffer().remaining() < sendBufferSize - 24) { optimiezeCommand = this.mergeBuffer(optimiezeCommand, writeQueue, executingCmds, sendBufferSize); } return optimiezeCommand; }