Esempio n. 1
0
  /**
   * Will create a new ClusteredServer and add it to the hash map.
   *
   * @param domainName The domain name for the new server
   * @param directory The director for the new server.
   */
  public synchronized void addServer(String domainName, String directory) {
    if (domainName == null) {
      throw new IllegalArgumentException("The domainName cannot be null");
    }
    if (directory == null) {
      directory = "";
    }

    ClusteredServer server = createNewServer(domainName, directory);
    servers.put(server.getServerId(), server);
    statusChecker.addServer(server);
    log.debug(
        "Added server " + domainName + directory + " to the cluster on id " + server.getServerId());
  }
Esempio n. 2
0
  /**
   * Checks the request for any session. If there is a session created we make sure that the server
   * returned is the one the issued the session. If no session is included in the request we will
   * choose the next server in a round-robin fashion.
   *
   * @see net.sf.j2ep.model.ServerContainer#getServer(javax.servlet.http.HttpServletRequest)
   */
  public Server getServer(HttpServletRequest request) {
    String serverId = getServerIdFromCookie(request.getCookies());
    ClusteredServer server = (ClusteredServer) servers.get(serverId);
    if (server == null || !server.online()) {
      server = getNextServer();
    } else {
      log.debug("Server found in session");
    }

    if (server.online()) {
      log.debug("Using id " + server.getServerId() + " for this request");
    } else {
      log.error(
          "All the servers in this cluster are offline. Using id "
              + server.getServerId()
              + ", will probably not work");
    }
    return server;
  }
Esempio n. 3
0
 /**
  * Sets the server to online status. Will only handle servers that are ClusteredServers
  *
  * @see net.sf.j2ep.servers.ServerStatusListener#serverOnline(net.sf.j2ep.model.Server)
  */
 public void serverOnline(Server server) {
   if (server instanceof ClusteredServer) {
     ((ClusteredServer) server).setOnline(true);
   }
 }