Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
streamingUserPortrait
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵威
streamingUserPortrait
Commits
fb29399c
Commit
fb29399c
authored
Feb 07, 2021
by
赵威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get data
parent
5250cae6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
16 deletions
+7
-16
Main.scala
src/main/scala/com.gmei.up/Main.scala
+5
-12
Redis.scala
src/main/scala/com.gmei.up/utils/Redis.scala
+2
-4
No files found.
src/main/scala/com.gmei.up/Main.scala
View file @
fb29399c
package
com.gmei.up
import
java.util.Properties
// TODO remove
// import com.typesafe.scalalogging.LazyLogging
import
com.typesafe.scalalogging.LazyLogging
import
org.apache.flink.api.scala._
import
org.apache.flink.streaming.api.scala.
{
StreamExecutionEnvironment
,
DataStream
}
import
org.apache.flink.streaming.connectors.kafka.
{
...
...
@@ -29,15 +28,12 @@ class UserInfoDeserializationSchema extends KafkaDeserializationSchema[UserInfo]
Types
.
GENERIC
(
classOf
[
UserInfo
])
}
// TODO remove
// extends LazyLogging
object
Main
{
object
Main
extends
LazyLogging
{
def
main
(
args
:
Array
[
String
])
:
Unit
=
// println("###############")
// val query = ES.generateServiceDiaryRequest(List("光子嫩肤", "水光针"), List("丰胸", "胸部塑身"), -1)
// println("###############")
try
{
// TODO logger
// logger.info("UserPortrait Flink Started")
val
env
=
StreamExecutionEnvironment
.
getExecutionEnvironment
...
...
@@ -112,8 +108,7 @@ object Main {
Redis
.
saveServiceDiary
(
ES
.
request
(
serviceDiaryReq
),
deviceId
)
// current time
// TODO logger
// logger.info(s"${user.eventCn} ${deviceId}")
logger
.
info
(
s
"${user.eventCn} ${deviceId}"
)
val
cost
=
streamTimeBegin
-
user
.
sendTimestamp
if
(
cost
>
1000
)
{
...
...
@@ -141,8 +136,7 @@ object Main {
Map
(
"Main.main"
->
"stream.map"
,
"error"
->
e
.
getStackTrace
.
mkString
(
"\n"
)),
contentType
=
"exception"
)
// TODO logger
// logger.error(e.getStackTrace.mkString("\n"))
logger
.
error
(
e
.
getStackTrace
.
mkString
(
"\n"
))
e
.
printStackTrace
()
""
}
...
...
@@ -157,8 +151,7 @@ object Main {
Map
(
"method"
->
"main"
,
"error"
->
e
.
getStackTrace
.
mkString
(
"\n"
)),
contentType
=
"exception"
)
// TODO logger
// logger.error(e.getStackTrace.mkString("\n"))
logger
.
error
(
e
.
getStackTrace
.
mkString
(
"\n"
))
e
.
printStackTrace
()
}
}
src/main/scala/com.gmei.up/utils/Redis.scala
View file @
fb29399c
...
...
@@ -7,7 +7,6 @@ import com.redis.{ RedisClient, RedisClientPool }
import
org.json4s._
import
org.json4s.jackson.Serialization
import
org.json4s.jackson.Serialization.
{
read
,
write
}
import
org.json4s.jackson.JsonMethods._
object
Redis
{
// TODO read from config file
...
...
@@ -78,11 +77,10 @@ object Redis {
pRc4
.
withClient
{
client
=>
contentFuture
.
foreach
{
seq
=>
val
idPairs
=
seq
.
map
(
c
=>
(
c
.
id
,
c
.
serviceId
.
getOrElse
(
"-1"
)))
val
a
=
write
(
idPairs
)
println
(
a
)
val
res
=
write
(
idPairs
)
if
(
idPairs
.
size
>
0
)
{
client
.
del
(
key
)
client
.
set
(
key
,
a
)
client
.
set
(
key
,
res
)
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment