Package net.rubyeye.xmemcached.command

Examples of net.rubyeye.xmemcached.command.Command.encode()


    keys.add("c");
    keys.add("a");

    Command cmd = this.commandFactory.createGetMultiCommand(keys, null,
        CommandType.GET_MANY, null);
    cmd.encode();
    assertEquals(CommandType.GET_MANY, cmd.getCommandType());
    String commandStr = new String(cmd.getIoBuffer().buf()
        .array());

    String expectedStr = "get a b c a\r\n";
View Full Code Here


  @Override
  protected WriteMessage preprocessWriteMessage(WriteMessage writeMessage) {
    Command currentCommand = (Command) writeMessage;
    // Check if IoBuffer is null
    if (currentCommand.getIoBuffer() == null) {
      currentCommand.encode();
    }
    if (currentCommand.getStatus() == OperationStatus.SENDING) {
      /**
       * optimieze commands
       */
 
View Full Code Here

  public void testEncode() {
    this.encoder = new MemcachedCodecFactory().getEncoder();
    Command command = new TextCommandFactory().createVersionCommand(
        new CountDownLatch(1), null);
    command.encode();
    IoBuffer buffer = this.encoder.encode(command, null);
    assertEquals(buffer.buf(), ServerAddressAware.VERSION);
  }

}
View Full Code Here

    checkByteBufferEquals(command, "incr test 10\r\n");

    command = this.commandFactory.createIncrDecrCommand("test",
        "test".getBytes(), 10, 0, 0, CommandType.INCR, true);
    assertNull(command.getIoBuffer());
    command.encode();

    checkByteBufferEquals(command, "incr test 10 noreply\r\n");
  }

  public void testEncodeDecr() {
View Full Code Here

  public void testEncodeDecr() {
    Command command = this.commandFactory.createIncrDecrCommand("test",
        "test".getBytes(), 10, 0, 0, CommandType.DECR, false);
    assertNull(command.getIoBuffer());
    command.encode();

    checkByteBufferEquals(command, "decr test 10\r\n");

    command = this.commandFactory.createIncrDecrCommand("test",
        "test".getBytes(), 10, 0, 0, CommandType.DECR, true);
View Full Code Here

    checkByteBufferEquals(command, "decr test 10\r\n");

    command = this.commandFactory.createIncrDecrCommand("test",
        "test".getBytes(), 10, 0, 0, CommandType.DECR, true);
    assertNull(command.getIoBuffer());
    command.encode();

    checkByteBufferEquals(command, "decr test 10 noreply\r\n");
  }

  public void testDecode() {
View Full Code Here

    this.executingCmds = new LinkedTransferQueue<Command>();
    for (int i = 0; i < 10; i++) {
      Command cmd = this.commandFactory.createGetCommand(
          String.valueOf(i), String.valueOf(i).getBytes(),
          CommandType.GET_ONE, null);
      cmd.encode();
      this.writeQueue.add(cmd);
      cmd.setWriteFuture(new FutureImpl<Boolean>());
    }
    this.currentCmd = (Command) this.writeQueue.poll();
    this.currentCmd.encode();
View Full Code Here

    int oneBufferSize = 0;
    for (int i = 0; i < 10; i++) {
      Command cmd = this.commandFactory.createSetCommand(
          String.valueOf(i), String.valueOf(i).getBytes(), 0, i,
          false, transcoder);
      cmd.encode();
      this.writeQueue.add(cmd);
      oneBufferSize = cmd.getIoBuffer().remaining();
      cmd.setWriteFuture(new FutureImpl<Boolean>());
    }
    this.currentCmd = (Command) this.writeQueue.poll();
View Full Code Here

    SerializingTranscoder transcoder = new SerializingTranscoder();
    for (int i = 0; i < 10; i++) {
      Command cmd = this.commandFactory.createSetCommand(
          String.valueOf(i), String.valueOf(i).getBytes(), 0, i,
          false, transcoder);
      cmd.encode();
      this.writeQueue.add(cmd);
      cmd.setWriteFuture(new FutureImpl<Boolean>());
    }
    this.currentCmd = (Command) this.writeQueue.poll();
    this.currentCmd.encode();
View Full Code Here

    Queue<Command> localQueue = new SimpleQueue<Command>();
    for (int i = 0; i < 10; i++) {
      Command cmd = this.commandFactory.createGetCommand(
          String.valueOf(0), String.valueOf(0).getBytes(),
          CommandType.GET_ONE, null);
      cmd.encode();
      this.writeQueue.add(cmd);
      cmd.setWriteFuture(new FutureImpl<Boolean>());
      localQueue.add(cmd);
    }
    TextGetOneCommand optimiezeCommand = (TextGetOneCommand) this.optimiezer
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.