Package net.rubyeye.xmemcached.command

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


    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


    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

  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

  public void testOptimieze() {
    this.optimiezer.setOptimizeMergeBuffer(true);
    for (int i = 0; i < 10; i++) {
      Command deleteCommand = this.commandFactory.createDeleteCommand(
          String.valueOf(i), String.valueOf(i).getBytes(), 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

  public void testDeleteEncodeAndDecode() {

    Command command = this.commandFactory.createDeleteCommand(this.key,
        this.keyBytes, 0, this.noreply);
    command.encode();
    ByteBuffer encodeBuffer = command.getIoBuffer().buf();
    assertNotNull(encodeBuffer);
    assertEquals(29, encodeBuffer.capacity());

    byte opCode = encodeBuffer.get(1);
View Full Code Here

    String key = "test";
    byte[] keyBytes = ByteUtils.getBytes(key);
    int time = 10;
    Command deleteCmd = this.commandFactory.createDeleteCommand("test",
        keyBytes, time,false);
    deleteCmd.encode();
    assertEquals(CommandType.DELETE, deleteCmd.getCommandType());
    String commandStr = new String(deleteCmd.getIoBuffer().buf()
        .array());

    String expectedStr = "delete test 10\r\n";
View Full Code Here

    assertEquals(expectedStr, commandStr);
  }

  public void testCreateVersionCommand() {
    Command versionCmd = this.commandFactory.createVersionCommand(new CountDownLatch(1),null);
    versionCmd.encode();
    String commandStr = new String(versionCmd.getIoBuffer().buf()
        .array());
    assertEquals("version\r\n", commandStr);
    assertEquals(CommandType.VERSION, versionCmd.getCommandType());
  }
View Full Code Here

    String value = "test";
    byte[] keyBytes = ByteUtils.getBytes(key);
    int exp = 0;
    Transcoder transcoder = new StringTranscoder();
    Command storeCmd = this.commandFactory.createSetCommand(key, keyBytes, exp, value,false, transcoder);
    storeCmd.encode();
    assertFalse(storeCmd.isNoreply());
    assertEquals(CommandType.SET, storeCmd.getCommandType());
    String commandStr = new String(storeCmd.getIoBuffer().buf()
        .array());
View Full Code Here

  public void testCreateGetCommand() {
    String key = "test";
    byte[] keyBytes = ByteUtils.getBytes(key);
    Command getCmd = this.commandFactory.createGetCommand(key, keyBytes,
        CommandType.GET_ONE, null);
    getCmd.encode();
    assertEquals(CommandType.GET_ONE, getCmd.getCommandType());
    String commandStr = new String(getCmd.getIoBuffer().buf()
        .array());

    String expectedStr = "get test\r\n";
View Full Code Here

    String key = "test";
    byte[] keyBytes = ByteUtils.getBytes(key);
    int num = 10;
    Command inCr = this.commandFactory.createIncrDecrCommand(key, keyBytes,
        num, 0,0, CommandType.INCR, false);
    inCr.encode();
    assertEquals(CommandType.INCR, inCr.getCommandType());
    String commandStr = new String(inCr.getIoBuffer().buf()
        .array());

    String expectedStr = "incr test 10\r\n";
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.