public int compare(Server s1, Server s2) {
          int l;
          l = s1.getHostname().compareTo(s2.getHostname());
          if (l != 0) return l;

          l = ((Integer) s1.getPort()).compareTo(s2.getPort());
          return l;
        }
 public void promoteServerInGroup(String groupName, String hostname, int port)
     throws FabricCommunicationException {
   ServerGroup serverGroup = getServerGroup(groupName);
   for (Server s : serverGroup.getServers()) {
     if (s.getHostname().equals(hostname) && s.getPort() == port) {
       errorSafeCallMethod(METHOD_GROUP_PROMOTE, new Object[] {groupName, s.getUuid()});
       break;
     }
   }
 }
 public void reportServerError(Server server, String errorDescription, boolean forceFaulty)
     throws FabricCommunicationException {
   String reporter = THREAT_REPORTER_NAME;
   String command = METHOD_THREAT_REPORT_ERROR;
   if (forceFaulty) {
     command = METHOD_THREAT_REPORT_FAILURE;
   }
   errorSafeCallMethod(command, new Object[] {server.getUuid(), reporter, errorDescription});
 }
 /** Facade for "dump.servers". Will not return empty server groups. */
 public FabricStateResponse<Set<ServerGroup>> getServerGroups(String groupPattern)
     throws FabricCommunicationException {
   int version = 0; // necessary but unused
   Response response =
       errorSafeCallMethod(METHOD_DUMP_SERVERS, new Object[] {version, groupPattern});
   // collect all servers by group name
   Map<String, Set<Server>> serversByGroupName = new HashMap<String, Set<Server>>();
   for (Map server : response.getResultSet()) {
     Server s = unmarshallServer(server);
     if (serversByGroupName.get(s.getGroupName()) == null) {
       serversByGroupName.put(s.getGroupName(), new HashSet<Server>());
     }
     serversByGroupName.get(s.getGroupName()).add(s);
   }
   // create group set
   Set<ServerGroup> serverGroups = new HashSet<ServerGroup>();
   for (Map.Entry<String, Set<Server>> entry : serversByGroupName.entrySet()) {
     ServerGroup g = new ServerGroup(entry.getKey(), entry.getValue());
     serverGroups.add(g);
   }
   return new FabricStateResponse<Set<ServerGroup>>(serverGroups, response.getTtl());
 }