diff options
author | Harald Musum <musum@verizonmedia.com> | 2021-02-11 11:46:09 +0100 |
---|---|---|
committer | Harald Musum <musum@verizonmedia.com> | 2021-02-11 11:46:09 +0100 |
commit | 10fd7a4589593ede6ffa649cc06a3f4918d87072 (patch) | |
tree | 671198356c39680b8623c85893cd3f242b76bdbd /zookeeper-server/zookeeper-server-common | |
parent | 9afe424d0469b4946574e77b56b9f108e4615c87 (diff) |
Do logAndDie in reconfigure method
Diffstat (limited to 'zookeeper-server/zookeeper-server-common')
-rw-r--r-- | zookeeper-server/zookeeper-server-common/src/main/java/com/yahoo/vespa/zookeeper/Reconfigurer.java | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/zookeeper-server/zookeeper-server-common/src/main/java/com/yahoo/vespa/zookeeper/Reconfigurer.java b/zookeeper-server/zookeeper-server-common/src/main/java/com/yahoo/vespa/zookeeper/Reconfigurer.java index f358ea827a9..f967f56b04f 100644 --- a/zookeeper-server/zookeeper-server-common/src/main/java/com/yahoo/vespa/zookeeper/Reconfigurer.java +++ b/zookeeper-server/zookeeper-server-common/src/main/java/com/yahoo/vespa/zookeeper/Reconfigurer.java @@ -5,6 +5,7 @@ import com.google.inject.Inject; import com.yahoo.cloud.config.ZookeeperServerConfig; import com.yahoo.component.AbstractComponent; import com.yahoo.net.HostName; +import com.yahoo.protect.Process; import com.yahoo.yolean.Exceptions; import java.time.Duration; @@ -52,10 +53,7 @@ public class Reconfigurer extends AbstractComponent { zooKeeperRunner = startServer(newConfig, server); if (shouldReconfigure(newConfig)) { - if ( ! reconfigure(newConfig)) { - server.shutdown(); - System.exit(1); // Reconfiguration failed, give up, we don't know why - } + reconfigure(newConfig, server); } } @@ -81,7 +79,7 @@ public class Reconfigurer extends AbstractComponent { return runner; } - private boolean reconfigure(ZookeeperServerConfig newConfig) { + private void reconfigure(ZookeeperServerConfig newConfig, VespaZooKeeperServer server) { Instant reconfigTriggered = Instant.now(); List<String> newServers = difference(servers(newConfig), servers(activeConfig)); String leavingServers = String.join(",", difference(serverIds(activeConfig), serverIds(newConfig))); @@ -92,7 +90,8 @@ public class Reconfigurer extends AbstractComponent { ", leaving servers: " + leavingServers); String connectionSpec = localConnectionSpec(activeConfig); Instant now = Instant.now(); - Instant end = now.plus(reconfigTimeout(newServers.size())); + Duration reconfigTimeout = reconfigTimeout(newServers.size()); + Instant end = now.plus(reconfigTimeout); // Loop reconfiguring since we might need to wait until another reconfiguration is finished before we can succeed for (int attempt = 1; now.isBefore(end); attempt++) { try { @@ -104,7 +103,7 @@ public class Reconfigurer extends AbstractComponent { ", after " + attempt + " attempt(s). ZooKeeper reconfig call took " + Duration.between(reconfigStarted, reconfigEnded)); activeConfig = newConfig; - return true; + return; } catch (ReconfigException e) { Duration delay = backoff.delay(attempt); log.log(Level.WARNING, "Reconfiguration attempt " + attempt + " failed. Retrying in " + delay + @@ -117,7 +116,8 @@ public class Reconfigurer extends AbstractComponent { } // Reconfiguration failed - return false; + server.shutdown(); + Process.logAndDie("Reconfiguration did not complete within timeout " + reconfigTimeout + ". Forcing shutdown"); } /** Returns the timeout to use for the given joining server count */ |