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();
}