Skip to content

Commit

Permalink
Merge pull request #292 from zendesk/heartbeats
Browse files Browse the repository at this point in the history
consume OpenReplicator heartbeats
  • Loading branch information
Ben Osheroff committed Mar 8, 2016
2 parents 32e3a61 + f27fa25 commit 4c101c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<dependency>
<groupId>com.zendesk</groupId>
<artifactId>open-replicator</artifactId>
<version>1.4.0</version>
<version>1.4.2</version>
</dependency>
<dependency>
<groupId>net.sf.jopt-simple</groupId>
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/zendesk/maxwell/MaxwellReplicator.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public MaxwellReplicator(Schema currentSchema, AbstractProducer producer, Abstra

this.replicator.setLevel2BufferSize(50 * 1024 * 1024);

this.replicator.setHeartbeatPeriod(0.5f);

this.producer = producer;
this.bootstrapper = bootstrapper;

Expand All @@ -79,6 +81,13 @@ private void ensureReplicatorThread() throws Exception {
LOGGER.warn("open-replicator stopped at position " + replicator.getBinlogFileName() + ":" + replicator.getBinlogPosition() + " -- restarting");
replicator.start();
}

Long ms = replicator.millisSinceLastEvent();
if ( ms != null && ms > 2000 ) {
LOGGER.warn("no heartbeat heard from server in " + ms + "ms. restarting replication.");
replicator.stop(5, TimeUnit.SECONDS);
replicator.start();
}
}

@Override
Expand Down

0 comments on commit 4c101c3

Please sign in to comment.