style changes to Bootstrap
This commit is contained in:
parent
c4f7385279
commit
a3d03fdeb8
|
@ -58,13 +58,13 @@ public class Bootstrap {
|
||||||
private static volatile CountDownLatch keepAliveLatch;
|
private static volatile CountDownLatch keepAliveLatch;
|
||||||
private static Bootstrap bootstrap;
|
private static Bootstrap bootstrap;
|
||||||
|
|
||||||
private void setup(boolean addShutdownHook, Tuple<Settings, Environment> tuple) throws Exception {
|
private void setup(boolean addShutdownHook, Settings settings, Environment environment) throws Exception {
|
||||||
setupSecurity(tuple.v1(), tuple.v2());
|
setupSecurity(settings, environment);
|
||||||
if (tuple.v1().getAsBoolean("bootstrap.mlockall", false)) {
|
if (settings.getAsBoolean("bootstrap.mlockall", false)) {
|
||||||
Natives.tryMlockall();
|
Natives.tryMlockall();
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder().settings(tuple.v1()).loadConfigSettings(false);
|
NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder().settings(settings).loadConfigSettings(false);
|
||||||
node = nodeBuilder.build();
|
node = nodeBuilder.build();
|
||||||
if (addShutdownHook) {
|
if (addShutdownHook) {
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
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() {
|
Natives.addConsoleCtrlHandler(new ConsoleCtrlHandler() {
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(int code) {
|
public boolean handle(int code) {
|
||||||
|
@ -105,10 +105,10 @@ public class Bootstrap {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressForbidden(reason = "Exception#printStackTrace()")
|
@SuppressForbidden(reason = "Exception#printStackTrace()")
|
||||||
private static void setupLogging(Tuple<Settings, Environment> tuple) {
|
private static void setupLogging(Settings settings, Environment environment) {
|
||||||
try {
|
try {
|
||||||
tuple.v1().getClassLoader().loadClass("org.apache.log4j.Logger");
|
settings.getClassLoader().loadClass("org.apache.log4j.Logger");
|
||||||
LogConfigurator.configure(tuple.v1());
|
LogConfigurator.configure(settings);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
// no log4j
|
// no log4j
|
||||||
} catch (NoClassDefFoundError e) {
|
} catch (NoClassDefFoundError e) {
|
||||||
|
@ -128,8 +128,10 @@ public class Bootstrap {
|
||||||
*/
|
*/
|
||||||
public void init(String[] args) throws Exception {
|
public void init(String[] args) throws Exception {
|
||||||
Tuple<Settings, Environment> tuple = initialSettings();
|
Tuple<Settings, Environment> tuple = initialSettings();
|
||||||
setupLogging(tuple);
|
Settings settings = tuple.v1();
|
||||||
setup(true, tuple);
|
Environment environment = tuple.v2();
|
||||||
|
setupLogging(settings, environment);
|
||||||
|
setup(true, settings, environment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -179,10 +181,13 @@ public class Bootstrap {
|
||||||
foreground = false;
|
foreground = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Tuple<Settings, Environment> tuple = null;
|
Settings settings = null;
|
||||||
|
Environment environment = null;
|
||||||
try {
|
try {
|
||||||
tuple = initialSettings();
|
Tuple<Settings, Environment> tuple = initialSettings();
|
||||||
setupLogging(tuple);
|
settings = tuple.v1();
|
||||||
|
environment = tuple.v2();
|
||||||
|
setupLogging(settings, environment);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String errorMessage = buildErrorMessage("Setup", e);
|
String errorMessage = buildErrorMessage("Setup", e);
|
||||||
sysError(errorMessage, true);
|
sysError(errorMessage, true);
|
||||||
|
@ -210,7 +215,7 @@ public class Bootstrap {
|
||||||
// fail if using broken version
|
// fail if using broken version
|
||||||
JVMCheck.check();
|
JVMCheck.check();
|
||||||
|
|
||||||
bootstrap.setup(true, tuple);
|
bootstrap.setup(true, settings, environment);
|
||||||
|
|
||||||
stage = "Startup";
|
stage = "Startup";
|
||||||
bootstrap.start();
|
bootstrap.start();
|
||||||
|
|
Loading…
Reference in New Issue