-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HelixAdmin APIs and pipeline changes to support Helix Node Swap #2661
HelixAdmin APIs and pipeline changes to support Helix Node Swap #2661
Conversation
7fca663
to
5f1a3f7
Compare
c16310f
to
7063dec
Compare
helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
Outdated
Show resolved
Hide resolved
New APIs: - isSwapReadyToComplete - completeSwapIfReady Updated APIs: - setInstanceOperation - addInstance (check to make sure no other instances with same logicalId unless old has SWAP_OUT and to add has SWAP_IN)
7063dec
to
ee03fd2
Compare
…following tests are not affected.
…and then used to remove duplicate logicalIds from enabledLiveNodes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are just my initial comments, i will do next pas soon..
* swapIn instance can be passed in. | ||
* @param clusterName The cluster name | ||
* @param instanceName The instance that is being swapped out or swapped in | ||
* @return True if the swap is ready to be completed, false otherwise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for my lack of understanding, typically swap involves 2 entries, why does the API take only one? Also what does "swap" mean in this context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unless instanceName is like "virtual" and there are 2 entities tied to the same virtual instance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instance name in this case will be one of the unique instance names(same as InstanceConfig znode ID) involved in the swap. Either SWAP_OUT or SWAP_IN. This API is intended to be used with the PerInstanceAccessor in helix-rest. For that endpoint you pass one instanceName.
Because we can find the matching swap instance for either SWAP_OUT or SWAP_IN node, we can take either as the instance name.
"swap" is referring to the operation between two instances which can be deduced from providing one of the instances involved in the swap.
...core/src/main/java/org/apache/helix/controller/dataproviders/BaseControllerDataProvider.java
Show resolved
Hide resolved
helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/PerInstanceAccessor.java
Show resolved
Hide resolved
… fix AssignableNode to check for clusterTopologyConfig when attempting to get logicalId.
…join the cluster with an invalid DOMAIN field.
…ONE and matching INSTANCE_CAPACITY_MAP to SWAP_OUT node.
helix-core/src/main/java/org/apache/helix/controller/rebalancer/DelayedAutoRebalancer.java
Outdated
Show resolved
Hide resolved
* | ||
* @return a set of SWAP_IN instanceNames that have a corresponding SWAP_OUT instance. | ||
*/ | ||
public Set<String> getEnabledLiveSwapInInstanceNames() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: when we tag SWAP_IN instanceNames, don't we already check if there is already an paring SWAP_OUT instance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed offline.
TLDR: Sanity checks ensure that we can't have a case where there are two instances with the same logicalId and both have InstanceOperation unset. This allows for setting either SWAP_OUT node or SWAP_IN node instance operation first.
@@ -113,9 +114,16 @@ public IdealState computeNewIdealState(String resourceName, | |||
allNodes = clusterData.getAllInstances(); | |||
} | |||
|
|||
Set<String> allNodesDeduped = DelayedRebalanceUtil.filterOutInstancesWithDuplicateLogicalIds( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we could integrate the logic into getEnabledLiveInstances
?
Probably with better name when we work on consolidating operation and disable/enable in one enum and we redesign all the getters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a TODO for this. We can do it when we refactor to use states instead of InstanceOperation.
…ed state before SWAP_OUT node has instance operation set.
helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/PerInstanceAccessor.java
Show resolved
Hide resolved
…mputed with logicalIds intead of instanceNames.
CI failure is due to recurring flaky test testDistributedController #2498 This PR is ready to be merged. Final Commit Message: Add ability for up to 2 nodes with the same logicalId to be added to the cluster at the same time when a SWAP is happening. Adding and updating Helix Admin APIs to support swap operation:
|
7613cab
into
apache:ApplicationClusterManager
Add ability for up to 2 nodes with the same logicalId to be added to the cluster at the same time when a SWAP is happening. During all paritionAssignment for WAGED and DelayedAutoRebalancer, we select just one instance for each logicalId. Achieves n -> n+1 for all replicas on SWAP_OUT node and back n when SWAP is marked complete, making it cancelable. Adding and updating Helix Admin APIs to support swap operation: setInstanceOperation addInstance canCompleteSwap completeSwapIfPossible * Refactor sanity checks for HelixAdmin swap APIs. * Helix Node Swap pipeline changes and integration tests. * Fix integration tests to properly restore stopped MockParticipant so following tests are not affected. * Add comments and docstrings. * Fix tests to clean up after themselves. * Optimize duplicate logicalId filtering to only be called on allNodes and then used to remove duplicate logicalIds from enabledLiveNodes. * Add handling for clusterConfig == null in updateSwappingInstances and fix AssignableNode to check for clusterTopologyConfig when attempting to get logicalId. * Fix integ tests. * Fix testGetDomainInformation since we no longer allow an instance to join the cluster with an invalid DOMAIN field. * Add checks to ensure that the SWAP_IN instance has a matching FAULT_ZONE and matching INSTANCE_CAPACITY_MAP to SWAP_OUT node. * Rename canSwapBeCompleted to canCompleteSwap. * Add sanity checks to allow SWAP_IN node to join the cluster in disabled state before SWAP_OUT node has instance operation set. * Fix print in test case. * Add canCompleteSwap to PerInstanceAccessor and fix formatting. * Fix flaky node swap after completion by making sure replica has is computed with logicalIds intead of instanceNames.
Add ability for up to 2 nodes with the same logicalId to be added to the cluster at the same time when a SWAP is happening. During all paritionAssignment for WAGED and DelayedAutoRebalancer, we select just one instance for each logicalId. Achieves n -> n+1 for all replicas on SWAP_OUT node and back n when SWAP is marked complete, making it cancelable. Adding and updating Helix Admin APIs to support swap operation: setInstanceOperation addInstance canCompleteSwap completeSwapIfPossible * Refactor sanity checks for HelixAdmin swap APIs. * Helix Node Swap pipeline changes and integration tests. * Fix integration tests to properly restore stopped MockParticipant so following tests are not affected. * Add comments and docstrings. * Fix tests to clean up after themselves. * Optimize duplicate logicalId filtering to only be called on allNodes and then used to remove duplicate logicalIds from enabledLiveNodes. * Add handling for clusterConfig == null in updateSwappingInstances and fix AssignableNode to check for clusterTopologyConfig when attempting to get logicalId. * Fix integ tests. * Fix testGetDomainInformation since we no longer allow an instance to join the cluster with an invalid DOMAIN field. * Add checks to ensure that the SWAP_IN instance has a matching FAULT_ZONE and matching INSTANCE_CAPACITY_MAP to SWAP_OUT node. * Rename canSwapBeCompleted to canCompleteSwap. * Add sanity checks to allow SWAP_IN node to join the cluster in disabled state before SWAP_OUT node has instance operation set. * Fix print in test case. * Add canCompleteSwap to PerInstanceAccessor and fix formatting. * Fix flaky node swap after completion by making sure replica has is computed with logicalIds intead of instanceNames.
Add ability for up to 2 nodes with the same logicalId to be added to the cluster at the same time when a SWAP is happening. During all paritionAssignment for WAGED and DelayedAutoRebalancer, we select just one instance for each logicalId. Achieves n -> n+1 for all replicas on SWAP_OUT node and back n when SWAP is marked complete, making it cancelable. Adding and updating Helix Admin APIs to support swap operation: setInstanceOperation addInstance canCompleteSwap completeSwapIfPossible * Refactor sanity checks for HelixAdmin swap APIs. * Helix Node Swap pipeline changes and integration tests. * Fix integration tests to properly restore stopped MockParticipant so following tests are not affected. * Add comments and docstrings. * Fix tests to clean up after themselves. * Optimize duplicate logicalId filtering to only be called on allNodes and then used to remove duplicate logicalIds from enabledLiveNodes. * Add handling for clusterConfig == null in updateSwappingInstances and fix AssignableNode to check for clusterTopologyConfig when attempting to get logicalId. * Fix integ tests. * Fix testGetDomainInformation since we no longer allow an instance to join the cluster with an invalid DOMAIN field. * Add checks to ensure that the SWAP_IN instance has a matching FAULT_ZONE and matching INSTANCE_CAPACITY_MAP to SWAP_OUT node. * Rename canSwapBeCompleted to canCompleteSwap. * Add sanity checks to allow SWAP_IN node to join the cluster in disabled state before SWAP_OUT node has instance operation set. * Fix print in test case. * Add canCompleteSwap to PerInstanceAccessor and fix formatting. * Fix flaky node swap after completion by making sure replica has is computed with logicalIds intead of instanceNames.
Add ability for up to 2 nodes with the same logicalId to be added to the cluster at the same time when a SWAP is happening. During all paritionAssignment for WAGED and DelayedAutoRebalancer, we select just one instance for each logicalId. Achieves n -> n+1 for all replicas on SWAP_OUT node and back n when SWAP is marked complete, making it cancelable. Adding and updating Helix Admin APIs to support swap operation: setInstanceOperation addInstance canCompleteSwap completeSwapIfPossible * Refactor sanity checks for HelixAdmin swap APIs. * Helix Node Swap pipeline changes and integration tests. * Fix integration tests to properly restore stopped MockParticipant so following tests are not affected. * Add comments and docstrings. * Fix tests to clean up after themselves. * Optimize duplicate logicalId filtering to only be called on allNodes and then used to remove duplicate logicalIds from enabledLiveNodes. * Add handling for clusterConfig == null in updateSwappingInstances and fix AssignableNode to check for clusterTopologyConfig when attempting to get logicalId. * Fix integ tests. * Fix testGetDomainInformation since we no longer allow an instance to join the cluster with an invalid DOMAIN field. * Add checks to ensure that the SWAP_IN instance has a matching FAULT_ZONE and matching INSTANCE_CAPACITY_MAP to SWAP_OUT node. * Rename canSwapBeCompleted to canCompleteSwap. * Add sanity checks to allow SWAP_IN node to join the cluster in disabled state before SWAP_OUT node has instance operation set. * Fix print in test case. * Add canCompleteSwap to PerInstanceAccessor and fix formatting. * Fix flaky node swap after completion by making sure replica has is computed with logicalIds intead of instanceNames.
Issues
HelixAdmin.setInstanceOperation and addInstance sanity checks for SWAP_IN & SWAP_OUT Helix Node/Instance Swap #2662
Create HelixAdmin.isSwapReadyToComplete and completeSwapIfReady(returns if swap finished) Helix Node/Instance Swap #2662
HELIX_ENABLED: false
and clear theINSTANCE_OPERATION
for SWAP_IN node.Change WAGED assignment tie breaker logic to use logicalId when present Helix Node/Instance Swap #2662
Refactor DelayedAutoRebalancerUtil and DelayedAutoRebalancer.computeBestPossibleStateForPartition
to filter out SWAP_IN node because we will add SWAP_IN node to the end of preference list in computeBestPossibleStateForPartition until the swap is complete Helix Node/Instance Swap #2662
Description
Adding Helix Admin APIs and updating existing setInstanceOperation and addInstance implementations to support Helix Node Swap.
INSTANCE_OPERATION
toSWAP_IN
, as this should be set when we addInstance to cluster. We can't have a case where where there are two instances in the cluster with the same logicalId unless there is exactly 1 withSWAP_OUT
and 1 withSWAP_IN
INSTANCE_OPERATION
.SWAP_OUT
INSTANCE_OPERATION
or the add instance is being added in the disable state.SWAP_OUT
orSWAP_IN
instance as an argument. It does the following checks:INSTANCE_OPERATION
and disable the SwapOut node.Add ability for up to 2 nodes with the same logicalId to be added to the cluster at the same time when a SWAP is happening.
During all paritionAssignment for WAGED and DelayedAutoRebalancer, we select just one instance for each logicalId.
Cases:
When SWAP_OUT nodes are the instances which pass through the filter and there are corresponding SWAP_IN nodes which are live and enabled, we add them to the end of all preference lists which contain the SWAP_OUT node following computeIdealState. This ensures that they are in secondTopState for all StateModels that can only have a single replica in the topState. For stateModels that allow multiple replicas of the topState, the SWAP_IN node could host topState replicas before the SWAP is completed.
Once the swap is complete and SWAP_IN node has InstanceOperation set to null, SWAP_IN node becomes assignable and WAGED and DelayedAutoRebalancer + CRUSHED will computePartitionAssignment and generate IdealState with SWAP_IN instance in same index of the preferenceList as the SWAP_OUT instance used to be in. This means that not only will SWAP_IN node have all the same partitions that the SWAP_OUT node had, but also the same states.
Tests
Changes that Break Backward Compatibility (Optional)
Documentation (Optional)
Commits
Code Quality
(helix-style-intellij.xml if IntelliJ IDE is used)