public void zkHostSortingTest() {
List<String> expectedHosts = Arrays.asList("rack1node1", "rack2node1", "rack4node1", "rack4node4");
// Add the states in a not correctly sorted order
TreeSet<ZooKeeperState> states = new TreeSet<ZooKeeperState>();
states.add(new ZooKeeperState("rack4node4", "leader", 10));
states.add(new ZooKeeperState("rack4node1", "follower", 10));
states.add(new ZooKeeperState("rack1node1", "follower", 10));
states.add(new ZooKeeperState("rack2node1", "follower", 10));
List<String> actualHosts = new ArrayList<String>(4);
for (ZooKeeperState state : states) {
actualHosts.add(state.keeper);
}