* @param instanceName the server instance name. If the server instance does not exist
* a newly constructed RuntimeStatus (in a not running state) will be returned.
* @return The RuntimeStatus of the given server instance.
*/
public synchronized RuntimeStatus getStatus(String instanceName) {
RuntimeStatus result = (RuntimeStatus)get(instanceName);
if (result == null) {
result = new RuntimeStatus(instanceName);
result.setStatus(new Status(Status.kInstanceNotRunningCode));
put(result.getName(), result);
}
//If we are in the state of running or not running, then we need to ensure
//that our internal state is in sync with that of the admin channel. We need to
//avoid our internal state getting out of sync.
if (result.isRunning() || result.isStopped()) {
updateStatusFromAdminChannel(instanceName, result.getStatus().getStatusCode());
}
return result;
}