From 8a9156c23ae599e424a8217a428f50a825e73cf0 Mon Sep 17 00:00:00 2001 From: Ngoc Dao Date: Sat, 21 Mar 2015 07:13:00 +0900 Subject: [PATCH] Fix #3 Log INFO when failed replication event queue changes from nonempty to empty --- CHANGELOG.md | 15 ++++++++++++--- build.sbt | 2 +- src/main/scala/mydit/Rep.scala | 13 +++++++++---- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e74fbed..f3fc19d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/build.sbt b/build.sbt index 383e70a..be79d38 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,6 @@ organization := "tv.cntt" name := "mydit" -version := "1.1-SNAPSHOT" +version := "1.2-SNAPSHOT" scalaVersion := "2.11.6" diff --git a/src/main/scala/mydit/Rep.scala b/src/main/scala/mydit/Rep.scala index ab84427..ec119d0 100644 --- a/src/main/scala/mydit/Rep.scala +++ b/src/main/scala/mydit/Rep.scala @@ -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) { @@ -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) } }