Interface QuotaService<T extends QuotaKey>

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      Quota get​(T key)
      Gets the quota of the resource from a given quota key.
      long getCurrentCount​(T key)
      Gets the current count from a given quota key
      Quota initialize​(T key, long maxCount)
      Initializes the quota of the resource for the given quota key.
      Quota initialize​(T key, long minCount, long maxCount)
      Initializes the quota of the resource for the given quota key.
      Quota initialize​(T key, Quota quota)
      Initializes the quota of the resource for the given quota key and from an existing quota.
      void remove​(T key)
      Removes quietly the quota of the resource from a given quota key.
      Quota verify​(T key)
      Verifies if the quota is full or not enough from a given quota key.
      Quota verify​(T key, Quota quota)
      Verifies if the given loaded and computed quota.
      Quota verify​(T key, Quota quota, AbstractQuotaCountingOffset countingOffset)
      Verifies if the given loaded and computed quota by adding a counting offset.
      Quota verify​(T key, AbstractQuotaCountingOffset countingOffset)
      Verifies if the quota is full or not enough from a given quota key and adding a counting offset.
    • Method Detail

      • getCurrentCount

        long getCurrentCount​(T key)
                      throws QuotaException
        Gets the current count from a given quota key
        Parameters:
        key - the key
        Returns:
        the current count
        Throws:
        QuotaException - on error
      • initialize

        Quota initialize​(T key,
                         long maxCount)
                  throws QuotaException
        Initializes the quota of the resource for the given quota key.
        Parameters:
        key - the key
        maxCount - the maximum count
        Returns:
        the quota
        Throws:
        QuotaException - on error
      • initialize

        Quota initialize​(T key,
                         long minCount,
                         long maxCount)
                  throws QuotaException
        Initializes the quota of the resource for the given quota key.
        Parameters:
        key - the key
        minCount - the minimum count
        maxCount - the maximum count
        Returns:
        the quota
        Throws:
        QuotaException - on error
      • initialize

        Quota initialize​(T key,
                         Quota quota)
                  throws QuotaException
        Initializes the quota of the resource for the given quota key and from an existing quota.
        Parameters:
        key - the key
        quota - a quota
        Returns:
        the quota
        Throws:
        QuotaException - on error
      • get

        Quota get​(T key)
           throws QuotaException
        Gets the quota of the resource from a given quota key. A save operation is done if the current count has changed.
        Parameters:
        key - the key
        Returns:
        the quota mapped with the key
        Throws:
        QuotaException
      • verify

        Quota verify​(T key)
              throws QuotaException
        Verifies if the quota is full or not enough from a given quota key.

        Be aware of that the quota count will be loaded and computed each time this signature is called.

        If full then a quota full exception is thrown If not enough then a quota not enough exception is thrown.
        Parameters:
        key - the key
        Returns:
        the quota used by the verify treatment
        Throws:
        QuotaException - on error
      • verify

        Quota verify​(T key,
                     AbstractQuotaCountingOffset countingOffset)
              throws QuotaException
        Verifies if the quota is full or not enough from a given quota key and adding a counting offset.

        Be aware of that the quota count will be loaded and computed each time this signature is called.

        If full then a quota full exception is throw. If not enough then a quota not enough exception is throw.
        Parameters:
        key - the key
        countingOffset - a counting offset
        Returns:
        the quota used by the verify treatment
        Throws:
        QuotaException - on error
      • verify

        Quota verify​(T key,
                     Quota quota)
              throws QuotaException
        Verifies if the given loaded and computed quota.

        Be aware of that the quota count is not again computed by this service. When this signature is called, it means that the Quota instance has been already loaded and there is no need to perform again the counting.

        If full then a quota full exception is thrown If not enough then a quota not enough exception is thrown.
        Parameters:
        key - the key
        quota - a loaded quota
        Returns:
        the quota used by the verify treatment
        Throws:
        QuotaException - on error
      • verify

        Quota verify​(T key,
                     Quota quota,
                     AbstractQuotaCountingOffset countingOffset)
              throws QuotaException
        Verifies if the given loaded and computed quota by adding a counting offset.

        Be aware of that the quota count is not again computed by this service. When this signature is called, it means that the Quota instance has been already loaded and there is no need to perform again the counting.

        If full then a quota full exception is thrown. If not enough then a quota not enough exception is thrown.
        Parameters:
        key - the key
        quota - a loaded quota
        countingOffset - a counting offset
        Returns:
        a copied quota from the given one containing the count with the offset used by the verify treatment
        Throws:
        QuotaException - on error
      • remove

        void remove​(T key)
        Removes quietly the quota of the resource from a given quota key.
        Parameters:
        key - the key