RoundRobinStrategy implements IReplicationStrategy { @Override public List<Integer> getNodeIds(List<Integer> activeNodes) { List<Integer> output = new ArrayList<Integer>(); int temp = 0; index++; if (activeNodes.size() < size) { return activeNodes; } while (output.size() < size) { output.add(activeNodes.get((index + temp) % activeNodes.size())); temp++; } return output; } RoundRobinStrategy(int size); @Override List<Integer> getNodeIds(List<Integer> activeNodes);  }
@Test public void testGetNodeIds() { List<Integer> output = new ArrayList<Integer>(); for (int j = 0; j < 20; j++) { int temp = 0; output = strategy.getNodeIds(activeNodes); for (Integer follower : output) { index = (index + temp) % activeNodes.size(); temp++; assertEquals(activeNodes.get(index), follower); } } }