org.apache.hadoop.hbase.stargate.util
Class HTableTokenBucket

java.lang.Object
  extended by org.apache.hadoop.hbase.stargate.util.HTableTokenBucket
All Implemented Interfaces:
Constants

public class HTableTokenBucket
extends Object
implements Constants

A HTable-backed token bucket.

Can be configured with rate, the number of tokens to add to the bucket each second, and size, the maximum number of tokens allowed to burst. Configuration is stored in the HTable adjacent to the token count and is periodically refreshed.

Expected columns:


Field Summary
 
Fields inherited from interface org.apache.hadoop.hbase.stargate.Constants
AUTHENTICATOR_KEY, DEFAULT_MAX_AGE, INSTANCE_ZNODE_ROOT, MIMETYPE_BINARY, MIMETYPE_HTML, MIMETYPE_JSON, MIMETYPE_PROTOBUF, MIMETYPE_TEXT, MIMETYPE_XML, MULTIUSER_KEY, STATUS_REPORT_PERIOD_KEY, USERS_TABLE, USERS_ZNODE_ROOT, VERSION_STRING
 
Constructor Summary
HTableTokenBucket(HBaseConfiguration conf, byte[] row)
          Constructor
HTableTokenBucket(HBaseConfiguration conf, String tableName, byte[] row)
          Constructor
 
Method Summary
 int available()
           
 double getRate()
           
 int getSize()
           
 void remove(int t)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTableTokenBucket

public HTableTokenBucket(HBaseConfiguration conf,
                         byte[] row)
                  throws IOException
Constructor

Parameters:
conf - configuration
row - row key for user
Throws:
IOException

HTableTokenBucket

public HTableTokenBucket(HBaseConfiguration conf,
                         String tableName,
                         byte[] row)
                  throws IOException
Constructor

Parameters:
conf - configuration
tableName - the table to use
row - row key for user
Throws:
IOException
Method Detail

available

public int available()
              throws IOException
Returns:
the number of remaining tokens in the bucket (roughly)
Throws:
IOException

remove

public void remove(int t)
            throws IOException
Parameters:
t - the number of tokens to consume from the bucket
Throws:
IOException

getRate

public double getRate()

getSize

public int getSize()


Copyright © 2010 The Apache Software Foundation