Package org.apache.hadoop.hbase.stargate.util

Examples of org.apache.hadoop.hbase.stargate.util.HTableTokenBucket.available()


      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


  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.