Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. public class MachineInfo {
  2.  
  3. private String hostname;
  4.  
  5. // getters and setters here
  6. }
  7.  
  8. public static String pickRandomMachine(List<MachineInfo> machines) {
  9. String hostname = null;
  10. Collections.shuffle(machines, new Random(System.nanoTime()));
  11. for (MachineInfo info : machines) {
  12. if (!checkHostUptime(info.getHostName())) {
  13. continue;
  14. }
  15.  
  16. hostname = info.getHostName();
  17. break;
  18. }
  19.  
  20. return hostname;
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement