-
Notifications
You must be signed in to change notification settings - Fork 841
Fixes #4948 | Lazy event parsing #4986
Fixes #4948 | Lazy event parsing #4986
Conversation
Can one of the admins verify this patch? |
1 similar comment
Can one of the admins verify this patch? |
6ae7526
to
a568f92
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good, I think it could actually be a fair amount simpler
val eventType: String = event.eventType | ||
lazy val message: String = Json.stringify(eventToJson(event)) | ||
} | ||
|
||
sealed trait MarathonEvent { | ||
val eventType: String | ||
val timestamp: String |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could have all of these have lazy val jsonString....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry I don't understand. If you are referring to put lazy val jsonString
into MarathonEvent
Then we need to ignore this filed during serialization. I created new class to distinct data from their view. We use JSON now but we can use Protobuf or something else in the future. Should I move JSONEvent
to SSE Actor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for forgetting about this... since we control the serialization/deserialization of these, we could have the jsonString as a member and not serialize the field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -16,7 +17,7 @@ import scala.util.Try | |||
trait HttpEventStreamHandle { | |||
def id: String | |||
def remoteAddress: String | |||
def sendEvent(event: String, message: String): Unit | |||
def sendEvent(event: Event): Unit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And then force these to be MarathonEvent
@@ -57,10 +55,10 @@ class HttpEventStreamHandleActor( | |||
private[this] def sendAllMessages(): Unit = { | |||
if (outstanding.nonEmpty) { | |||
val toSend = outstanding.reverse | |||
outstanding = List.empty[MarathonEvent] | |||
outstanding = List.empty[JsonEvent] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer Seq.empty over List.empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -5,11 +5,9 @@ import java.io.EOFException | |||
import akka.actor.{ Actor, ActorLogging, Status } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change the package into a double declaration?
e.g.
package mesosphere.marathon
package core.event.impl.stream```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -1,6 +1,7 @@ | |||
package mesosphere.marathon.core.event |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you double package this too?
ok to test |
27065b0
to
a4cb973
Compare
a4cb973
to
33a52c1
Compare
Rebased |
Change SSE event stream handler to use events that are lazy parsed to JSON. This will reduce CPU time when most events are filtered and/or when more then one subscriper is connected.
33a52c1
to
de22344
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Thanks @janisz !
|
Cherry-picked: de22344
Change SSE event stream handler to use events that are
lazy parsed to JSON. This will reduce CPU time when most events
are filtered and/or when more then one subscriper is connected.