ReplicationServerLoadBalancingTest.java:
Extracted method stopRs() to improve expressiveness again.
| | |
| | | { |
| | | if (rs[i] != null) |
| | | { |
| | | rs[i].clearDb(); |
| | | rs[i].remove(); |
| | | stopRs(i); |
| | | StaticUtils.recursiveDelete(new File(DirectoryServer.getInstanceRoot(), |
| | | rs[i].getDbDirName())); |
| | | rs[i] = null; |
| | |
| | | /** |
| | | * Stop RS2 and RS4, we must end up with RS1 has 4 DSs, and RS3 has 16 DSs |
| | | */ |
| | | |
| | | // Stop RS2 |
| | | rs[1].clearDb(); |
| | | rs[1].remove(); |
| | | // Stop RS4 |
| | | rs[3].clearDb(); |
| | | rs[3].remove(); |
| | | stopRs(1, 3); |
| | | |
| | | checkForCorrectNumbersOfConnectedDSs(new int[][]{new int[] {4, -1, 16, -1}}, |
| | | "Stopped RS2 and RS4"); |
| | |
| | | * Stop RS3, we must end up with RS1 has 3 DSs, and RS2 has 7 DSs and |
| | | * RS4 has 10 DSs |
| | | */ |
| | | |
| | | // Stop RS3 |
| | | rs[2].clearDb(); |
| | | rs[2].remove(); |
| | | stopRs(2); |
| | | |
| | | checkForCorrectNumbersOfConnectedDSs(new int[][]{ |
| | | new int[] {2, 8, -1, 10}, |
| | |
| | | /** |
| | | * Stop RS1, RS2 and RS3, all DSs should be connected to RS4 |
| | | */ |
| | | |
| | | // Stop RS1 |
| | | rs[0].clearDb(); |
| | | rs[0].remove(); |
| | | // Stop RS2 |
| | | rs[1].clearDb(); |
| | | rs[1].remove(); |
| | | // Stop RS3 |
| | | rs[2].clearDb(); |
| | | rs[2].remove(); |
| | | stopRs(0, 1, 2); |
| | | |
| | | checkForCorrectNumbersOfConnectedDSs(new int[][]{new int[] {-1, -1, -1, 20}}, |
| | | "Stopped RS1, RS2 and RS3"); |
| | |
| | | } |
| | | } |
| | | |
| | | private void stopRs(int... rsIndexes) |
| | | { |
| | | for (int rsIndex : rsIndexes) |
| | | { |
| | | if (rs[rsIndex] != null) |
| | | { |
| | | rs[rsIndex].clearDb(); |
| | | rs[rsIndex].remove(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** Translate an int array into a human readable string */ |
| | | private static String intArrayToString(int[] ints) |
| | | { |