Skip to content

Commit

Permalink
#302 Improve replication service
Browse files Browse the repository at this point in the history
  • Loading branch information
dvoraka committed Jan 6, 2018
1 parent 82abcd7 commit e57b896
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,22 @@ public void stop() {

private void scheduleDiscovery() {
executorService.scheduleWithFixedDelay(
this::discoverNeighbours, 0, DISCOVER_DELAY, TimeUnit.MILLISECONDS);
this::discoverNeighboursSafe, 0, DISCOVER_DELAY, TimeUnit.MILLISECONDS);
}

private void waitForOthers() {
waitUntil(responseClient::isRunning);
waitUntil(remoteLock::isRunning);
}

private void discoverNeighboursSafe() {
try {
discoverNeighbours();
} catch (Exception e) {
log.warn("Discovery failed!", e);
}
}

private void discoverNeighbours() {
log.debug("Discovering neighbours {}...", idString);

Expand All @@ -139,6 +147,7 @@ private void discoverNeighbours() {
log.debug("Discovered {}: {}", idString, neighbourCount());
}

//TODO: if it's stopped it sets running flag again
if (!isRunning()) {
setRunning(true);
}
Expand Down

0 comments on commit e57b896

Please sign in to comment.