Commit 83ac5e1b authored by 赵威's avatar 赵威

get time

parent ee417a0d
package com.gmei.up package com.gmei.up
import java.util.Properties import java.util.Properties
import java.time.Instant
import com.typesafe.scalalogging.LazyLogging import com.typesafe.scalalogging.LazyLogging
import org.apache.flink.api.scala._ import org.apache.flink.api.scala._
import org.apache.flink.streaming.api.scala.{ StreamExecutionEnvironment, DataStream } import org.apache.flink.streaming.api.scala.{ StreamExecutionEnvironment, DataStream }
...@@ -63,7 +62,7 @@ object Main extends LazyLogging { ...@@ -63,7 +62,7 @@ object Main extends LazyLogging {
val secondPositions = user.secondPositions.toList val secondPositions = user.secondPositions.toList
val secondSolutions = user.secondSolutions.toList val secondSolutions = user.secondSolutions.toList
val cityId = user.cityId val cityId = user.cityId
val streamBeginTimestamp: Long = Instant.now.getEpochSecond val streamTimeBegin: Long = System.currentTimeMillis
println(deviceId) println(deviceId)
// println(projects.mkString(" ")) // println(projects.mkString(" "))
...@@ -103,10 +102,10 @@ object Main extends LazyLogging { ...@@ -103,10 +102,10 @@ object Main extends LazyLogging {
100 100
) )
Redis.save(ES.request(diaryReq), deviceId, "diary", streamBeginTimestamp) Redis.save(ES.request(diaryReq), deviceId, "diary", streamTimeBegin)
Redis.save(ES.request(tractateReq), deviceId, "tractate", streamBeginTimestamp) Redis.save(ES.request(tractateReq), deviceId, "tractate", streamTimeBegin)
Redis.save(ES.request(answerReq), deviceId, "answer", streamBeginTimestamp) Redis.save(ES.request(answerReq), deviceId, "answer", streamTimeBegin)
Redis.save(ES.request(serviceDiaryReq), deviceId, "service_diary", streamBeginTimestamp) Redis.save(ES.request(serviceDiaryReq), deviceId, "service_diary", streamTimeBegin)
// current time // current time
logger.info(s"${user.eventCn} ${deviceId}") logger.info(s"${user.eventCn} ${deviceId}")
......
...@@ -2,7 +2,6 @@ package com.gmei.up.utils ...@@ -2,7 +2,6 @@ package com.gmei.up.utils
import scala.concurrent.Future import scala.concurrent.Future
import scala.collection.JavaConverters._ import scala.collection.JavaConverters._
import java.time.Instant
import com.alibaba.fastjson.JSON import com.alibaba.fastjson.JSON
import com.redis.{ RedisClient, RedisClientPool } import com.redis.{ RedisClient, RedisClientPool }
...@@ -27,7 +26,7 @@ object Redis { ...@@ -27,7 +26,7 @@ object Redis {
contentEitherFuture: Either[Throwable, Future[IndexedSeq[Content]]], contentEitherFuture: Either[Throwable, Future[IndexedSeq[Content]]],
deviceId: String, deviceId: String,
contentType: String, contentType: String,
timestampBegin: Long timeBegin: Long
): Unit = { ): Unit = {
val key = s"streaming:candidate:${contentType}:device_id:${deviceId}" val key = s"streaming:candidate:${contentType}:device_id:${deviceId}"
...@@ -50,7 +49,7 @@ object Redis { ...@@ -50,7 +49,7 @@ object Redis {
"method" -> "Redis.save", "method" -> "Redis.save",
"deviceId" -> deviceId, "deviceId" -> deviceId,
"contentType" -> contentType, "contentType" -> contentType,
"streamTotalSeconds" -> s"${(Instant.now.getEpochSecond * 1000 - timestampBegin * 1000)}ms" "streamTotalSeconds" -> s"${(System.currentTimeMillis - timeBegin * 1000)}ms"
) )
) )
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment