From a3d03fdeb8333590b304a9b7d72d1e137e082511 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Fri, 24 Apr 2015 10:09:30 -0400 Subject: [PATCH] style changes to Bootstrap --- .../elasticsearch/bootstrap/Bootstrap.java | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java b/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java index 56643105dd5..19bc81b9972 100644 --- a/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java +++ b/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java @@ -58,13 +58,13 @@ public class Bootstrap { private static volatile CountDownLatch keepAliveLatch; private static Bootstrap bootstrap; - private void setup(boolean addShutdownHook, Tuple tuple) throws Exception { - setupSecurity(tuple.v1(), tuple.v2()); - if (tuple.v1().getAsBoolean("bootstrap.mlockall", false)) { + private void setup(boolean addShutdownHook, Settings settings, Environment environment) throws Exception { + setupSecurity(settings, environment); + if (settings.getAsBoolean("bootstrap.mlockall", false)) { Natives.tryMlockall(); } - NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder().settings(tuple.v1()).loadConfigSettings(false); + NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder().settings(settings).loadConfigSettings(false); node = nodeBuilder.build(); if (addShutdownHook) { Runtime.getRuntime().addShutdownHook(new Thread() { @@ -75,7 +75,7 @@ public class Bootstrap { }); } - if (tuple.v1().getAsBoolean("bootstrap.ctrlhandler", true)) { + if (settings.getAsBoolean("bootstrap.ctrlhandler", true)) { Natives.addConsoleCtrlHandler(new ConsoleCtrlHandler() { @Override public boolean handle(int code) { @@ -105,10 +105,10 @@ public class Bootstrap { } @SuppressForbidden(reason = "Exception#printStackTrace()") - private static void setupLogging(Tuple tuple) { + private static void setupLogging(Settings settings, Environment environment) { try { - tuple.v1().getClassLoader().loadClass("org.apache.log4j.Logger"); - LogConfigurator.configure(tuple.v1()); + settings.getClassLoader().loadClass("org.apache.log4j.Logger"); + LogConfigurator.configure(settings); } catch (ClassNotFoundException e) { // no log4j } catch (NoClassDefFoundError e) { @@ -128,8 +128,10 @@ public class Bootstrap { */ public void init(String[] args) throws Exception { Tuple tuple = initialSettings(); - setupLogging(tuple); - setup(true, tuple); + Settings settings = tuple.v1(); + Environment environment = tuple.v2(); + setupLogging(settings, environment); + setup(true, settings, environment); } /** @@ -179,10 +181,13 @@ public class Bootstrap { foreground = false; } - Tuple tuple = null; + Settings settings = null; + Environment environment = null; try { - tuple = initialSettings(); - setupLogging(tuple); + Tuple tuple = initialSettings(); + settings = tuple.v1(); + environment = tuple.v2(); + setupLogging(settings, environment); } catch (Exception e) { String errorMessage = buildErrorMessage("Setup", e); sysError(errorMessage, true); @@ -210,7 +215,7 @@ public class Bootstrap { // fail if using broken version JVMCheck.check(); - bootstrap.setup(true, tuple); + bootstrap.setup(true, settings, environment); stage = "Startup"; bootstrap.start();