* @return the load average of the given instance.
* @throws java.sql.SQLException, if exception in writing to the database.
*/
public static double getLoadAverageFromInstances(String hostName, int serviceID) throws SQLException {
double loadAverage = -1;
LoadBalanceAgentServiceStub stub;
String serviceUrl;
// gets the instance and the service
try {
serviceUrl = "https://" + hostName + services + serviceName;
} catch (Exception e) {
if (log.isDebugEnabled()) {
log.debug("Unable to get the running application instances to get the " +
"load average", e);
}
return loadAverage;
}
// gets the load average of the service instance
try {
stub = new LoadBalanceAgentServiceStub(serviceUrl);
loadAverage = stub.getLoadAverage();
} catch (AxisFault e) {
MySQLConnector.insertStats(serviceID, false);
MySQLConnector.insertState(serviceID, false, e.getMessage());
String msg = "Invoking the Load Balance Agent Client Failed";
log.warn(msg, e);