public abstract class LeaseDTO extends Object
| Constructor and Description |
|---|
LeaseDTO() |
| Modifier and Type | Method and Description |
|---|---|
abstract double |
addLocalBalance(double extraLease)
Extra amount left at the end of the call is added to the lease (make sure to provide +ve value).
|
abstract int |
appendAttributes(byte[] data,
int index)
Append all the required attributes into the given byte array, so that it can be sent to the slave.
|
protected abstract void |
executeLuaScript(String luaFileName) |
abstract long |
getAccountId() |
abstract double |
getAvailableLocalBalance() |
abstract double |
getAvailableRedisBalance() |
protected static void |
getClassReference() |
static LeaseDTO |
getInstance() |
abstract double |
getLease(double lease,
LeaseResponse response,
boolean partialEnabled)
Try to get a lease from this account balance.
|
abstract long |
getLocalBalanceSyncTime()
Get the timestamp in millis when last time this instance was synced with slaved.
|
protected abstract double |
increaseRedis(double amount)
Call hincrByFloat method in
JedisCluster instance. |
abstract void |
init(long accountId,
BalanceManager balanceManager)
Initialize a
LeaseDTO instance for the given account id |
abstract void |
init(long accountId,
double availableLocalBalance,
BalanceManager balanceManager)
This initialization is useful when take-over is happening.
|
abstract boolean |
isFrozen() |
abstract void |
onProcessShutdown(boolean returnBalance)
Do all the task required to do while the application is shutting down.
|
abstract double |
returnAvailableBalancePercentage(double percentage)
A percentage of available balance for this account will be returned to redis cluster when this method is called.
|
abstract void |
setFrozen(boolean frozen)
Setter for freeze/unfreeze state of an account
|
abstract void |
setLocalBalanceSyncTime(long localBalanceSyncTime)
Set the timestamp in millis when last time this instance was synced with slaved.
|
abstract boolean |
syncBalance()
Check and assign values in #localBalanceSyncTime.
|
abstract void |
updateAvailableRedisAmount()
After completing account freeze request we must set available redis amount to 0.
|
abstract void |
updateInformation(byte[] data,
int offset,
int length)
We have received information from master, Now we will update this
LeaseDTO with this latest attributes. |
public abstract void init(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 abstract void init(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 abstract 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 abstract void executeLuaScript(String luaFileName) throws Exception
Exceptionprotected abstract double increaseRedis(double amount)
JedisCluster instance. with given amount.amount - this amount will be increased in redispublic abstract double addLocalBalance(double extraLease)
extraLease - remaining lease amount. make sure that it's +vepublic abstract double returnAvailableBalancePercentage(double percentage)
percentage - What percentage of the available will be returned. For a full return percentage will be 100public abstract void updateAvailableRedisAmount()
public abstract long getAccountId()
public abstract double getAvailableLocalBalance()
public abstract double getAvailableRedisBalance()
public abstract void setFrozen(boolean frozen)
frozen - Boolean to freeze or unfreeze accountpublic abstract boolean isFrozen()
public abstract boolean syncBalance()
LeaseDTO. Otherwise, return falsepublic abstract long getLocalBalanceSyncTime()
public abstract void setLocalBalanceSyncTime(long localBalanceSyncTime)
localBalanceSyncTime - timestamp in milliseconds to be setpublic abstract int appendAttributes(byte[] data,
int index)
LeaseDTOConstantsdata - byte array where this LeaseDTO information will be appended.index - starting index of the byte array where this instance should be appended.public abstract void updateInformation(byte[] data,
int offset,
int length)
LeaseDTO with this latest attributes.data - byte array received from master.offset - starting index of the byte array.length - length of the byte array that contains valid information.public abstract void onProcessShutdown(boolean returnBalance)
returnBalance - If we want all the local balance to return in redis cluster then this value should be true,
otherwise this value should be false. If the application is running in standalone or running
as master this value should be true. It is considered that if the application is running in
redundancy mode only master should return balance in redis cluster and slave should not.public static LeaseDTO getInstance()
protected static void getClassReference()
Copyright © 2023. All rights reserved.