Class ClusterHeartbeatDAOHibernate


public class ClusterHeartbeatDAOHibernate extends HibernateDao<ClusterHeartbeatEntity>
Hibernate DAO to store node heartbeats
  • Constructor Details

    • ClusterHeartbeatDAOHibernate

      public ClusterHeartbeatDAOHibernate()
  • Method Details

    • getPersistentClass

      public Class<ClusterHeartbeatEntity> getPersistentClass()
      Description copied from class: HibernateDao
      All subclasses of HibernateDao must implement this method for HibernateDao.load(Serializable) to work correctly.
      Specified by:
      getPersistentClass in class HibernateDao<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 ids
      nodeName - the desired node names
      timestamp - 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

      @Nullable public ClusterHeartbeatEntity getHeartbeat(String nodeId)
      Parameters:
      nodeId - the node id to find the heartbeat for
      Returns:
      the heartbeat entity, or null if not found
    • findHeartbeatsAfter

      public List<ClusterHeartbeatEntity> findHeartbeatsAfter(long timestamp)
    • removeHeartbeatsBefore

      public int removeHeartbeatsBefore(long timestamp)