Examples of TextGetOneCommand


Examples of net.rubyeye.xmemcached.command.text.TextGetOneCommand

      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);
View Full Code Here

Examples of net.rubyeye.xmemcached.command.text.TextGetOneCommand

   */
  @SuppressWarnings("unchecked")
  public final Command createGetCommand(final String key,
      final byte[] keyBytes, final CommandType cmdType,
      Transcoder transcoder) {
    return new TextGetOneCommand(key, keyBytes, cmdType,
        new CountDownLatch(1));
  }
View Full Code Here

Examples of net.rubyeye.xmemcached.command.text.TextGetOneCommand

    this.currentCmd.encode();
  }

  public void testOptimiezeGet() {

    TextGetOneCommand optimiezeCommand = (TextGetOneCommand) this.optimiezer
        .optimiezeGet(this.writeQueue, this.executingCmds,
            this.currentCmd);

    assertEquals(10, optimiezeCommand.getMergeCommands().size());
    assertEquals(10, optimiezeCommand.getMergeCount());
    assertEquals(0, this.writeQueue.size());
    assertNull(this.writeQueue.peek());
    assertSame(CommandType.GET_ONE, optimiezeCommand.getCommandType());
    assertEquals(10, optimiezeCommand.getMergeCount());
    assertEquals("get 0 1 2 3 4 5 6 7 8 9\r\n", new String(optimiezeCommand
        .getIoBuffer().buf().array()));
  }
View Full Code Here

Examples of net.rubyeye.xmemcached.command.text.TextGetOneCommand

      cmd.encode();
      this.writeQueue.add(cmd);
      cmd.setWriteFuture(new FutureImpl<Boolean>());
      localQueue.add(cmd);
    }
    TextGetOneCommand optimiezeCommand = (TextGetOneCommand) this.optimiezer
        .optimiezeGet(this.writeQueue, this.executingCmds,
            this.currentCmd);

    assertEquals(1, optimiezeCommand.getMergeCommands().size());
    assertEquals(11, optimiezeCommand.getMergeCount());
    assertEquals(0, this.writeQueue.size());
    assertNull(this.writeQueue.peek());
    assertSame(CommandType.GET_ONE, optimiezeCommand.getCommandType());
    assertEquals(11, optimiezeCommand.getMergeCount());
    assertEquals("get 0\r\n", new String(optimiezeCommand.getIoBuffer()
        .buf().array()));
    optimiezeCommand.decode(null, ByteBuffer.wrap("VALUE 0 0 2\r\n10\r\n"
        .getBytes()));

    assertEquals(0, this.currentCmd.getLatch().getCount());
    Transcoder transcoder = new SerializingTranscoder();
    assertEquals("10", transcoder.decode((CachedData) this.currentCmd
        .getResult()));
    for (Command cmd : localQueue) {
      assertEquals(0, cmd.getLatch().getCount());
      assertEquals("10", transcoder.decode((CachedData) this.currentCmd
          .getResult()));
    }
    assertEquals(0, optimiezeCommand.getMergeCount());
  }
View Full Code Here

Examples of net.rubyeye.xmemcached.command.text.TextGetOneCommand

    assertEquals(0, optimiezeCommand.getMergeCount());
  }

  public void testMergeFactorDecrease() {
    this.optimiezer.setMergeFactor(5);
    TextGetOneCommand optimiezeCommand = (TextGetOneCommand) this.optimiezer
        .optimiezeGet(this.writeQueue, this.executingCmds,
            this.currentCmd);

    assertEquals(5, optimiezeCommand.getMergeCommands().size());
    assertSame(CommandType.GET_ONE, optimiezeCommand.getCommandType());
    assertEquals(5, optimiezeCommand.getMergeCount());
    assertEquals("get 0 1 2 3 4\r\n", new String(optimiezeCommand
        .getIoBuffer().buf().array()));
    assertEquals(5, this.writeQueue.size()); // remain five commands
  }
View Full Code Here

