From 0706aeead13cbd85303cfe8ddafa183cca4ee10d Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Tue, 26 May 2015 09:38:45 -0400 Subject: [PATCH] Absorb ImmutableSettings into Settings --- .../azure/itest/AzureSimpleITest.java | 5 ++-- .../cloud/azure/AbstractAzureTest.java | 5 ++-- .../AbstractAzureComputeServiceTest.java | 5 ++-- .../azure/AzureMinimumMasterNodesTest.java | 3 +-- .../discovery/azure/AzureSimpleTest.java | 8 +++---- .../azure/AzureTwoStartedNodesTest.java | 6 ++--- .../index/store/SmbMMapFsTest.java | 3 +-- .../index/store/SmbSimpleFsTest.java | 3 +-- .../AbstractAzureRepositoryServiceTest.java | 5 ++-- .../azure/AzureSnapshotRestoreITest.java | 23 +++++++++---------- .../azure/AzureSnapshotRestoreTest.java | 4 ++-- 11 files changed, 31 insertions(+), 39 deletions(-) diff --git a/src/test/java/org/elasticsearch/azure/itest/AzureSimpleITest.java b/src/test/java/org/elasticsearch/azure/itest/AzureSimpleITest.java index 1a740681e02..2ab09adac95 100644 --- a/src/test/java/org/elasticsearch/azure/itest/AzureSimpleITest.java +++ b/src/test/java/org/elasticsearch/azure/itest/AzureSimpleITest.java @@ -21,7 +21,6 @@ package org.elasticsearch.azure.itest; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; import org.elasticsearch.cloud.azure.AbstractAzureTest; -import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.hamcrest.Matchers; @@ -41,7 +40,7 @@ public class AzureSimpleITest extends AbstractAzureTest { @Override protected Settings nodeSettings(int nodeOrdinal) { - return ImmutableSettings.builder() + return Settings.builder() .put(super.nodeSettings(nodeOrdinal)) // For now we let the user who runs tests to define if he wants or not to run discovery tests // by setting in elasticsearch.yml: discovery.type: azure @@ -62,7 +61,7 @@ public class AzureSimpleITest extends AbstractAzureTest { public Settings indexSettings() { // During restore we frequently restore index to exactly the same state it was before, that might cause the same // checksum file to be written twice during restore operation - return ImmutableSettings.builder().put(super.indexSettings()) + return Settings.builder().put(super.indexSettings()) .build(); } } diff --git a/src/test/java/org/elasticsearch/cloud/azure/AbstractAzureTest.java b/src/test/java/org/elasticsearch/cloud/azure/AbstractAzureTest.java index 7e85b6522d8..7a2cc37d136 100644 --- a/src/test/java/org/elasticsearch/cloud/azure/AbstractAzureTest.java +++ b/src/test/java/org/elasticsearch/cloud/azure/AbstractAzureTest.java @@ -20,7 +20,6 @@ package org.elasticsearch.cloud.azure; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.env.FailedToResolveConfigException; @@ -39,7 +38,7 @@ public abstract class AbstractAzureTest extends ElasticsearchIntegrationTest { @Override protected Settings nodeSettings(int nodeOrdinal) { - return ImmutableSettings.builder() + return Settings.builder() .put(super.nodeSettings(nodeOrdinal)) .put(PluginsService.LOAD_PLUGIN_FROM_CLASSPATH, true) .put(readSettingsFromFile()) @@ -47,7 +46,7 @@ public abstract class AbstractAzureTest extends ElasticsearchIntegrationTest { } protected Settings readSettingsFromFile() { - ImmutableSettings.Builder settings = ImmutableSettings.builder(); + Settings.Builder settings = Settings.builder(); settings.put("path.home", createTempDir()); Environment environment = new Environment(settings.build()); diff --git a/src/test/java/org/elasticsearch/discovery/azure/AbstractAzureComputeServiceTest.java b/src/test/java/org/elasticsearch/discovery/azure/AbstractAzureComputeServiceTest.java index 212d453fb0c..cf3b7848d0e 100644 --- a/src/test/java/org/elasticsearch/discovery/azure/AbstractAzureComputeServiceTest.java +++ b/src/test/java/org/elasticsearch/discovery/azure/AbstractAzureComputeServiceTest.java @@ -23,7 +23,6 @@ import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; import org.elasticsearch.cloud.azure.management.AzureComputeService; import org.elasticsearch.cloud.azure.management.AzureComputeService.Discovery; import org.elasticsearch.cloud.azure.management.AzureComputeService.Management; -import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.plugins.PluginsService; import org.elasticsearch.test.ElasticsearchIntegrationTest; @@ -39,7 +38,7 @@ public abstract class AbstractAzureComputeServiceTest extends ElasticsearchInteg @Override protected Settings nodeSettings(int nodeOrdinal) { - ImmutableSettings.Builder settings = ImmutableSettings.builder() + Settings.Builder settings = Settings.builder() .put(super.nodeSettings(nodeOrdinal)) .put(PluginsService.LOAD_PLUGIN_FROM_CLASSPATH, true); return settings.build(); @@ -53,7 +52,7 @@ public abstract class AbstractAzureComputeServiceTest extends ElasticsearchInteg } protected Settings settingsBuilder() { - ImmutableSettings.Builder builder = ImmutableSettings.settingsBuilder() + Settings.Builder builder = Settings.settingsBuilder() .put("discovery.type", "azure") .put(Management.API_IMPLEMENTATION, mock) // We need the network to make the mock working diff --git a/src/test/java/org/elasticsearch/discovery/azure/AzureMinimumMasterNodesTest.java b/src/test/java/org/elasticsearch/discovery/azure/AzureMinimumMasterNodesTest.java index 042fd079a96..53a23acc93c 100644 --- a/src/test/java/org/elasticsearch/discovery/azure/AzureMinimumMasterNodesTest.java +++ b/src/test/java/org/elasticsearch/discovery/azure/AzureMinimumMasterNodesTest.java @@ -20,7 +20,6 @@ package org.elasticsearch.discovery.azure; import org.elasticsearch.cloud.azure.management.AzureComputeServiceTwoNodesMock; -import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.discovery.MasterNotDiscoveredException; import org.elasticsearch.test.ElasticsearchIntegrationTest; @@ -47,7 +46,7 @@ public class AzureMinimumMasterNodesTest extends AbstractAzureComputeServiceTest @Override protected final Settings settingsBuilder() { - ImmutableSettings.Builder builder = ImmutableSettings.settingsBuilder() + Settings.Builder builder = Settings.settingsBuilder() .put(super.settingsBuilder()) .put("discovery.zen.minimum_master_nodes", 2) // Make the test run faster diff --git a/src/test/java/org/elasticsearch/discovery/azure/AzureSimpleTest.java b/src/test/java/org/elasticsearch/discovery/azure/AzureSimpleTest.java index a0dd325dcf1..14084d33a73 100644 --- a/src/test/java/org/elasticsearch/discovery/azure/AzureSimpleTest.java +++ b/src/test/java/org/elasticsearch/discovery/azure/AzureSimpleTest.java @@ -22,7 +22,7 @@ package org.elasticsearch.discovery.azure; import org.elasticsearch.cloud.azure.management.AzureComputeService.Discovery; import org.elasticsearch.cloud.azure.management.AzureComputeService.Management; import org.elasticsearch.cloud.azure.management.AzureComputeServiceSimpleMock; -import org.elasticsearch.common.settings.ImmutableSettings; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.junit.Test; @@ -40,7 +40,7 @@ public class AzureSimpleTest extends AbstractAzureComputeServiceTest { @Test public void one_node_should_run_using_private_ip() { - ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder() + Settings.Builder settings = Settings.settingsBuilder() .put(Management.SERVICE_NAME, "dummy") .put(Discovery.HOST_TYPE, "private_ip") .put(super.settingsBuilder()); @@ -55,7 +55,7 @@ public class AzureSimpleTest extends AbstractAzureComputeServiceTest { @Test public void one_node_should_run_using_public_ip() { - ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder() + Settings.Builder settings = Settings.settingsBuilder() .put(Management.SERVICE_NAME, "dummy") .put(Discovery.HOST_TYPE, "public_ip") .put(super.settingsBuilder()); @@ -70,7 +70,7 @@ public class AzureSimpleTest extends AbstractAzureComputeServiceTest { @Test public void one_node_should_run_using_wrong_settings() { - ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder() + Settings.Builder settings = Settings.settingsBuilder() .put(Management.SERVICE_NAME, "dummy") .put(Discovery.HOST_TYPE, "do_not_exist") .put(super.settingsBuilder()); diff --git a/src/test/java/org/elasticsearch/discovery/azure/AzureTwoStartedNodesTest.java b/src/test/java/org/elasticsearch/discovery/azure/AzureTwoStartedNodesTest.java index 69e3e369f88..66fe96dedae 100644 --- a/src/test/java/org/elasticsearch/discovery/azure/AzureTwoStartedNodesTest.java +++ b/src/test/java/org/elasticsearch/discovery/azure/AzureTwoStartedNodesTest.java @@ -22,7 +22,7 @@ package org.elasticsearch.discovery.azure; import org.elasticsearch.cloud.azure.management.AzureComputeService.Discovery; import org.elasticsearch.cloud.azure.management.AzureComputeService.Management; import org.elasticsearch.cloud.azure.management.AzureComputeServiceTwoNodesMock; -import org.elasticsearch.common.settings.ImmutableSettings; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.junit.Test; @@ -40,7 +40,7 @@ public class AzureTwoStartedNodesTest extends AbstractAzureComputeServiceTest { @Test public void two_nodes_should_run_using_private_ip() { - ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder() + Settings.Builder settings = Settings.settingsBuilder() .put(Management.SERVICE_NAME, "dummy") .put(Discovery.HOST_TYPE, "private_ip") .put(super.settingsBuilder()); @@ -59,7 +59,7 @@ public class AzureTwoStartedNodesTest extends AbstractAzureComputeServiceTest { @Test public void two_nodes_should_run_using_public_ip() { - ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder() + Settings.Builder settings = Settings.settingsBuilder() .put(Management.SERVICE_NAME, "dummy") .put(Discovery.HOST_TYPE, "public_ip") .put(super.settingsBuilder()); diff --git a/src/test/java/org/elasticsearch/index/store/SmbMMapFsTest.java b/src/test/java/org/elasticsearch/index/store/SmbMMapFsTest.java index ec4941cb24d..2b925a86820 100644 --- a/src/test/java/org/elasticsearch/index/store/SmbMMapFsTest.java +++ b/src/test/java/org/elasticsearch/index/store/SmbMMapFsTest.java @@ -19,7 +19,6 @@ package org.elasticsearch.index.store; -import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; @@ -27,7 +26,7 @@ public class SmbMMapFsTest extends AbstractAzureFsTest { @Override public Settings indexSettings() { - return ImmutableSettings.builder() + return Settings.builder() .put(super.indexSettings()) .put("index.store.type", "smb_mmap_fs") .build(); diff --git a/src/test/java/org/elasticsearch/index/store/SmbSimpleFsTest.java b/src/test/java/org/elasticsearch/index/store/SmbSimpleFsTest.java index 96c55a42562..482075ad327 100644 --- a/src/test/java/org/elasticsearch/index/store/SmbSimpleFsTest.java +++ b/src/test/java/org/elasticsearch/index/store/SmbSimpleFsTest.java @@ -19,14 +19,13 @@ package org.elasticsearch.index.store; -import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; public class SmbSimpleFsTest extends AbstractAzureFsTest { @Override public Settings indexSettings() { - return ImmutableSettings.builder() + return Settings.builder() .put(super.indexSettings()) .put("index.store.type", "smb_simple_fs") .build(); diff --git a/src/test/java/org/elasticsearch/repositories/azure/AbstractAzureRepositoryServiceTest.java b/src/test/java/org/elasticsearch/repositories/azure/AbstractAzureRepositoryServiceTest.java index bc80ffc0808..56bad4cd0e3 100644 --- a/src/test/java/org/elasticsearch/repositories/azure/AbstractAzureRepositoryServiceTest.java +++ b/src/test/java/org/elasticsearch/repositories/azure/AbstractAzureRepositoryServiceTest.java @@ -24,7 +24,6 @@ import org.elasticsearch.cloud.azure.AbstractAzureTest; import org.elasticsearch.cloud.azure.storage.AzureStorageService; import org.elasticsearch.cloud.azure.storage.AzureStorageService.Storage; import org.elasticsearch.cluster.metadata.IndexMetaData; -import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.plugins.PluginsService; import org.elasticsearch.repositories.RepositoryMissingException; @@ -65,7 +64,7 @@ public abstract class AbstractAzureRepositoryServiceTest extends AbstractAzureTe @Override protected Settings nodeSettings(int nodeOrdinal) { - ImmutableSettings.Builder builder = ImmutableSettings.settingsBuilder() + Settings.Builder builder = Settings.settingsBuilder() .put(PluginsService.LOAD_PLUGIN_FROM_CLASSPATH, true) .put(Storage.API_IMPLEMENTATION, mock) .put(Storage.CONTAINER, "snapshots"); @@ -81,7 +80,7 @@ public abstract class AbstractAzureRepositoryServiceTest extends AbstractAzureTe public Settings indexSettings() { // During restore we frequently restore index to exactly the same state it was before, that might cause the same // checksum file to be written twice during restore operation - return ImmutableSettings.builder().put(super.indexSettings()) + return Settings.builder().put(super.indexSettings()) .put(MockFSDirectoryService.RANDOM_PREVENT_DOUBLE_WRITE, false) .put(MockFSDirectoryService.RANDOM_NO_DELETE_OPEN_FILE, false) .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0) diff --git a/src/test/java/org/elasticsearch/repositories/azure/AzureSnapshotRestoreITest.java b/src/test/java/org/elasticsearch/repositories/azure/AzureSnapshotRestoreITest.java index dda48fd541f..aa01b61bbce 100644 --- a/src/test/java/org/elasticsearch/repositories/azure/AzureSnapshotRestoreITest.java +++ b/src/test/java/org/elasticsearch/repositories/azure/AzureSnapshotRestoreITest.java @@ -34,7 +34,6 @@ import org.elasticsearch.cloud.azure.storage.AzureStorageServiceImpl; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.common.Strings; import org.elasticsearch.common.base.Predicate; -import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.repositories.RepositoryMissingException; import org.elasticsearch.repositories.RepositoryVerificationException; @@ -75,7 +74,7 @@ public class AzureSnapshotRestoreITest extends AbstractAzureTest { @Override protected Settings nodeSettings(int nodeOrdinal) { - return ImmutableSettings.builder().put(super.nodeSettings(nodeOrdinal)) + return Settings.builder().put(super.nodeSettings(nodeOrdinal)) // In snapshot tests, we explicitly disable cloud discovery .put("discovery.type", "local") .build(); @@ -85,7 +84,7 @@ public class AzureSnapshotRestoreITest extends AbstractAzureTest { public Settings indexSettings() { // During restore we frequently restore index to exactly the same state it was before, that might cause the same // checksum file to be written twice during restore operation - return ImmutableSettings.builder().put(super.indexSettings()) + return Settings.builder().put(super.indexSettings()) .put(MockFSDirectoryService.RANDOM_PREVENT_DOUBLE_WRITE, false) .put(MockFSDirectoryService.RANDOM_NO_DELETE_OPEN_FILE, false) .build(); @@ -105,7 +104,7 @@ public class AzureSnapshotRestoreITest extends AbstractAzureTest { Client client = client(); logger.info("--> creating azure repository with path [{}]", getRepositoryPath()); PutRepositoryResponse putRepositoryResponse = client.admin().cluster().preparePutRepository("test-repo") - .setType("azure").setSettings(ImmutableSettings.settingsBuilder() + .setType("azure").setSettings(Settings.settingsBuilder() .put(Storage.CONTAINER, getContainerName()) .put(Storage.BASE_PATH, getRepositoryPath()) .put(Storage.CHUNK_SIZE, randomIntBetween(1000, 10000)) @@ -178,14 +177,14 @@ public class AzureSnapshotRestoreITest extends AbstractAzureTest { Client client = client(); logger.info("--> creating azure repository with path [{}]", getRepositoryPath()); PutRepositoryResponse putRepositoryResponse1 = client.admin().cluster().preparePutRepository("test-repo1") - .setType("azure").setSettings(ImmutableSettings.settingsBuilder() + .setType("azure").setSettings(Settings.settingsBuilder() .put(Repository.CONTAINER, getContainerName().concat("-1")) .put(Repository.BASE_PATH, getRepositoryPath()) .put(Repository.CHUNK_SIZE, randomIntBetween(1000, 10000)) ).get(); assertThat(putRepositoryResponse1.isAcknowledged(), equalTo(true)); PutRepositoryResponse putRepositoryResponse2 = client.admin().cluster().preparePutRepository("test-repo2") - .setType("azure").setSettings(ImmutableSettings.settingsBuilder() + .setType("azure").setSettings(Settings.settingsBuilder() .put(Repository.CONTAINER, getContainerName().concat("-2")) .put(Repository.BASE_PATH, getRepositoryPath()) .put(Repository.CHUNK_SIZE, randomIntBetween(1000, 10000)) @@ -258,7 +257,7 @@ public class AzureSnapshotRestoreITest extends AbstractAzureTest { ClusterAdminClient client = client().admin().cluster(); logger.info("--> creating azure repository without any path"); PutRepositoryResponse putRepositoryResponse = client.preparePutRepository("test-repo").setType("azure") - .setSettings(ImmutableSettings.settingsBuilder() + .setSettings(Settings.settingsBuilder() .put(Repository.CONTAINER, getContainerName()) ).get(); assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true)); @@ -279,7 +278,7 @@ public class AzureSnapshotRestoreITest extends AbstractAzureTest { logger.info("--> creating azure repository path [{}]", getRepositoryPath()); putRepositoryResponse = client.preparePutRepository("test-repo").setType("azure") - .setSettings(ImmutableSettings.settingsBuilder() + .setSettings(Settings.settingsBuilder() .put(Repository.CONTAINER, getContainerName()) .put(Repository.BASE_PATH, getRepositoryPath()) ).get(); @@ -306,7 +305,7 @@ public class AzureSnapshotRestoreITest extends AbstractAzureTest { ClusterAdminClient client = client().admin().cluster(); logger.info("--> creating azure repository without any path"); PutRepositoryResponse putRepositoryResponse = client.preparePutRepository("test-repo").setType("azure") - .setSettings(ImmutableSettings.settingsBuilder() + .setSettings(Settings.settingsBuilder() .put(Repository.CONTAINER, getContainerName()) ).get(); assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true)); @@ -356,7 +355,7 @@ public class AzureSnapshotRestoreITest extends AbstractAzureTest { public boolean apply(Object obj) { try { PutRepositoryResponse putRepositoryResponse = client().admin().cluster().preparePutRepository("test-repo") - .setType("azure").setSettings(ImmutableSettings.settingsBuilder() + .setType("azure").setSettings(Settings.settingsBuilder() .put(Repository.CONTAINER, container) .put(Repository.BASE_PATH, getRepositoryPath()) .put(Repository.CHUNK_SIZE, randomIntBetween(1000, 10000)) @@ -388,7 +387,7 @@ public class AzureSnapshotRestoreITest extends AbstractAzureTest { Client client = client(); logger.info("--> creating azure repository with path [{}]", getRepositoryPath()); PutRepositoryResponse putRepositoryResponse = client.admin().cluster().preparePutRepository("test-repo") - .setType("azure").setSettings(ImmutableSettings.settingsBuilder() + .setType("azure").setSettings(Settings.settingsBuilder() .put(Repository.CONTAINER, getContainerName()) .put(Repository.BASE_PATH, getRepositoryPath()) .put(Repository.CHUNK_SIZE, randomIntBetween(1000, 10000)) @@ -436,7 +435,7 @@ public class AzureSnapshotRestoreITest extends AbstractAzureTest { logger.info("--> creating azure repository while container is being removed"); try { client.preparePutRepository("test-repo").setType("azure") - .setSettings(ImmutableSettings.settingsBuilder() + .setSettings(Settings.settingsBuilder() .put(Repository.CONTAINER, container) ).get(); fail("we should get a RepositoryVerificationException"); diff --git a/src/test/java/org/elasticsearch/repositories/azure/AzureSnapshotRestoreTest.java b/src/test/java/org/elasticsearch/repositories/azure/AzureSnapshotRestoreTest.java index b95420536ff..4c2a59124ce 100644 --- a/src/test/java/org/elasticsearch/repositories/azure/AzureSnapshotRestoreTest.java +++ b/src/test/java/org/elasticsearch/repositories/azure/AzureSnapshotRestoreTest.java @@ -26,7 +26,7 @@ import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotR import org.elasticsearch.client.Client; import org.elasticsearch.cloud.azure.storage.AzureStorageServiceMock; import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.common.settings.ImmutableSettings; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.snapshots.SnapshotState; import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.junit.Test; @@ -50,7 +50,7 @@ public class AzureSnapshotRestoreTest extends AbstractAzureRepositoryServiceTest Client client = client(); logger.info("--> creating azure repository with path [{}]", basePath); PutRepositoryResponse putRepositoryResponse = client.admin().cluster().preparePutRepository("test-repo") - .setType("azure").setSettings(ImmutableSettings.settingsBuilder() + .setType("azure").setSettings(Settings.settingsBuilder() .put("base_path", basePath) .put("chunk_size", randomIntBetween(1000, 10000)) ).get();