Package com.reve.balancemanager.pubsub
Class PubSubPublisher
java.lang.Object
java.lang.Thread
com.reve.balancemanager.pubsub.PubSubPublisher
- All Implemented Interfaces:
Runnable
Publisher class to publish messages in Redis cluster pubsub
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionPubSubPublisher(String identifier, com.reve.redis.cluster.ClusterObserver clusterObserver) -
Method Summary
Modifier and TypeMethodDescriptionvoidackFreezeRequest(long accountID) For some reason like balance mismatch between redis and mysql in some point, we may need to freeze the account and match the balance in redis and mysql.voidpublishCompletedFreeze(long accountID) For some reason like balance mismatch between redis and mysql in some point, we may need to freeze the account and match the balance in redis and mysql.voidpublishCompletedUnfreeze(long accountID) When balance matching is done by mitigation process, it will send an unfreeze request.voidpublishEmptyLeaseStatus(long accountID) Whenever Balance manager detects zero balance in redis cache, it transmits a warning to all Balance manager.voidpublishFreezeRequest(long accountID) Publish aMessageType.FREEZE_REQUESTmessage inChannels.BALANCE_FREEZE_CHANNELto freeze the given account ID.voidpublishUnfreezeRequest(long accountID) Publish aMessageType.UNFREEZE_REQUESTmessage inChannels.BALANCE_FREEZE_CHANNELto un-freeze the given account ID.voidrun()Thread run method.voidshutDown()Shutdown this threadMethods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
Constructor Details
-
PubSubPublisher
-
-
Method Details
-
run
public void run()Thread run method. -
publishEmptyLeaseStatus
public void publishEmptyLeaseStatus(long accountID) Whenever Balance manager detects zero balance in redis cache, it transmits a warning to all Balance manager. So other balance manager can return some of their local money in redis, and this one can take it.- Parameters:
accountID- Account ID for which balance goes to zero in redis.
-
ackFreezeRequest
public void ackFreezeRequest(long accountID) For some reason like balance mismatch between redis and mysql in some point, we may need to freeze the account and match the balance in redis and mysql. So whenever any freeze request is received, we must send an ACK to notify that this BM has received this request, and it is processing.- Parameters:
accountID- Account ID for which freeze request was received.
-
publishCompletedFreeze
public void publishCompletedFreeze(long accountID) For some reason like balance mismatch between redis and mysql in some point, we may need to freeze the account and match the balance in redis and mysql. So whenever any freeze request is received, we must freeze all transaction as well as drop all the call of that account make the bill. Then we must notify that my side of freezing this account is done.- Parameters:
accountID- Account ID for which freeze request was received.
-
publishCompletedUnfreeze
public void publishCompletedUnfreeze(long accountID) When balance matching is done by mitigation process, it will send an unfreeze request. We must respond to that.- Parameters:
accountID- Account ID for which unfreeze request was received.
-
publishFreezeRequest
public void publishFreezeRequest(long accountID) Publish aMessageType.FREEZE_REQUESTmessage inChannels.BALANCE_FREEZE_CHANNELto freeze the given account ID. Once we send this message, the receiver on the other end will send anMessageType.ACK_FREEZE_REQUESTimmediately. And then the receiver will do whatever it required at their end to freeze the request.- Parameters:
accountID- Account ID for which freeze request to be sent.
-
publishUnfreezeRequest
public void publishUnfreezeRequest(long accountID) Publish aMessageType.UNFREEZE_REQUESTmessage inChannels.BALANCE_FREEZE_CHANNELto un-freeze the given account ID. Once we send this message, the receiver on the other end will do whatever it required at their end to un-freeze the request.- Parameters:
accountID- Account ID for which un-freeze request to be sent.
-
shutDown
public void shutDown()Shutdown this thread
-