Skip to content

Commit

Permalink
Fix #3 Log INFO when failed replication event queue changes from none…
Browse files Browse the repository at this point in the history
…mpty to empty
  • Loading branch information
ngocdaothanh committed Mar 20, 2015
1 parent 99da83a commit 8a9156c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
15 changes: 12 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
1.1: Improve performance by running event processing in a separate thread to
avoid blocking the MySQL binlog [event reader thread](https://github.com/shyiko/mysql-binlog-connector-java/issues/32).
1.2:

1.0: First public release.
* [#3](https://github.com/ngocdaothanh/mydit/issues/3)
Log INFO when failed replication event queue changes from nonempty to empty

1.1:

* [#1](https://github.com/ngocdaothanh/mydit/issues/1)
Improve performance by running event processing in a separate thread to
avoid blocking the MySQL binlog
[event reader thread](https://github.com/shyiko/mysql-binlog-connector-java/issues/32)

1.0: First public release
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
organization := "tv.cntt"
name := "mydit"
version := "1.1-SNAPSHOT"
version := "1.2-SNAPSHOT"

scalaVersion := "2.11.6"

Expand Down
13 changes: 9 additions & 4 deletions src/main/scala/mydit/Rep.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class Rep(config: Config) extends RepEvent.Listener {
}

private def processEvent(event: RepEvent.Event) {
val lastQSize = failedEventQ.size

// Replicate things in the queue first
var ok = true
while (ok && failedEventQ.nonEmpty) {
Expand All @@ -49,16 +51,19 @@ class Rep(config: Config) extends RepEvent.Listener {

if (!ok) failedEventQ.enqueue(event)

val qSize = failedEventQ.size
if (qSize > 0) {
Log.info("Failed replication event queue size: {}", qSize)
if (qSize > config.maxFailedEventQueueSize) {
val newQSize = failedEventQ.size
if (newQSize > 0) {
Log.info("Failed replication event queue size: {}", newQSize)
if (newQSize > config.maxFailedEventQueueSize) {
Log.error(
"Replicator program now exits because the failed replication event queue size exceeds {} (see config/application.conf)",
config.maxFailedEventQueueSize
)
System.exit(-1)
}
} else if (lastQSize > 0) {
// newQSize is now 0, congratulations!
Log.info("Failed replication event queue is now empty, before: {}", lastQSize)
}
}

Expand Down

0 comments on commit 8a9156c

Please sign in to comment.