Package org.jredis

Examples of org.jredis.JRedisFuture


   * all pending responses, and then issue the quit command.
   */
  @AfterTest()
  public void testQuit() {
    try {
      JRedisFuture pipeline = getProviderInstance();
      pipeline.quit();
    }
    catch (Exception e) {
      fail("QUIT" + e);
    }
  }
View Full Code Here


    private static void runJRedisPipelineGET (ConnectionSpec spec, int reqCnt, int size, boolean forever) {
      long totTime = 0;
      long avgRespTime = 0;
      float avgThroughput = 0;
      long iters = 0;
      JRedisFuture pipeline = new JRedisPipeline(spec);
      try {
        String key = "pipeKey";
        byte[] data = new byte[size];
        (new Random()).nextBytes(data);
      pipeline.del(key);
      pipeline.set(key, data);
     
        do {
          int cnt = 0;
          Util.Timer timer = Timer.startNewTimer();
          Future<byte[]> futureBytes = null;
          while(cnt < reqCnt){
            futureBytes = pipeline.get(key);
            cnt++;
          }
          long reqDoneTime = timer.mark();
          assert futureBytes != null;
        @SuppressWarnings("null")
        byte[] value = futureBytes.get();
          long respDoneTime = timer.mark();
//        System.out.format("JRedisPipeline: %d GETs invoked   @ %5d  (%.2f ops/s)\n", cnt, reqDoneTime, timer.opsPerSecAtDelta(cnt, reqDoneTime));
        float throughput = timer.opsPerSecAtMark(cnt);
//        System.out.format("JRedisPipeline: %d GETs completed @ %5d  (%.2f ops/s) [%d msecs to comp] \n", cnt, timer.deltaAtMark(), throughput, respDoneTime-reqDoneTime);
        if(iters > 0){
          totTime += respDoneTime;
          avgRespTime = (totTime) / iters;
          avgThroughput =(float)( reqCnt * 1000) / (float) avgRespTime;
          System.out.format("JRedisPipeline: %d GETs [%d bytes/GET] average response time @ %dms (%.2f ops/s) last: %dms\n", cnt, data.length, avgRespTime, avgThroughput, respDoneTime);
//          Assert.isEquivalent(data, value);
        }
        iters ++;
//        System.out.println ();
        } while(forever);

        pipeline.quit();
        }
        catch (ProviderException e) {
          e.printStackTrace();
        }
        catch (InterruptedException e) {
View Full Code Here

    private static void runJRedisPipelinePING (ConnectionSpec spec, int reqCnt, int size, boolean forever) {
      long totTime = 0;
      long avgRespTime = 0;
      float avgThroughput = 0;
      long iters = 0;
      JRedisFuture pipeline = new JRedisPipeline(spec);
      try {
        do {
          int cnt = 0;
          Util.Timer timer = Timer.startNewTimer();
          Future<ResponseStatus> futureStat = null;
          while(cnt < reqCnt){
            futureStat = pipeline.ping();
            cnt++;
          }
          long reqDoneTime = timer.mark();
          assert futureStat != null;
        @SuppressWarnings("null")
        ResponseStatus rstat = futureStat.get();
          long respDoneTime = timer.mark();
//        System.out.format("JRedisPipeline: %d PINGs invoked   @ %5d  (%.2f ops/s)\n", cnt, reqDoneTime, timer.opsPerSecAtDelta(cnt, reqDoneTime));
        float throughput = timer.opsPerSecAtMark(cnt);
//        System.out.format("JRedisPipeline: %d PINGs completed @ %5d  (%.2f ops/s) [%d msecs to comp] \n", cnt, timer.deltaAtMark(), throughput, respDoneTime-reqDoneTime);
        if(iters > 0){
          totTime += reqDoneTime;
          avgRespTime = (totTime) / iters;
          avgThroughput =(float)( reqCnt * 1000) / (float) avgRespTime;
          System.out.print("\r");
          System.out.format("JRedisPipeline: %d PINGs average response time @ %dms (%.2f ops/s)", cnt, avgRespTime, avgThroughput);
        }
        iters ++;
//        System.out.println ();
        } while(forever);

        pipeline.quit();
        }
        catch (ProviderException e) {
          e.printStackTrace();
        }
        catch (InterruptedException e) {
View Full Code Here

          e.printStackTrace();
        }
    }
    @SuppressWarnings("boxing")
  private static void runJRedisPipelineLPUSH (ConnectionSpec spec, int reqCnt, int size, boolean forever) {
      JRedisFuture pipeline = new JRedisPipeline(spec);
      long totTime = 0;
      long avgRespTime = 0;
      float avgThroughput = 0;
      long iters = 0;
      try {
        String key = "pipeKey";
        byte[] data = new byte[size];
        (new Random()).nextBytes(data);
      Future<Long> futureLong = pipeline.del(key);
      futureLong.get();
        do {
          int cnt = 0;
          Util.Timer timer = Timer.startNewTimer();
          Future<ResponseStatus> futureStat = null;
          while(cnt < reqCnt){
            futureLong = pipeline.lpush(key, data);
            cnt++;
          }
          long reqDoneTime = timer.mark();
          assert futureStat != null;
          @SuppressWarnings({ "null", "unused" })
        ResponseStatus rstat = futureStat.get();
          long respDoneTime = timer.mark();
        System.out.format("JRedisPipeline: %d LPUSHs invoked   @ %5d  (%.2f ops/s)\n", cnt, reqDoneTime, timer.opsPerSecAtDelta(cnt, reqDoneTime));
        System.out.format("JRedisPipeline: %d LPUSHs completed @ %5d  (%.2f ops/s) [%d msecs to comp] \n", cnt, timer.deltaAtMark(), timer.opsPerSecAtMark(cnt), respDoneTime-reqDoneTime);
        if(iters > 0){
          totTime += reqDoneTime;
          avgRespTime = (totTime) / iters;
          avgThroughput =(float)( reqCnt * 1000) / (float) avgRespTime;
          System.out.format("JRedisPipeline: %d LPUSHs average response time @ %dms (%.2f ops/s) \n", cnt, avgRespTime, avgThroughput);
        }
        iters ++;
        System.out.println ();
        } while(forever);

        pipeline.quit();
        }
        catch (ProviderException e) {
          e.printStackTrace();
        }
        catch (InterruptedException e) {
View Full Code Here

     * @param reqCnt
     * @param forever
     */
    @SuppressWarnings("boxing")
  private static void runJRedisPipelineSET (ConnectionSpec spec, int reqCnt, int size, boolean forever) {
      JRedisFuture pipeline = new JRedisPipeline(spec);
      long totTime = 0;
      long avgRespTime = 0;
      float avgThroughput = 0;
      long iters = 0;
      try {
        String key = "pipeKey";
        byte[] data = new byte[size];
        (new Random()).nextBytes(data);
      Future<Long> futureLong = pipeline.del(key);
      futureLong.get();
        do {
          int cnt = 0;
          Util.Timer timer = Timer.startNewTimer();
          Future<ResponseStatus> futureStat = null;
          while(cnt < reqCnt){
            futureStat = pipeline.set(key, data);
            cnt++;
          }
          assert futureStat != null;
          @SuppressWarnings({ "null", "unused" })
        ResponseStatus rstat = futureStat.get();
          long respDoneTime = timer.mark();
        if(iters > 0){
          totTime += respDoneTime;
          avgRespTime = (totTime) / iters;
          avgThroughput =(float)( reqCnt * 1000) / (float) avgRespTime;
          System.out.format("JRedisPipeline: %d SETs [%d bytes/GET] average response time @ %dms (%.2f ops/s) \n", cnt, data.length, avgRespTime, avgThroughput);
        }
        iters ++;
        } while(forever);

        pipeline.quit();
        }
        catch (ProviderException e) {
          e.printStackTrace();
        }
        catch (InterruptedException e) {
View Full Code Here

     * @param reqCnt
     * @param forever
     */
    @SuppressWarnings("boxing")
  private static void runJRedisPipelineINCR (ConnectionSpec spec, int reqCnt, int size, boolean forever) {
      JRedisFuture pipeline = new JRedisPipeline(spec);
      long totTime = 0;
      long avgRespTime = 0;
      float avgThroughput = 0;
      long iters = 0;
      try {
        String key = "pipeCounter";
      Future<Long> futureDelCnt = pipeline.del(key);
      futureDelCnt.get();
        do {
          int cnt = 0;
          Util.Timer timer = Timer.startNewTimer();
          Future<Long> futureLong = null;
          while(cnt < reqCnt){
            futureLong = pipeline.incr(key);
            cnt++;
          }
          long reqDoneTime = timer.mark();
          assert futureLong != null;
        @SuppressWarnings("null")
        long counter = futureLong.get();
          long respDoneTime = timer.mark();
        System.out.format("JRedisPipeline: %d INCRs invoked   @ %5d  (%.2f ops/s)\n", cnt, reqDoneTime, timer.opsPerSecAtDelta(cnt, reqDoneTime));
        System.out.format("JRedisPipeline: %d INCRs completed @ %5d  (%.2f ops/s) [%d msecs to comp] \n", cnt, timer.deltaAtMark(), timer.opsPerSecAtMark(cnt), respDoneTime-reqDoneTime);
        System.out.format ("counter is now: %d\n\n", counter);
        if(iters > 0){
          totTime += reqDoneTime;
          avgRespTime = (totTime) / iters;
          avgThroughput =(float)( reqCnt * 1000) / (float) avgRespTime;
          System.out.format("JRedisPipeline: %d INCRs average response time @ %dms (%.2f ops/s) \n", cnt, avgRespTime, avgThroughput);
        }
        iters ++;
        System.out.println ();
        } while(forever);

        pipeline.quit();
        }
        catch (ProviderException e) {
          e.printStackTrace();
        }
        catch (InterruptedException e) {
View Full Code Here

  public static void usingAsyncClient () {
    ConnectionSpec spec = DefaultConnectionSpec.newSpec()
    .setCredentials("jredis".getBytes())
    .setDatabase(10);

    JRedisFuture jredis = new JRedisAsyncClient(spec);

    System.out.println ("\nusing the AsyncClient: \n\n");
    useMSet(jredis);
    useMSetNX (jredis);
   
        jredis.quit();

  }
View Full Code Here

  public static void usingAsyncClient () {
    ConnectionSpec spec = DefaultConnectionSpec.newSpec()
    .setCredentials("jredis".getBytes())
    .setDatabase(10);

    JRedisFuture jredis = new JRedisAsyncClient(spec);

    System.out.println ("\n\n** using JRedisFuture **");
    useZRangeSubset(jredis);
   
        jredis.quit();

  }
View Full Code Here

  /* (non-Javadoc)
   * @see org.jredis.ri.ProviderTestBase#newProviderInstance()
   */
  @Override
  protected JRedisFuture newProviderInstance () {
    JRedisFuture provider = null;
    try {
      ConnectionSpec connectionSpec = DefaultConnectionSpec.newSpec(this.host, this.port, this.db2, this.password.getBytes());
      provider = new JRedisAsyncClient(connectionSpec);
        }
        catch (ClientRuntimeException e) {
View Full Code Here

   * all pending responses, and then issue the quit command.
   */
  @AfterTest
  public void testQuit() {
    try {
      JRedisFuture pipeline = getProviderInstance();
      pipeline.ping().get();
      pipeline.quit().get();
    }
    catch (Exception e) {
      fail("QUIT" + e);
    }
  }
View Full Code Here

TOP

Related Classes of org.jredis.JRedisFuture

Copyright © 2018 www.massapicom. 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.