From ab3a129bfd7572d6d3d9457b5ded57c1a811f748 Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Sun, 2 Aug 2015 23:26:58 +0200 Subject: Remove dependency to quartz --- src/main/scala/org/xapek/influxdb/Main.scala | 34 ++++++---------------------- 1 file changed, 7 insertions(+), 27 deletions(-) (limited to 'src/main/scala/org/xapek') diff --git a/src/main/scala/org/xapek/influxdb/Main.scala b/src/main/scala/org/xapek/influxdb/Main.scala index 89fcd2f..206183c 100644 --- a/src/main/scala/org/xapek/influxdb/Main.scala +++ b/src/main/scala/org/xapek/influxdb/Main.scala @@ -3,7 +3,6 @@ package org.xapek.influxdb import java.util.Date import java.util.Calendar - import akka.actor.Actor import akka.actor.Props import akka.event.Logging @@ -11,13 +10,10 @@ import akka.actor.ActorDSL import akka.actor.ActorRef import akka.actor.ActorSystem import akka.actor.ActorLogging - -import com.typesafe.akka.extension.quartz.QuartzSchedulerExtension import com.typesafe.config.ConfigFactory -import org.quartz.impl.StdSchedulerFactory - import org.xapek.influxdb.InfluxDB._ - +import scala.concurrent.duration.Duration +import java.util.concurrent.TimeUnit case object TimerSignal @@ -39,7 +35,6 @@ class ConsoleWriter extends Actor with ActorLogging { } object Main { - def main(args: Array[String]): Unit = { val db: InfluxDB = fromUrl("http://root:root@db.2.localnet.cc:8086/query?db=data&user=root&password=root") @@ -49,30 +44,15 @@ object Main { calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) + 1) val date2 = calendar.getTime - // Disable silly update check - System.setProperty(StdSchedulerFactory.PROP_SCHED_SKIP_UPDATE_CHECK, "true"); - - val akkaConfig = ConfigFactory.parseString(""" - akka { - quartz { - defaultTimezone = "UTC" - schedules { - cronEvery5Seconds { - description = "A cron job that fires off every 10 seconds" - expression = "*/5 * * ? * *" - } - } - } - }""".stripMargin) - - println(akkaConfig) - val system = ActorSystem("test", akkaConfig) - val scheduler = QuartzSchedulerExtension(system) + val system = ActorSystem("AkkaSystem") val writer = system.actorOf(Props(new ConsoleWriter()), "writer") val reader = system.actorOf(Props(new InfluxReader(db, date1, date2, writer)), "reader") - scheduler.schedule("cronEvery5Seconds", reader, TimerSignal) + system.scheduler.schedule( + Duration.create(5, TimeUnit.SECONDS), + Duration.create(5, TimeUnit.SECONDS), + reader, TimerSignal)(system.dispatcher, null) println("Press key to exit") System.in.read() -- cgit v1.2.1