This is an automated email from the ASF dual-hosted git repository.
jxue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git
The following commit(s) were added to refs/heads/master by this push:
new b027a8d74 [apache/helix] -- Updated Maps.of to Sets.of for Java-8
build complaince (#2756)
b027a8d74 is described below
commit b027a8d740a25739d91c24f7841ccceef5a2ed45
Author: Himanshu Kandwal <[email protected]>
AuthorDate: Thu Feb 22 15:33:48 2024 -0800
[apache/helix] -- Updated Maps.of to Sets.of for Java-8 build complaince
(#2756)
Final Commit Message: Updated Helix codebase to be build compatible with
JDK-8. Open source release will be based on Java 11.
---
.../rebalancer/TestInstanceOperation.java | 27 +++++++++++-----------
.../resources/helix/PerInstanceAccessor.java | 7 +++---
.../rest/server/TestPartitionAssignmentAPI.java | 3 ++-
3 files changed, 20 insertions(+), 17 deletions(-)
diff --git
a/helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestInstanceOperation.java
b/helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestInstanceOperation.java
index 765add7fd..276757741 100644
---
a/helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestInstanceOperation.java
+++
b/helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestInstanceOperation.java
@@ -14,6 +14,7 @@ import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
+import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import org.apache.helix.ConfigAccessor;
import org.apache.helix.HelixAdmin;
@@ -558,7 +559,7 @@ public class TestInstanceOperation extends ZkTestBase {
// but none of them are in a top state.
Assert.assertTrue(_bestPossibleClusterVerifier.verifyByPolling());
validateEVsCorrect(getEVs(), originalEVs,
swapOutInstancesToSwapInInstances,
- Set.of(instanceToSwapInName), Collections.emptySet());
+ ImmutableSet.of(instanceToSwapInName), Collections.emptySet());
// Assert canSwapBeCompleted is true
Assert.assertTrue(_gSetupTool.getClusterManagementTool()
@@ -585,7 +586,7 @@ public class TestInstanceOperation extends ZkTestBase {
// Validate that the SWAP_IN instance has the same partitions the SWAP_OUT
instance had before
// swap was completed.
verifier(() -> (validateEVsCorrect(getEVs(), originalEVs,
swapOutInstancesToSwapInInstances,
- Collections.emptySet(), Set.of(instanceToSwapInName))), TIMEOUT);
+ Collections.emptySet(), ImmutableSet.of(instanceToSwapInName))),
TIMEOUT);
}
@Test(dependsOnMethods = "testNodeSwap")
@@ -624,7 +625,7 @@ public class TestInstanceOperation extends ZkTestBase {
// but none of them are in a top state.
Assert.assertTrue(_bestPossibleClusterVerifier.verifyByPolling());
validateEVsCorrect(getEVs(), originalEVs,
swapOutInstancesToSwapInInstances,
- Set.of(instanceToSwapInName), Collections.emptySet());
+ ImmutableSet.of(instanceToSwapInName), Collections.emptySet());
// Assert canSwapBeCompleted is true
Assert.assertTrue(_gSetupTool.getClusterManagementTool()
@@ -676,7 +677,7 @@ public class TestInstanceOperation extends ZkTestBase {
// Validate that the SWAP_IN instance has the same partitions the SWAP_OUT
instance had before
// swap was completed.
verifier(() -> (validateEVsCorrect(getEVs(), originalEVs,
swapOutInstancesToSwapInInstances,
- Collections.emptySet(), Set.of(instanceToSwapInName))), TIMEOUT);
+ Collections.emptySet(), ImmutableSet.of(instanceToSwapInName))),
TIMEOUT);
}
@Test(dependsOnMethods = "testNodeSwapDisableAndReenable")
@@ -723,7 +724,7 @@ public class TestInstanceOperation extends ZkTestBase {
// but none of them are in a top state.
Assert.assertTrue(_bestPossibleClusterVerifier.verifyByPolling());
validateEVsCorrect(getEVs(), originalEVs,
swapOutInstancesToSwapInInstances,
- Set.of(instanceToSwapInName), Collections.emptySet());
+ ImmutableSet.of(instanceToSwapInName), Collections.emptySet());
// Validate that the SWAP_OUT instance is in routing tables and SWAP_IN is
not.
validateRoutingTablesInstance(getEVs(), instanceToSwapOutName, true);
@@ -745,7 +746,7 @@ public class TestInstanceOperation extends ZkTestBase {
// Validate that the SWAP_IN instance has the same partitions the SWAP_OUT
instance had before
// swap was completed.
verifier(() -> (validateEVsCorrect(getEVs(), originalEVs,
swapOutInstancesToSwapInInstances,
- Collections.emptySet(), Set.of(instanceToSwapInName))), TIMEOUT);
+ Collections.emptySet(), ImmutableSet.of(instanceToSwapInName))),
TIMEOUT);
}
@Test(dependsOnMethods = "testNodeSwapSwapInNodeNoInstanceOperationDisabled")
@@ -786,7 +787,7 @@ public class TestInstanceOperation extends ZkTestBase {
// but none of them are in a top state.
Assert.assertTrue(_bestPossibleClusterVerifier.verifyByPolling());
validateEVsCorrect(getEVs(), originalEVs,
swapOutInstancesToSwapInInstances,
- Set.of(instanceToSwapInName), Collections.emptySet());
+ ImmutableSet.of(instanceToSwapInName), Collections.emptySet());
// Validate that the SWAP_OUT instance is in routing tables and SWAP_IN is
not.
validateRoutingTablesInstance(getEVs(), instanceToSwapOutName, true);
@@ -877,7 +878,7 @@ public class TestInstanceOperation extends ZkTestBase {
// but none of them are in a top state.
Assert.assertTrue(_bestPossibleClusterVerifier.verifyByPolling());
validateEVsCorrect(getEVs(), originalEVs,
swapOutInstancesToSwapInInstances,
- Set.of(instanceToSwapInName), Collections.emptySet());
+ ImmutableSet.of(instanceToSwapInName), Collections.emptySet());
// Validate that the SWAP_OUT instance is in routing tables and SWAP_IN is
not.
validateRoutingTablesInstance(getEVs(), instanceToSwapOutName, true);
@@ -902,7 +903,7 @@ public class TestInstanceOperation extends ZkTestBase {
// Validate that the SWAP_IN instance has the same partitions the SWAP_OUT
instance had before
// swap was completed.
verifier(() -> (validateEVsCorrect(getEVs(), originalEVs,
swapOutInstancesToSwapInInstances,
- Collections.emptySet(), Set.of(instanceToSwapInName))), TIMEOUT);
+ Collections.emptySet(), ImmutableSet.of(instanceToSwapInName))),
TIMEOUT);
}
@Test(dependsOnMethods = "testNodeSwapAfterEMM")
@@ -1032,7 +1033,7 @@ public class TestInstanceOperation extends ZkTestBase {
// Validate that the SWAP_IN instance has the same partitions the SWAP_OUT
instance had before
// swap was completed.
verifier(() -> (validateEVsCorrect(getEVs(), originalEVs,
swapOutInstancesToSwapInInstances,
- Collections.emptySet(), Set.of(instanceToSwapInName))), TIMEOUT);
+ Collections.emptySet(), ImmutableSet.of(instanceToSwapInName))),
TIMEOUT);
}
@Test(dependsOnMethods = "testNodeSwapWithSwapOutInstanceOffline")
@@ -1076,7 +1077,7 @@ public class TestInstanceOperation extends ZkTestBase {
// Validate that the SWAP_IN instance has the same partitions the SWAP_OUT
instance had.
verifier(() -> (validateEVsCorrect(getEVs(), originalEVs,
swapOutInstancesToSwapInInstances,
- Collections.emptySet(), Set.of(instanceToSwapInName))), TIMEOUT);
+ Collections.emptySet(), ImmutableSet.of(instanceToSwapInName))),
TIMEOUT);
// Assert isEvacuateFinished is true
Assert.assertTrue(_gSetupTool.getClusterManagementTool()
@@ -1090,7 +1091,7 @@ public class TestInstanceOperation extends ZkTestBase {
// Validate that dropping the instance has not changed the assignment
verifier(() -> (validateEVsCorrect(getEVs(), originalEVs,
swapOutInstancesToSwapInInstances,
- Collections.emptySet(), Set.of(instanceToSwapInName))), TIMEOUT);
+ Collections.emptySet(), ImmutableSet.of(instanceToSwapInName))),
TIMEOUT);
}
@Test(expectedExceptions = HelixException.class, dependsOnMethods =
"testNodeSwapWithSwapOutInstanceOffline")
@@ -1443,7 +1444,7 @@ public class TestInstanceOperation extends ZkTestBase {
.build(participantName);
if (capacity >= 0) {
- config.setInstanceCapacityMap(Map.of(TEST_CAPACITY_KEY, capacity));
+ config.setInstanceCapacityMap(ImmutableMap.of(TEST_CAPACITY_KEY,
capacity));
}
_gSetupTool.getClusterManagementTool().addInstance(CLUSTER_NAME, config);
diff --git
a/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/PerInstanceAccessor.java
b/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/PerInstanceAccessor.java
index bf0e74653..efeeee7f7 100644
---
a/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/PerInstanceAccessor.java
+++
b/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/PerInstanceAccessor.java
@@ -44,6 +44,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.collect.ImmutableMap;
import org.apache.helix.ConfigAccessor;
import org.apache.helix.HelixAdmin;
import org.apache.helix.HelixDataAccessor;
@@ -438,10 +439,10 @@ public class PerInstanceAccessor extends
AbstractHelixResource {
break;
case canCompleteSwap:
return OK(OBJECT_MAPPER.writeValueAsString(
- Map.of("successful", admin.canCompleteSwap(clusterId,
instanceName))));
+ ImmutableMap.of("successful", admin.canCompleteSwap(clusterId,
instanceName))));
case completeSwapIfPossible:
return OK(OBJECT_MAPPER.writeValueAsString(
- Map.of("successful", admin.completeSwapIfPossible(clusterId,
instanceName, force))));
+ ImmutableMap.of("successful",
admin.completeSwapIfPossible(clusterId, instanceName, force))));
case addInstanceTag:
if (!validInstance(node, instanceName)) {
return badRequest("Instance names are not match!");
@@ -487,7 +488,7 @@ public class PerInstanceAccessor extends
AbstractHelixResource {
+ "{}, instance: {}", clusterId, instanceName), e);
return serverError(e);
}
- return OK(OBJECT_MAPPER.writeValueAsString(Map.of("successful",
evacuateFinished)));
+ return
OK(OBJECT_MAPPER.writeValueAsString(ImmutableMap.of("successful",
evacuateFinished)));
default:
LOG.error("Unsupported command :" + command);
return badRequest("Unsupported command :" + command);
diff --git
a/helix-rest/src/test/java/org/apache/helix/rest/server/TestPartitionAssignmentAPI.java
b/helix-rest/src/test/java/org/apache/helix/rest/server/TestPartitionAssignmentAPI.java
index 01e88394d..2c7a46b09 100644
---
a/helix-rest/src/test/java/org/apache/helix/rest/server/TestPartitionAssignmentAPI.java
+++
b/helix-rest/src/test/java/org/apache/helix/rest/server/TestPartitionAssignmentAPI.java
@@ -32,6 +32,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import com.fasterxml.jackson.core.type.TypeReference;
+import com.google.common.collect.ImmutableList;
import org.apache.helix.ConfigAccessor;
import org.apache.helix.HelixDataAccessor;
import org.apache.helix.TestHelper;
@@ -88,7 +89,7 @@ public class TestPartitionAssignmentAPI extends
AbstractTestClass {
clusterConfig.setPersistBestPossibleAssignment(true);
clusterConfig.setDefaultInstanceCapacityMap(
Collections.singletonMap(INSTANCE_CAPACITY_KEY,
DEFAULT_INSTANCE_CAPACITY));
- clusterConfig.setInstanceCapacityKeys(List.of(INSTANCE_CAPACITY_KEY));
+
clusterConfig.setInstanceCapacityKeys(ImmutableList.of(INSTANCE_CAPACITY_KEY));
_configAccessor.setClusterConfig(CLUSTER_NAME, clusterConfig);
_controller = startController(CLUSTER_NAME);