Package com.atlassian.crowd.dao.cluster
Class ClusterHeartbeatDAOHibernate
java.lang.Object
com.atlassian.crowd.util.persistence.hibernate.StatelessDao
com.atlassian.crowd.util.persistence.hibernate.HibernateDao<ClusterHeartbeatEntity>
com.atlassian.crowd.dao.cluster.ClusterHeartbeatDAOHibernate
Hibernate DAO to store node heartbeats
-
Field Summary
Fields inherited from class com.atlassian.crowd.util.persistence.hibernate.HibernateDao
batchFinder, batchProcessor, logger, statelessSessionBatchProcessor, timeSource
Fields inherited from class com.atlassian.crowd.util.persistence.hibernate.StatelessDao
sessionFactory
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindHeartbeatsAfter
(long timestamp) getHeartbeat
(String nodeId) All subclasses of HibernateDao must implement this method forHibernateDao.load(Serializable)
to work correctly.int
removeHeartbeatsBefore
(long timestamp) void
writeHeartBeat
(ClusterHeartbeatEntity heartbeatEntity) Inserts or updates the heartbeat entitywriteNewHeartbeat
(Supplier<String> nodeIdSupplier, String nodeName, long timestamp) Tries to insert a new heartbeat based on the parameters.Methods inherited from class com.atlassian.crowd.util.persistence.hibernate.HibernateDao
createDeleteQuery, createDeleteQuery, createQuery, createQuery, executeHQLQuery, findAllInternal, findByProperties, findByPropertiesOptional, findByProperty, findByProperty, findByPropertyOptional, findByPropertyOrThrow, getCountByProperties, load, load, loadOptional, loadReference, loadReference, remove, removeByIdIfPresent, save, saveOrUpdate, session, setBatchFinder, setBatchProcessor, setClock, setStatelessSessionBatchProcessor, toPredicates, update
Methods inherited from class com.atlassian.crowd.util.persistence.hibernate.StatelessDao
setSessionFactory, withStatelessSession
-
Constructor Details
-
ClusterHeartbeatDAOHibernate
public ClusterHeartbeatDAOHibernate()
-
-
Method Details
-
getPersistentClass
Description copied from class:HibernateDao
All subclasses of HibernateDao must implement this method forHibernateDao.load(Serializable)
to work correctly.- Specified by:
getPersistentClass
in classHibernateDao<ClusterHeartbeatEntity>
- Returns:
- the entity class for this DAO
-
writeNewHeartbeat
public String writeNewHeartbeat(Supplier<String> nodeIdSupplier, String nodeName, long timestamp) throws OperationFailedException Tries to insert a new heartbeat based on the parameters. Should be used on node startup, to guarantee a unique nodeId. If the node id provided is already used, will call the supplier multiple times to obtain one that isn't.- Parameters:
nodeIdSupplier
- a supplier of unique node idsnodeName
- the desired node namestimestamp
- the desired timestamp of the heartbeat- Returns:
- the node id for the successfully inserted heartbeat
- Throws:
OperationFailedException
- if insertion fails despite retries
-
writeHeartBeat
public void writeHeartBeat(ClusterHeartbeatEntity heartbeatEntity) throws org.springframework.dao.DataAccessException Inserts or updates the heartbeat entity- Throws:
org.springframework.dao.DataAccessException
-
getHeartbeat
- Parameters:
nodeId
- the node id to find the heartbeat for- Returns:
- the heartbeat entity, or null if not found
-
findHeartbeatsAfter
-
removeHeartbeatsBefore
public int removeHeartbeatsBefore(long timestamp)
-