org.apache.hadoop.hbase.stargate.util
Class HTableTokenBucket
java.lang.Object
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:
- user:
- user:tokens
- user:tokens.rate
- user:tokens.size
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 |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
HTableTokenBucket
public HTableTokenBucket(HBaseConfiguration conf,
byte[] row)
throws IOException
- Constructor
- Parameters:
conf
- configurationrow
- row key for user
- Throws:
IOException
HTableTokenBucket
public HTableTokenBucket(HBaseConfiguration conf,
String tableName,
byte[] row)
throws IOException
- Constructor
- Parameters:
conf
- configurationtableName
- the table to userow
- row key for user
- Throws:
IOException
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