style changes to Bootstrap

This commit is contained in:
Robert Muir 2015-04-24 10:09:30 -04:00
parent c4f7385279
commit a3d03fdeb8
1 changed files with 19 additions and 14 deletions

View File

@ -58,13 +58,13 @@ public class Bootstrap {
private static volatile CountDownLatch keepAliveLatch;
private static Bootstrap bootstrap;
private void setup(boolean addShutdownHook, Tuple<Settings, Environment> 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<Settings, Environment> 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<Settings, Environment> 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<Settings, Environment> tuple = null;
Settings settings = null;
Environment environment = null;
try {
tuple = initialSettings();
setupLogging(tuple);
Tuple<Settings, Environment> 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();