// Request that each manager(s) stop.
for (int i = 0; i < managerArray.length; i++) {
// Get this manager.
Manager manager = (Manager)managerArray[i];
// Remove this manager from the list of managers.
// It will get added back in during manager.init().
callbackRegistry.removeFromManagerList(manager, this);
// Clear out the LogRegistry (which is used to check for duplicate
// log files).
LogUtils.clearManagersFromLogRegistry(manager);
// Request for the manager to stop running.
manager.stopRunningRequest(false);
}
// Wait for the managers to stop and restart.
for (int i = 0; i < managerArray.length; i++) {
// Get this manager.
Manager manager = (Manager)managerArray[i];
// Get the node from the existing manager and wait for it to stop.
Node mgrNode = manager.stopRunningWait();
// Re-initialize that manager with its node. If no sucess, retry.
try {
if (!manager.init(mgrNode, Xmultra.getXmultraRootDir(),
manager.getStartingManagersSyncFlag())) {
// There is an error so throw exception.
throw new InvalidConfigFileFormatException();
}
}
catch (InvalidConfigFileFormatException e) {
msgEntry.setAppContext("reloadProcessorConfigFile()");
msgEntry.setDocInfo(origConfigFile.toString());
msgEntry.setMessageText("Error in new config file. " +
"Reverting to previous config file. " +
"Bad config file moved to 'old' location.");
msgEntry.setError(e.getMessage());
logger.logWarning(msgEntry);
// Restore the original file.
restoreOriginalConfigFile(oldFile, origConfigFile, newConfigFile);
// Try to reload again.
try {
// Remove this manager from the list of managers.
// It will get added back in during manager.init().
callbackRegistry.removeFromManagerList(manager, this);
// Re-initialize the manager with original cfg file.
// If no sucess, give up.
if (!manager.init(mgrNode, Xmultra.getXmultraRootDir(),
manager.getStartingManagersSyncFlag())) {
// There is an error so throw exception.
throw new InvalidConfigFileFormatException();
}
}
catch (InvalidConfigFileFormatException ie) {
// Couldn't even reload the old config file.
msgEntry.setAppContext("reloadProcessorConfigFile()");
msgEntry.setDocInfo(configFile.toString());
msgEntry.setMessageText("'" + manager.getManagerDescription() +
"' unable to reload old config file!\nManager NOT reloaded.");
msgEntry.setError(e.getMessage());
logger.logWarning(msgEntry);
return null;
}
}
// Create & launch the thread.
Thread t = new Thread(manager, "Manager Thread");
t.start();
// Log message.
msgEntry.setAppContext("reloadProcessorConfigFile()");
msgEntry.setDocInfo(configFile.toString());
msgEntry.setMessageText("'" + manager.getManagerDescription() +
"' Manager reloaded.");
logger.logProcess(msgEntry);
}
// Delete new file now that reload is complete.