Package com.ibm.fhir.schema.app
Class LeaseManager
- java.lang.Object
-
- com.ibm.fhir.schema.app.LeaseManager
-
- All Implemented Interfaces:
ILeaseManager
public class LeaseManager extends Object implements ILeaseManager
Manages acquisition and maintenance of the lease we need before we are allowed to perform any schema changes
-
-
Constructor Summary
Constructors Constructor Description LeaseManager(IDatabaseTranslator translator, IConnectionProvider connectionPool, ITransactionProvider transactionProvider, String adminSchema, String schemaName, ILeaseManagerConfig config)
Public constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
cancelLease()
Cancel the lease if this instance is the current ownerboolean
hasLease()
Do we have the lease?void
shutdown()
Stop the maintenance loopvoid
signalHeartbeat()
Marks the heartbeat flag true in the LeaseManager implementation to signal that forward progress is being made so the lease should continue to be held.boolean
waitForLease(int seconds)
Initial call to try to obtain the lease within the given number of seconds If the lease is obtained, we set up a lease maintenance thread to refresh the lease as long as heartbeat has been set to true since it last ran
-
-
-
Constructor Detail
-
LeaseManager
public LeaseManager(IDatabaseTranslator translator, IConnectionProvider connectionPool, ITransactionProvider transactionProvider, String adminSchema, String schemaName, ILeaseManagerConfig config)
Public constructor- Parameters:
translator
-connectionPool
-transactionProvider
-adminSchema
-schemaName
-config
-
-
-
Method Detail
-
signalHeartbeat
public void signalHeartbeat()
Description copied from interface:ILeaseManager
Marks the heartbeat flag true in the LeaseManager implementation to signal that forward progress is being made so the lease should continue to be held. Ignored (not required) ifILeaseManagerConfig.stayAlive()
is true (which is default).- Specified by:
signalHeartbeat
in interfaceILeaseManager
-
hasLease
public boolean hasLease()
Description copied from interface:ILeaseManager
Do we have the lease?- Specified by:
hasLease
in interfaceILeaseManager
- Returns:
-
shutdown
public void shutdown()
Stop the maintenance loop
-
waitForLease
public boolean waitForLease(int seconds)
Initial call to try to obtain the lease within the given number of seconds If the lease is obtained, we set up a lease maintenance thread to refresh the lease as long as heartbeat has been set to true since it last ran- Parameters:
seconds
-- Returns:
-
cancelLease
public boolean cancelLease()
Cancel the lease if this instance is the current owner
-
-