//We can only restart a process that is in the running state...Currently we have
//a problem in that on Unix platforms instance that are stopped gracefully
//exit with a non-zero return code if pinged by the ProcessManagerMonitor
//before being completely stopped. This can be reproduced by reducing the sleep
//time in the montior and stopping an instance gracefully -- it will be restarted.
RuntimeStatus status = InstanceStatus.getInstance().getStatus(pInstance.getName());
if (status.isStopped()) {
// set for observer to check status and to setChanged flag so notification will be sent
String clusterName = NodeAgentMain.getClusterName(pInstance.getName());
if (clusterName != null || !clusterName.equals("")) {
HashMap gmsMap = NodeAgentMain.getGMSHandleMap();
GroupManagementService gms = (GroupManagementService) gmsMap.get(clusterName);
if (gms != null) {
GroupHandle gh = gms.getGroupHandle();
try {
getLogger().log(Level.INFO, "GMS WATCHDOG notification to group:"+ clusterName + " that member:" +
pInstance.getName() + " has failed.");
gh.announceWatchdogObservedFailure(pInstance.getName());
} catch (Error e) {
getLogger().log(Level.FINE, "Exception is ", e);
}
}
}
pInstance.setExitCode(iExit);
// set process to null so ProcessManagerMonitor will
// set notify the ProcessManager again
// exitCode is already stored in ProcessInstance for restart check
pInstance.setProcess(null);
// notify the observers that something has changed after setting process to null
// our jvm uses the same thread to perform notification which is not guarented sematics
// but it was messing me up when it returned
// TODO: Currently the notification & restart will be done on the polling thread, need to put on another
// thread so in case of catastrophic failures, servers can be restarted faster ???
pInstance.notifyObservers();
} else {
getLogger().log(Level.FINE, "ProcessManager: did not restart" + pInstance.getName() +
" since it is " + status.getStatus().getStatusString() + " and not running.");
}
} catch (IllegalThreadStateException itse) {
// ignore, because it will be the normal case that the process has
// not returned.
getLogger().log(Level.FINEST, "exitValue exception returned - " + itse.toString());