Skip to content

Commit eb596d7

Browse files
committed
more renames
1 parent 6e406ae commit eb596d7

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,10 @@ protected void validateNodeBeforeAcceptingRequests(
223223
};
224224
}
225225

226-
private static KeyStoreWrapper loadKeyStore(Environment env0) throws BootstrapException {
226+
private static KeyStoreWrapper loadKeyStore(Environment initialEnv) throws BootstrapException {
227227
final KeyStoreWrapper keystore;
228228
try {
229-
keystore = KeyStoreWrapper.load(env0.configFile());
229+
keystore = KeyStoreWrapper.load(initialEnv.configFile());
230230
} catch (IOException e) {
231231
throw new BootstrapException(e);
232232
}
@@ -281,7 +281,7 @@ static void init(
281281
final boolean foreground,
282282
final Path pidFile,
283283
final boolean quiet,
284-
final Environment env0) throws BootstrapException, NodeValidationException, UserException {
284+
final Environment initialEnv) throws BootstrapException, NodeValidationException, UserException {
285285
// Set the system property before anything has a chance to trigger its use
286286
initLoggerPrefix();
287287

@@ -291,8 +291,8 @@ static void init(
291291

292292
INSTANCE = new Bootstrap();
293293

294-
final KeyStoreWrapper keystore = loadKeyStore(env0);
295-
Environment environment = initialEnvironment(foreground, pidFile, keystore, env0.settings());
294+
final KeyStoreWrapper keystore = loadKeyStore(initialEnv);
295+
Environment environment = initialEnvironment(foreground, pidFile, keystore, initialEnv.settings());
296296
try {
297297
LogConfigurator.configure(environment);
298298
} catch (IOException e) {

core/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ protected void execute(Terminal terminal, OptionSet options, Environment env) th
117117
}
118118
}
119119

120-
void init(final boolean daemonize, final Path pidFile, final boolean quiet, Environment env0)
120+
void init(final boolean daemonize, final Path pidFile, final boolean quiet, Environment initialEnv)
121121
throws NodeValidationException, UserException {
122122
try {
123-
Bootstrap.init(!daemonize, pidFile, quiet, env0);
123+
Bootstrap.init(!daemonize, pidFile, quiet, initialEnv);
124124
} catch (BootstrapException | RuntimeException e) {
125125
// format exceptions to the console in a special way
126126
// to avoid 2MB stacktraces from guice, etc.

core/src/main/java/org/elasticsearch/common/settings/KeyStoreWrapper.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
import org.apache.lucene.store.IOContext;
5353
import org.apache.lucene.store.IndexInput;
5454
import org.apache.lucene.store.IndexOutput;
55-
import org.apache.lucene.store.NIOFSDirectory;
55+
import org.apache.lucene.store.SimpleFSDirectory;
5656
import org.apache.lucene.util.SetOnce;
5757

5858
/**
@@ -140,7 +140,7 @@ public static KeyStoreWrapper load(Path configDir) throws IOException {
140140
return null;
141141
}
142142

143-
NIOFSDirectory directory = new NIOFSDirectory(configDir);
143+
SimpleFSDirectory directory = new SimpleFSDirectory(configDir);
144144
try (IndexInput indexInput = directory.openInput(KEYSTORE_FILENAME, IOContext.READONCE)) {
145145
ChecksumIndexInput input = new BufferedChecksumIndexInput(indexInput);
146146
CodecUtil.checkHeader(input, KEYSTORE_FILENAME, FORMAT_VERSION, FORMAT_VERSION);
@@ -199,7 +199,7 @@ public void decrypt(char[] password) throws GeneralSecurityException, IOExceptio
199199
void save(Path configDir) throws Exception {
200200
char[] password = this.keystorePassword.get().getPassword();
201201

202-
NIOFSDirectory directory = new NIOFSDirectory(configDir);
202+
SimpleFSDirectory directory = new SimpleFSDirectory(configDir);
203203
// write to tmp file first, then overwrite
204204
String tmpFile = KEYSTORE_FILENAME + ".tmp";
205205
try (IndexOutput output = directory.createOutput(tmpFile, IOContext.DEFAULT)) {
@@ -217,7 +217,7 @@ void save(Path configDir) throws Exception {
217217
}
218218

219219
Path keystoreFile = keystorePath(configDir);
220-
Files.move(configDir.resolve(tmpFile), keystoreFile, StandardCopyOption.REPLACE_EXISTING);
220+
Files.move(configDir.resolve(tmpFile), keystoreFile, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
221221
PosixFileAttributeView attrs = Files.getFileAttributeView(keystoreFile, PosixFileAttributeView.class);
222222
if (attrs != null) {
223223
// don't rely on umask: ensure the keystore has minimal permissions
@@ -230,6 +230,7 @@ public Set<String> getSettings() {
230230
return settingNames;
231231
}
232232

233+
// TODO: make settings accessible only to code that registered the setting
233234
/** Retrieve a string setting. The {@link SecureString} should be closed once it is used. */
234235
SecureString getStringSetting(String setting) throws GeneralSecurityException {
235236
KeyStore.Entry entry = keystore.get().getEntry(setting, keystorePassword.get());

test/framework/src/main/java/org/elasticsearch/bootstrap/ESElasticsearchCliTestCase.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
abstract class ESElasticsearchCliTestCase extends ESTestCase {
3636

3737
interface InitConsumer {
38-
void accept(final boolean foreground, final Path pidFile, final boolean quiet, final Environment env0);
38+
void accept(final boolean foreground, final Path pidFile, final boolean quiet, final Environment initialEnv);
3939
}
4040

4141
void runTest(
@@ -57,9 +57,9 @@ protected Environment createEnv(Terminal terminal, Map<String, String> settings)
5757
return new Environment(realSettings);
5858
}
5959
@Override
60-
void init(final boolean daemonize, final Path pidFile, final boolean quiet, Environment env0) {
60+
void init(final boolean daemonize, final Path pidFile, final boolean quiet, Environment initialEnv) {
6161
init.set(true);
62-
initConsumer.accept(!daemonize, pidFile, quiet, env0);
62+
initConsumer.accept(!daemonize, pidFile, quiet, initialEnv);
6363
}
6464

6565
@Override

0 commit comments

Comments
 (0)