public class LeaseDTO extends Object implements Serializable
| Constructor and Description |
|---|
LeaseDTO(long accountId,
BalanceManager balanceManager)
Create a
LeaseDTO instance for the given account id |
LeaseDTO(long accountId,
double availableLocalBalance,
BalanceManager balanceManager)
This constructor is useful when take-over is happening.
|
| Modifier and Type | Method and Description |
|---|---|
double |
addLocalBalance(double extraLease)
Extra amount left at the end of the call is added to the lease (make sure to provide +ve
value).
|
void |
adjustLeaseChunkAmount(long leaseTimeDelta)
This method will try to adjust
leaseChunkAmount dynamically. |
long |
getAccountId() |
double |
getAvailableLocalBalance() |
double |
getLease(double lease,
LeaseResponse response,
boolean partialEnabled)
Try to get a lease from this account balance.
|
protected double |
increaseRedis(double amount)
Call hincrByFloat method in
JedisCluster instance. |
void |
loadLeaseInfoToClusterIfNotPresent()
Successful completion of this method will ensure the presence of this
LeaseDTO in redis
cluster Either in the nearest node or In the far nod. |
void |
onProcessShutdown()
Do all the task required to do while the application is shutting down.
|
double |
returnAvailableBalancePercentage(double percentage)
A percentage of available balance for this account will be returned to redis cluster when this method is called.
|
void |
setFrozen(boolean frozen)
Setter for freeze/unfreeze state of an account
|
String |
toString()
For debugging purpose
|
void |
updateUnSyncedInformation(BalanceManager balanceManager)
When slave has taken over as master.
|
public LeaseDTO(long accountId,
BalanceManager balanceManager)
LeaseDTO instance for the given account idaccountId - Account id for balance informationbalanceManager - Parent BalanceManager instance from where this LeaseDTO instance is being
maintained.public LeaseDTO(long accountId,
double availableLocalBalance,
BalanceManager balanceManager)
accountId - The account ID for which this instance belongs to.availableLocalBalance - At the time take-over what was the available local balance.balanceManager - Parent BalanceManager instance from where this LeaseDTO instance is being
maintained.public void loadLeaseInfoToClusterIfNotPresent()
LeaseDTO in redis
cluster Either in the nearest node or In the far nod. If no one else has loaded the data, It
will load data from mysql and save it in My cluster Node
Which will be needed for all consecutive callpublic double getLease(double lease,
LeaseResponse response,
boolean partialEnabled)
lease - The amount to be added to the leaseresponse - The response value will be updated into this instance. This instance must be passed from the
caller, and values will be updated here.partialEnabled - if caller can be happy with partial lease, then this value must be true.protected double increaseRedis(double amount)
JedisCluster instance. with given amount.amount - this amount will be increased in redispublic double addLocalBalance(double extraLease)
extraLease - remaining lease amount. make sure that it's +vepublic double returnAvailableBalancePercentage(double percentage)
percentage - What percentage of the available will be returned. For a full return percentage will be 100public void adjustLeaseChunkAmount(long leaseTimeDelta)
leaseChunkAmount dynamically. It will follow step-wise increase decrease
methodologies.leaseTimeDelta - difference in millis between last two consecutive lease taken time from redis.public long getAccountId()
public double getAvailableLocalBalance()
public void setFrozen(boolean frozen)
frozen - Boolean to freeze or unfreeze accountpublic String toString()
public void updateUnSyncedInformation(BalanceManager balanceManager)
balanceManager - instance of BalanceManager who is the owner of this instance.public void onProcessShutdown()
Copyright © 2022. All rights reserved.