Class SchedulerDao


  • public class SchedulerDao
    extends java.lang.Object
    • Field Detail

      • SCHEDULER_NAME_FIELD

        public static final java.lang.String SCHEDULER_NAME_FIELD
        See Also:
        Constant Field Values
      • INSTANCE_ID_FIELD

        public static final java.lang.String INSTANCE_ID_FIELD
        See Also:
        Constant Field Values
      • LAST_CHECKIN_TIME_FIELD

        public static final java.lang.String LAST_CHECKIN_TIME_FIELD
        See Also:
        Constant Field Values
      • CHECKIN_INTERVAL_FIELD

        public static final java.lang.String CHECKIN_INTERVAL_FIELD
        See Also:
        Constant Field Values
      • schedulerCollection

        public final com.mongodb.client.MongoCollection<org.bson.Document> schedulerCollection
      • schedulerName

        public final java.lang.String schedulerName
      • instanceId

        public final java.lang.String instanceId
      • clusterCheckinIntervalMillis

        public final long clusterCheckinIntervalMillis
      • clock

        public final Clock clock
    • Constructor Detail

      • SchedulerDao

        public SchedulerDao​(com.mongodb.client.MongoCollection<org.bson.Document> schedulerCollection,
                            java.lang.String schedulerName,
                            java.lang.String instanceId,
                            long clusterCheckinIntervalMillis,
                            Clock clock)
    • Method Detail

      • getCollection

        public com.mongodb.client.MongoCollection<org.bson.Document> getCollection()
      • createIndex

        public void createIndex()
      • checkIn

        public void checkIn()
        Checks-in in cluster to inform other nodes that its alive.
      • findInstance

        public Scheduler findInstance​(java.lang.String instanceId)
        Returns:
        Scheduler or null when not found
      • isNotSelf

        public boolean isNotSelf​(Scheduler scheduler)
      • getAllByCheckinTime

        public java.util.List<Scheduler> getAllByCheckinTime()
        Return all scheduler instances in ascending order by last check-in time.
        Returns:
        schedler instances ordered by last check-in time
      • remove

        public boolean remove​(java.lang.String instanceId,
                              long lastCheckinTime)
        Remove selected scheduler instance entry from database. The scheduler is selected based on its name, instanceId, and lastCheckinTime. If the last check-in time is different, then it is not removed, for it might have gotten back to live.
        Parameters:
        instanceId - instance id
        lastCheckinTime - last time scheduler has checked in
        Returns:
        when removed successfully