diff --git a/src/main/java/org/opensearch/ad/indices/AnomalyDetectionIndices.java b/src/main/java/org/opensearch/ad/indices/AnomalyDetectionIndices.java index 50e16b652..0d44c056b 100644 --- a/src/main/java/org/opensearch/ad/indices/AnomalyDetectionIndices.java +++ b/src/main/java/org/opensearch/ad/indices/AnomalyDetectionIndices.java @@ -1153,7 +1153,7 @@ private void updateJobIndexSettingIfNecessary(IndexState jobIndexState, ActionLi private static Integer getIntegerSetting(GetSettingsResponse settingsResponse, String settingKey) { Integer value = null; - Iterator iter = settingsResponse.getIndexToSettings().valuesIt(); + Iterator iter = settingsResponse.getIndexToSettings().values().iterator(); while (iter.hasNext()) { Settings settings = iter.next(); value = settings.getAsInt(settingKey, null); @@ -1166,7 +1166,7 @@ private static Integer getIntegerSetting(GetSettingsResponse settingsResponse, S private static String getStringSetting(GetSettingsResponse settingsResponse, String settingKey) { String value = null; - Iterator iter = settingsResponse.getIndexToSettings().valuesIt(); + Iterator iter = settingsResponse.getIndexToSettings().values().iterator(); while (iter.hasNext()) { Settings settings = iter.next(); value = settings.get(settingKey, null); diff --git a/src/test/java/org/opensearch/ad/ADIntegTestCase.java b/src/test/java/org/opensearch/ad/ADIntegTestCase.java index 66d8fabf5..a1dfe0320 100644 --- a/src/test/java/org/opensearch/ad/ADIntegTestCase.java +++ b/src/test/java/org/opensearch/ad/ADIntegTestCase.java @@ -53,7 +53,6 @@ import org.opensearch.client.node.NodeClient; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.node.DiscoveryNodes; -import org.opensearch.common.collect.ImmutableOpenMap; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.index.query.MatchAllQueryBuilder; @@ -65,7 +64,6 @@ import org.opensearch.test.OpenSearchIntegTestCase; import org.opensearch.test.transport.MockTransportService; -import com.carrotsearch.hppc.cursors.ObjectObjectCursor; import com.google.common.collect.ImmutableMap; public abstract class ADIntegTestCase extends OpenSearchIntegTestCase { @@ -252,7 +250,7 @@ public ClusterUpdateSettingsResponse updateTransientSettings(Map sett return clusterAdmin().updateSettings(updateSettingsRequest).actionGet(timeout); } - public ImmutableOpenMap getDataNodes() { + public Map getDataNodes() { DiscoveryNodes nodes = clusterService().state().getNodes(); return nodes.getDataNodes(); } @@ -268,10 +266,10 @@ public Client getDataNodeClient() { public DiscoveryNode[] getDataNodesArray() { DiscoveryNodes nodes = clusterService().state().getNodes(); - Iterator> iterator = nodes.getDataNodes().iterator(); + Iterator iterator = nodes.getDataNodes().values().iterator(); List dataNodes = new ArrayList<>(); while (iterator.hasNext()) { - dataNodes.add(iterator.next().value); + dataNodes.add(iterator.next()); } return dataNodes.toArray(new DiscoveryNode[0]); } diff --git a/src/test/java/test/org/opensearch/ad/util/ClusterCreation.java b/src/test/java/test/org/opensearch/ad/util/ClusterCreation.java index 2061e42fc..c4af50118 100644 --- a/src/test/java/test/org/opensearch/ad/util/ClusterCreation.java +++ b/src/test/java/test/org/opensearch/ad/util/ClusterCreation.java @@ -18,7 +18,9 @@ import java.net.InetAddress; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.opensearch.Version; import org.opensearch.cluster.ClusterName; @@ -26,7 +28,6 @@ import org.opensearch.cluster.metadata.Metadata; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.node.DiscoveryNodes; -import org.opensearch.common.collect.ImmutableOpenMap; import org.opensearch.common.transport.TransportAddress; public class ClusterCreation { @@ -66,12 +67,12 @@ public static ClusterState state( * * TODO: ModelManagerTests has the same method. Refactor. */ - public static ImmutableOpenMap createDataNodes(int numDataNodes) { - ImmutableOpenMap.Builder dataNodes = ImmutableOpenMap.builder(); + public static Map createDataNodes(int numDataNodes) { + final Map dataNodes = new HashMap<>(); for (int i = 0; i < numDataNodes; i++) { dataNodes.put("foo" + i, mock(DiscoveryNode.class)); } - return dataNodes.build(); + return dataNodes; } /**