소스 검색

Remove path.home command-line setting

Jason Tedor 9 년 전
부모
커밋
4ee90db13d

+ 2 - 4
core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java

@@ -188,10 +188,9 @@ final class Bootstrap {
         node = new Node(nodeSettings);
     }
 
-    private static Environment initialSettings(boolean foreground, String pathHome, String pidFile) {
+    private static Environment initialSettings(boolean foreground, 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)) {
             builder.put(Environment.PIDFILE_SETTING.getKey(), pidFile);
         }
@@ -224,7 +223,6 @@ final class Bootstrap {
      */
     static void init(
             final boolean foreground,
-            final String pathHome,
             final String pidFile,
             final Map<String, String> esSettings) throws Throwable {
         // Set the system property before anything has a chance to trigger its use
@@ -234,7 +232,7 @@ final class Bootstrap {
 
         INSTANCE = new Bootstrap();
 
-        Environment environment = initialSettings(foreground, pathHome, pidFile);
+        Environment environment = initialSettings(foreground, pidFile);
         Settings settings = environment.settings();
         LogConfigurator.configure(settings, true);
         checkForCustomConfFile();

+ 4 - 8
core/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java

@@ -41,7 +41,6 @@ class Elasticsearch extends Command {
 
     private final OptionSpec<Void> versionOption;
     private final OptionSpec<Void> daemonizeOption;
-    private final OptionSpec<String> pathHomeOption;
     private final OptionSpec<String> pidfileOption;
     private final OptionSpec<KeyValuePair> propertyOption;
 
@@ -54,8 +53,6 @@ class Elasticsearch extends Command {
         daemonizeOption = parser.acceptsAll(Arrays.asList("d", "daemonize"),
             "Starts Elasticsearch in the background");
         // TODO: in jopt-simple 5.0 this option type can be a Path
-        pathHomeOption = parser.acceptsAll(Arrays.asList("H", "path.home"), "").withRequiredArg();
-        // TODO: in jopt-simple 5.0 this option type can be a Path
         pidfileOption = parser.acceptsAll(Arrays.asList("p", "pidfile"),
             "Creates a pid file in the specified path on start")
             .withRequiredArg();
@@ -80,7 +77,7 @@ class Elasticsearch extends Command {
     @Override
     protected void execute(Terminal terminal, OptionSet options) throws Exception {
         if (options.has(versionOption)) {
-            if (options.has(daemonizeOption) || options.has(pathHomeOption) || options.has(pidfileOption)) {
+            if (options.has(daemonizeOption) || options.has(pidfileOption)) {
                 throw new UserError(ExitCodes.USAGE, "Elasticsearch version option is mutually exclusive with any other option");
             }
             terminal.println("Version: " + org.elasticsearch.Version.CURRENT
@@ -90,7 +87,6 @@ class Elasticsearch extends Command {
         }
 
         final boolean daemonize = options.has(daemonizeOption);
-        final String pathHome = pathHomeOption.value(options);
         final String pidFile = pidfileOption.value(options);
 
         final Map<String, String> esSettings = new HashMap<>();
@@ -104,12 +100,12 @@ class Elasticsearch extends Command {
             esSettings.put(kvp.key, kvp.value);
         }
 
-        init(daemonize, pathHome, pidFile, esSettings);
+        init(daemonize, pidFile, esSettings);
     }
 
-    void init(final boolean daemonize, final String pathHome, final String pidFile, final Map<String, String> esSettings) {
+    void init(final boolean daemonize, final String pidFile, final Map<String, String> esSettings) {
         try {
-            Bootstrap.init(!daemonize, pathHome, pidFile, esSettings);
+            Bootstrap.init(!daemonize, pidFile, esSettings);
         } catch (final Throwable t) {
             // format exceptions to the console in a special way
             // to avoid 2MB stacktraces from guice, etc.

+ 0 - 3
core/src/main/resources/org/elasticsearch/bootstrap/security.policy

@@ -72,9 +72,6 @@ grant {
   // set by ESTestCase to improve test reproducibility
   // TODO: set this with gradle or some other way that repros with seed?
   permission java.util.PropertyPermission "es.processors.override", "write";
-  // set by CLIToolTestCase
-  // TODO: do this differently? or test commandline tools differently?
-  permission java.util.PropertyPermission "es.default.path.home", "write";
 
   // TODO: these simply trigger a noisy warning if its unable to clear the properties
   // fix that in randomizedtesting

+ 10 - 14
core/src/test/java/org/elasticsearch/bootstrap/ElasticsearchCliTests.java

@@ -45,14 +45,10 @@ public class ElasticsearchCliTests extends ESTestCase {
     public void testVersion() throws Exception {
         runTestThatVersionIsMutuallyExclusiveToOtherOptions("-V", "-d");
         runTestThatVersionIsMutuallyExclusiveToOtherOptions("-V", "--daemonize");
-        runTestThatVersionIsMutuallyExclusiveToOtherOptions("-V", "-H", "/tmp/home");
-        runTestThatVersionIsMutuallyExclusiveToOtherOptions("-V", "--path.home", "/tmp/home");
         runTestThatVersionIsMutuallyExclusiveToOtherOptions("-V", "-p", "/tmp/pid");
         runTestThatVersionIsMutuallyExclusiveToOtherOptions("-V", "--pidfile", "/tmp/pid");
         runTestThatVersionIsMutuallyExclusiveToOtherOptions("--version", "-d");
         runTestThatVersionIsMutuallyExclusiveToOtherOptions("--version", "--daemonize");
-        runTestThatVersionIsMutuallyExclusiveToOtherOptions("--version", "-H", "/tmp/home");
-        runTestThatVersionIsMutuallyExclusiveToOtherOptions("--version", "--path.home", "/tmp/home");
         runTestThatVersionIsMutuallyExclusiveToOtherOptions("--version", "-p", "/tmp/pid");
         runTestThatVersionIsMutuallyExclusiveToOtherOptions("--version", "--pidfile", "/tmp/pid");
         runTestThatVersionIsReturned("-V");
@@ -77,7 +73,7 @@ public class ElasticsearchCliTests extends ESTestCase {
     }
 
     private void runTestVersion(int expectedStatus, Consumer<String> outputConsumer, String... args) throws Exception {
-        runTest(expectedStatus, false, outputConsumer, (foreground, pathHome, pidFile, esSettings) -> {}, args);
+        runTest(expectedStatus, false, outputConsumer, (foreground, pidFile, esSettings) -> {}, args);
     }
 
     public void testThatPidFileCanBeConfigured() throws Exception {
@@ -92,7 +88,7 @@ public class ElasticsearchCliTests extends ESTestCase {
                 expectedStatus,
                 expectedInit,
                 outputConsumer,
-                (foreground, pathHome, pidFile, esSettings) -> assertThat(pidFile, equalTo("/tmp/pid")),
+                (foreground, pidFile, esSettings) -> assertThat(pidFile, equalTo("/tmp/pid")),
                 args);
     }
 
@@ -107,7 +103,7 @@ public class ElasticsearchCliTests extends ESTestCase {
                 ExitCodes.OK,
                 true,
                 output -> {},
-                (foreground, pathHome, pidFile, esSettings) -> assertThat(foreground, equalTo(!expectedDaemonize)),
+                (foreground, pidFile, esSettings) -> assertThat(foreground, equalTo(!expectedDaemonize)),
                 args);
     }
 
@@ -116,7 +112,7 @@ public class ElasticsearchCliTests extends ESTestCase {
                 ExitCodes.OK,
                 true,
                 output -> {},
-                (foreground, pathHome, pidFile, esSettings) -> {
+                (foreground, pidFile, esSettings) -> {
                     assertThat(esSettings.size(), equalTo(2));
                     assertThat(esSettings, hasEntry("es.foo", "bar"));
                     assertThat(esSettings, hasEntry("es.baz", "qux"));
@@ -136,7 +132,7 @@ public class ElasticsearchCliTests extends ESTestCase {
                 ExitCodes.USAGE,
                 false,
                 output -> assertThat(output, containsString("Elasticsearch settings must be prefixed with [es.] but was [")),
-                (foreground, pathHome, pidFile, esSettings) -> {},
+                (foreground, pidFile, esSettings) -> {},
                 args
         );
     }
@@ -146,7 +142,7 @@ public class ElasticsearchCliTests extends ESTestCase {
                 ExitCodes.USAGE,
                 false,
                 output -> assertThat(output, containsString("Elasticsearch setting [es.foo] must not be empty")),
-                (foreground, pathHome, pidFile, esSettings) -> {},
+                (foreground, pidFile, esSettings) -> {},
                 "-E", "es.foo="
         );
     }
@@ -156,12 +152,12 @@ public class ElasticsearchCliTests extends ESTestCase {
                 ExitCodes.USAGE,
                 false,
                 output -> assertThat(output, containsString("network.host is not a recognized option")),
-                (foreground, pathHome, pidFile, esSettings) -> {},
+                (foreground, pidFile, esSettings) -> {},
                 "--network.host");
     }
 
     private interface InitConsumer {
-        void accept(final boolean foreground, final String pathHome, final String pidFile, final Map<String, String> esSettings);
+        void accept(final boolean foreground, final String pidFile, final Map<String, String> esSettings);
     }
 
     private void runTest(
@@ -175,9 +171,9 @@ public class ElasticsearchCliTests extends ESTestCase {
             final AtomicBoolean init = new AtomicBoolean();
             final int status = Elasticsearch.main(args, new Elasticsearch() {
                 @Override
-                void init(final boolean daemonize, final String pathHome, final String pidFile, final Map<String, String> esSettings) {
+                void init(final boolean daemonize, final String pidFile, final Map<String, String> esSettings) {
                     init.set(true);
-                    initConsumer.accept(!daemonize, pathHome, pidFile, esSettings);
+                    initConsumer.accept(!daemonize, pidFile, esSettings);
                 }
             }, terminal);
             assertThat(status, equalTo(expectedStatus));

+ 1 - 1
distribution/deb/src/main/packaging/init.d/elasticsearch

@@ -99,7 +99,7 @@ fi
 # Define other required variables
 PID_FILE="$PID_DIR/$NAME.pid"
 DAEMON=$ES_HOME/bin/elasticsearch
-DAEMON_OPTS="-d -p $PID_FILE -Ees.default.path.home=$ES_HOME -Ees.default.path.logs=$LOG_DIR -Ees.default.path.data=$DATA_DIR -Ees.default.path.conf=$CONF_DIR"
+DAEMON_OPTS="-d -p $PID_FILE -Ees.default.path.logs=$LOG_DIR -Ees.default.path.data=$DATA_DIR -Ees.default.path.conf=$CONF_DIR"
 
 export ES_HEAP_SIZE
 export ES_HEAP_NEWSIZE

+ 0 - 1
distribution/src/main/packaging/systemd/elasticsearch.service

@@ -21,7 +21,6 @@ ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec
 
 ExecStart=/usr/share/elasticsearch/bin/elasticsearch \
                                                 -p ${PID_DIR}/elasticsearch.pid \
-                                                -Ees.default.path.home=${ES_HOME} \
                                                 -Ees.default.path.logs=${LOG_DIR} \
                                                 -Ees.default.path.data=${DATA_DIR} \
                                                 -Ees.default.path.conf=${CONF_DIR}

+ 4 - 4
distribution/src/main/resources/bin/elasticsearch

@@ -126,11 +126,11 @@ export HOSTNAME
 # manual parsing to find out, if process should be detached
 daemonized=`echo $* | egrep -- '(^-d |-d$| -d |--daemonize$|--daemonize )'`
 if [ -z "$daemonized" ] ; then
-    exec "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS -cp "$ES_CLASSPATH" \
-          org.elasticsearch.bootstrap.Elasticsearch --path.home "$ES_HOME" "$@"
+    exec "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS -Des.path.home="$ES_HOME" -cp "$ES_CLASSPATH" \
+          org.elasticsearch.bootstrap.Elasticsearch "$@"
 else
-    exec "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS -cp "$ES_CLASSPATH" \
-          org.elasticsearch.bootstrap.Elasticsearch --path.home "$ES_HOME" "$@" <&- &
+    exec "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS -Des.path.home="$ES_HOME" -cp "$ES_CLASSPATH" \
+          org.elasticsearch.bootstrap.Elasticsearch "$@" <&- &
     retval=$?
     pid=$!
     [ $retval -eq 0 ] || exit $retval

+ 1 - 1
distribution/src/main/resources/bin/service.bat

@@ -152,7 +152,7 @@ if "%DATA_DIR%" == "" set DATA_DIR=%ES_HOME%\data
 
 if "%CONF_DIR%" == "" set CONF_DIR=%ES_HOME%\config
 
-set ES_PARAMS=-Delasticsearch;-Des.path.home="%ES_HOME%";-Des.default.path.home="%ES_HOME%";-Des.default.path.logs="%LOG_DIR%";-Des.default.path.data="%DATA_DIR%";-Des.default.path.conf="%CONF_DIR%"
+set ES_PARAMS=-Delasticsearch;-Des.path.home="%ES_HOME%";-Des.default.path.logs="%LOG_DIR%";-Des.default.path.data="%DATA_DIR%";-Des.default.path.conf="%CONF_DIR%"
 
 set JVM_OPTS=%JAVA_OPTS: =;%