Examples of net.rubyeye.xmemcached.command.text.TextGetOneCommand

    assertEquals(5, this.writeQueue.size()); // remain five commands
  }

  public void testMergeFactorEqualsZero() {
    this.optimiezer.setMergeFactor(0);
    TextGetOneCommand optimiezeCommand = (TextGetOneCommand) this.optimiezer
        .optimiezeGet(this.writeQueue, this.executingCmds,
            this.currentCmd);
    optimiezeCommand.encode();

    assertNull(optimiezeCommand.getMergeCommands());
    assertSame(CommandType.GET_ONE, optimiezeCommand.getCommandType());
    assertNull(optimiezeCommand.getMergeCommands());
    assertEquals(-1, optimiezeCommand.getMergeCount());
    assertEquals("get 0\r\n", new String(optimiezeCommand.getIoBuffer()
        .buf().array()));
    assertEquals(9, this.writeQueue.size());
    assertSame(this.currentCmd, optimiezeCommand);
  }
View Full Code Here

Examples of net.rubyeye.xmemcached.command.text.TextGetOneCommand

    assertSame(this.currentCmd, optimiezeCommand);
  }

  public void testDisableMergeGet() {
    this.optimiezer.setOptimizeGet(false); // disable merge get
    TextGetOneCommand optimiezeCommand = (TextGetOneCommand) this.optimiezer
        .optimiezeGet(this.writeQueue, this.executingCmds,
            this.currentCmd);
    optimiezeCommand.encode();
    assertNull(optimiezeCommand.getMergeCommands());
    assertSame(CommandType.GET_ONE, optimiezeCommand.getCommandType());
    assertNull(optimiezeCommand.getMergeCommands());
    assertEquals(-1, optimiezeCommand.getMergeCount());
    assertEquals("get 0\r\n", new String(optimiezeCommand.getIoBuffer()
        .buf().array()));
    assertEquals(9, this.writeQueue.size());
    assertSame(this.currentCmd, optimiezeCommand);
  }
View Full Code Here

Examples of net.rubyeye.xmemcached.command.text.TextGetOneCommand

          .valueOf(i), String.valueOf(i).getBytes(), 0, false);
      this.writeQueue.add(cmd);
      cmd.setWriteFuture(new FutureImpl<Boolean>());
    }
    // merge five get commands at most
    TextGetOneCommand optimiezeCommand = (TextGetOneCommand) this.optimiezer
        .optimiezeGet(this.writeQueue, this.executingCmds,
            this.currentCmd);

    assertEquals(5, optimiezeCommand.getMergeCommands().size());
    assertSame(CommandType.GET_ONE, optimiezeCommand.getCommandType());
    assertEquals(6, optimiezeCommand.getMergeCount());
    assertEquals("get 0 1 2 3 4\r\n", new String(optimiezeCommand
        .getIoBuffer().buf().array()));
    assertEquals(5, this.writeQueue.size()); // remain five commands

  }
View Full Code Here

Examples of net.rubyeye.xmemcached.command.text.TextGetOneCommand

      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);
View Full Code Here

Examples of net.rubyeye.xmemcached.command.text.TextGetOneCommand

    assertEquals(optimiezedCommand.getMergeCount(), 10);
  }

  public void testOptimiezeGet() {

    TextGetOneCommand optimiezeCommand = (TextGetOneCommand) this.optimiezer
        .optimiezeGet(this.writeQueue, this.executingCmds,
            this.currentCmd);

    assertEquals(10, optimiezeCommand.getMergeCommands().size());
    assertEquals(10, optimiezeCommand.getMergeCount());
    assertEquals(0, this.writeQueue.size());
    assertNull(this.writeQueue.peek());
    assertSame(CommandType.GET_ONE, optimiezeCommand.getCommandType());
    assertEquals(10, optimiezeCommand.getMergeCount());
    assertEquals("get 0 1 2 3 4 5 6 7 8 9\r\n", new String(optimiezeCommand
        .getIoBuffer().buf().array()));
  }
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.