Package com.netgrif.quartz.mongodb.dao
Class SchedulerDao
- java.lang.Object
-
- com.netgrif.quartz.mongodb.dao.SchedulerDao
-
public class SchedulerDao extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCHECKIN_INTERVAL_FIELDClockclocklongclusterCheckinIntervalMillisstatic java.lang.StringINSTANCE_ID_FIELDjava.lang.StringinstanceIdstatic java.lang.StringLAST_CHECKIN_TIME_FIELDstatic java.lang.StringSCHEDULER_NAME_FIELDcom.mongodb.client.MongoCollection<org.bson.Document>schedulerCollectionjava.lang.StringschedulerName
-
Constructor Summary
Constructors Constructor Description SchedulerDao(com.mongodb.client.MongoCollection<org.bson.Document> schedulerCollection, java.lang.String schedulerName, java.lang.String instanceId, long clusterCheckinIntervalMillis, Clock clock)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckIn()Checks-in in cluster to inform other nodes that its alive.voidcreateIndex()SchedulerfindInstance(java.lang.String instanceId)java.util.List<Scheduler>getAllByCheckinTime()Return all scheduler instances in ascending order by last check-in time.com.mongodb.client.MongoCollection<org.bson.Document>getCollection()booleanisNotSelf(Scheduler scheduler)booleanremove(java.lang.String instanceId, long lastCheckinTime)Remove selected scheduler instance entry from database.
-
-
-
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 idlastCheckinTime- last time scheduler has checked in- Returns:
- when removed successfully
-
-