Class TokenStore

  • @ThreadSafe
    public class TokenStore
    extends java.lang.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.

    • Constructor Summary

      Constructor Description
      TokenStore​(QuotaConfig config, java.util.concurrent.ScheduledExecutorService refreshExecutor, Clock clock)  
    • Method Summary

      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TokenStore

        public TokenStore​(QuotaConfig config,
                          java.util.concurrent.ScheduledExecutorService refreshExecutor,
                          Clock clock)