diff options
author | Yves Fischer <yvesf-git@xapek.org> | 2015-08-03 00:18:20 +0200 |
---|---|---|
committer | Yves Fischer <yvesf-git@xapek.org> | 2015-08-03 00:18:20 +0200 |
commit | dcabe1a774ac3ab6eee7e837aa09ee26b60e8b82 (patch) | |
tree | 1647576f1d327c8720acda6dc489e051402aa6e9 /src/main/scala/org/xapek/influxdb/Main.scala | |
parent | ab3a129bfd7572d6d3d9457b5ded57c1a811f748 (diff) | |
download | influxdb-tools-master.tar.gz influxdb-tools-master.zip |
Diffstat (limited to 'src/main/scala/org/xapek/influxdb/Main.scala')
-rw-r--r-- | src/main/scala/org/xapek/influxdb/Main.scala | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/src/main/scala/org/xapek/influxdb/Main.scala b/src/main/scala/org/xapek/influxdb/Main.scala deleted file mode 100644 index 206183c..0000000 --- a/src/main/scala/org/xapek/influxdb/Main.scala +++ /dev/null @@ -1,62 +0,0 @@ -package org.xapek.influxdb - - -import java.util.Date -import java.util.Calendar -import akka.actor.Actor -import akka.actor.Props -import akka.event.Logging -import akka.actor.ActorDSL -import akka.actor.ActorRef -import akka.actor.ActorSystem -import akka.actor.ActorLogging -import com.typesafe.config.ConfigFactory -import org.xapek.influxdb.InfluxDB._ -import scala.concurrent.duration.Duration -import java.util.concurrent.TimeUnit - -case object TimerSignal - -class InfluxReader(db: InfluxDB, date1: Date, date2: Date, receiver: ActorRef) extends Actor with ActorLogging { - val query = SELECT("Bid")("Ask")("Volume") FROM "yahoo.GOOGL" WHERE time > date1 && time < date2 - val mapper = new Mapper(db, query) - def receive = { - case TimerSignal => - log.info("Run query") - receiver ! (mapper.map { (time, bid, ask, volume) => s"time=$time bid=$bid ask=$ask volume=$volume" }) - } -} - -class ConsoleWriter extends Actor with ActorLogging { - def receive = { - case value => - log.info(value.toString) - } -} - -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") - - val calendar = Calendar.getInstance - calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 4) - val date1 = calendar.getTime - calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) + 1) - val date2 = calendar.getTime - - val system = ActorSystem("AkkaSystem") - - val writer = system.actorOf(Props(new ConsoleWriter()), "writer") - val reader = system.actorOf(Props(new InfluxReader(db, date1, date2, writer)), "reader") - - 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() - system.shutdown() - } -} - |