Examples of HTableTokenBucket


Examples of org.apache.hadoop.hbase.stargate.util.HTableTokenBucket

      table.flushCommits();
    }
  }

  public void testTokenBucketConfig() throws Exception {
    HTableTokenBucket tb = new HTableTokenBucket(conf, TABLE,
      Bytes.toBytes(USER_TOKEN));
    assertEquals(tb.getRate(), RATE);
    assertEquals(tb.getSize(), SIZE);
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.stargate.util.HTableTokenBucket

   */
  public boolean userRequestLimit(final User user, int want)
      throws IOException {
    if (multiuser) {
      UserData ud = SoftUserData.get(user);
      HTableTokenBucket tb = (HTableTokenBucket) ud.get(UserData.TOKENBUCKET);
      if (tb == null) {
        tb = new HTableTokenBucket(conf, Bytes.toBytes(user.getToken()));
        ud.put(UserData.TOKENBUCKET, tb);
      }
      if (tb.available() < want) {
        return false;
      }
      tb.remove(want);
    }
    return true;
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.stargate.util.HTableTokenBucket

    assertEquals(tb.getRate(), RATE);
    assertEquals(tb.getSize(), SIZE);
  }

  public void testTokenBucket() throws Exception {
    HTableTokenBucket tb = new HTableTokenBucket(conf, TABLE,
      Bytes.toBytes(USER_TOKEN));
    int last = 0;
    for (int i = 0; i <= 5 && last < 10; i++) {
      int avail = tb.available();
      assertTrue("bucket did not increment", avail > last);
      assertTrue("bucket updated too quickly", avail - last < 3);
      last = avail;
      Thread.sleep(2000);
    }
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.