more renames

This commit is contained in:
Ryan Ernst 2017-01-06 01:03:45 -08:00
parent 6e406aed2d
commit eb596d7270
4 changed files with 15 additions and 14 deletions

View File

@ -223,10 +223,10 @@ final class Bootstrap {
};
}
private static KeyStoreWrapper loadKeyStore(Environment env0) throws BootstrapException {
private static KeyStoreWrapper loadKeyStore(Environment initialEnv) throws BootstrapException {
final KeyStoreWrapper keystore;
try {
keystore = KeyStoreWrapper.load(env0.configFile());
keystore = KeyStoreWrapper.load(initialEnv.configFile());
} catch (IOException e) {
throw new BootstrapException(e);
}
@ -281,7 +281,7 @@ final class Bootstrap {
final boolean foreground,
final Path pidFile,
final boolean quiet,
final Environment env0) throws BootstrapException, NodeValidationException, UserException {
final Environment initialEnv) throws BootstrapException, NodeValidationException, UserException {
// Set the system property before anything has a chance to trigger its use
initLoggerPrefix();
@ -291,8 +291,8 @@ final class Bootstrap {
INSTANCE = new Bootstrap();
final KeyStoreWrapper keystore = loadKeyStore(env0);
Environment environment = initialEnvironment(foreground, pidFile, keystore, env0.settings());
final KeyStoreWrapper keystore = loadKeyStore(initialEnv);
Environment environment = initialEnvironment(foreground, pidFile, keystore, initialEnv.settings());
try {
LogConfigurator.configure(environment);
} catch (IOException e) {

View File

@ -117,10 +117,10 @@ class Elasticsearch extends EnvironmentAwareCommand {
}
}
void init(final boolean daemonize, final Path pidFile, final boolean quiet, Environment env0)
void init(final boolean daemonize, final Path pidFile, final boolean quiet, Environment initialEnv)
throws NodeValidationException, UserException {
try {
Bootstrap.init(!daemonize, pidFile, quiet, env0);
Bootstrap.init(!daemonize, pidFile, quiet, initialEnv);
} catch (BootstrapException | RuntimeException e) {
// format exceptions to the console in a special way
// to avoid 2MB stacktraces from guice, etc.

View File

@ -52,7 +52,7 @@ import org.apache.lucene.store.ChecksumIndexInput;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.IndexOutput;
import org.apache.lucene.store.NIOFSDirectory;
import org.apache.lucene.store.SimpleFSDirectory;
import org.apache.lucene.util.SetOnce;
/**
@ -140,7 +140,7 @@ public class KeyStoreWrapper implements Closeable {
return null;
}
NIOFSDirectory directory = new NIOFSDirectory(configDir);
SimpleFSDirectory directory = new SimpleFSDirectory(configDir);
try (IndexInput indexInput = directory.openInput(KEYSTORE_FILENAME, IOContext.READONCE)) {
ChecksumIndexInput input = new BufferedChecksumIndexInput(indexInput);
CodecUtil.checkHeader(input, KEYSTORE_FILENAME, FORMAT_VERSION, FORMAT_VERSION);
@ -199,7 +199,7 @@ public class KeyStoreWrapper implements Closeable {
void save(Path configDir) throws Exception {
char[] password = this.keystorePassword.get().getPassword();
NIOFSDirectory directory = new NIOFSDirectory(configDir);
SimpleFSDirectory directory = new SimpleFSDirectory(configDir);
// write to tmp file first, then overwrite
String tmpFile = KEYSTORE_FILENAME + ".tmp";
try (IndexOutput output = directory.createOutput(tmpFile, IOContext.DEFAULT)) {
@ -217,7 +217,7 @@ public class KeyStoreWrapper implements Closeable {
}
Path keystoreFile = keystorePath(configDir);
Files.move(configDir.resolve(tmpFile), keystoreFile, StandardCopyOption.REPLACE_EXISTING);
Files.move(configDir.resolve(tmpFile), keystoreFile, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
PosixFileAttributeView attrs = Files.getFileAttributeView(keystoreFile, PosixFileAttributeView.class);
if (attrs != null) {
// don't rely on umask: ensure the keystore has minimal permissions
@ -230,6 +230,7 @@ public class KeyStoreWrapper implements Closeable {
return settingNames;
}
// TODO: make settings accessible only to code that registered the setting
/** Retrieve a string setting. The {@link SecureString} should be closed once it is used. */
SecureString getStringSetting(String setting) throws GeneralSecurityException {
KeyStore.Entry entry = keystore.get().getEntry(setting, keystorePassword.get());

View File

@ -35,7 +35,7 @@ import static org.hamcrest.CoreMatchers.equalTo;
abstract class ESElasticsearchCliTestCase extends ESTestCase {
interface InitConsumer {
void accept(final boolean foreground, final Path pidFile, final boolean quiet, final Environment env0);
void accept(final boolean foreground, final Path pidFile, final boolean quiet, final Environment initialEnv);
}
void runTest(
@ -57,9 +57,9 @@ abstract class ESElasticsearchCliTestCase extends ESTestCase {
return new Environment(realSettings);
}
@Override
void init(final boolean daemonize, final Path pidFile, final boolean quiet, Environment env0) {
void init(final boolean daemonize, final Path pidFile, final boolean quiet, Environment initialEnv) {
init.set(true);
initConsumer.accept(!daemonize, pidFile, quiet, env0);
initConsumer.accept(!daemonize, pidFile, quiet, initialEnv);
}
@Override