Rename "daemonize" to "foreground"

This commit renames the Bootstrap#init parameter "daemonize" to
"foreground" for clarity.
This commit is contained in:
Jason Tedor 2016-03-15 09:27:01 -04:00
parent 8a05c2a2be
commit fac0f990fc
3 changed files with 18 additions and 18 deletions

View File

@ -188,8 +188,8 @@ final class Bootstrap {
node = new Node(nodeSettings);
}
private static Environment initialSettings(boolean daemonize, String pathHome, String pidFile) {
Terminal terminal = daemonize ? null : Terminal.DEFAULT;
private static Environment initialSettings(boolean foreground, String pathHome, String pidFile) {
Terminal terminal = foreground ? Terminal.DEFAULT : null;
Settings.Builder builder = Settings.builder();
builder.put(Environment.PATH_HOME_SETTING.getKey(), pathHome);
if (Strings.hasLength(pidFile)) {
@ -223,7 +223,7 @@ final class Bootstrap {
* to startup elasticsearch.
*/
static void init(
final boolean daemonize,
final boolean foreground,
final String pathHome,
final String pidFile,
final Map<String, String> esSettings) throws Throwable {
@ -234,7 +234,7 @@ final class Bootstrap {
INSTANCE = new Bootstrap();
Environment environment = initialSettings(daemonize, pathHome, pidFile);
Environment environment = initialSettings(foreground, pathHome, pidFile);
Settings settings = environment.settings();
LogConfigurator.configure(settings, true);
checkForCustomConfFile();
@ -250,7 +250,7 @@ final class Bootstrap {
}
try {
if (daemonize) {
if (!foreground) {
Loggers.disableConsoleLogging();
closeSystOut();
}
@ -265,12 +265,12 @@ final class Bootstrap {
INSTANCE.start();
if (daemonize) {
if (!foreground) {
closeSysError();
}
} catch (Throwable e) {
// disable console logging, so user does not see the exception twice (jvm will show it already)
if (!daemonize) {
if (foreground) {
Loggers.disableConsoleLogging();
}
ESLogger logger = Loggers.getLogger(Bootstrap.class);
@ -290,7 +290,7 @@ final class Bootstrap {
logger.error("Exception", e);
}
// re-enable it if appropriate, so they can see any logging during the shutdown process
if (!daemonize) {
if (foreground) {
Loggers.enableConsoleLogging();
}

View File

@ -109,7 +109,7 @@ class Elasticsearch extends Command {
void init(final boolean daemonize, final String pathHome, final String pidFile, final Map<String, String> esSettings) {
try {
Bootstrap.init(daemonize, pathHome, pidFile, esSettings);
Bootstrap.init(!daemonize, pathHome, pidFile, esSettings);
} catch (final Throwable t) {
// format exceptions to the console in a special way
// to avoid 2MB stacktraces from guice, etc.

View File

@ -77,7 +77,7 @@ public class ElasticsearchCommandLineParsingTests extends ESTestCase {
}
private void runTestVersion(int expectedStatus, Consumer<String> outputConsumer, String... args) throws Exception {
runTest(expectedStatus, false, outputConsumer, (daemonize, pathHome, pidFile, esSettings) -> {}, args);
runTest(expectedStatus, false, outputConsumer, (foreground, pathHome, pidFile, esSettings) -> {}, args);
}
public void testThatPidFileCanBeConfigured() throws Exception {
@ -92,7 +92,7 @@ public class ElasticsearchCommandLineParsingTests extends ESTestCase {
expectedStatus,
expectedInit,
outputConsumer,
(daemonize, pathHome, pidFile, esSettings) -> assertThat(pidFile, equalTo("/tmp/pid")),
(foreground, pathHome, pidFile, esSettings) -> assertThat(pidFile, equalTo("/tmp/pid")),
args);
}
@ -107,7 +107,7 @@ public class ElasticsearchCommandLineParsingTests extends ESTestCase {
ExitCodes.OK,
true,
output -> {},
(daemonize, pathHome, pidFile, esSettings) -> assertThat(daemonize, equalTo(expectedDaemonize)),
(foreground, pathHome, pidFile, esSettings) -> assertThat(foreground, equalTo(!expectedDaemonize)),
args);
}
@ -116,7 +116,7 @@ public class ElasticsearchCommandLineParsingTests extends ESTestCase {
ExitCodes.OK,
true,
output -> {},
(daemonize, pathHome, pidFile, esSettings) -> {
(foreground, pathHome, pidFile, esSettings) -> {
assertThat(esSettings.size(), equalTo(2));
assertThat(esSettings, hasEntry("es.foo", "bar"));
assertThat(esSettings, hasEntry("es.baz", "qux"));
@ -136,7 +136,7 @@ public class ElasticsearchCommandLineParsingTests extends ESTestCase {
ExitCodes.USAGE,
false,
output -> assertThat(output, containsString("Elasticsearch settings must be prefixed with [es.] but was [")),
(daemonize, pathHome, pidFile, esSettings) -> {},
(foreground, pathHome, pidFile, esSettings) -> {},
args
);
}
@ -146,7 +146,7 @@ public class ElasticsearchCommandLineParsingTests extends ESTestCase {
ExitCodes.USAGE,
false,
output -> assertThat(output, containsString("Elasticsearch setting [es.foo] must not be empty")),
(daemonize, pathHome, pidFile, esSettings) -> {},
(foreground, pathHome, pidFile, esSettings) -> {},
"-E", "es.foo="
);
}
@ -156,12 +156,12 @@ public class ElasticsearchCommandLineParsingTests extends ESTestCase {
ExitCodes.USAGE,
false,
output -> assertThat(output, containsString("network.host is not a recognized option")),
(daemonize, pathHome, pidFile, esSettings) -> {},
(foreground, pathHome, pidFile, esSettings) -> {},
"--network.host");
}
private interface InitConsumer {
void accept(final boolean daemonize, final String pathHome, final String pidFile, final Map<String, String> esSettings);
void accept(final boolean foreground, final String pathHome, final String pidFile, final Map<String, String> esSettings);
}
private void runTest(
@ -177,7 +177,7 @@ public class ElasticsearchCommandLineParsingTests extends ESTestCase {
@Override
void init(final boolean daemonize, final String pathHome, final String pidFile, final Map<String, String> esSettings) {
init.set(true);
initConsumer.accept(daemonize, pathHome, pidFile, esSettings);
initConsumer.accept(!daemonize, pathHome, pidFile, esSettings);
}
}, terminal);
assertThat(status, equalTo(expectedStatus));