Package net.rubyeye.xmemcached.command

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


  public void testMergeGetCommandsWithEmptyWriteQueue() {
    this.writeQueue.clear();
    Command optimiezeCommand = this.optimiezer.optimiezeGet(
        this.writeQueue, this.executingCmds, this.currentCmd);
    optimiezeCommand.encode();
    ByteBuffer mergeBuffer = optimiezeCommand.getIoBuffer().buf();
    assertSame(this.currentCmd, optimiezeCommand);
    assertTrue(mergeBuffer.remaining() < 100);
    assertSame(mergeBuffer, this.currentCmd.getIoBuffer().buf());
    assertEquals(0, this.writeQueue.size());
View Full Code Here


      if (this.prevCommand != null) {
        // first n-1 send getq command
        Command getqCommand = new BinaryGetCommand(
            this.prevCommand.getKey(), this.prevCommand.getKeyBytes(), null,
            null, OpCode.GET_KEY_QUIETLY, true);
        getqCommand.encode();
        this.totalBytes += getqCommand.getIoBuffer().remaining();
        this.bufferList.add(getqCommand.getIoBuffer());
      }
      this.prevCommand = command;
    }
View Full Code Here

    this.optimiezer.setOptimizeMergeBuffer(true);
    for (int i = 0; i < 10; i++) {
      Command deleteCommand = this.commandFactory.createDeleteCommand(
          String.valueOf(i), String.valueOf(i).getBytes(), 0, 0,
          false);
      deleteCommand.encode();
      this.writeQueue.add(deleteCommand);
      deleteCommand.setWriteFuture(new FutureImpl<Boolean>());
    }
    Command optimiezeCommand = this.optimiezer.optimize(this.currentCmd,
        this.writeQueue, this.executingCmds, 16 * 1024);
 
View Full Code Here

      // getq commands sending response back
      Command lastGetKCommand = new BinaryGetCommand(
          this.prevCommand.getKey(), this.prevCommand.getKeyBytes(),
          CommandType.GET_ONE, new CountDownLatch(1), OpCode.GET_KEY,
          false);
      lastGetKCommand.encode();
      this.bufferList.add(lastGetKCommand.getIoBuffer());
      this.totalBytes += lastGetKCommand.getIoBuffer().remaining();
    }

  }
View Full Code Here

public class TextStatsCommandUnitTest extends BaseTextCommandUnitTest {
  public void testEncode() {
    Command command = this.commandFactory.createStatsCommand(null,
        new CountDownLatch(1), null);
    assertNull(command.getIoBuffer());
    command.encode();
    assertEquals(TextStatsCommand.STATS, command.getIoBuffer().buf());
  }

  public void testItemEncode() {
    Command command = this.commandFactory.createStatsCommand(null,
View Full Code Here

      keys.add(String.valueOf(i));
    }

    Command command = this.commandFactory.createGetMultiCommand(keys,
        new CountDownLatch(1), CommandType.GET_MANY, this.transcoder);
    command.encode();
    ByteBuffer encodeBuffer = command.getIoBuffer().buf();
    assertNotNull(encodeBuffer);
    // (header length + key length) x Count
    assertEquals((24 + 1) * keys.size(), encodeBuffer.capacity());

View Full Code Here

  public void testItemEncode() {
    Command command = this.commandFactory.createStatsCommand(null,
        new CountDownLatch(1), "items");
    assertNull(command.getIoBuffer());
    command.encode();
    assertEquals(ByteBuffer.wrap("stats items\r\n".getBytes()), command
        .getIoBuffer().buf());
  }

  public void testDecode() {
View Full Code Here

public class TextDeleteCommandUnitTest extends BaseTextCommandUnitTest {
  public void testEncode() {
    Command command = this.commandFactory.createDeleteCommand("test",
        "test".getBytes(), 10, 0, false);
    assertNull(command.getIoBuffer());
    command.encode();
    this.checkByteBufferEquals(command, "delete test\r\n");

    command = this.commandFactory.createDeleteCommand("test",
        "test".getBytes(), 10, 0, true);
    assertNull(command.getIoBuffer());
View Full Code Here

    this.checkByteBufferEquals(command, "delete test\r\n");

    command = this.commandFactory.createDeleteCommand("test",
        "test".getBytes(), 10, 0, true);
    assertNull(command.getIoBuffer());
    command.encode();
    this.checkByteBufferEquals(command, "delete test noreply\r\n");
  }

  public void testDecode() {
    Command command = this.commandFactory.createDeleteCommand("test",
View Full Code Here

  public void testGetEncodeAndDecode() {

    Command command = this.commandFactory.createGetCommand(this.key, this.keyBytes,
        CommandType.GET_ONE, this.transcoder);
    command.encode();
    ByteBuffer encodeBuffer = command.getIoBuffer().buf();
    assertNotNull(encodeBuffer);
    assertEquals(29, encodeBuffer.capacity());

    byte opCode = encodeBuffer.get(1);
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.