public static void main(String args[]) throws Exception {
    List<ServerAddress> addrs = new LinkedList<ServerAddress>();
    addrs.add(new ServerAddress("127.0.0.1", 27017));
    addrs.add(new ServerAddress("127.0.0.1", 27018));

    Mongo m = new Mongo(addrs);

    ReplicaSetStatus status = new ReplicaSetStatus(m, addrs);
    System.out.println(status.ensureMaster()._addr);

    while (true) {
      System.out.println(status.ready());
      if (status.ready()) {
        status.printStatus();
        System.out.println(
            "master: " + status.getMaster() + "\t secondary: " + status.getASecondary());
      }
      System.out.println("-----------------------");
      Thread.sleep(5000);
    }
  }