[jboss-user] [Clustering/JBoss] - Re: Sever Failover

sboying do-not-reply at jboss.com
Thu May 17 17:43:42 EDT 2007


Is this just a matter of putting the "preferred server" definition in the jboss-service.xml and then implementing an interface to determine what server you are on? When I initially started down this path, I had written a small amount of code to compare the current server with a configured LDAP value to see if one is the preferred:

* PrimaryServer.java
 *
 */
package com.eds.sea.common.jmx.service.config;

import org.apache.log4j.Logger;
import java.io.*;

import com.eds.sea.common.jmx.service.config.*;

public class PrimaryServer
{
   public PrimaryServer() {}

   public static boolean IsPrimary(String complex)
   {   
       try
       {
    	  String currServer  = null;
                  String outErrStr   = null;
    	  boolean rCode      = false;
    	  LDAPConfig lConfig = new LDAPConfig();
                  String priServer   = lConfig.getPrimaryServer(complex);
                  String cmd         = "/usr/bin/uname -n";  
    	  Logger.getLogger(PrimaryServer.class.getName()).info(cmd);
                  Process p               = Runtime.getRuntime().exec(cmd);
                  BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
                  BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));          

          while ((currServer = stdInput.readLine()) != null)
                System.out.println(currServer);

          while ((outErrStr = stdError.readLine()) != null)
                System.out.println(outErrStr);
          
          rCode = currServer.equalsIgnoreCase(priServer) ? true : false;
       }
       catch ( Exception e )
       {
          rCode = false;
          Logger.getLogger(PrimaryServer.class.getName()).error(e);
       }

       return rCode;
   }
}


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4046650#4046650

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4046650



More information about the jboss-user mailing list