FileDocCategorySizeDatePackage
StatusProber.javaAPI DocGlassfish v2 API8867Fri May 04 22:35:04 BST 2007com.sun.enterprise.launcher

StatusProber

public class StatusProber extends Object
Create a filter for Appserver to use commons launcher. This filter is used to parse out the jvm-options from server.xml and use it to launch the vm.
author
Ramesh Mandava (ramesh.mandava@sun.com)

Fields Summary
final String
domainConfigFilePath
Constructors Summary
public StatusProber(String configFilePath)

        this.domainConfigFilePath = configFilePath;
    
Methods Summary
public static voidmain(java.lang.String[] args)

        if ( args.length != 1 ) {
            System.out.println("Usage : java StatusProber <s1as-instanceRoot>" );
            System.exit (1 );
        }
        String instanceRoot = args[0];
        String domainConfigFilePath = instanceRoot + File.separator +
                "config" + File.separator +
                "domain.xml";
        new StatusProber( domainConfigFilePath);
            //System.out.println("Domain Config Path -> " +domainConfigFilePath);

    
public voidprobeStatus()

        try {

	    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
	    DocumentBuilder db = dbf.newDocumentBuilder();
                 
	    Document doc = db.parse(domainConfigFilePath );

	    Element root = doc.getDocumentElement();
            Element httpListenerElement = null;
	    String webserverHostname= null;
	    String webserverPort= null;
	    String adminserverHostname= null;
	    String adminserverPort= null;

            NodeList httpListeners = root.getElementsByTagName("http-listener");
            // for loop. PENDING : Error condition check 
            for ( int hl=0; hl<httpListeners.getLength(); hl++ ) {
                httpListenerElement = (Element)httpListeners.item(hl);
	        String server_id = httpListenerElement.getAttribute ("id");
                String server_name= httpListenerElement.getAttribute
                    ("server-name");
                String server_port= httpListenerElement.getAttribute
                    ("server-port");
                if ( server_id.equals("admin-listener") ) {
                    adminserverHostname = server_name;
                    adminserverPort = server_port;
                } else {
                    webserverHostname = server_name;
                    webserverPort = server_port;
                }

            }
            /*
            System.out.println("Web Server HostName => " + webserverHostname);
            System.out.println("Web Server Port => " + webserverPort);
            System.out.println("Admin Server HostName => "+adminserverHostname);
            System.out.println("Admin Server Port => " +adminserverPort);
            System.out.println("Trying to check the status of Web Server");
            */
            int webServerPort = new Integer( webserverPort ).intValue();
            int adminServerPort = new Integer( adminserverPort ).intValue();
            StatusChecker sc = new StatusChecker( webserverHostname,  webServerPort );
            boolean serverUp = sc.probeServer();
            if ( !serverUp ) {
                System.out.println("Error : Web Server is not up in specified time interval");
                return;
            }
            //System.out.println("Now trying to see if admin server is up");
            sc = new StatusChecker( adminserverHostname, adminServerPort );
            serverUp = sc.probeServer();
            if ( !serverUp ) {
                System.out.println("Error : Admin Server is not up in specified time interval");
            }
	} catch(Exception e) {
	    e.printStackTrace();
	}