currentCmd.setStatus(OperationStatus.WRITING); commandCollector.visit(currentCmd); while (mergeCount < this.mergeFactor) { Command nextCmd = (Command) writeQueue.peek(); commandCollector.visit(nextCmd); mergeCommands.put(removedCommand.getKey(), removedCommand); return currentCmd; } else { commandCollector.finish(); if (log.isDebugEnabled()) { log.debug("Merge optimieze:merge " + mergeCount + " get commands");
currentCmd.setStatus(OperationStatus.WRITING); int totalBytes = currentCmd.getIoBuffer().remaining(); commandCollector.visit(currentCmd); while (mergeCount < this.mergeFactor && totalBytes <= sendBufferSize) { Command nextCmd = (Command) writeQueue.peek(); writeQueue.remove(); commandCollector.visit(nextCmd); return currentCmd; } else { commandCollector.finish(); if (log.isDebugEnabled()) { log.debug("Merge optimieze:merge " + mergeCount + " get commands"); return (Command) commandCollector.getResult();
currentCmd.setStatus(OperationStatus.WRITING); commandCollector.visit(currentCmd); while (mergeCount < this.mergeFactor) { Command nextCmd = (Command) writeQueue.peek(); commandCollector.visit(nextCmd); mergeCommands.put(removedCommand.getKey(), removedCommand); return currentCmd; } else { commandCollector.finish(); if (log.isDebugEnabled()) { log.debug("Merge optimieze:merge " + mergeCount + " get commands");
currentCmd.setStatus(OperationStatus.WRITING); int totalBytes = currentCmd.getIoBuffer().remaining(); commandCollector.visit(currentCmd); while (mergeCount < this.mergeFactor && totalBytes <= sendBufferSize) { Command nextCmd = (Command) writeQueue.peek(); writeQueue.remove(); commandCollector.visit(nextCmd); return currentCmd; } else { commandCollector.finish(); if (log.isDebugEnabled()) { log.debug("Merge optimieze:merge " + mergeCount + " get commands"); return (Command) commandCollector.getResult();
private Command newMergedCommand(final Map<Object, Command> mergeCommands, int mergeCount, final CommandCollector commandCollector, final CommandType commandType) { if (this.protocol == Protocol.Text) { String resultKey = (String) commandCollector.getResult(); byte[] keyBytes = ByteUtils.getBytes(resultKey); byte[] cmdBytes = commandType == CommandType.GET_ONE ? Constants.GET : Constants.GETS; final byte[] buf = new byte[cmdBytes.length + 3 + keyBytes.length]; ByteUtils.setArguments(buf, 0, cmdBytes, keyBytes); TextGetOneCommand cmd = new TextGetOneCommand(resultKey, keyBytes, commandType, null); cmd.setMergeCommands(mergeCommands); cmd.setWriteFuture(new FutureImpl<Boolean>()); cmd.setMergeCount(mergeCount); cmd.setIoBuffer(IoBuffer.wrap(buf)); return cmd; } else { BinaryGetMultiCommand result = (BinaryGetMultiCommand) commandCollector.getResult(); result.setMergeCount(mergeCount); result.setMergeCommands(mergeCommands); return result; } } }
private Command newMergedCommand(final Map<Object, Command> mergeCommands, int mergeCount, final CommandCollector commandCollector, final CommandType commandType) { if (this.protocol == Protocol.Text) { String resultKey = (String) commandCollector.getResult(); byte[] keyBytes = ByteUtils.getBytes(resultKey); byte[] cmdBytes = commandType == CommandType.GET_ONE ? Constants.GET : Constants.GETS; final byte[] buf = new byte[cmdBytes.length + 3 + keyBytes.length]; ByteUtils.setArguments(buf, 0, cmdBytes, keyBytes); TextGetOneCommand cmd = new TextGetOneCommand(resultKey, keyBytes, commandType, null); cmd.setMergeCommands(mergeCommands); cmd.setWriteFuture(new FutureImpl<Boolean>()); cmd.setMergeCount(mergeCount); cmd.setIoBuffer(IoBuffer.wrap(buf)); return cmd; } else { BinaryGetMultiCommand result = (BinaryGetMultiCommand) commandCollector.getResult(); result.setMergeCount(mergeCount); result.setMergeCommands(mergeCommands); return result; } } }