diff --git a/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/cli/InstallPluginAction.java b/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/cli/InstallPluginAction.java index 1fcafa1f8ce1a..f24f4d5255e70 100644 --- a/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/cli/InstallPluginAction.java +++ b/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/cli/InstallPluginAction.java @@ -484,8 +484,8 @@ Path downloadZip(String urlString, Path tmpDir) throws IOException { } // for testing only - void setEnvironment(Environment env) { - this.env = env; + void setEnvironment(Environment environment) { + this.env = environment; } // for testing only diff --git a/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/cli/SyncPluginsAction.java b/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/cli/SyncPluginsAction.java index b5d2a42df2812..d141b4aeced4c 100644 --- a/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/cli/SyncPluginsAction.java +++ b/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/cli/SyncPluginsAction.java @@ -115,7 +115,7 @@ public void execute() throws Exception { // @VisibleForTesting PluginChanges getPluginChanges(PluginsConfig pluginsConfig, Optional cachedPluginsConfig) throws PluginSyncException { - final List existingPlugins = getExistingPlugins(this.env); + final List existingPlugins = getExistingPlugins(); final List pluginsThatShouldExist = pluginsConfig.getPlugins(); final List pluginsThatActuallyExist = existingPlugins.stream() @@ -230,7 +230,7 @@ private List getPluginsToUpgrade( }).collect(Collectors.toList()); } - private List getExistingPlugins(Environment env) throws PluginSyncException { + private List getExistingPlugins() throws PluginSyncException { final List plugins = new ArrayList<>(); try { diff --git a/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/cli/InstallPluginActionTests.java b/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/cli/InstallPluginActionTests.java index 22b435c5384e3..01db337dc5bc4 100644 --- a/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/cli/InstallPluginActionTests.java +++ b/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/cli/InstallPluginActionTests.java @@ -293,15 +293,15 @@ void installPlugin(PluginDescriptor plugin, Path home, InstallPluginAction actio } void installPlugins(final List plugins, final Path home, final InstallPluginAction action) throws Exception { - final Environment env = TestEnvironment.newEnvironment(Settings.builder().put("path.home", home).build()); - action.setEnvironment(env); + final Environment environment = TestEnvironment.newEnvironment(Settings.builder().put("path.home", home).build()); + action.setEnvironment(environment); action.execute(plugins); } - void assertPlugin(String name, Path original, Environment env) throws IOException { - assertPluginInternal(name, env.pluginsFile(), original); - assertConfigAndBin(name, original, env); - assertInstallCleaned(env); + void assertPlugin(String name, Path original, Environment environment) throws IOException { + assertPluginInternal(name, environment.pluginsFile(), original); + assertConfigAndBin(name, original, environment); + assertInstallCleaned(environment); } void assertPluginInternal(String name, Path pluginsFile, Path originalPlugin) throws IOException { @@ -333,9 +333,9 @@ void assertPluginInternal(String name, Path pluginsFile, Path originalPlugin) th assertFalse("config was not copied", Files.exists(got.resolve("config"))); } - void assertConfigAndBin(String name, Path original, Environment env) throws IOException { + void assertConfigAndBin(String name, Path original, Environment environment) throws IOException { if (Files.exists(original.resolve("bin"))) { - Path binDir = env.binFile().resolve(name); + Path binDir = environment.binFile().resolve(name); assertTrue("bin dir exists", Files.exists(binDir)); assertTrue("bin is a dir", Files.isDirectory(binDir)); try (DirectoryStream stream = Files.newDirectoryStream(binDir)) { @@ -349,7 +349,7 @@ void assertConfigAndBin(String name, Path original, Environment env) throws IOEx } } if (Files.exists(original.resolve("config"))) { - Path configDir = env.configFile().resolve(name); + Path configDir = environment.configFile().resolve(name); assertTrue("config dir exists", Files.exists(configDir)); assertTrue("config is a dir", Files.isDirectory(configDir)); @@ -357,7 +357,7 @@ void assertConfigAndBin(String name, Path original, Environment env) throws IOEx GroupPrincipal group = null; if (isPosix) { - PosixFileAttributes configAttributes = Files.getFileAttributeView(env.configFile(), PosixFileAttributeView.class) + PosixFileAttributes configAttributes = Files.getFileAttributeView(environment.configFile(), PosixFileAttributeView.class) .readAttributes(); user = configAttributes.owner(); group = configAttributes.group(); @@ -385,8 +385,8 @@ void assertConfigAndBin(String name, Path original, Environment env) throws IOEx } } - void assertInstallCleaned(Environment env) throws IOException { - try (DirectoryStream stream = Files.newDirectoryStream(env.pluginsFile())) { + void assertInstallCleaned(Environment environment) throws IOException { + try (DirectoryStream stream = Files.newDirectoryStream(environment.pluginsFile())) { for (Path file : stream) { if (file.getFileName().toString().startsWith(".installing")) { fail("Installation dir still exists, " + file); @@ -600,22 +600,22 @@ public void testBinPermissions() throws Exception { public void testPluginPermissions() throws Exception { assumeTrue("posix filesystem", isPosix); - final Path pluginDir = createPluginDir(temp); - final Path resourcesDir = pluginDir.resolve("resources"); - final Path platformDir = pluginDir.resolve("platform"); + final Path tempPluginDir = createPluginDir(temp); + final Path resourcesDir = tempPluginDir.resolve("resources"); + final Path platformDir = tempPluginDir.resolve("platform"); final Path platformNameDir = platformDir.resolve("linux-x86_64"); final Path platformBinDir = platformNameDir.resolve("bin"); Files.createDirectories(platformBinDir); - Files.createFile(pluginDir.resolve("fake-" + Version.CURRENT.toString() + ".jar")); + Files.createFile(tempPluginDir.resolve("fake-" + Version.CURRENT.toString() + ".jar")); Files.createFile(platformBinDir.resolve("fake_executable")); Files.createDirectory(resourcesDir); Files.createFile(resourcesDir.resolve("resource")); - final PluginDescriptor pluginZip = createPluginZip("fake", pluginDir); + final PluginDescriptor pluginZip = createPluginZip("fake", tempPluginDir); installPlugin(pluginZip); - assertPlugin("fake", pluginDir, env.v2()); + assertPlugin("fake", tempPluginDir, env.v2()); final Path fake = env.v2().pluginsFile().resolve("fake"); final Path resources = fake.resolve("resources"); @@ -731,9 +731,9 @@ public void testZipRelativeOutsideEntryName() throws Exception { } public void testOfficialPluginsHelpSortedAndMissingObviouslyWrongPlugins() throws Exception { - MockTerminal terminal = new MockTerminal(); - new MockInstallPluginCommand().main(new String[] { "--help" }, terminal); - try (BufferedReader reader = new BufferedReader(new StringReader(terminal.getOutput()))) { + MockTerminal mockTerminal = new MockTerminal(); + new MockInstallPluginCommand().main(new String[] { "--help" }, mockTerminal); + try (BufferedReader reader = new BufferedReader(new StringReader(mockTerminal.getOutput()))) { String line = reader.readLine(); // first find the beginning of our list of official plugins @@ -1362,7 +1362,8 @@ private String signature(final byte[] bytes, final PGPSecretKey secretKey) { // checks the plugin requires a policy confirmation, and does not install when that is rejected by the user // the plugin is installed after this method completes - private void assertPolicyConfirmation(Tuple env, PluginDescriptor pluginZip, String... warnings) throws Exception { + private void assertPolicyConfirmation(Tuple pathEnvironmentTuple, PluginDescriptor pluginZip, String... warnings) + throws Exception { for (int i = 0; i < warnings.length; ++i) { String warning = warnings[i]; for (int j = 0; j < i; ++j) { @@ -1374,7 +1375,7 @@ private void assertPolicyConfirmation(Tuple env, PluginDescri assertThat(e.getMessage(), containsString("installation aborted by user")); assertThat(terminal.getErrorOutput(), containsString("WARNING: " + warning)); - try (Stream fileStream = Files.list(env.v2().pluginsFile())) { + try (Stream fileStream = Files.list(pathEnvironmentTuple.v2().pluginsFile())) { assertThat(fileStream.collect(Collectors.toList()), empty()); } @@ -1387,7 +1388,7 @@ private void assertPolicyConfirmation(Tuple env, PluginDescri e = expectThrows(UserException.class, () -> installPlugin(pluginZip)); assertThat(e.getMessage(), containsString("installation aborted by user")); assertThat(terminal.getErrorOutput(), containsString("WARNING: " + warning)); - try (Stream fileStream = Files.list(env.v2().pluginsFile())) { + try (Stream fileStream = Files.list(pathEnvironmentTuple.v2().pluginsFile())) { assertThat(fileStream.collect(Collectors.toList()), empty()); } } diff --git a/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java b/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java index 1bca887b8573f..2f61e51345340 100644 --- a/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java +++ b/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java @@ -680,7 +680,7 @@ public void testSingleDoc() throws IOException { * Tests that a single empty shard index is correctly recovered. Empty shards are often an edge case. */ public void testEmptyShard() throws IOException { - final String index = "test_empty_shard"; + final String indexName = "test_empty_shard"; if (isRunningAgainstOldCluster()) { Settings.Builder settings = Settings.builder() @@ -698,9 +698,9 @@ public void testEmptyShard() throws IOException { if (randomBoolean()) { settings.put(IndexSettings.INDEX_TRANSLOG_RETENTION_SIZE_SETTING.getKey(), "-1"); } - createIndex(index, settings.build()); + createIndex(indexName, settings.build()); } - ensureGreen(index); + ensureGreen(indexName); } /** @@ -1077,21 +1077,24 @@ public void testClosedIndices() throws Exception { * that the index has started shards. */ @SuppressWarnings("unchecked") - private void assertClosedIndex(final String index, final boolean checkRoutingTable) throws IOException { + private void assertClosedIndex(final String indexName, final boolean checkRoutingTable) throws IOException { final Map state = entityAsMap(client().performRequest(new Request("GET", "/_cluster/state"))); - final Map metadata = (Map) XContentMapValues.extractValue("metadata.indices." + index, state); + final Map metadata = (Map) XContentMapValues.extractValue("metadata.indices." + indexName, state); assertThat(metadata, notNullValue()); assertThat(metadata.get("state"), equalTo("close")); - final Map blocks = (Map) XContentMapValues.extractValue("blocks.indices." + index, state); + final Map blocks = (Map) XContentMapValues.extractValue("blocks.indices." + indexName, state); assertThat(blocks, notNullValue()); assertThat(blocks.containsKey(String.valueOf(MetadataIndexStateService.INDEX_CLOSED_BLOCK_ID)), is(true)); final Map settings = (Map) XContentMapValues.extractValue("settings", metadata); assertThat(settings, notNullValue()); - final Map routingTable = (Map) XContentMapValues.extractValue("routing_table.indices." + index, state); + final Map routingTable = (Map) XContentMapValues.extractValue( + "routing_table.indices." + indexName, + state + ); if (checkRoutingTable) { assertThat(routingTable, notNullValue()); assertThat(Booleans.parseBoolean((String) XContentMapValues.extractValue("index.verified_before_close", settings)), is(true)); @@ -1110,7 +1113,7 @@ private void assertClosedIndex(final String index, final boolean checkRoutingTab for (Map shard : shards) { assertThat(XContentMapValues.extractValue("shard", shard), equalTo(i)); assertThat(XContentMapValues.extractValue("state", shard), equalTo("STARTED")); - assertThat(XContentMapValues.extractValue("index", shard), equalTo(index)); + assertThat(XContentMapValues.extractValue("index", shard), equalTo(indexName)); } } } else { @@ -1320,12 +1323,12 @@ private void refresh() throws IOException { client().performRequest(new Request("POST", "/" + index + "/_refresh")); } - private List dataNodes(String index, RestClient client) throws IOException { - Request request = new Request("GET", index + "/_stats"); + private List dataNodes(String indexName, RestClient client) throws IOException { + Request request = new Request("GET", indexName + "/_stats"); request.addParameter("level", "shards"); Response response = client.performRequest(request); List nodes = new ArrayList<>(); - List shardStats = ObjectPath.createFromResponse(response).evaluate("indices." + index + ".shards.0"); + List shardStats = ObjectPath.createFromResponse(response).evaluate("indices." + indexName + ".shards.0"); for (Object shard : shardStats) { final String nodeId = ObjectPath.evaluate(shard, "routing.node"); nodes.add(nodeId); @@ -1337,8 +1340,8 @@ private List dataNodes(String index, RestClient client) throws IOExcepti * Wait for an index to have green health, waiting longer than * {@link ESRestTestCase#ensureGreen}. */ - protected void ensureGreenLongWait(String index) throws IOException { - Request request = new Request("GET", "/_cluster/health/" + index); + protected void ensureGreenLongWait(String indexName) throws IOException { + Request request = new Request("GET", "/_cluster/health/" + indexName); request.addParameter("timeout", "2m"); request.addParameter("wait_for_status", "green"); request.addParameter("wait_for_no_relocating_shards", "true"); diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/PackagingTestCase.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/PackagingTestCase.java index dc6db49533688..5ebe65aa9854e 100644 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/PackagingTestCase.java +++ b/qa/os/src/test/java/org/elasticsearch/packaging/test/PackagingTestCase.java @@ -104,12 +104,12 @@ public abstract class PackagingTestCase extends Assert { // the java installation already installed on the system protected static final String systemJavaHome; static { - Shell sh = new Shell(); + Shell initShell = new Shell(); if (Platforms.WINDOWS) { - systemJavaHome = sh.run("$Env:SYSTEM_JAVA_HOME").stdout.trim(); + systemJavaHome = initShell.run("$Env:SYSTEM_JAVA_HOME").stdout.trim(); } else { assert Platforms.LINUX || Platforms.DARWIN; - systemJavaHome = sh.run("echo $SYSTEM_JAVA_HOME").stdout.trim(); + systemJavaHome = initShell.run("echo $SYSTEM_JAVA_HOME").stdout.trim(); } } diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/util/Distribution.java b/qa/os/src/test/java/org/elasticsearch/packaging/util/Distribution.java index b0c540192bd97..3b759b70d1710 100644 --- a/qa/os/src/test/java/org/elasticsearch/packaging/util/Distribution.java +++ b/qa/os/src/test/java/org/elasticsearch/packaging/util/Distribution.java @@ -43,17 +43,14 @@ public Distribution(Path path) { this.platform = filename.contains("windows") ? Platform.WINDOWS : Platform.LINUX; this.hasJdk = filename.contains("no-jdk") == false; - String version = filename.split("-", 3)[1]; + String tmpVersion = filename.split("-", 3)[1]; if (packaging == Packaging.DEB) { - version = version.replace(".deb", ""); + tmpVersion = tmpVersion.replace(".deb", ""); } else if (packaging == Packaging.RPM) { - version = version.replace(".rpm", ""); + tmpVersion = tmpVersion.replace(".rpm", ""); } - this.baseVersion = version; - if (filename.contains("-SNAPSHOT")) { - version += "-SNAPSHOT"; - } - this.version = version; + this.baseVersion = tmpVersion; + this.version = filename.contains("-SNAPSHOT") ? this.baseVersion + "-SNAPSHOT" : this.baseVersion; } public boolean isArchive() { diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/util/docker/DockerRun.java b/qa/os/src/test/java/org/elasticsearch/packaging/util/docker/DockerRun.java index 3df891e9e3d4c..27566cbe3e368 100644 --- a/qa/os/src/test/java/org/elasticsearch/packaging/util/docker/DockerRun.java +++ b/qa/os/src/test/java/org/elasticsearch/packaging/util/docker/DockerRun.java @@ -71,18 +71,18 @@ public DockerRun volume(Path from, Path to) { /** * Sets the UID that the container is run with, and the GID too if specified. * - * @param uid the UID to use, or {@code null} to use the image default - * @param gid the GID to use, or {@code null} to use the image default + * @param uidToUse the UID to use, or {@code null} to use the image default + * @param gidToUse the GID to use, or {@code null} to use the image default * @return the current builder */ - public DockerRun uid(Integer uid, Integer gid) { - if (uid == null) { - if (gid != null) { + public DockerRun uid(Integer uidToUse, Integer gidToUse) { + if (uidToUse == null) { + if (gidToUse != null) { throw new IllegalArgumentException("Cannot override GID without also overriding UID"); } } - this.uid = uid; - this.gid = gid; + this.uid = uidToUse; + this.gid = gidToUse; return this; } diff --git a/server/src/test/java/org/elasticsearch/index/replication/RetentionLeasesReplicationTests.java b/server/src/test/java/org/elasticsearch/index/replication/RetentionLeasesReplicationTests.java index 7ce1d873a955b..76998cf0ce605 100644 --- a/server/src/test/java/org/elasticsearch/index/replication/RetentionLeasesReplicationTests.java +++ b/server/src/test/java/org/elasticsearch/index/replication/RetentionLeasesReplicationTests.java @@ -76,8 +76,8 @@ public void testOutOfOrderRetentionLeasesRequests() throws Exception { IndexMetadata indexMetadata = buildIndexMetadata(numberOfReplicas, settings, indexMapping); try (ReplicationGroup group = new ReplicationGroup(indexMetadata) { @Override - protected void syncRetentionLeases(ShardId shardId, RetentionLeases leases, ActionListener listener) { - listener.onResponse(new SyncRetentionLeasesResponse(new RetentionLeaseSyncAction.Request(shardId, leases))); + protected void syncRetentionLeases(ShardId id, RetentionLeases leases, ActionListener listener) { + listener.onResponse(new SyncRetentionLeasesResponse(new RetentionLeaseSyncAction.Request(id, leases))); } }) { group.startAll(); @@ -103,8 +103,8 @@ public void testSyncRetentionLeasesWithPrimaryPromotion() throws Exception { IndexMetadata indexMetadata = buildIndexMetadata(numberOfReplicas, settings, indexMapping); try (ReplicationGroup group = new ReplicationGroup(indexMetadata) { @Override - protected void syncRetentionLeases(ShardId shardId, RetentionLeases leases, ActionListener listener) { - listener.onResponse(new SyncRetentionLeasesResponse(new RetentionLeaseSyncAction.Request(shardId, leases))); + protected void syncRetentionLeases(ShardId id, RetentionLeases leases, ActionListener listener) { + listener.onResponse(new SyncRetentionLeasesResponse(new RetentionLeaseSyncAction.Request(id, leases))); } }) { group.startAll(); diff --git a/test/framework/src/main/java/org/elasticsearch/cluster/DiskUsageIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/cluster/DiskUsageIntegTestCase.java index 4640a00295c76..8c0b35bc0e7b2 100644 --- a/test/framework/src/main/java/org/elasticsearch/cluster/DiskUsageIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/cluster/DiskUsageIntegTestCase.java @@ -113,11 +113,11 @@ public String name() { @Override public long getTotalSpace() throws IOException { - final long totalSpace = this.totalSpace; - if (totalSpace == -1) { + final long totalSpaceCopy = this.totalSpace; + if (totalSpaceCopy == -1) { return super.getTotalSpace(); } else { - return totalSpace; + return totalSpaceCopy; } } @@ -128,21 +128,21 @@ public void setTotalSpace(long totalSpace) { @Override public long getUsableSpace() throws IOException { - final long totalSpace = this.totalSpace; - if (totalSpace == -1) { + final long totalSpaceCopy = this.totalSpace; + if (totalSpaceCopy == -1) { return super.getUsableSpace(); } else { - return Math.max(0L, totalSpace - getTotalFileSize(path)); + return Math.max(0L, totalSpaceCopy - getTotalFileSize(path)); } } @Override public long getUnallocatedSpace() throws IOException { - final long totalSpace = this.totalSpace; - if (totalSpace == -1) { + final long totalSpaceCopy = this.totalSpace; + if (totalSpaceCopy == -1) { return super.getUnallocatedSpace(); } else { - return Math.max(0L, totalSpace - getTotalFileSize(path)); + return Math.max(0L, totalSpaceCopy - getTotalFileSize(path)); } } diff --git a/test/framework/src/main/java/org/elasticsearch/cluster/MockInternalClusterInfoService.java b/test/framework/src/main/java/org/elasticsearch/cluster/MockInternalClusterInfoService.java index f346f012632e1..1d50a7ddfcfb3 100644 --- a/test/framework/src/main/java/org/elasticsearch/cluster/MockInternalClusterInfoService.java +++ b/test/framework/src/main/java/org/elasticsearch/cluster/MockInternalClusterInfoService.java @@ -40,13 +40,13 @@ public MockInternalClusterInfoService(Settings settings, ClusterService clusterS super(settings, clusterService, threadPool, client); } - public void setDiskUsageFunctionAndRefresh(BiFunction diskUsageFunction) { - this.diskUsageFunction = diskUsageFunction; + public void setDiskUsageFunctionAndRefresh(BiFunction diskUsageFn) { + this.diskUsageFunction = diskUsageFn; ClusterInfoServiceUtils.refresh(this); } - public void setShardSizeFunctionAndRefresh(Function shardSizeFunction) { - this.shardSizeFunction = shardSizeFunction; + public void setShardSizeFunctionAndRefresh(Function shardSizeFn) { + this.shardSizeFunction = shardSizeFn; ClusterInfoServiceUtils.refresh(this); } @@ -58,8 +58,8 @@ public ClusterInfo getClusterInfo() { @Override List adjustNodesStats(List nodesStats) { - final BiFunction diskUsageFunction = this.diskUsageFunction; - if (diskUsageFunction == null) { + final BiFunction diskUsageFunctionCopy = this.diskUsageFunction; + if (diskUsageFunctionCopy == null) { return nodesStats; } @@ -78,7 +78,7 @@ List adjustNodesStats(List nodesStats) { oldFsInfo.getTimestamp(), oldFsInfo.getIoStats(), StreamSupport.stream(oldFsInfo.spliterator(), false) - .map(fsInfoPath -> diskUsageFunction.apply(discoveryNode, fsInfoPath)) + .map(fsInfoPath -> diskUsageFunctionCopy.apply(discoveryNode, fsInfoPath)) .toArray(FsInfo.Path[]::new) ), nodeStats.getTransport(), @@ -108,12 +108,12 @@ class SizeFakingClusterInfo extends ClusterInfo { @Override public Long getShardSize(ShardRouting shardRouting) { - final Function shardSizeFunction = MockInternalClusterInfoService.this.shardSizeFunction; - if (shardSizeFunction == null) { + final Function shardSizeFunctionCopy = MockInternalClusterInfoService.this.shardSizeFunction; + if (shardSizeFunctionCopy == null) { return super.getShardSize(shardRouting); } - return shardSizeFunction.apply(shardRouting); + return shardSizeFunctionCopy.apply(shardRouting); } } diff --git a/test/framework/src/main/java/org/elasticsearch/cluster/coordination/AbstractCoordinatorTestCase.java b/test/framework/src/main/java/org/elasticsearch/cluster/coordination/AbstractCoordinatorTestCase.java index 693a0f9d4475c..77f0387bbe717 100644 --- a/test/framework/src/main/java/org/elasticsearch/cluster/coordination/AbstractCoordinatorTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/cluster/coordination/AbstractCoordinatorTestCase.java @@ -802,14 +802,14 @@ ClusterNode getAnyNode() { return getAnyNodeExcept(); } - ClusterNode getAnyNodeExcept(ClusterNode... clusterNodes) { - List filteredNodes = getAllNodesExcept(clusterNodes); + ClusterNode getAnyNodeExcept(ClusterNode... clusterNodesToExclude) { + List filteredNodes = getAllNodesExcept(clusterNodesToExclude); assert filteredNodes.isEmpty() == false; return randomFrom(filteredNodes); } - List getAllNodesExcept(ClusterNode... clusterNodes) { - Set forbiddenIds = Arrays.stream(clusterNodes).map(ClusterNode::getId).collect(Collectors.toSet()); + List getAllNodesExcept(ClusterNode... clusterNodesToExclude) { + Set forbiddenIds = Arrays.stream(clusterNodesToExclude).map(ClusterNode::getId).collect(Collectors.toSet()); return this.clusterNodes.stream().filter(n -> forbiddenIds.contains(n.getId()) == false).collect(Collectors.toList()); } @@ -1250,7 +1250,7 @@ ClusterNode restartedNode() { ClusterNode restartedNode( Function adaptGlobalMetadata, Function adaptCurrentTerm, - Settings nodeSettings + Settings settings ) { final TransportAddress address = randomBoolean() ? buildNewFakeTransportAddress() : localNode.getAddress(); final DiscoveryNode newLocalNode = new DiscoveryNode( @@ -1261,7 +1261,7 @@ ClusterNode restartedNode( address.getAddress(), address, Collections.emptyMap(), - localNode.isMasterNode() && DiscoveryNode.isMasterNode(nodeSettings) ? DiscoveryNodeRole.BUILT_IN_ROLES : emptySet(), + localNode.isMasterNode() && DiscoveryNode.isMasterNode(settings) ? DiscoveryNodeRole.BUILT_IN_ROLES : emptySet(), Version.CURRENT ); try { @@ -1269,7 +1269,7 @@ ClusterNode restartedNode( nodeIndex, newLocalNode, node -> new MockPersistedState(newLocalNode, persistedState, adaptGlobalMetadata, adaptCurrentTerm), - nodeSettings, + settings, nodeHealthService ); } finally { diff --git a/test/framework/src/main/java/org/elasticsearch/index/engine/EngineTestCase.java b/test/framework/src/main/java/org/elasticsearch/index/engine/EngineTestCase.java index 70fc78eb0557f..63fcad4ef70fa 100644 --- a/test/framework/src/main/java/org/elasticsearch/index/engine/EngineTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/index/engine/EngineTestCase.java @@ -143,6 +143,7 @@ import static org.hamcrest.Matchers.lessThanOrEqualTo; import static org.hamcrest.Matchers.notNullValue; +@SuppressWarnings("HiddenField") public abstract class EngineTestCase extends ESTestCase { protected final ShardId shardId = new ShardId(new Index("index", "_na_"), 0); diff --git a/test/framework/src/main/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java b/test/framework/src/main/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java index a97f3f62aff32..cfb384e490fae 100644 --- a/test/framework/src/main/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java @@ -190,13 +190,13 @@ protected class ReplicationGroup implements AutoCloseable, Iterable ); private final RetentionLeaseSyncer retentionLeaseSyncer = new RetentionLeaseSyncer( - (shardId, primaryAllocationId, primaryTerm, retentionLeases, listener) -> syncRetentionLeases( - shardId, + (_shardId, primaryAllocationId, primaryTerm, retentionLeases, listener) -> syncRetentionLeases( + _shardId, retentionLeases, listener ), - (shardId, primaryAllocationId, primaryTerm, retentionLeases) -> syncRetentionLeases( - shardId, + (_shardId, primaryAllocationId, primaryTerm, retentionLeases) -> syncRetentionLeases( + _shardId, retentionLeases, ActionListener.wrap(r -> {}, e -> { throw new AssertionError("failed to background sync retention lease", e); }) ) @@ -213,13 +213,13 @@ protected ReplicationGroup(final IndexMetadata indexMetadata) throws IOException } } - private ShardRouting createShardRouting(String nodeId, boolean primary) { + private ShardRouting createShardRouting(String nodeId, boolean isPrimary) { return TestShardRouting.newShardRouting( shardId, nodeId, - primary, + isPrimary, ShardRoutingState.INITIALIZING, - primary ? RecoverySource.EmptyStoreRecoverySource.INSTANCE : RecoverySource.PeerRecoverySource.INSTANCE + isPrimary ? RecoverySource.EmptyStoreRecoverySource.INSTANCE : RecoverySource.PeerRecoverySource.INSTANCE ); } @@ -342,10 +342,10 @@ assert shardRoutings().stream().anyMatch(shardRouting -> shardRouting.isSameAllo updateAllocationIDsOnPrimary(); } - protected synchronized void recoverPrimary(IndexShard primary) { - final DiscoveryNode pNode = getDiscoveryNode(primary.routingEntry().currentNodeId()); - primary.markAsRecovering("store", new RecoveryState(primary.routingEntry(), pNode, null)); - recoverFromStore(primary); + protected synchronized void recoverPrimary(IndexShard primaryShard) { + final DiscoveryNode pNode = getDiscoveryNode(primaryShard.routingEntry().currentNodeId()); + primaryShard.markAsRecovering("store", new RecoveryState(primaryShard.routingEntry(), pNode, null)); + recoverFromStore(primaryShard); } public synchronized IndexShard addReplicaWithExistingPath(final ShardPath shardPath, final String nodeId) throws IOException { @@ -406,7 +406,7 @@ public void onFailure(Exception e) { public synchronized void promoteReplicaToPrimary( IndexShard replica, - BiConsumer> primaryReplicaSyncer + BiConsumer> primaryReplicaSyncerArg ) throws IOException { final long newTerm = indexMetadata.primaryTerm(shardId.id()) + 1; IndexMetadata.Builder newMetadata = IndexMetadata.builder(indexMetadata).primaryTerm(shardId.id(), newTerm); @@ -421,7 +421,7 @@ public synchronized void promoteReplicaToPrimary( primary.updateShardState( primaryRouting, newTerm, - primaryReplicaSyncer, + primaryReplicaSyncerArg, currentClusterStateVersion.incrementAndGet(), activeIds(), routingTable @@ -589,12 +589,9 @@ private ReplicationTargets getReplicationTargets() { return replicationTargets; } - protected void syncRetentionLeases(ShardId shardId, RetentionLeases leases, ActionListener listener) { - new SyncRetentionLeases( - new RetentionLeaseSyncAction.Request(shardId, leases), - this, - listener.map(r -> new ReplicationResponse()) - ).execute(); + protected void syncRetentionLeases(ShardId id, RetentionLeases leases, ActionListener listener) { + new SyncRetentionLeases(new RetentionLeaseSyncAction.Request(id, leases), this, listener.map(r -> new ReplicationResponse())) + .execute(); } public synchronized RetentionLease addRetentionLease( @@ -722,8 +719,8 @@ public void failShard(String message, Exception exception) { } @Override - public void perform(Request request, ActionListener listener) { - performOnPrimary(getPrimaryShard(), request, listener); + public void perform(Request replicationRequest, ActionListener primaryResultListener) { + performOnPrimary(getPrimaryShard(), replicationRequest, primaryResultListener); } @Override @@ -772,20 +769,20 @@ class ReplicasRef implements ReplicationOperation.Replicas { @Override public void performOn( final ShardRouting replicaRouting, - final ReplicaRequest request, + final ReplicaRequest replicaRequest, final long primaryTerm, final long globalCheckpoint, final long maxSeqNoOfUpdatesOrDeletes, - final ActionListener listener + final ActionListener replicaResponseListener ) { IndexShard replica = replicationTargets.findReplicaShard(replicaRouting); replica.acquireReplicaOperationPermit( getPrimaryShard().getPendingPrimaryTerm(), globalCheckpoint, maxSeqNoOfUpdatesOrDeletes, - listener.delegateFailure((delegatedListener, releasable) -> { + replicaResponseListener.delegateFailure((delegatedListener, releasable) -> { try { - performOnReplica(request, replica); + performOnReplica(replicaRequest, replica); releasable.close(); delegatedListener.onResponse( new ReplicaResponse(replica.getLocalCheckpoint(), replica.getLastKnownGlobalCheckpoint()) @@ -796,7 +793,7 @@ public void performOn( } }), ThreadPool.Names.WRITE, - request + replicaRequest ); } @@ -806,19 +803,19 @@ public void failShardIfNeeded( long primaryTerm, String message, Exception exception, - ActionListener listener + ActionListener actionListener ) { throw new UnsupportedOperationException("failing shard " + replica + " isn't supported. failure: " + message, exception); } @Override public void markShardCopyAsStaleIfNeeded( - ShardId shardId, + ShardId id, String allocationId, long primaryTerm, - ActionListener listener + ActionListener actionListener ) { - throw new UnsupportedOperationException("can't mark " + shardId + ", aid [" + allocationId + "] as stale"); + throw new UnsupportedOperationException("can't mark " + id + ", aid [" + allocationId + "] as stale"); } } @@ -842,8 +839,8 @@ public void setShardInfo(ReplicationResponse.ShardInfo shardInfo) { } @Override - public void runPostReplicationActions(ActionListener listener) { - listener.onResponse(null); + public void runPostReplicationActions(ActionListener actionListener) { + actionListener.onResponse(null); } } @@ -889,7 +886,7 @@ private void executeShardBulkOnPrimary( final PlainActionFuture permitAcquiredFuture = new PlainActionFuture<>(); primary.acquirePrimaryOperationPermit(permitAcquiredFuture, ThreadPool.Names.SAME, request); try (Releasable ignored = permitAcquiredFuture.actionGet()) { - MappingUpdatePerformer noopMappingUpdater = (update, shardId, type, listener1) -> {}; + MappingUpdatePerformer noopMappingUpdater = (_update, _shardId, _type, _listener1) -> {}; TransportShardBulkAction.performOnPrimary( request, primary, diff --git a/test/framework/src/main/java/org/elasticsearch/script/MockScriptEngine.java b/test/framework/src/main/java/org/elasticsearch/script/MockScriptEngine.java index b1a4f39b33a6f..a811acb579b6a 100644 --- a/test/framework/src/main/java/org/elasticsearch/script/MockScriptEngine.java +++ b/test/framework/src/main/java/org/elasticsearch/script/MockScriptEngine.java @@ -70,12 +70,12 @@ public MockScriptEngine( Map, ContextCompiler> contexts ) { - Map scripts = new HashMap<>(deterministicScripts.size() + nonDeterministicScripts.size()); - deterministicScripts.forEach((key, value) -> scripts.put(key, MockDeterministicScript.asDeterministic(value))); - nonDeterministicScripts.forEach((key, value) -> scripts.put(key, MockDeterministicScript.asNonDeterministic(value))); + Map scriptMap = new HashMap<>(deterministicScripts.size() + nonDeterministicScripts.size()); + deterministicScripts.forEach((key, value) -> scriptMap.put(key, MockDeterministicScript.asDeterministic(value))); + nonDeterministicScripts.forEach((key, value) -> scriptMap.put(key, MockDeterministicScript.asNonDeterministic(value))); this.type = type; - this.scripts = Collections.unmodifiableMap(scripts); + this.scripts = Collections.unmodifiableMap(scriptMap); this.contexts = Collections.unmodifiableMap(contexts); } diff --git a/test/framework/src/main/java/org/elasticsearch/test/BackgroundIndexer.java b/test/framework/src/main/java/org/elasticsearch/test/BackgroundIndexer.java index 77e16e4dbb49f..f6e63e8f30f2d 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/BackgroundIndexer.java +++ b/test/framework/src/main/java/org/elasticsearch/test/BackgroundIndexer.java @@ -251,8 +251,8 @@ private XContentBuilder generateSource(long id, Random random) throws IOExceptio private volatile TimeValue timeout = BulkShardRequest.DEFAULT_TIMEOUT; - public void setRequestTimeout(TimeValue timeout) { - this.timeout = timeout; + public void setRequestTimeout(TimeValue requestTimeout) { + this.timeout = requestTimeout; } private volatile boolean ignoreIndexingFailures; diff --git a/test/framework/src/main/java/org/elasticsearch/test/ExternalTestCluster.java b/test/framework/src/main/java/org/elasticsearch/test/ExternalTestCluster.java index 1f3507489a596..43404a0fc01c5 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ExternalTestCluster.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ExternalTestCluster.java @@ -88,10 +88,10 @@ public ExternalTestCluster( } } Settings clientSettings = clientSettingsBuilder.build(); - MockTransportClient client = new MockTransportClient(clientSettings, pluginClasses); + MockTransportClient mockClient = new MockTransportClient(clientSettings, pluginClasses); try { - client.addTransportAddresses(transportAddresses); - NodesInfoResponse nodeInfos = client.admin() + mockClient.addTransportAddresses(transportAddresses); + NodesInfoResponse nodeInfos = mockClient.admin() .cluster() .prepareNodesInfo() .clear() @@ -113,11 +113,11 @@ public ExternalTestCluster( } this.numDataNodes = dataNodes; this.numMasterAndDataNodes = masterAndDataNodes; - this.client = client; + this.client = mockClient; logger.info("Setup ExternalTestCluster [{}] made of [{}] nodes", nodeInfos.getClusterName().value(), size()); } catch (Exception e) { - client.close(); + mockClient.close(); throw e; } } diff --git a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java index a38161c3860ce..ded988faae762 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java +++ b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java @@ -961,7 +961,7 @@ private final class NodeAndClient implements Closeable { this.name = name; this.originalNodeSettings = originalNodeSettings; this.nodeAndClientId = nodeAndClientId; - markNodeDataDirsAsNotEligibleForWipe(node); + markNodeDataDirsAsNotEligibleForWipe(); } Node node() { @@ -1138,7 +1138,7 @@ public void afterStart() { } }); closed.set(false); - markNodeDataDirsAsNotEligibleForWipe(node); + markNodeDataDirsAsNotEligibleForWipe(); } @Override @@ -1148,7 +1148,7 @@ public void close() throws IOException { resetClient(); } finally { closed.set(true); - markNodeDataDirsAsPendingForWipe(node); + markNodeDataDirsAsPendingForWipe(); node.close(); try { if (node.awaitClose(10, TimeUnit.SECONDS) == false) { @@ -1160,17 +1160,17 @@ public void close() throws IOException { } } - private void markNodeDataDirsAsPendingForWipe(Node node) { + private void markNodeDataDirsAsPendingForWipe() { assert Thread.holdsLock(InternalTestCluster.this); - NodeEnvironment nodeEnv = node.getNodeEnvironment(); + NodeEnvironment nodeEnv = this.node.getNodeEnvironment(); if (nodeEnv.hasNodeFile()) { dataDirToClean.addAll(Arrays.asList(nodeEnv.nodeDataPaths())); } } - private void markNodeDataDirsAsNotEligibleForWipe(Node node) { + private void markNodeDataDirsAsNotEligibleForWipe() { assert Thread.holdsLock(InternalTestCluster.this); - NodeEnvironment nodeEnv = node.getNodeEnvironment(); + NodeEnvironment nodeEnv = this.node.getNodeEnvironment(); if (nodeEnv.hasNodeFile()) { dataDirToClean.removeAll(Arrays.asList(nodeEnv.nodeDataPaths())); } @@ -2219,14 +2219,14 @@ public synchronized Set nodesInclude(String index) { if (clusterService().state().routingTable().hasIndex(index)) { List allShards = clusterService().state().routingTable().allShards(index); DiscoveryNodes discoveryNodes = clusterService().state().getNodes(); - Set nodes = new HashSet<>(); + Set nodeNames = new HashSet<>(); for (ShardRouting shardRouting : allShards) { if (shardRouting.assignedToNode()) { DiscoveryNode discoveryNode = discoveryNodes.get(shardRouting.currentNodeId()); - nodes.add(discoveryNode.getName()); + nodeNames.add(discoveryNode.getName()); } } - return nodes; + return nodeNames; } return Collections.emptySet(); } @@ -2329,7 +2329,7 @@ public synchronized List startNodes(Settings... extraSettings) { } else { defaultMinMasterNodes = -1; } - final List nodes = new ArrayList<>(); + final List nodeList = new ArrayList<>(); final int prevMasterCount = getMasterNodesCount(); int autoBootstrapMasterNodeIndex = autoManageMasterNodes && prevMasterCount == 0 @@ -2368,15 +2368,15 @@ public synchronized List startNodes(Settings... extraSettings) { firstNodeId + i, builder.put(nodeSettings).build(), false, - () -> rebuildUnicastHostFiles(nodes) + () -> rebuildUnicastHostFiles(nodeList) ); - nodes.add(nodeAndClient); + nodeList.add(nodeAndClient); } - startAndPublishNodesAndClients(nodes); + startAndPublishNodesAndClients(nodeList); if (autoManageMasterNodes) { validateClusterFormed(); } - return nodes.stream().map(NodeAndClient::getName).collect(Collectors.toList()); + return nodeList.stream().map(NodeAndClient::getName).collect(Collectors.toList()); } public List startMasterOnlyNodes(int numNodes) { diff --git a/test/framework/src/main/java/org/elasticsearch/test/TestCluster.java b/test/framework/src/main/java/org/elasticsearch/test/TestCluster.java index c9254b82318ea..afd7dec110a77 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/TestCluster.java +++ b/test/framework/src/main/java/org/elasticsearch/test/TestCluster.java @@ -55,11 +55,11 @@ public long seed() { /** * This method should be executed before each test to reset the cluster to its initial state. */ - public void beforeTest(Random random, double transportClientRatio) throws IOException, InterruptedException { + public void beforeTest(Random randomGenerator, double transportClientRatioValue) throws IOException, InterruptedException { assert transportClientRatio >= 0.0 && transportClientRatio <= 1.0; - logger.debug("Reset test cluster with transport client ratio: [{}]", transportClientRatio); - this.transportClientRatio = transportClientRatio; - this.random = new Random(random.nextLong()); + logger.debug("Reset test cluster with transport client ratio: [{}]", transportClientRatioValue); + this.transportClientRatio = transportClientRatioValue; + this.random = new Random(randomGenerator.nextLong()); } /** diff --git a/test/framework/src/main/java/org/elasticsearch/test/TestSearchContext.java b/test/framework/src/main/java/org/elasticsearch/test/TestSearchContext.java index 97cdc02ba61b2..5b15010bbd92f 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/TestSearchContext.java +++ b/test/framework/src/main/java/org/elasticsearch/test/TestSearchContext.java @@ -121,7 +121,7 @@ public void setSearcher(ContextIndexSearcher searcher) { public void preProcess() {} @Override - public Query buildFilteredQuery(Query query) { + public Query buildFilteredQuery(Query q) { return null; } @@ -166,8 +166,8 @@ public SearchContextAggregations aggregations() { } @Override - public SearchContext aggregations(SearchContextAggregations aggregations) { - this.aggregations = aggregations; + public SearchContext aggregations(SearchContextAggregations searchContextAggregations) { + this.aggregations = searchContextAggregations; return this; } @@ -302,8 +302,8 @@ public Float minimumScore() { } @Override - public SearchContext sort(SortAndFormats sort) { - this.sort = sort; + public SearchContext sort(SortAndFormats sortAndFormats) { + this.sort = sortAndFormats; return this; } @@ -313,8 +313,8 @@ public SortAndFormats sort() { } @Override - public SearchContext trackScores(boolean trackScores) { - this.trackScores = trackScores; + public SearchContext trackScores(boolean shouldTrackScores) { + this.trackScores = shouldTrackScores; return this; } @@ -324,8 +324,8 @@ public boolean trackScores() { } @Override - public SearchContext trackTotalHitsUpTo(int trackTotalHitsUpTo) { - this.trackTotalHitsUpTo = trackTotalHitsUpTo; + public SearchContext trackTotalHitsUpTo(int trackTotalHitsUpToValue) { + this.trackTotalHitsUpTo = trackTotalHitsUpToValue; return this; } @@ -335,8 +335,8 @@ public int trackTotalHitsUpTo() { } @Override - public SearchContext searchAfter(FieldDoc searchAfter) { - this.searchAfter = searchAfter; + public SearchContext searchAfter(FieldDoc searchAfterDoc) { + this.searchAfter = searchAfterDoc; return this; } @@ -356,8 +356,8 @@ public CollapseContext collapse() { } @Override - public SearchContext parsedPostFilter(ParsedQuery postFilter) { - this.postFilter = postFilter; + public SearchContext parsedPostFilter(ParsedQuery postFilterQuery) { + this.postFilter = postFilterQuery; return this; } @@ -367,9 +367,9 @@ public ParsedQuery parsedPostFilter() { } @Override - public SearchContext parsedQuery(ParsedQuery query) { - this.originalQuery = query; - this.query = query.query(); + public SearchContext parsedQuery(ParsedQuery parsedQuery) { + this.originalQuery = parsedQuery; + this.query = parsedQuery.query(); return this; } @@ -389,8 +389,8 @@ public int from() { } @Override - public SearchContext from(int from) { - this.from = from; + public SearchContext from(int fromValue) { + this.from = fromValue; return this; } @@ -404,7 +404,7 @@ public void setSize(int size) { } @Override - public SearchContext size(int size) { + public SearchContext size(int sizeValue) { return null; } diff --git a/test/framework/src/main/java/org/elasticsearch/test/disruption/NetworkDisruption.java b/test/framework/src/main/java/org/elasticsearch/test/disruption/NetworkDisruption.java index 77811ce5f59fa..da04419d62bc0 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/disruption/NetworkDisruption.java +++ b/test/framework/src/main/java/org/elasticsearch/test/disruption/NetworkDisruption.java @@ -59,28 +59,28 @@ public NetworkLinkDisruptionType getNetworkLinkDisruptionType() { } @Override - public void applyToCluster(InternalTestCluster cluster) { - this.cluster = cluster; + public void applyToCluster(InternalTestCluster testCluster) { + this.cluster = testCluster; } @Override - public void removeFromCluster(InternalTestCluster cluster) { + public void removeFromCluster(InternalTestCluster testCluster) { stopDisrupting(); } @Override - public void removeAndEnsureHealthy(InternalTestCluster cluster) { - removeFromCluster(cluster); - ensureHealthy(cluster); + public void removeAndEnsureHealthy(InternalTestCluster testCluster) { + removeFromCluster(testCluster); + ensureHealthy(testCluster); } /** * ensures the cluster is healthy after the disruption */ - public void ensureHealthy(InternalTestCluster cluster) { + public void ensureHealthy(InternalTestCluster testCluster) { assert activeDisruption == false; - ensureNodeCount(cluster); - ensureFullyConnectedCluster(cluster); + ensureNodeCount(testCluster); + ensureFullyConnectedCluster(testCluster); } /** @@ -105,20 +105,20 @@ public static void ensureFullyConnectedCluster(InternalTestCluster cluster) { } } - protected void ensureNodeCount(InternalTestCluster cluster) { - cluster.validateClusterFormed(); + protected void ensureNodeCount(InternalTestCluster testCluster) { + testCluster.validateClusterFormed(); } @Override - public synchronized void applyToNode(String node, InternalTestCluster cluster) { + public synchronized void applyToNode(String node, InternalTestCluster testCluster) { } @Override - public synchronized void removeFromNode(String node1, InternalTestCluster cluster) { + public synchronized void removeFromNode(String node1, InternalTestCluster testCluster) { logger.info("stop disrupting node (disruption type: {}, disrupted links: {})", networkLinkDisruptionType, disruptedLinks); - applyToNodes(new String[] { node1 }, cluster.getNodeNames(), networkLinkDisruptionType::removeDisruption); - applyToNodes(cluster.getNodeNames(), new String[] { node1 }, networkLinkDisruptionType::removeDisruption); + applyToNodes(new String[] { node1 }, testCluster.getNodeNames(), networkLinkDisruptionType::removeDisruption); + applyToNodes(testCluster.getNodeNames(), new String[] { node1 }, networkLinkDisruptionType::removeDisruption); } @Override diff --git a/test/framework/src/main/java/org/elasticsearch/test/disruption/SingleNodeDisruption.java b/test/framework/src/main/java/org/elasticsearch/test/disruption/SingleNodeDisruption.java index 8aa73f7871435..a70afedb6f221 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/disruption/SingleNodeDisruption.java +++ b/test/framework/src/main/java/org/elasticsearch/test/disruption/SingleNodeDisruption.java @@ -28,28 +28,28 @@ public SingleNodeDisruption(Random random) { } @Override - public void applyToCluster(InternalTestCluster cluster) { - this.cluster = cluster; + public void applyToCluster(InternalTestCluster testCluster) { + this.cluster = testCluster; if (disruptedNode == null) { - String[] nodes = cluster.getNodeNames(); + String[] nodes = testCluster.getNodeNames(); disruptedNode = nodes[random.nextInt(nodes.length)]; } } @Override - public void removeFromCluster(InternalTestCluster cluster) { + public void removeFromCluster(InternalTestCluster testCluster) { if (disruptedNode != null) { - removeFromNode(disruptedNode, cluster); + removeFromNode(disruptedNode, testCluster); } } @Override - public synchronized void applyToNode(String node, InternalTestCluster cluster) { + public synchronized void applyToNode(String node, InternalTestCluster testCluster) { } @Override - public synchronized void removeFromNode(String node, InternalTestCluster cluster) { + public synchronized void removeFromNode(String node, InternalTestCluster testCluster) { if (disruptedNode == null) { return; } @@ -65,14 +65,14 @@ public synchronized void testClusterClosed() { disruptedNode = null; } - protected void ensureNodeCount(InternalTestCluster cluster) { + protected void ensureNodeCount(InternalTestCluster testCluster) { assertFalse( "cluster failed to form after disruption was healed", - cluster.client() + testCluster.client() .admin() .cluster() .prepareHealth() - .setWaitForNodes(String.valueOf(cluster.size())) + .setWaitForNodes(String.valueOf(testCluster.size())) .setWaitForNoRelocatingShards(true) .get() .isTimedOut() diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java index b9a01af36e0cc..d2f2927118a85 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java @@ -268,10 +268,10 @@ public void current(String... requiredWarnings) { /** * Adds to the set of warnings that are permissible (but not required) when running * in mixed-version clusters or those that differ in version from the test client. - * @param allowedWarnings optional warnings that will be ignored if received + * @param allowedWarningsToAdd optional warnings that will be ignored if received */ - public void compatible(String... allowedWarnings) { - this.allowedWarnings.addAll(Arrays.asList(allowedWarnings)); + public void compatible(String... allowedWarningsToAdd) { + this.allowedWarnings.addAll(Arrays.asList(allowedWarningsToAdd)); } @Override @@ -417,11 +417,11 @@ protected static RestClient adminClient() { * Wait for outstanding tasks to complete. The specified admin client is used to check the outstanding tasks and this is done using * {@link ESTestCase#assertBusy(CheckedRunnable)} to give a chance to any outstanding tasks to complete. * - * @param adminClient the admin client + * @param restClient the admin client * @throws Exception if an exception is thrown while checking the outstanding tasks */ - public static void waitForPendingTasks(final RestClient adminClient) throws Exception { - waitForPendingTasks(adminClient, taskName -> false); + public static void waitForPendingTasks(final RestClient restClient) throws Exception { + waitForPendingTasks(restClient, taskName -> false); } /** @@ -429,16 +429,16 @@ public static void waitForPendingTasks(final RestClient adminClient) throws Exce * {@link ESTestCase#assertBusy(CheckedRunnable)} to give a chance to any outstanding tasks to complete. The specified filter is used * to filter out outstanding tasks that are expected to be there. * - * @param adminClient the admin client + * @param restClient the admin client * @param taskFilter predicate used to filter tasks that are expected to be there * @throws Exception if an exception is thrown while checking the outstanding tasks */ - public static void waitForPendingTasks(final RestClient adminClient, final Predicate taskFilter) throws Exception { + public static void waitForPendingTasks(final RestClient restClient, final Predicate taskFilter) throws Exception { assertBusy(() -> { try { final Request request = new Request("GET", "/_cat/tasks"); request.addParameter("detailed", "true"); - final Response response = adminClient.performRequest(request); + final Response response = restClient.performRequest(request); /* * Check to see if there are outstanding tasks; we exclude the list task itself, and any expected outstanding tasks using * the specified task filter. @@ -1436,15 +1436,15 @@ public static void ensureHealth(String index, Consumer requestConsumer) ensureHealth(client(), index, requestConsumer); } - protected static void ensureHealth(RestClient client, String index, Consumer requestConsumer) throws IOException { + protected static void ensureHealth(RestClient restClient, String index, Consumer requestConsumer) throws IOException { Request request = new Request("GET", "/_cluster/health" + (index.trim().isEmpty() ? "" : "/" + index)); requestConsumer.accept(request); try { - client.performRequest(request); + restClient.performRequest(request); } catch (ResponseException e) { if (e.getResponse().getStatusLine().getStatusCode() == HttpStatus.SC_REQUEST_TIMEOUT) { try { - final Response clusterStateResponse = client.performRequest(new Request("GET", "/_cluster/state?pretty")); + final Response clusterStateResponse = restClient.performRequest(new Request("GET", "/_cluster/state?pretty")); fail( "timed out waiting for green state for index [" + index @@ -1505,9 +1505,9 @@ protected static void deleteIndex(String name) throws IOException { deleteIndex(client(), name); } - protected static void deleteIndex(RestClient client, String name) throws IOException { + protected static void deleteIndex(RestClient restClient, String name) throws IOException { Request request = new Request("DELETE", "/" + name); - client.performRequest(request); + restClient.performRequest(request); } protected static void updateIndexSettings(String index, Settings.Builder settings) throws IOException { @@ -1636,13 +1636,13 @@ protected static void registerRepository(String repository, String type, boolean registerRepository(client(), repository, type, verify, settings); } - protected static void registerRepository(RestClient client, String repository, String type, boolean verify, Settings settings) + protected static void registerRepository(RestClient restClient, String repository, String type, boolean verify, Settings settings) throws IOException { final Request request = new Request(HttpPut.METHOD_NAME, "_snapshot/" + repository); request.addParameter("verify", Boolean.toString(verify)); request.setJsonEntity(Strings.toString(new PutRepositoryRequest(repository).type(type).settings(settings))); - final Response response = client.performRequest(request); + final Response response = restClient.performRequest(request); assertAcked("Failed to create repository [" + repository + "] of type [" + type + "]: " + response, response); } @@ -1650,12 +1650,12 @@ protected static void createSnapshot(String repository, String snapshot, boolean createSnapshot(client(), repository, snapshot, waitForCompletion); } - protected static void createSnapshot(RestClient client, String repository, String snapshot, boolean waitForCompletion) + protected static void createSnapshot(RestClient restClient, String repository, String snapshot, boolean waitForCompletion) throws IOException { final Request request = new Request(HttpPut.METHOD_NAME, "_snapshot/" + repository + '/' + snapshot); request.addParameter("wait_for_completion", Boolean.toString(waitForCompletion)); - final Response response = client.performRequest(request); + final Response response = restClient.performRequest(request); assertThat( "Failed to create snapshot [" + snapshot + "] in repository [" + repository + "]: " + response, response.getStatusLine().getStatusCode(), @@ -1679,12 +1679,13 @@ protected static void deleteSnapshot(String repository, String snapshot, boolean deleteSnapshot(client(), repository, snapshot, ignoreMissing); } - protected static void deleteSnapshot(RestClient client, String repository, String snapshot, boolean ignoreMissing) throws IOException { + protected static void deleteSnapshot(RestClient restClient, String repository, String snapshot, boolean ignoreMissing) + throws IOException { final Request request = new Request(HttpDelete.METHOD_NAME, "_snapshot/" + repository + '/' + snapshot); if (ignoreMissing) { request.addParameter("ignore", "404"); } - final Response response = client.performRequest(request); + final Response response = restClient.performRequest(request); assertThat(response.getStatusLine().getStatusCode(), ignoreMissing ? anyOf(equalTo(200), equalTo(404)) : equalTo(200)); } diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/FakeRestRequest.java b/test/framework/src/main/java/org/elasticsearch/test/rest/FakeRestRequest.java index 01656d81bb1d7..33287bfdcbae5 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/FakeRestRequest.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/FakeRestRequest.java @@ -109,17 +109,17 @@ public HttpRequest removeHeader(String header) { } @Override - public HttpResponse createResponse(RestStatus status, BytesReference content) { - Map headers = new HashMap<>(); + public HttpResponse createResponse(RestStatus status, BytesReference unused) { + Map responseHeaders = new HashMap<>(); return new HttpResponse() { @Override public void addHeader(String name, String value) { - headers.put(name, value); + responseHeaders.put(name, value); } @Override public boolean containsHeader(String name) { - return headers.containsKey(name); + return responseHeaders.containsKey(name); } }; } @@ -209,8 +209,8 @@ public Builder withParams(Map params) { return this; } - public Builder withContent(BytesReference content, XContentType xContentType) { - this.content = content; + public Builder withContent(BytesReference contentBytes, XContentType xContentType) { + this.content = contentBytes; if (xContentType != null) { headers.put("Content-Type", Collections.singletonList(xContentType.mediaType())); } @@ -227,8 +227,8 @@ public Builder withMethod(Method method) { return this; } - public Builder withRemoteAddress(InetSocketAddress address) { - this.address = address; + public Builder withRemoteAddress(InetSocketAddress remoteAddress) { + this.address = remoteAddress; return this; } diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/ObjectPath.java b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/ObjectPath.java index 945dcfb27d9e9..ef1a774c23366 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/ObjectPath.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/ObjectPath.java @@ -24,7 +24,7 @@ import java.util.Map; /** - * Holds an object and allows to extract specific values from it given their path + * Holds an object and allows extraction of specific values from it, given their path */ public class ObjectPath { @@ -77,24 +77,24 @@ public T evaluate(String path) throws IOException { @SuppressWarnings("unchecked") public T evaluate(String path, Stash stash) throws IOException { String[] parts = parsePath(path); - Object object = this.object; + Object result = this.object; for (String part : parts) { - object = evaluate(part, object, stash); - if (object == null) { + result = evaluate(part, result, stash); + if (result == null) { return null; } } - return (T) object; + return (T) result; } @SuppressWarnings("unchecked") - private Object evaluate(String key, Object object, Stash stash) throws IOException { + private Object evaluate(String key, Object objectToEvaluate, Stash stash) throws IOException { if (stash.containsStashedValue(key)) { key = stash.getValue(key).toString(); } - if (object instanceof Map) { - final Map objectAsMap = (Map) object; + if (objectToEvaluate instanceof Map) { + final Map objectAsMap = (Map) objectToEvaluate; if ("_arbitrary_key_".equals(key)) { if (objectAsMap.isEmpty()) { throw new IllegalArgumentException("requested [" + key + "] but the map was empty"); @@ -106,10 +106,10 @@ private Object evaluate(String key, Object object, Stash stash) throws IOExcepti } return objectAsMap.get(key); } - if (object instanceof List) { - List list = (List) object; + if (objectToEvaluate instanceof List) { + List list = (List) objectToEvaluate; try { - return list.get(Integer.valueOf(key)); + return list.get(Integer.parseInt(key)); } catch (NumberFormatException e) { throw new IllegalArgumentException("element was a list, but [" + key + "] was not numeric", e); } catch (IndexOutOfBoundsException e) { @@ -120,7 +120,9 @@ private Object evaluate(String key, Object object, Stash stash) throws IOExcepti } } - throw new IllegalArgumentException("no object found for [" + key + "] within object of class [" + object.getClass() + "]"); + throw new IllegalArgumentException( + "no object found for [" + key + "] within object of class [" + objectToEvaluate.getClass() + "]" + ); } private String[] parsePath(String path) { diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/restspec/ClientYamlSuiteRestApi.java b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/restspec/ClientYamlSuiteRestApi.java index 13c099af6e4ef..b6264e0a6d5e7 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/restspec/ClientYamlSuiteRestApi.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/restspec/ClientYamlSuiteRestApi.java @@ -166,11 +166,11 @@ public List getRequestMimeTypes() { * - /{index}/_alias/{name}, /{index}/_aliases/{name} * - /{index}/{type}/_mapping, /{index}/{type}/_mappings, /{index}/_mappings/{type}, /{index}/_mapping/{type} */ - public List getBestMatchingPaths(Set params) { + public List getBestMatchingPaths(Set pathParams) { PriorityQueue> queue = new PriorityQueue<>(Comparator.comparing(Tuple::v1, (a, b) -> Integer.compare(b, a))); for (ClientYamlSuiteRestApi.Path path : paths) { int matches = 0; - for (String actualParameter : params) { + for (String actualParameter : pathParams) { if (path.getParts().contains(actualParameter)) { matches++; } @@ -180,17 +180,17 @@ public List getBestMatchingPaths(Set params } } if (queue.isEmpty()) { - throw new IllegalStateException("Unable to find a matching path for api [" + name + "]" + params); + throw new IllegalStateException("Unable to find a matching path for api [" + name + "]" + pathParams); } - List paths = new ArrayList<>(); + List pathsByRelevance = new ArrayList<>(); Tuple poll = queue.poll(); int maxMatches = poll.v1(); do { - paths.add(poll.v2()); + pathsByRelevance.add(poll.v2()); poll = queue.poll(); } while (poll != null && poll.v1() == maxMatches); - return paths; + return pathsByRelevance; } public static class Path { @@ -224,8 +224,8 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - Path path = (Path) o; - return this.path.equals(path.path); + Path other = (Path) o; + return this.path.equals(other.path); } @Override diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java index 876dfca1054ec..b88ad1a2a2a9d 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java @@ -253,8 +253,8 @@ public String getCatch() { return catchParam; } - public void setCatch(String catchParam) { - this.catchParam = catchParam; + public void setCatch(String param) { + this.catchParam = param; } public ApiCallSection getApiCallSection() { diff --git a/test/framework/src/main/java/org/elasticsearch/test/transport/FakeTransport.java b/test/framework/src/main/java/org/elasticsearch/test/transport/FakeTransport.java index 4f750d9d563ee..d17b7aa021078 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/transport/FakeTransport.java +++ b/test/framework/src/main/java/org/elasticsearch/test/transport/FakeTransport.java @@ -35,11 +35,11 @@ public class FakeTransport extends AbstractLifecycleComponent implements Transpo private TransportMessageListener listener; @Override - public void setMessageListener(TransportMessageListener listener) { + public void setMessageListener(TransportMessageListener messageListener) { if (this.listener != null) { throw new IllegalStateException("listener already set"); } - this.listener = listener; + this.listener = messageListener; } @Override @@ -63,8 +63,8 @@ public List getDefaultSeedAddresses() { } @Override - public void openConnection(DiscoveryNode node, ConnectionProfile profile, ActionListener listener) { - listener.onResponse(new CloseableConnection() { + public void openConnection(DiscoveryNode node, ConnectionProfile profile, ActionListener actionListener) { + actionListener.onResponse(new CloseableConnection() { @Override public DiscoveryNode getNode() { return node; diff --git a/test/framework/src/main/java/org/elasticsearch/test/transport/MockTransport.java b/test/framework/src/main/java/org/elasticsearch/test/transport/MockTransport.java index 8d6c078fd12c5..55d2e66bdcc0d 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/transport/MockTransport.java +++ b/test/framework/src/main/java/org/elasticsearch/test/transport/MockTransport.java @@ -74,7 +74,9 @@ public TransportService createTransportService( public MockTransport() { super(new FakeTransport()); - setDefaultConnectBehavior((transport, discoveryNode, profile, listener) -> listener.onResponse(createConnection(discoveryNode))); + setDefaultConnectBehavior( + (transport, discoveryNode, profile, actionListener) -> actionListener.onResponse(createConnection(discoveryNode)) + ); } /** @@ -172,12 +174,12 @@ public void sendRequest(long requestId, String action, TransportRequest request, protected void onSendRequest(long requestId, String action, TransportRequest request, DiscoveryNode node) {} @Override - public void setMessageListener(TransportMessageListener listener) { + public void setMessageListener(TransportMessageListener messageListener) { if (this.listener != null) { throw new IllegalStateException("listener already set"); } - this.listener = listener; - super.setMessageListener(listener); + this.listener = messageListener; + super.setMessageListener(messageListener); } protected NamedWriteableRegistry writeableRegistry() { diff --git a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/boxplot/InternalBoxplot.java b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/boxplot/InternalBoxplot.java index 477ea5c9b6ba6..b731e992b8e3b 100644 --- a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/boxplot/InternalBoxplot.java +++ b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/boxplot/InternalBoxplot.java @@ -44,8 +44,8 @@ enum Metrics { } @Override - double value(TDigestState state) { - return state == null ? Double.NEGATIVE_INFINITY : state.getMin(); + double value(TDigestState digestState) { + return digestState == null ? Double.NEGATIVE_INFINITY : digestState.getMin(); } }, MAX { @@ -55,8 +55,8 @@ enum Metrics { } @Override - double value(TDigestState state) { - return state == null ? Double.POSITIVE_INFINITY : state.getMax(); + double value(TDigestState digestState) { + return digestState == null ? Double.POSITIVE_INFINITY : digestState.getMax(); } }, Q1 { @@ -66,8 +66,8 @@ enum Metrics { } @Override - double value(TDigestState state) { - return state == null ? Double.NaN : state.quantile(0.25); + double value(TDigestState digestState) { + return digestState == null ? Double.NaN : digestState.quantile(0.25); } }, Q2 { @@ -77,8 +77,8 @@ enum Metrics { } @Override - double value(TDigestState state) { - return state == null ? Double.NaN : state.quantile(0.5); + double value(TDigestState digestState) { + return digestState == null ? Double.NaN : digestState.quantile(0.5); } }, Q3 { @@ -88,8 +88,8 @@ enum Metrics { } @Override - double value(TDigestState state) { - return state == null ? Double.NaN : state.quantile(0.75); + double value(TDigestState digestState) { + return digestState == null ? Double.NaN : digestState.quantile(0.75); } }, LOWER { @@ -99,8 +99,8 @@ enum Metrics { } @Override - double value(TDigestState state) { - return whiskers(state)[0]; + double value(TDigestState digestState) { + return whiskers(digestState)[0]; } }, UPPER { @@ -110,8 +110,8 @@ enum Metrics { } @Override - double value(TDigestState state) { - return whiskers(state)[1]; + double value(TDigestState digestState) { + return whiskers(digestState)[1]; } }; diff --git a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/multiterms/InternalMultiTerms.java b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/multiterms/InternalMultiTerms.java index 9a55a991fb771..d43c15582e9c5 100644 --- a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/multiterms/InternalMultiTerms.java +++ b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/multiterms/InternalMultiTerms.java @@ -350,6 +350,7 @@ protected void doWriteTo(StreamOutput out) throws IOException { } @Override + @SuppressWarnings("HiddenField") protected InternalMultiTerms create( String name, List buckets, @@ -415,11 +416,13 @@ protected int getRequiredSize() { } @Override + @SuppressWarnings("HiddenField") protected Bucket createBucket(long docCount, InternalAggregations aggs, long docCountError, Bucket prototype) { return new Bucket(prototype.terms, docCount, aggs, prototype.showDocCountError, docCountError, formats, keyConverters); } @Override + @SuppressWarnings("HiddenField") public InternalMultiTerms create(List buckets) { return new InternalMultiTerms( name, @@ -493,9 +496,9 @@ private boolean[] needsPromotionToDouble(List aggregations) private InternalAggregation promoteToDouble(InternalAggregation aggregation, boolean[] needsPromotion) { InternalMultiTerms multiTerms = (InternalMultiTerms) aggregation; - List buckets = multiTerms.getBuckets(); + List multiTermsBuckets = multiTerms.getBuckets(); List> newKeys = new ArrayList<>(); - for (InternalMultiTerms.Bucket bucket : buckets) { + for (InternalMultiTerms.Bucket bucket : multiTermsBuckets) { newKeys.add(new ArrayList<>(bucket.terms.size())); } @@ -505,20 +508,20 @@ private InternalAggregation promoteToDouble(InternalAggregation aggregation, boo DocValueFormat format = formats.get(i); if (needsPromotion[i]) { newKeyConverters.add(KeyConverter.DOUBLE); - for (int j = 0; j < buckets.size(); j++) { - newKeys.get(j).add(converter.toDouble(format, buckets.get(j).terms.get(i))); + for (int j = 0; j < multiTermsBuckets.size(); j++) { + newKeys.get(j).add(converter.toDouble(format, multiTermsBuckets.get(j).terms.get(i))); } } else { newKeyConverters.add(converter); - for (int j = 0; j < buckets.size(); j++) { - newKeys.get(j).add(buckets.get(j).terms.get(i)); + for (int j = 0; j < multiTermsBuckets.size(); j++) { + newKeys.get(j).add(multiTermsBuckets.get(j).terms.get(i)); } } } - List newBuckets = new ArrayList<>(buckets.size()); - for (int i = 0; i < buckets.size(); i++) { - Bucket oldBucket = buckets.get(i); + List newBuckets = new ArrayList<>(multiTermsBuckets.size()); + for (int i = 0; i < multiTermsBuckets.size(); i++) { + Bucket oldBucket = multiTermsBuckets.get(i); newBuckets.add( new Bucket( newKeys.get(i), diff --git a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/multiterms/MultiTermsAggregationFactory.java b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/multiterms/MultiTermsAggregationFactory.java index 2642f5c3c6111..fb9d1f1f5f35e 100644 --- a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/multiterms/MultiTermsAggregationFactory.java +++ b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/multiterms/MultiTermsAggregationFactory.java @@ -57,15 +57,15 @@ public MultiTermsAggregationFactory( @Override protected Aggregator createInternal(Aggregator parent, CardinalityUpperBound cardinality, Map metadata) throws IOException { - TermsAggregator.BucketCountThresholds bucketCountThresholds = new TermsAggregator.BucketCountThresholds(this.bucketCountThresholds); + TermsAggregator.BucketCountThresholds thresholds = new TermsAggregator.BucketCountThresholds(this.bucketCountThresholds); if (InternalOrder.isKeyOrder(order) == false - && bucketCountThresholds.getShardSize() == MultiTermsAggregationBuilder.DEFAULT_BUCKET_COUNT_THRESHOLDS.getShardSize()) { + && thresholds.getShardSize() == MultiTermsAggregationBuilder.DEFAULT_BUCKET_COUNT_THRESHOLDS.getShardSize()) { // The user has not made a shardSize selection. Use default // heuristic to avoid any wrong-ranking caused by distributed // counting - bucketCountThresholds.setShardSize(BucketUtils.suggestShardSideQueueSize(bucketCountThresholds.getRequiredSize())); + thresholds.setShardSize(BucketUtils.suggestShardSideQueueSize(thresholds.getRequiredSize())); } - bucketCountThresholds.ensureValidity(); + thresholds.ensureValidity(); return new MultiTermsAggregator( name, factories, @@ -76,7 +76,7 @@ protected Aggregator createInternal(Aggregator parent, CardinalityUpperBound car showTermDocCountError, order, collectMode, - bucketCountThresholds, + thresholds, cardinality, metadata ); diff --git a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/multiterms/MultiTermsAggregator.java b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/multiterms/MultiTermsAggregator.java index 33155a431176b..91b2d32aacb1d 100644 --- a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/multiterms/MultiTermsAggregator.java +++ b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/multiterms/MultiTermsAggregator.java @@ -146,11 +146,11 @@ List termValuesList(LeafReaderContext ctx) throws IOException { List> docTerms(List termValuesList, int doc) throws IOException { List> terms = new ArrayList<>(); for (TermValues termValues : termValuesList) { - List values = termValues.collectValues(doc); - if (values == null) { + List collectValues = termValues.collectValues(doc); + if (collectValues == null) { return null; } - terms.add(values); + terms.add(collectValues); } return terms; } diff --git a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/normalize/NormalizePipelineMethods.java b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/normalize/NormalizePipelineMethods.java index 7b7f11846ee00..150dcfeeb8a50 100644 --- a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/normalize/NormalizePipelineMethods.java +++ b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/normalize/NormalizePipelineMethods.java @@ -94,14 +94,14 @@ static class Softmax implements DoubleUnaryOperator { private double sumExp; Softmax(double[] values) { - double sumExp = 0.0; + double _sumExp = 0.0; for (Double value : values) { if (value.isNaN() == false) { - sumExp += Math.exp(value); + _sumExp += Math.exp(value); } } - this.sumExp = sumExp; + this.sumExp = _sumExp; } @Override @@ -117,6 +117,7 @@ abstract static class SinglePassSimpleStatisticsMethod implements DoubleUnaryOpe protected final double mean; protected final int count; + @SuppressWarnings("HiddenField") SinglePassSimpleStatisticsMethod(double[] values) { int count = 0; double sum = 0.0; diff --git a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/rate/AbstractRateAggregator.java b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/rate/AbstractRateAggregator.java index 5105ee73729ca..263969b59e932 100644 --- a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/rate/AbstractRateAggregator.java +++ b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/rate/AbstractRateAggregator.java @@ -61,20 +61,20 @@ public AbstractRateAggregator( } private SizedBucketAggregator findSizedBucketAncestor() { - SizedBucketAggregator sizedBucketAggregator = null; + SizedBucketAggregator aggregator = null; for (Aggregator ancestor = parent; ancestor != null; ancestor = ancestor.parent()) { if (ancestor instanceof SizedBucketAggregator) { - sizedBucketAggregator = (SizedBucketAggregator) ancestor; + aggregator = (SizedBucketAggregator) ancestor; break; } } - if (sizedBucketAggregator == null) { + if (aggregator == null) { throw new IllegalArgumentException( "The rate aggregation can only be used inside a date histogram aggregation or " + "composite aggregation with one date histogram value source" ); } - return sizedBucketAggregator; + return aggregator; } @Override diff --git a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/rate/InternalRate.java b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/rate/InternalRate.java index c221fc612336e..4181e25a2864c 100644 --- a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/rate/InternalRate.java +++ b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/rate/InternalRate.java @@ -72,15 +72,15 @@ public InternalRate reduce(List aggregations, ReduceContext // Compute the sum of double values with Kahan summation algorithm which is more // accurate than naive summation. CompensatedSum kahanSummation = new CompensatedSum(0, 0); - Double divisor = null; + Double firstDivisor = null; for (InternalAggregation aggregation : aggregations) { double value = ((InternalRate) aggregation).sum; kahanSummation.add(value); - if (divisor == null) { - divisor = ((InternalRate) aggregation).divisor; + if (firstDivisor == null) { + firstDivisor = ((InternalRate) aggregation).divisor; } } - return new InternalRate(name, kahanSummation.value(), divisor, format, getMetadata()); + return new InternalRate(name, kahanSummation.value(), firstDivisor, format, getMetadata()); } @Override diff --git a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/stringstats/InternalStringStats.java b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/stringstats/InternalStringStats.java index b39cc0fda4e9c..e21a99fecaec4 100644 --- a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/stringstats/InternalStringStats.java +++ b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/stringstats/InternalStringStats.java @@ -199,6 +199,7 @@ public Object value(String name) { } @Override + @SuppressWarnings("HiddenField") public InternalStringStats reduce(List aggregations, ReduceContext reduceContext) { long count = 0; long totalLength = 0; diff --git a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/topmetrics/TopMetricsAggregationBuilder.java b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/topmetrics/TopMetricsAggregationBuilder.java index e86df85c02959..9ae97cf953e1b 100644 --- a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/topmetrics/TopMetricsAggregationBuilder.java +++ b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/topmetrics/TopMetricsAggregationBuilder.java @@ -147,7 +147,7 @@ public TopMetricsAggregationBuilder( */ public TopMetricsAggregationBuilder(StreamInput in) throws IOException { super(in); - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "HiddenField" }) List> sortBuilders = (List>) (List) in.readNamedWriteableList(SortBuilder.class); this.sortBuilders = sortBuilders; this.size = in.readVInt(); diff --git a/x-pack/plugin/async-search/src/main/java/org/elasticsearch/xpack/search/AsyncSearchTask.java b/x-pack/plugin/async-search/src/main/java/org/elasticsearch/xpack/search/AsyncSearchTask.java index 386826162dcc4..9d411418c25fd 100644 --- a/x-pack/plugin/async-search/src/main/java/org/elasticsearch/xpack/search/AsyncSearchTask.java +++ b/x-pack/plugin/async-search/src/main/java/org/elasticsearch/xpack/search/AsyncSearchTask.java @@ -132,8 +132,8 @@ Listener getSearchProgressActionListener() { * Update the expiration time of the (partial) response. */ @Override - public void setExpirationTime(long expirationTimeMillis) { - this.expirationTimeMillis = expirationTimeMillis; + public void setExpirationTime(long expirationTime) { + this.expirationTimeMillis = expirationTime; } @Override diff --git a/x-pack/plugin/async-search/src/main/java/org/elasticsearch/xpack/search/MutableSearchResponse.java b/x-pack/plugin/async-search/src/main/java/org/elasticsearch/xpack/search/MutableSearchResponse.java index 597376006d3bc..f3e0dc47878d1 100644 --- a/x-pack/plugin/async-search/src/main/java/org/elasticsearch/xpack/search/MutableSearchResponse.java +++ b/x-pack/plugin/async-search/src/main/java/org/elasticsearch/xpack/search/MutableSearchResponse.java @@ -85,6 +85,7 @@ class MutableSearchResponse { * Updates the response with the result of a partial reduction. * @param reducedAggs is a strategy for producing the reduced aggs */ + @SuppressWarnings("HiddenField") synchronized void updatePartialResponse( int successfulShards, TotalHits totalHits, @@ -138,11 +139,11 @@ synchronized void updateWithFailure(ElasticsearchException exc) { /** * Adds a shard failure concurrently (non-blocking). */ - void addQueryFailure(int shardIndex, ShardSearchFailure failure) { + void addQueryFailure(int shardIndex, ShardSearchFailure shardSearchFailure) { synchronized (this) { failIfFrozen(); } - queryFailures.set(shardIndex, failure); + queryFailures.set(shardIndex, shardSearchFailure); } private SearchResponse buildResponse(long taskStartTimeNanos, InternalAggregations reducedAggs) { @@ -290,9 +291,9 @@ private ShardSearchFailure[] buildQueryFailures() { } List failures = new ArrayList<>(); for (int i = 0; i < queryFailures.length(); i++) { - ShardSearchFailure failure = queryFailures.get(i); - if (failure != null) { - failures.add(failure); + ShardSearchFailure shardSearchFailure = queryFailures.get(i); + if (shardSearchFailure != null) { + failures.add(shardSearchFailure); } } return failures.toArray(new ShardSearchFailure[0]); diff --git a/x-pack/plugin/async/src/main/java/org/elasticsearch/xpack/async/AsyncResultsIndexPlugin.java b/x-pack/plugin/async/src/main/java/org/elasticsearch/xpack/async/AsyncResultsIndexPlugin.java index 75dc6d60ff9ba..1b0f61755d9d2 100644 --- a/x-pack/plugin/async/src/main/java/org/elasticsearch/xpack/async/AsyncResultsIndexPlugin.java +++ b/x-pack/plugin/async/src/main/java/org/elasticsearch/xpack/async/AsyncResultsIndexPlugin.java @@ -44,7 +44,7 @@ public AsyncResultsIndexPlugin(Settings settings) { } @Override - public Collection getSystemIndexDescriptors(Settings settings) { + public Collection getSystemIndexDescriptors(Settings unused) { return Collections.singletonList(new SystemIndexDescriptor(XPackPlugin.ASYNC_RESULTS_INDEX + "*", this.getClass().getSimpleName())); } diff --git a/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/Autoscaling.java b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/Autoscaling.java index 94ac6bc2d2dbc..ca50045ab67f1 100644 --- a/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/Autoscaling.java +++ b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/Autoscaling.java @@ -88,7 +88,7 @@ public class Autoscaling extends Plugin implements ActionPlugin, ExtensiblePlugi ); private final List autoscalingExtensions; - private final SetOnce clusterService = new SetOnce<>(); + private final SetOnce clusterServiceHolder = new SetOnce<>(); private final SetOnce allocationDeciders = new SetOnce<>(); private final AutoscalingLicenseChecker autoscalingLicenseChecker; @@ -115,7 +115,7 @@ public Collection createComponents( IndexNameExpressionResolver indexNameExpressionResolver, Supplier repositoriesServiceSupplier ) { - this.clusterService.set(clusterService); + this.clusterServiceHolder.set(clusterService); return org.elasticsearch.core.List.of( new AutoscalingCalculateCapacityService.Holder(this), autoscalingLicenseChecker, @@ -209,26 +209,19 @@ public void loadExtensions(ExtensionLoader loader) { @Override public Collection deciders() { assert allocationDeciders.get() != null; + final ClusterService clusterService = clusterServiceHolder.get(); return org.elasticsearch.core.List.of( new FixedAutoscalingDeciderService(), - new ReactiveStorageDeciderService( - clusterService.get().getSettings(), - clusterService.get().getClusterSettings(), - allocationDeciders.get() - ), - new ProactiveStorageDeciderService( - clusterService.get().getSettings(), - clusterService.get().getClusterSettings(), - allocationDeciders.get() - ), + new ReactiveStorageDeciderService(clusterService.getSettings(), clusterService.getClusterSettings(), allocationDeciders.get()), + new ProactiveStorageDeciderService(clusterService.getSettings(), clusterService.getClusterSettings(), allocationDeciders.get()), new FrozenShardsDeciderService(), new FrozenStorageDeciderService(), new FrozenExistenceDeciderService() ); } - public Set createDeciderServices(AllocationDeciders allocationDeciders) { - this.allocationDeciders.set(allocationDeciders); + public Set createDeciderServices(AllocationDeciders deciders) { + this.allocationDeciders.set(deciders); return autoscalingExtensions.stream().flatMap(p -> p.deciders().stream()).collect(Collectors.toSet()); } diff --git a/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/AutoscalingMetadata.java b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/AutoscalingMetadata.java index e6c52ed5b770d..c36bdda977321 100644 --- a/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/AutoscalingMetadata.java +++ b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/AutoscalingMetadata.java @@ -75,12 +75,12 @@ public AutoscalingMetadata(final SortedMap po public AutoscalingMetadata(final StreamInput in) throws IOException { final int size = in.readVInt(); - final SortedMap policies = new TreeMap<>(); + final SortedMap policiesMap = new TreeMap<>(); for (int i = 0; i < size; i++) { final AutoscalingPolicyMetadata policyMetadata = new AutoscalingPolicyMetadata(in); - policies.put(policyMetadata.policy().name(), policyMetadata); + policiesMap.put(policyMetadata.policy().name(), policyMetadata); } - this.policies = policies; + this.policies = policiesMap; } @Override diff --git a/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/action/PutAutoscalingPolicyAction.java b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/action/PutAutoscalingPolicyAction.java index 5e5209d82e105..c76255f786004 100644 --- a/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/action/PutAutoscalingPolicyAction.java +++ b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/action/PutAutoscalingPolicyAction.java @@ -93,11 +93,11 @@ public Request(final StreamInput in) throws IOException { } if (in.readBoolean()) { int deciderCount = in.readInt(); - SortedMap deciders = new TreeMap<>(); + SortedMap decidersMap = new TreeMap<>(); for (int i = 0; i < deciderCount; ++i) { - deciders.put(in.readString(), Settings.readSettingsFromStream(in)); + decidersMap.put(in.readString(), Settings.readSettingsFromStream(in)); } - this.deciders = Collections.unmodifiableSortedMap(deciders); + this.deciders = Collections.unmodifiableSortedMap(decidersMap); } else { this.deciders = null; } diff --git a/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/action/TransportDeleteAutoscalingPolicyAction.java b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/action/TransportDeleteAutoscalingPolicyAction.java index a26c8e15a2de5..95e2ca770cc3d 100644 --- a/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/action/TransportDeleteAutoscalingPolicyAction.java +++ b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/action/TransportDeleteAutoscalingPolicyAction.java @@ -33,7 +33,7 @@ public class TransportDeleteAutoscalingPolicyAction extends AcknowledgedTransportMasterNodeAction { - private static final Logger logger = LogManager.getLogger(TransportPutAutoscalingPolicyAction.class); + private static final Logger LOGGER = LogManager.getLogger(TransportPutAutoscalingPolicyAction.class); @Inject public TransportDeleteAutoscalingPolicyAction( @@ -66,7 +66,7 @@ protected void masterOperation( clusterService.submitStateUpdateTask("delete-autoscaling-policy", new AckedClusterStateUpdateTask(request, listener) { @Override public ClusterState execute(final ClusterState currentState) { - return deleteAutoscalingPolicy(currentState, request.name(), logger); + return deleteAutoscalingPolicy(currentState, request.name(), LOGGER); } }); } diff --git a/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/action/TransportPutAutoscalingPolicyAction.java b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/action/TransportPutAutoscalingPolicyAction.java index ae22c3825dda2..619c2b4d66f6f 100644 --- a/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/action/TransportPutAutoscalingPolicyAction.java +++ b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/action/TransportPutAutoscalingPolicyAction.java @@ -44,7 +44,7 @@ public class TransportPutAutoscalingPolicyAction extends AcknowledgedTransportMasterNodeAction { - private static final Logger logger = LogManager.getLogger(TransportPutAutoscalingPolicyAction.class); + private static final Logger LOGGER = LogManager.getLogger(TransportPutAutoscalingPolicyAction.class); private final PolicyValidator policyValidator; private final AutoscalingLicenseChecker autoscalingLicenseChecker; @@ -119,7 +119,7 @@ protected void masterOperation( clusterService.submitStateUpdateTask("put-autoscaling-policy", new AckedClusterStateUpdateTask(request, listener) { @Override public ClusterState execute(final ClusterState currentState) { - return putAutoscalingPolicy(currentState, request, policyValidator, logger); + return putAutoscalingPolicy(currentState, request, policyValidator, LOGGER); } }); } diff --git a/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/capacity/memory/AutoscalingMemoryInfoService.java b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/capacity/memory/AutoscalingMemoryInfoService.java index 729e9ac5207fb..43047feb84b09 100644 --- a/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/capacity/memory/AutoscalingMemoryInfoService.java +++ b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/capacity/memory/AutoscalingMemoryInfoService.java @@ -185,9 +185,9 @@ private void addNodeStats(ImmutableOpenMap.Builder builder, NodeSt } public AutoscalingMemoryInfo snapshot() { - final ImmutableOpenMap nodeToMemory = this.nodeToMemory; + final ImmutableOpenMap nodeToMemoryRef = this.nodeToMemory; return node -> { - Long result = nodeToMemory.get(node.getEphemeralId()); + Long result = nodeToMemoryRef.get(node.getEphemeralId()); // noinspection NumberEquality if (result == FETCHING_SENTINEL) { return null; diff --git a/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/policy/AutoscalingPolicy.java b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/policy/AutoscalingPolicy.java index a9b22d0515201..3dcb0932c9f2c 100644 --- a/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/policy/AutoscalingPolicy.java +++ b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/policy/AutoscalingPolicy.java @@ -90,11 +90,11 @@ public AutoscalingPolicy(final StreamInput in) throws IOException { this.name = in.readString(); this.roles = Collections.unmodifiableSortedSet(new TreeSet<>(in.readSet(StreamInput::readString))); int deciderCount = in.readInt(); - SortedMap deciders = new TreeMap<>(); + SortedMap decidersMap = new TreeMap<>(); for (int i = 0; i < deciderCount; ++i) { - deciders.put(in.readString(), Settings.readSettingsFromStream(in)); + decidersMap.put(in.readString(), Settings.readSettingsFromStream(in)); } - this.deciders = Collections.unmodifiableSortedMap(deciders); + this.deciders = Collections.unmodifiableSortedMap(decidersMap); } @Override diff --git a/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageDeciderService.java b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageDeciderService.java index 2f662e44041da..203b689cc2057 100644 --- a/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageDeciderService.java +++ b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageDeciderService.java @@ -400,7 +400,7 @@ private IndexMetadata indexMetadata(ShardRouting shard, RoutingAllocation alloca return allocation.metadata().getIndexSafe(shard.index()); } - private Optional highestPreferenceTier(List preferredTiers, DiscoveryNodes nodes) { + private Optional highestPreferenceTier(List preferredTiers, DiscoveryNodes unused) { assert preferredTiers.isEmpty() == false; return Optional.of(preferredTiers.get(0)); } @@ -430,8 +430,8 @@ private long getExpectedShardSize(ShardRouting shard) { } long unmovableSize(String nodeId, Collection shards) { - ClusterInfo info = this.info; - DiskUsage diskUsage = info.getNodeMostAvailableDiskUsages().get(nodeId); + ClusterInfo clusterInfo = this.info; + DiskUsage diskUsage = clusterInfo.getNodeMostAvailableDiskUsages().get(nodeId); if (diskUsage == null) { // do not want to scale up then, since this should only happen when node has just joined (clearly edge case). return 0; diff --git a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/capacity/memory/AutoscalingMemoryInfoServiceTests.java b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/capacity/memory/AutoscalingMemoryInfoServiceTests.java index 6d29b30378a38..9ad6adf7a7e18 100644 --- a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/capacity/memory/AutoscalingMemoryInfoServiceTests.java +++ b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/capacity/memory/AutoscalingMemoryInfoServiceTests.java @@ -395,9 +395,9 @@ public void respond(NodesStatsResponse response, Runnable whileFetching) { }); } - public void respond(BiConsumer> responder) { - assertThat(responder, notNullValue()); - this.responder = responder; + public void respond(BiConsumer> responderValue) { + assertThat(responderValue, notNullValue()); + this.responder = responderValue; } @Override @@ -410,11 +410,11 @@ protected void NodesStatsRequest nodesStatsRequest = (NodesStatsRequest) request; assertThat(nodesStatsRequest.timeout(), equalTo(fetchTimeout)); assertThat(responder, notNullValue()); - BiConsumer> responder = this.responder; + BiConsumer> responderValue = this.responder; this.responder = null; @SuppressWarnings("unchecked") ActionListener statsListener = (ActionListener) listener; - responder.accept(nodesStatsRequest, statsListener); + responderValue.accept(nodesStatsRequest, statsListener); } public void assertNoResponder() { diff --git a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageDeciderDecisionTests.java b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageDeciderDecisionTests.java index 058f3433d68b7..6f25c075b6529 100644 --- a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageDeciderDecisionTests.java +++ b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageDeciderDecisionTests.java @@ -131,13 +131,13 @@ public Decision canRemain(ShardRouting shardRouting, RoutingNode node, RoutingAl @Before public void setup() { - ClusterState state = ClusterState.builder(new ClusterName("test")).build(); - state = addRandomIndices(hotNodes, hotNodes, state); - state = addDataNodes(DATA_HOT_NODE_ROLE, "hot", state, hotNodes); - state = addDataNodes(DATA_WARM_NODE_ROLE, "warm", state, warmNodes); - this.state = state; + ClusterState clusterState = ClusterState.builder(new ClusterName("test")).build(); + clusterState = addRandomIndices(hotNodes, hotNodes, clusterState); + clusterState = addDataNodes(DATA_HOT_NODE_ROLE, "hot", clusterState, hotNodes); + clusterState = addDataNodes(DATA_WARM_NODE_ROLE, "warm", clusterState, warmNodes); + this.state = clusterState; - Set shardIds = shardIds(state.getRoutingNodes().unassigned()); + Set shardIds = shardIds(clusterState.getRoutingNodes().unassigned()); this.subjectShards = new HashSet<>(randomSubsetOf(randomIntBetween(1, shardIds.size()), shardIds)); } @@ -371,8 +371,7 @@ private void verify(VerificationSubject subject, long expected, AllocationDecide } private void verify(VerificationSubject subject, long expected, DiscoveryNodeRole role, AllocationDecider... allocationDeciders) { - ClusterState state = this.state; - verify(state, subject, expected, role, allocationDeciders); + verify(this.state, subject, expected, role, allocationDeciders); } private static void verify( diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/Ccr.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/Ccr.java index 8ff0aa1e1bef1..c60d0172836f6 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/Ccr.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/Ccr.java @@ -168,6 +168,7 @@ public Ccr(final Settings settings) { } @Override + @SuppressWarnings("HiddenField") public Collection createComponents( final Client client, final ClusterService clusterService, @@ -208,6 +209,7 @@ public Collection createComponents( } @Override + @SuppressWarnings("HiddenField") public List> getPersistentTasksExecutor( ClusterService clusterService, ThreadPool threadPool, @@ -264,7 +266,7 @@ public List> getPersistentTasksExecutor( } public List getRestHandlers( - Settings settings, + Settings unused, RestController restController, ClusterSettings clusterSettings, IndexScopedSettings indexScopedSettings, @@ -357,6 +359,7 @@ public Optional getEngineFactory(final IndexSettings indexSetting } } + @SuppressWarnings("HiddenField") public List> getExecutorBuilders(Settings settings) { if (enabled == false) { return Collections.emptyList(); @@ -414,7 +417,7 @@ public Collection> ind } @Override - public Collection createAllocationDeciders(Settings settings, ClusterSettings clusterSettings) { + public Collection createAllocationDeciders(Settings unused, ClusterSettings clusterSettings) { return Collections.singletonList(new CcrPrimaryFollowerAllocationDecider()); } } diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinator.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinator.java index b6d4d5d99defb..cf72e6e2f0b22 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinator.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinator.java @@ -150,9 +150,9 @@ protected void doClose() { } public synchronized AutoFollowStats getStats() { - final Map autoFollowers = this.autoFollowers; + final Map autoFollowersCopy = this.autoFollowers; final TreeMap timesSinceLastAutoFollowPerRemoteCluster = new TreeMap<>(); - for (Map.Entry entry : autoFollowers.entrySet()) { + for (Map.Entry entry : autoFollowersCopy.entrySet()) { long lastAutoFollowTimeInMillis = entry.getValue().lastAutoFollowTimeInMillis; long lastSeenMetadataVersion = entry.getValue().metadataVersion; if (lastAutoFollowTimeInMillis != -1) { @@ -231,13 +231,13 @@ void updateAutoFollowers(ClusterState followerClusterState) { return; } - final CopyOnWriteHashMap autoFollowers = CopyOnWriteHashMap.copyOf(this.autoFollowers); + final CopyOnWriteHashMap autoFollowersCopy = CopyOnWriteHashMap.copyOf(this.autoFollowers); Set newRemoteClusters = autoFollowMetadata.getPatterns() .values() .stream() .filter(AutoFollowPattern::isActive) .map(AutoFollowPattern::getRemoteCluster) - .filter(remoteCluster -> autoFollowers.containsKey(remoteCluster) == false) + .filter(remoteCluster -> autoFollowersCopy.containsKey(remoteCluster) == false) .collect(Collectors.toSet()); Map newAutoFollowers = new HashMap<>(newRemoteClusters.size()); @@ -317,7 +317,7 @@ public void clusterStateProcessed(String source, ClusterState oldState, ClusterS } List removedRemoteClusters = new ArrayList<>(); - for (Map.Entry entry : autoFollowers.entrySet()) { + for (Map.Entry entry : autoFollowersCopy.entrySet()) { String remoteCluster = entry.getKey(); AutoFollower autoFollower = entry.getValue(); boolean exist = autoFollowMetadata.getPatterns() @@ -338,7 +338,7 @@ public void clusterStateProcessed(String source, ClusterState oldState, ClusterS } } assert assertNoOtherActiveAutoFollower(newAutoFollowers); - this.autoFollowers = autoFollowers.copyAndPutAll(newAutoFollowers).copyAndRemoveAll(removedRemoteClusters); + this.autoFollowers = autoFollowersCopy.copyAndPutAll(newAutoFollowers).copyAndRemoveAll(removedRemoteClusters); } private boolean assertNoOtherActiveAutoFollower(Map newAutoFollowers) { @@ -531,7 +531,7 @@ private void autoFollowIndices( private void checkAutoFollowPattern( String autoFollowPattenName, - String remoteCluster, + String remoteClusterString, AutoFollowPattern autoFollowPattern, List leaderIndicesToFollow, Map headers, @@ -617,7 +617,7 @@ private void checkAutoFollowPattern( followLeaderIndex( autoFollowPattenName, - remoteCluster, + remoteClusterString, indexToFollow, autoFollowPattern, headers, @@ -647,7 +647,7 @@ private static boolean leaderIndexAlreadyFollowed(AutoFollowPattern autoFollowPa private void followLeaderIndex( String autoFollowPattenName, - String remoteCluster, + String remoteClusterString, Index indexToFollow, AutoFollowPattern pattern, Map headers, @@ -657,7 +657,7 @@ private void followLeaderIndex( final String followIndexName = getFollowerIndexName(pattern, leaderIndexName); PutFollowAction.Request request = new PutFollowAction.Request(); - request.setRemoteCluster(remoteCluster); + request.setRemoteCluster(remoteClusterString); request.setLeaderIndex(indexToFollow.getName()); request.setFollowerIndex(followIndexName); request.setSettings(pattern.getSettings()); @@ -866,13 +866,13 @@ static class AutoFollowResult { AutoFollowResult(String autoFollowPatternName, List> results) { this.autoFollowPatternName = autoFollowPatternName; - Map autoFollowExecutionResults = new HashMap<>(); + Map mutableAutoFollowExecutionResults = new HashMap<>(); for (Tuple result : results) { - autoFollowExecutionResults.put(result.v1(), result.v2()); + mutableAutoFollowExecutionResults.put(result.v1(), result.v2()); } this.clusterStateFetchException = null; - this.autoFollowExecutionResults = Collections.unmodifiableMap(autoFollowExecutionResults); + this.autoFollowExecutionResults = Collections.unmodifiableMap(mutableAutoFollowExecutionResults); } AutoFollowResult(String autoFollowPatternName, Exception e) { diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowNodeTask.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowNodeTask.java index 541af27e6f6af..2e502e30f53f3 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowNodeTask.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowNodeTask.java @@ -136,6 +136,7 @@ protected boolean removeEldestEntry(final Map.Entry operations, - long leaderMaxSeqNoOfUpdatesOrDeletes, + long leaderMaxSequenceNoOfUpdatesOrDeletes, AtomicInteger retryCounter ) { - assert leaderMaxSeqNoOfUpdatesOrDeletes != SequenceNumbers.UNASSIGNED_SEQ_NO : "mus is not replicated"; + assert leaderMaxSequenceNoOfUpdatesOrDeletes != SequenceNumbers.UNASSIGNED_SEQ_NO : "mus is not replicated"; final long startTime = relativeTimeProvider.getAsLong(); - innerSendBulkShardOperationsRequest(followerHistoryUUID, operations, leaderMaxSeqNoOfUpdatesOrDeletes, response -> { + innerSendBulkShardOperationsRequest(followerHistoryUUID, operations, leaderMaxSequenceNoOfUpdatesOrDeletes, response -> { synchronized (ShardFollowNodeTask.this) { totalWriteTimeMillis += TimeUnit.NANOSECONDS.toMillis(relativeTimeProvider.getAsLong() - startTime); successfulWriteRequests++; @@ -459,7 +460,7 @@ private void sendBulkShardOperationsRequest( handleFailure( e, retryCounter, - () -> sendBulkShardOperationsRequest(operations, leaderMaxSeqNoOfUpdatesOrDeletes, retryCounter) + () -> sendBulkShardOperationsRequest(operations, leaderMaxSequenceNoOfUpdatesOrDeletes, retryCounter) ); }); } diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTasksExecutor.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTasksExecutor.java index c33f2eb4bedd6..d08f7cd995ed3 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTasksExecutor.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTasksExecutor.java @@ -620,12 +620,12 @@ protected void nodeOperation(final AllocatedPersistentTask task, final ShardFoll } private void fetchFollowerShardInfo( - final Client client, + final Client followerClient, final ShardId shardId, final FollowerStatsInfoHandler handler, final Consumer errorHandler ) { - client.admin().indices().stats(new IndicesStatsRequest().indices(shardId.getIndexName()), ActionListener.wrap(r -> { + followerClient.admin().indices().stats(new IndicesStatsRequest().indices(shardId.getIndexName()), ActionListener.wrap(r -> { IndexStats indexStats = r.getIndex(shardId.getIndexName()); if (indexStats == null) { IndexMetadata indexMetadata = clusterService.state().metadata().index(shardId.getIndex()); diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportPutFollowAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportPutFollowAction.java index ec475dd375973..e82cab2fce0ee 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportPutFollowAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportPutFollowAction.java @@ -273,7 +273,7 @@ public void onFailure(Exception e) { } private void initiateFollowing( - final Client client, + final Client clientWithHeaders, final PutFollowAction.Request request, final ActionListener listener ) { @@ -282,7 +282,7 @@ private void initiateFollowing( ResumeFollowAction.Request resumeFollowRequest = new ResumeFollowAction.Request(); resumeFollowRequest.setFollowerIndex(request.getFollowerIndex()); resumeFollowRequest.setParameters(new FollowParameters(parameters)); - client.execute( + clientWithHeaders.execute( ResumeFollowAction.INSTANCE, resumeFollowRequest, ActionListener.wrap( diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/repository/CcrRepository.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/repository/CcrRepository.java index e9ff58927cff6..e317d95f79323 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/repository/CcrRepository.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/repository/CcrRepository.java @@ -197,8 +197,8 @@ public void getSnapshotInfo(GetSnapshotInfoContext context) { .setMetadata(true) .setNodes(true) .get(ccrSettings.getRecoveryActionTimeout()); - Metadata metadata = response.getState().metadata(); - ImmutableOpenMap indicesMap = metadata.indices(); + Metadata responseMetadata = response.getState().metadata(); + ImmutableOpenMap indicesMap = responseMetadata.indices(); List indices = new ArrayList<>(indicesMap.keySet()); // fork to the snapshot meta pool because the context expects to run on it and asserts that it does @@ -208,7 +208,7 @@ public void getSnapshotInfo(GetSnapshotInfoContext context) { new SnapshotInfo( new Snapshot(this.metadata.name(), SNAPSHOT_ID), indices, - new ArrayList<>(metadata.dataStreams().keySet()), + new ArrayList<>(responseMetadata.dataStreams().keySet()), Collections.emptyList(), response.getState().getNodes().getMaxNodeVersion(), SnapshotState.SUCCESS @@ -250,12 +250,12 @@ public IndexMetadata getSnapshotIndexMetaData(RepositoryData repositoryData, Sna IndexMetadata.Builder imdBuilder = IndexMetadata.builder(leaderIndex); // Adding the leader index uuid for each shard as custom metadata: - Map metadata = new HashMap<>(); - metadata.put(CcrConstants.CCR_CUSTOM_METADATA_LEADER_INDEX_SHARD_HISTORY_UUIDS, String.join(",", leaderHistoryUUIDs)); - metadata.put(CcrConstants.CCR_CUSTOM_METADATA_LEADER_INDEX_UUID_KEY, leaderIndexMetadata.getIndexUUID()); - metadata.put(CcrConstants.CCR_CUSTOM_METADATA_LEADER_INDEX_NAME_KEY, leaderIndexMetadata.getIndex().getName()); - metadata.put(CcrConstants.CCR_CUSTOM_METADATA_REMOTE_CLUSTER_NAME_KEY, remoteClusterAlias); - imdBuilder.putCustom(CcrConstants.CCR_CUSTOM_METADATA_KEY, metadata); + Map customMetadata = new HashMap<>(); + customMetadata.put(CcrConstants.CCR_CUSTOM_METADATA_LEADER_INDEX_SHARD_HISTORY_UUIDS, String.join(",", leaderHistoryUUIDs)); + customMetadata.put(CcrConstants.CCR_CUSTOM_METADATA_LEADER_INDEX_UUID_KEY, leaderIndexMetadata.getIndexUUID()); + customMetadata.put(CcrConstants.CCR_CUSTOM_METADATA_LEADER_INDEX_NAME_KEY, leaderIndexMetadata.getIndex().getName()); + customMetadata.put(CcrConstants.CCR_CUSTOM_METADATA_REMOTE_CLUSTER_NAME_KEY, remoteClusterAlias); + imdBuilder.putCustom(CcrConstants.CCR_CUSTOM_METADATA_KEY, customMetadata); imdBuilder.settings(leaderIndexMetadata.getSettings()); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardFollowTaskReplicationTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardFollowTaskReplicationTests.java index 4368d492e9a79..d814e6b89b543 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardFollowTaskReplicationTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardFollowTaskReplicationTests.java @@ -509,11 +509,11 @@ protected EngineFactory getEngineFactory(ShardRouting routing) { } @Override - protected synchronized void recoverPrimary(IndexShard primary) { + protected synchronized void recoverPrimary(IndexShard primaryShard) { DiscoveryNode localNode = new DiscoveryNode("foo", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT); Snapshot snapshot = new Snapshot("foo", new SnapshotId("bar", UUIDs.randomBase64UUID())); ShardRouting routing = ShardRoutingHelper.newWithRestoreSource( - primary.routingEntry(), + primaryShard.routingEntry(), new RecoverySource.SnapshotRecoverySource( UUIDs.randomBase64UUID(), snapshot, @@ -521,9 +521,9 @@ protected synchronized void recoverPrimary(IndexShard primary) { new IndexId("test", UUIDs.randomBase64UUID(random())) ) ); - primary.markAsRecovering("remote recovery from leader", new RecoveryState(routing, localNode, null)); + primaryShard.markAsRecovering("remote recovery from leader", new RecoveryState(routing, localNode, null)); final PlainActionFuture future = PlainActionFuture.newFuture(); - primary.restoreFromRepository(new RestoreOnlyRepository(index.getName()) { + primaryShard.restoreFromRepository(new RestoreOnlyRepository(index.getName()) { @Override public void restoreShard( Store store, @@ -535,11 +535,11 @@ public void restoreShard( ) { ActionListener.completeWith(listener, () -> { IndexShard leader = leaderGroup.getPrimary(); - Lucene.cleanLuceneIndex(primary.store().directory()); + Lucene.cleanLuceneIndex(primaryShard.store().directory()); try (Engine.IndexCommitRef sourceCommit = leader.acquireSafeIndexCommit()) { Store.MetadataSnapshot sourceSnapshot = leader.store().getMetadata(sourceCommit.getIndexCommit()); for (StoreFileMetadata md : sourceSnapshot) { - primary.store() + primaryShard.store() .directory() .copyFrom(leader.store().directory(), md.name(), md.name(), IOContext.DEFAULT); } diff --git a/x-pack/plugin/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamsSnapshotsIT.java b/x-pack/plugin/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamsSnapshotsIT.java index 216a0611f2d59..2d86d4741aa16 100644 --- a/x-pack/plugin/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamsSnapshotsIT.java +++ b/x-pack/plugin/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamsSnapshotsIT.java @@ -315,16 +315,16 @@ public void testSnapshotAndRestoreAllIncludeSpecificDataStream() throws Exceptio assertEquals(DocWriteResponse.Result.CREATED, indexResponse.getResult()); String id2 = indexResponse.getId(); - String id; + String idToGet; String dataStreamToSnapshot; String backingIndexName; if (randomBoolean()) { dataStreamToSnapshot = "ds"; - id = this.id; + idToGet = this.id; backingIndexName = this.dsBackingIndexName; } else { dataStreamToSnapshot = "other-ds"; - id = id2; + idToGet = id2; backingIndexName = this.otherDsBackingIndexName; } boolean filterDuringSnapshotting = randomBoolean(); @@ -359,7 +359,7 @@ public void testSnapshotAndRestoreAllIncludeSpecificDataStream() throws Exceptio assertEquals(1, restoreSnapshotResponse.getRestoreInfo().successfulShards()); - assertEquals(DOCUMENT_SOURCE, client.prepareGet(backingIndexName, "_doc", id).get().getSourceAsMap()); + assertEquals(DOCUMENT_SOURCE, client.prepareGet(backingIndexName, "_doc", idToGet).get().getSourceAsMap()); SearchHit[] hits = client.prepareSearch(backingIndexName).get().getHits().getHits(); assertEquals(1, hits.length); assertEquals(DOCUMENT_SOURCE, hits[0].getSourceAsMap()); @@ -850,7 +850,7 @@ public void testDataStreamNotIncludedInLimitedSnapshot() throws ExecutionExcepti } public void testDeleteDataStreamDuringSnapshot() throws Exception { - Client client = client(); + Client client1 = client(); // this test uses a MockRepository assertAcked(client().admin().cluster().prepareDeleteRepository(REPO)); @@ -871,7 +871,7 @@ public void testDeleteDataStreamDuringSnapshot() throws Exception { logger.info("--> indexing some data"); for (int i = 0; i < 100; i++) { - client.prepareIndex(dataStream, "_doc") + client1.prepareIndex(dataStream, "_doc") .setOpType(DocWriteRequest.OpType.CREATE) .setId(Integer.toString(i)) .setSource(Collections.singletonMap("@timestamp", "2020-12-12")) @@ -882,7 +882,7 @@ public void testDeleteDataStreamDuringSnapshot() throws Exception { assertDocCount(dataStream, 100L); logger.info("--> snapshot"); - ActionFuture future = client.admin() + ActionFuture future = client1.admin() .cluster() .prepareCreateSnapshot(repositoryName, SNAPSHOT) .setIndices(dataStream) @@ -895,7 +895,7 @@ public void testDeleteDataStreamDuringSnapshot() throws Exception { // non-partial snapshots do not allow delete operations on data streams where snapshot has not been completed try { logger.info("--> delete index while non-partial snapshot is running"); - client.execute(DeleteDataStreamAction.INSTANCE, new DeleteDataStreamAction.Request(new String[] { dataStream })).actionGet(); + client1.execute(DeleteDataStreamAction.INSTANCE, new DeleteDataStreamAction.Request(new String[] { dataStream })).actionGet(); fail("Expected deleting index to fail during snapshot"); } catch (SnapshotInProgressException e) { assertThat(e.getMessage(), containsString("Cannot delete data streams that are being snapshotted: [" + dataStream)); diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/DeprecationIndexingAppender.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/DeprecationIndexingAppender.java index 5e7429efeaec1..edd9a85862b01 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/DeprecationIndexingAppender.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/DeprecationIndexingAppender.java @@ -71,10 +71,10 @@ public void append(LogEvent event) { /** * Sets whether this appender is enabled or disabled. When disabled, the appender will * not perform indexing operations. - * @param isEnabled the enabled status of the appender. + * @param enabled the enabled status of the appender. */ - public void setEnabled(boolean isEnabled) { - this.isEnabled = isEnabled; + public void setEnabled(boolean enabled) { + this.isEnabled = enabled; } /**