-
Notifications
You must be signed in to change notification settings - Fork 625
HDDS-8383. Misreplication cannot be resolved with single rack #4539
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 5 commits
8e6b956
251eeb7
1ef8ae9
3e3adb2
7a0b56a
2d59517
7e871b3
bfd3791
a261e76
8731b61
8ca9e43
3e1a0e7
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 |
|---|---|---|
|
|
@@ -386,6 +386,7 @@ protected int getMaxReplicasPerRack(int numReplicas, int numberOfRacks) { | |
|
|
||
| @Override | ||
| protected int getRequiredRackCount(int numReplicas) { | ||
| return REQUIRED_RACKS; | ||
| int racks = networkTopology != null ? networkTopology.getRackCount() : 1; | ||
| return Math.min(REQUIRED_RACKS, racks); | ||
|
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. From my understanding, this is the only change which fixes the particular issue. I think it would be better to create another refactoring jira, if you want to change the other interfaces. |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -438,8 +438,7 @@ protected int getRequiredRackCount(int numReplicas) { | |
| if (networkTopology == null) { | ||
| return 1; | ||
| } | ||
| int maxLevel = networkTopology.getMaxLevel(); | ||
| int numRacks = networkTopology.getNumOfNodes(maxLevel - 1); | ||
| int numRacks = networkTopology.getRackCount(); | ||
|
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. I guess we can move this particular logic into SCM common placement policy instead of relying on NetworkTopology since NetworkTopology class is meant to be more generic & need not understand racks. |
||
| // Return the num of Rack if numRack less than numReplicas | ||
| return Math.min(numRacks, numReplicas); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,53 +35,44 @@ public class TestContainerPlacementStatusDefault { | |
| @Test | ||
| public void testPlacementSatisfiedCorrectly() { | ||
| ContainerPlacementStatusDefault stat = | ||
| new ContainerPlacementStatusDefault(1, 1, 1); | ||
| new ContainerPlacementStatusDefault(1, 1); | ||
| assertTrue(stat.isPolicySatisfied()); | ||
| assertEquals(0, stat.misReplicationCount()); | ||
|
|
||
| // Requires 2 racks, but cluster only has 1 | ||
| stat = new ContainerPlacementStatusDefault(1, 2, 1); | ||
| stat = new ContainerPlacementStatusDefault(2, 2); | ||
| assertTrue(stat.isPolicySatisfied()); | ||
| assertEquals(0, stat.misReplicationCount()); | ||
|
|
||
| stat = new ContainerPlacementStatusDefault(2, 2, 3); | ||
| assertTrue(stat.isPolicySatisfied()); | ||
| assertEquals(0, stat.misReplicationCount()); | ||
|
|
||
| stat = new ContainerPlacementStatusDefault(3, 2, 3); | ||
| assertTrue(stat.isPolicySatisfied()); | ||
| assertEquals(0, stat.misReplicationCount()); | ||
|
|
||
| stat = new ContainerPlacementStatusDefault(3, 2, 3); | ||
| stat = new ContainerPlacementStatusDefault(3, 2); | ||
| assertTrue(stat.isPolicySatisfied()); | ||
| assertEquals(0, stat.misReplicationCount()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testPlacementNotSatisfied() { | ||
| ContainerPlacementStatusDefault stat = | ||
| new ContainerPlacementStatusDefault(1, 2, 2); | ||
| new ContainerPlacementStatusDefault(1, 2); | ||
| assertFalse(stat.isPolicySatisfied()); | ||
| assertEquals(1, stat.misReplicationCount()); | ||
|
|
||
| // Zero rack, but need 2 - shouldn't really happen in practice | ||
| stat = new ContainerPlacementStatusDefault(0, 2, 1); | ||
| stat = new ContainerPlacementStatusDefault(0, 2); | ||
| assertFalse(stat.isPolicySatisfied()); | ||
| assertEquals(1, stat.misReplicationCount()); | ||
| assertEquals(2, stat.misReplicationCount()); | ||
|
|
||
| stat = new ContainerPlacementStatusDefault(2, 3, 3); | ||
| stat = new ContainerPlacementStatusDefault(2, 3); | ||
| assertFalse(stat.isPolicySatisfied()); | ||
| assertEquals(1, stat.misReplicationCount()); | ||
|
|
||
| stat = new ContainerPlacementStatusDefault(2, 4, 3, 1, Arrays.asList(1, 3)); | ||
| stat = new ContainerPlacementStatusDefault(2, 4, 1, Arrays.asList(1, 3)); | ||
| assertFalse(stat.isPolicySatisfied()); | ||
| assertEquals(2, stat.misReplicationCount()); | ||
|
|
||
| stat = new ContainerPlacementStatusDefault(1, 4, 3, 1, Arrays.asList(1, 2)); | ||
| stat = new ContainerPlacementStatusDefault(1, 4, 1, Arrays.asList(1, 2)); | ||
| assertFalse(stat.isPolicySatisfied()); | ||
| assertEquals(2, stat.misReplicationCount()); | ||
|
Comment on lines
-80
to
-82
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. The original code here doesn't make much sense to me because it's saying |
||
| assertEquals(3, stat.misReplicationCount()); | ||
|
|
||
| stat = new ContainerPlacementStatusDefault(2, 2, 3, 2, Arrays.asList(3, 1)); | ||
| stat = new ContainerPlacementStatusDefault(2, 2, 2, Arrays.asList(3, 1)); | ||
| assertFalse(stat.isPolicySatisfied()); | ||
| assertEquals(1, stat.misReplicationCount()); | ||
|
|
||
|
|
||
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.
Should we have the concept of Racks in Network Topology? Should this particular function go in PlacementPolicy class instead.
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.
@sodonnel I remember us discussing this before.