Modifier and Type | Method and Description |
---|---|
protected void |
addSession(SFSession session,
long masterTokenValidityInSecs,
int heartbeatFrequencyInSecs)
Method to add a session
|
static HeartbeatBackground |
getInstance() |
protected void |
removeSession(SFSession session)
Method to remove a session.
|
void |
run()
Run heartbeat: for each session send a heartbeat request and schedule
next heartbeat as long as there are sessions left.
|
public static HeartbeatBackground getInstance()
protected void addSession(SFSession session, long masterTokenValidityInSecs, int heartbeatFrequencyInSecs)
It will compare the master token validity and stored master token validity and if it is less, we will update the stored one and the heartbeat interval and reschedule heartbeat.
This method is called when a session is created.
session
- the session will be addedmasterTokenValidityInSecs
- time interval for which client need to
check validity of master token with serverprotected void removeSession(SFSession session)
session
- the session will be removedpublic void run()
Notice that the synchronization is only around the code that visits the global sessions map and the code that schedules next heartbeat, but not around the heartbeat calls for each session in order to minimize the chance of blocking the adding of a session by performing the heartbeats. This is because adding a session is called from JDBC connection creation call which directly affects application performance.
Copyright © 2020. All rights reserved.