tech.mlsql.scheduler.algorithm.TimeScheduler.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mlsql-scheduler Show documentation
Show all versions of mlsql-scheduler Show documentation
A library for job scheduler based on MLSQL
The newest version!
package tech.mlsql.scheduler.algorithm
import java.util.TimeZone
import it.sauronsoftware.cron4j.{Scheduler, TaskCollector}
/**
* 2019-09-05 WilliamZhu([email protected])
*/
object TimeScheduler {
val scheduler = new Scheduler()
def start(tc: TaskCollector, timeZone: String) = {
if (!scheduler.isStarted) {
scheduler.setTimeZone(TimeZone.getTimeZone(timeZone))
scheduler.addTaskCollector(tc)
scheduler.start()
}
}
def stop() = {
scheduler.stop()
}
}