Package balance

Class LeaseDTO

java.lang.Object
balance.LeaseDTO

public class LeaseDTO extends Object
This class is responsible for caching balance, taking advanced loan from mysql, giving lease when needed, syncing the balance information between mysql and redis cluster
  • Field Details

  • Constructor Details

    • LeaseDTO

      public LeaseDTO(long accountID, BalanceManager balanceManager)
      Create a LeaseDTO instance for the given account id
      Parameters:
      accountID - Account id for balance information
      balanceManager - Parent BalanceManager instance from where this LeaseDTO instance is being maintained.
  • Method Details

    • getLease

      public double getLease(double lease)
      Try to get a lease from this account balance. If possible take that lease of given amount. If full amount not possible then try to take lease of possible amount. If that is even not possible then return with zero lease
      Parameters:
      lease - The amount to be added to the lease
      Returns:
      the exact amount that lease was possible for. 0 when no balance available for this client
    • decreaseLeaseAmount

      public void decreaseLeaseAmount(double extraLease)
      Extra amount left at the end of the call is added to the lease (make sure to provide +ve value). The optional total bill, if present, is also queued to be updated in the db at next update cycle.
      Parameters:
      extraLease - remaining lease amount. make sure that it's +ve
    • getLeasedBalance

      public double getLeasedBalance()
      Returns:
      the amount of available local balance
    • returnAvailableBalancePercentage

      public void returnAvailableBalancePercentage(double percentage)
      As LeaseDTO is taking lease in chunk amount of from redis Even if all of them are not used. So this method will return all the remaining lease amount to redis cluster.
    • getAvailableLocalBalance

      public double getAvailableLocalBalance()