Class TokenStore

java.lang.Object
google.registry.proxy.quota.TokenStore

@ThreadSafe public class TokenStore extends Object
A thread-safe token store that supports concurrent take(java.lang.String), put(java.lang.String, org.joda.time.DateTime), and refresh() operations.

The tokens represent quota allocated to each user, which needs to be leased to the user upon connection and optionally returned to the store upon termination. Failure to acquire tokens results in quota fulfillment failure, leading to automatic connection termination. For details on tokens, see config/default-config.yaml.

The store also lazily refills tokens for a userId when a take(java.lang.String) or a put(java.lang.String, org.joda.time.DateTime) takes place. It also exposes a refresh() method that goes through each entry in the store and purges stale entries, in order to prevent the token store from growing too large.

There should be one token store for each protocol.