diff options
-rw-r--r-- | pom.xml | 5 | ||||
-rw-r--r-- | src/main/scala/org/xapek/influxdb/Main.scala | 34 |
2 files changed, 7 insertions, 32 deletions
@@ -59,11 +59,6 @@ <scope>test</scope> </dependency> <dependency> - <groupId>com.enragedginger</groupId> - <artifactId>akka-quartz-scheduler_${scala.version}</artifactId> - <version>1.4.0-akka-2.3.x</version> - </dependency> - <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.5</version> 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() |