-
Notifications
You must be signed in to change notification settings - Fork 589
HDDS-2923 Add fall-back protection for rack awareness in pipeline creation. #516
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,10 +83,66 @@ public void testChooseNodeBasedOnRackAwareness() { | |
| DatanodeDetails nextNode = placementPolicy.chooseNodeBasedOnRackAwareness( | ||
| healthyNodes, new ArrayList<>(PIPELINE_PLACEMENT_MAX_NODES_COUNT), | ||
| topologyWithDifRacks, anchor); | ||
| Assert.assertNotNull(nextNode); | ||
| Assert.assertFalse(anchor.getNetworkLocation().equals( | ||
| nextNode.getNetworkLocation())); | ||
| } | ||
|
|
||
| @Test | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we add a test simple test case with topology that all nodes on the same rack with topology aware and fall back enabled?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I add a test. Please check the latest commit. |
||
| public void testFallBackPickNodes() { | ||
| List<DatanodeDetails> healthyNodes = overWriteLocationInNodes( | ||
| nodeManager.getNodes(HddsProtos.NodeState.HEALTHY)); | ||
| DatanodeDetails node; | ||
| try { | ||
| node = placementPolicy.fallBackPickNodes(healthyNodes, null); | ||
| Assert.assertNotNull(node); | ||
| } catch (SCMException e) { | ||
| Assert.fail("Should not reach here."); | ||
| } | ||
|
|
||
| // when input nodeSet are all excluded. | ||
| List<DatanodeDetails> exclude = healthyNodes; | ||
| try { | ||
| node = placementPolicy.fallBackPickNodes(healthyNodes, exclude); | ||
| Assert.assertNull(node); | ||
| } catch (SCMException e) { | ||
| Assert.assertEquals(SCMException.ResultCodes.FAILED_TO_FIND_SUITABLE_NODE, | ||
| e.getResult()); | ||
| } catch (Exception ex) { | ||
| Assert.fail("Should not reach here."); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void testRackAwarenessNotEnabledWithFallBack() throws SCMException{ | ||
| List<DatanodeDetails> healthyNodes = | ||
| nodeManager.getNodes(HddsProtos.NodeState.HEALTHY); | ||
| DatanodeDetails anchor = placementPolicy.chooseNode(healthyNodes); | ||
| DatanodeDetails randomNode = placementPolicy.chooseNode(healthyNodes); | ||
| // rack awareness is not enabled. | ||
| Assert.assertTrue(anchor.getNetworkLocation().equals( | ||
| randomNode.getNetworkLocation())); | ||
|
|
||
| NetworkTopology topology = new NetworkTopologyImpl(new Configuration()); | ||
| DatanodeDetails nextNode = placementPolicy.chooseNodeBasedOnRackAwareness( | ||
| healthyNodes, new ArrayList<>(PIPELINE_PLACEMENT_MAX_NODES_COUNT), | ||
| topology, anchor); | ||
| // RackAwareness should not be able to choose any node. | ||
| Assert.assertNull(nextNode); | ||
|
|
||
| // PlacementPolicy should still be able to pick a set of 3 nodes. | ||
| int numOfNodes = HddsProtos.ReplicationFactor.THREE.getNumber(); | ||
| List<DatanodeDetails> results = placementPolicy | ||
| .getResultSet(numOfNodes, healthyNodes); | ||
|
|
||
| Assert.assertEquals(numOfNodes, results.size()); | ||
| // All nodes are on same rack. | ||
| Assert.assertEquals(results.get(0).getNetworkLocation(), | ||
| results.get(1).getNetworkLocation()); | ||
| Assert.assertEquals(results.get(0).getNetworkLocation(), | ||
| results.get(2).getNetworkLocation()); | ||
| } | ||
|
|
||
| private final static Node[] NODES = new NodeImpl[] { | ||
| new NodeImpl("h1", "/r1", NetConstants.NODE_COST_DEFAULT), | ||
| new NodeImpl("h2", "/r1", NetConstants.NODE_COST_DEFAULT), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.