diff options
author | Harald Musum <musum@oath.com> | 2018-12-18 13:10:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-18 13:10:49 +0100 |
commit | 89d7fe502befea2d85e14d15116270cba6c8a71d (patch) | |
tree | a195e753f0d3eea5c5d9f562d48e6b31b900885b | |
parent | 7461afb5fb96d389c9d61831b36abf96f7e02472 (diff) | |
parent | bd15c3ad7d04966bf3b60c2fd4095791648a4e24 (diff) |
Merge pull request #7959 from vespa-engine/hmusum/use-feature-flag-for-bootstrap-in-separate-thread
Use feature flag to control how to do bootstrapping
3 files changed, 28 insertions, 17 deletions
diff --git a/configdefinitions/src/vespa/configserver.def b/configdefinitions/src/vespa/configserver.def index 999a25d32f7..de626d5f3fa 100644 --- a/configdefinitions/src/vespa/configserver.def +++ b/configdefinitions/src/vespa/configserver.def @@ -70,4 +70,3 @@ sleepTimeWhenRedeployingFails long default=30 buildMinimalSetOfConfigModels bool default=true useDedicatedNodeForLogserver bool default=true throwIfBootstrappingTenantRepoFails bool default=true -bootstrapInSeparateThread bool default=true diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ConfigServerBootstrap.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ConfigServerBootstrap.java index f163a100fd8..0b1684b6735 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/ConfigServerBootstrap.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ConfigServerBootstrap.java @@ -12,6 +12,8 @@ import com.yahoo.container.jdisc.state.StateMonitor; import com.yahoo.log.LogLevel; import com.yahoo.vespa.config.server.rpc.RpcServer; import com.yahoo.vespa.config.server.version.VersionState; +import com.yahoo.vespa.flags.FeatureFlag; +import com.yahoo.vespa.flags.FlagSource; import java.time.Duration; import java.time.Instant; @@ -26,6 +28,9 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; +import java.util.logging.Logger; + +import static com.yahoo.vespa.config.server.ConfigServerBootstrap.RedeployingApplicationsFails.*; /** * Main component that bootstraps and starts config server threads. @@ -39,9 +44,11 @@ import java.util.concurrent.TimeUnit; */ public class ConfigServerBootstrap extends AbstractComponent implements Runnable { - private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(ConfigServerBootstrap.class.getName()); + private static final Logger log = Logger.getLogger(ConfigServerBootstrap.class.getName()); + private static final String bootstrapFeatureFlag = "config-server-bootstrap-in-separate-thread"; - enum Mode {BOOTSTRAP_IN_CONSTRUCTOR, BOOTSTRAP_IN_SEPARATE_THREAD, INITIALIZE_ONLY} // INITIALIZE_ONLY is for testing only + // INITIALIZE_ONLY is for testing only + enum Mode {BOOTSTRAP_IN_CONSTRUCTOR, BOOTSTRAP_IN_SEPARATE_THREAD, INITIALIZE_ONLY} enum RedeployingApplicationsFails {EXIT_JVM, CONTINUE} private final ApplicationRepository applicationRepository; @@ -56,21 +63,27 @@ public class ConfigServerBootstrap extends AbstractComponent implements Runnable private final RedeployingApplicationsFails exitIfRedeployingApplicationsFails; private final ExecutorService rpcServerExecutor; - // The tenants object is injected so that all initial requests handlers are - // added to the rpc server before it starts answering rpc requests. - @SuppressWarnings("WeakerAccess") + @SuppressWarnings("unused") @Inject public ConfigServerBootstrap(ApplicationRepository applicationRepository, RpcServer server, - VersionState versionState, StateMonitor stateMonitor, VipStatus vipStatus) { + VersionState versionState, StateMonitor stateMonitor, VipStatus vipStatus, + FlagSource flagSource) { this(applicationRepository, server, versionState, stateMonitor, vipStatus, - applicationRepository.configserverConfig().bootstrapInSeparateThread () ? Mode.BOOTSTRAP_IN_SEPARATE_THREAD : Mode.BOOTSTRAP_IN_CONSTRUCTOR, - RedeployingApplicationsFails.EXIT_JVM); + new FeatureFlag(bootstrapFeatureFlag, true, flagSource).value() + ? Mode.BOOTSTRAP_IN_SEPARATE_THREAD + : Mode.BOOTSTRAP_IN_CONSTRUCTOR, + EXIT_JVM); } // For testing only ConfigServerBootstrap(ApplicationRepository applicationRepository, RpcServer server, VersionState versionState, - StateMonitor stateMonitor, VipStatus vipStatus, Mode mode, - RedeployingApplicationsFails exitIfRedeployingApplicationsFails) { + StateMonitor stateMonitor, VipStatus vipStatus, Mode mode) { + this(applicationRepository, server, versionState, stateMonitor, vipStatus, mode, CONTINUE); + } + + private ConfigServerBootstrap(ApplicationRepository applicationRepository, RpcServer server, + VersionState versionState, StateMonitor stateMonitor, VipStatus vipStatus, + Mode mode, RedeployingApplicationsFails exitIfRedeployingApplicationsFails) { this.applicationRepository = applicationRepository; this.server = server; this.versionState = versionState; @@ -190,7 +203,7 @@ public class ConfigServerBootstrap extends AbstractComponent implements Runnable } private void redeployingApplicationsFailed() { - if (exitIfRedeployingApplicationsFails == RedeployingApplicationsFails.EXIT_JVM) System.exit(1); + if (exitIfRedeployingApplicationsFails == EXIT_JVM) System.exit(1); } private boolean redeployAllApplications() throws InterruptedException { diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerBootstrapTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerBootstrapTest.java index 6030ac1ac9f..4e8c272476d 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerBootstrapTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerBootstrapTest.java @@ -68,8 +68,7 @@ public class ConfigServerBootstrapTest { provisioner.allocations().values().iterator().next().remove(0); ConfigServerBootstrap bootstrap = new ConfigServerBootstrap(tester.applicationRepository(), rpcServer, versionState, createStateMonitor(), vipStatus, - ConfigServerBootstrap.Mode.INITIALIZE_ONLY, - ConfigServerBootstrap.RedeployingApplicationsFails.CONTINUE); + ConfigServerBootstrap.Mode.INITIALIZE_ONLY); assertFalse(vipStatus.isInRotation()); bootstrap.start(); waitUntil(rpcServer::isRunning, "failed waiting for Rpc server running"); @@ -102,8 +101,7 @@ public class ConfigServerBootstrapTest { VipStatus vipStatus = new VipStatus(); ConfigServerBootstrap bootstrap = new ConfigServerBootstrap(tester.applicationRepository(), rpcServer, versionState, createStateMonitor(), vipStatus, - ConfigServerBootstrap.Mode.INITIALIZE_ONLY, - ConfigServerBootstrap.RedeployingApplicationsFails.CONTINUE); + ConfigServerBootstrap.Mode.INITIALIZE_ONLY); assertFalse(vipStatus.isInRotation()); // Call method directly, to be sure that it is finished redeploying all applications and we can check status bootstrap.start(); @@ -144,7 +142,8 @@ public class ConfigServerBootstrapTest { RpcServer rpcServer = createRpcServer(configserverConfig); VipStatus vipStatus = new VipStatus(); ConfigServerBootstrap bootstrap = new ConfigServerBootstrap(tester.applicationRepository(), rpcServer, versionState, - createStateMonitor(), vipStatus); + createStateMonitor(), vipStatus, + ConfigServerBootstrap.Mode.BOOTSTRAP_IN_SEPARATE_THREAD); waitUntil(rpcServer::isRunning, "failed waiting for Rpc server running"); waitUntil(() -> bootstrap.status() == StateMonitor.Status.up, "failed waiting for status 'up'"); |