You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by da...@apache.org on 2006/04/20 19:24:17 UTC
svn commit: r395648 - in /geronimo/branches/1.1/modules:
deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/
kernel/src/java/org/apache/geronimo/kernel/config/
kernel/src/test/org/apache/geronimo/kernel/config/
Author: dain
Date: Thu Apr 20 10:24:14 2006
New Revision: 395648
URL: http://svn.apache.org/viewcvs?rev=395648&view=rev
Log:
Rewrite of configuration manager reload
Removed reloaded and rewrite from LifecycleResults
Modified:
geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java
geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationModel.java
geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationStatus.java
geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/LifecycleException.java
geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/LifecycleResults.java
geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java
geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java
Modified: geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java?rev=395648&r1=395647&r2=395648&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java (original)
+++ geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java Thu Apr 20 10:24:14 2006
@@ -139,17 +139,9 @@
Artifact name = (Artifact) it.next();
updateStatus("Unloaded "+name);
}
- for (Iterator it = results.getReloaded().iterator(); it.hasNext();) {
- Artifact name = (Artifact) it.next();
- updateStatus("Reloaded "+name);
- }
for (Iterator it = results.getLoaded().iterator(); it.hasNext();) {
Artifact name = (Artifact) it.next();
updateStatus("Loaded "+name);
- }
- for (Iterator it = results.getRestarted().iterator(); it.hasNext();) {
- Artifact name = (Artifact) it.next();
- updateStatus("Restarted "+name);
}
for (Iterator it = results.getStarted().iterator(); it.hasNext();) {
Artifact name = (Artifact) it.next();
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationModel.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationModel.java?rev=395648&r1=395647&r2=395648&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationModel.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationModel.java Thu Apr 20 10:24:14 2006
@@ -35,7 +35,7 @@
public void addConfiguation(Artifact configurationId, Set loadParentIds, Set startParentIds) throws NoSuchConfigException {
Set startParents = getStatuses(startParentIds);
- // load parents are both the class parents and the service parents
+ // load parents are a superset of start parents
Set loadParents = new LinkedHashSet(startParents);
loadParents.addAll(getStatuses(loadParentIds));
@@ -70,6 +70,21 @@
return configurations.containsKey(configurationId);
}
+ public void upgradeConfiguration(Artifact existingId, Artifact newId, Set newLoadParentIds, Set newStartParentIds) throws NoSuchConfigException {
+ Set newStartParents = getStatuses(newStartParentIds);
+
+ // load parents are a superset of start parents
+ Set newLoadParents = new LinkedHashSet(newStartParents);
+ newLoadParents.addAll(getStatuses(newLoadParentIds));
+
+ ConfigurationStatus configurationStatus = (ConfigurationStatus) configurations.remove(existingId);
+ if (configurationStatus == null) {
+ throw new NoSuchConfigException(existingId);
+ }
+ configurations.put(newId, configurationStatus);
+ configurationStatus.upgrade(newId, newLoadParents, newStartParents);
+ }
+
public boolean isLoaded(Artifact configurationId) {
ConfigurationStatus configurationStatus = (ConfigurationStatus) configurations.get(configurationId);
if (configurationStatus != null) {
@@ -160,10 +175,10 @@
return configurationStatus.unload(gc);
}
- public LinkedHashSet reload(Artifact configurationId) throws NoSuchConfigException {
- ConfigurationStatus configurationStatus = (ConfigurationStatus) configurations.get(configurationId);
+ public LinkedHashSet reload(Artifact exitingConfigurationId) throws NoSuchConfigException {
+ ConfigurationStatus configurationStatus = (ConfigurationStatus) configurations.get(exitingConfigurationId);
if (configurationStatus == null) {
- throw new NoSuchConfigException(configurationId);
+ throw new NoSuchConfigException(exitingConfigurationId);
}
return configurationStatus.reload();
}
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationStatus.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationStatus.java?rev=395648&r1=395647&r2=395648&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationStatus.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationStatus.java Thu Apr 20 10:24:14 2006
@@ -26,9 +26,9 @@
* @version $Rev$ $Date$
*/
public class ConfigurationStatus {
- private final Artifact configurationId;
- private final Set loadParents;
- private final Set startParents;
+ private Artifact configurationId;
+ private final Set loadParents = new LinkedHashSet();
+ private final Set startParents = new LinkedHashSet();
private final LinkedHashSet loadChildren = new LinkedHashSet();
private final LinkedHashSet startChildren = new LinkedHashSet();
private boolean loaded = false;
@@ -44,8 +44,8 @@
throw new IllegalArgumentException("loadParents must contain all startParents");
}
this.configurationId = configId;
- this.loadParents = loadParents;
- this.startParents = startParents;
+ this.loadParents.addAll(loadParents);
+ this.startParents.addAll(startParents);
for (Iterator iterator = loadParents.iterator(); iterator.hasNext();) {
ConfigurationStatus loadParent = (ConfigurationStatus) iterator.next();
@@ -102,30 +102,40 @@
return userStarted;
}
- public boolean hasLoadDependencyOn(Artifact parentId) {
+
+ public void upgrade(Artifact newId, Set newLoadParents, Set newStartParents) {
+ this.configurationId = newId;
+
+ //
+ // remove links from the current parents to me
+ //
for (Iterator iterator = loadParents.iterator(); iterator.hasNext();) {
ConfigurationStatus loadParent = (ConfigurationStatus) iterator.next();
- if (loadParent.getConfigurationId().equals(parentId)) {
- return true;
- }
- if (loadParent.hasLoadDependencyOn(parentId)) {
- return true;
- }
+ loadParent.loadChildren.remove(this);
+ }
+ loadParents.clear();
+
+ for (Iterator iterator = startParents.iterator(); iterator.hasNext();) {
+ ConfigurationStatus startParent = (ConfigurationStatus) iterator.next();
+ startParent.startChildren.remove(this);
+ }
+ startChildren.clear();
+
+ //
+ // connect to to the new parents
+ //
+ this.loadParents.addAll(newLoadParents);
+ this.startParents.addAll(newStartParents);
+
+ for (Iterator iterator = loadParents.iterator(); iterator.hasNext();) {
+ ConfigurationStatus loadParent = (ConfigurationStatus) iterator.next();
+ loadParent.loadChildren.add(this);
}
- return false;
- }
- public boolean hasStartDependencyOn(Artifact parentId) {
for (Iterator iterator = startParents.iterator(); iterator.hasNext();) {
ConfigurationStatus startParent = (ConfigurationStatus) iterator.next();
- if (startParent.getConfigurationId().equals(parentId)) {
- return true;
- }
- if (startParent.hasStartDependencyOn(parentId)) {
- return true;
- }
+ startParent.startChildren.add(this);
}
- return false;
}
public LinkedHashSet load() {
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/LifecycleException.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/LifecycleException.java?rev=395648&r1=395647&r2=395648&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/LifecycleException.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/LifecycleException.java Thu Apr 20 10:24:14 2006
@@ -26,6 +26,11 @@
private final Artifact configurationId;
private final LifecycleResults lifecycleResults;
+ public LifecycleException(String command, Artifact configurationId, Throwable cause) {
+ this(command, configurationId, new LifecycleResults(), cause);
+ lifecycleResults.addFailed(configurationId, cause);
+ }
+
public LifecycleException(String command, Artifact configurationId, LifecycleResults lifecycleResults) {
this(command, configurationId, lifecycleResults, lifecycleResults.getFailedCause(configurationId));
}
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/LifecycleResults.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/LifecycleResults.java?rev=395648&r1=395647&r2=395648&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/LifecycleResults.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/LifecycleResults.java Thu Apr 20 10:24:14 2006
@@ -35,8 +35,6 @@
private final Set unloaded = new LinkedHashSet();
private final Set started = new LinkedHashSet();
private final Set stopped = new LinkedHashSet();
- private final Set restarted = new LinkedHashSet();
- private final Set reloaded = new LinkedHashSet();
private final Map failed = new LinkedHashMap();
/**
@@ -173,74 +171,6 @@
public void setStopped(Set stopped) {
this.stopped.clear();
this.stopped.addAll(stopped);
- }
-
- /**
- * Was the specified configuration restarted.
- * @param configurationId the configuration identifier
- * @return true if the specified configuration was restarted during the lifecycle operation
- */
- public boolean wasRestarted(Artifact configurationId) {
- return restarted.contains(configurationId);
- }
-
- /**
- * Gets the configuration identifiers (Artifact) of the configurations restarted.
- * @return the configuration identifiers (Artifact)
- */
- public Set getRestarted() {
- return Collections.unmodifiableSet(restarted);
- }
-
- /**
- * Adds a configuration the set of restarted configurations.
- * @param configurationId the configuration identifiers (Artifact)
- */
- public void addRestarted(Artifact configurationId) {
- restarted.add(configurationId);
- }
-
- /**
- * Clears the existing restarted set and add alls the specified configurations to the set
- * @param restarted the configuration identifiers (Artifact)
- */
- public void setRestarted(Set restarted) {
- this.restarted.clear();
- this.restarted.addAll(restarted);
- }
-
- /**
- * Was the specified configuration reloaded.
- * @param configurationId the configuration identifier
- * @return true if the specified configuration was reloaded during the lifecycle operation
- */
- public boolean wasReloaded(Artifact configurationId) {
- return reloaded.contains(configurationId);
- }
-
- /**
- * Gets the configuration identifiers (Artifact) of the configurations reloaded.
- * @return the configuration identifiers (Artifact)
- */
- public Set getReloaded() {
- return Collections.unmodifiableSet(reloaded);
- }
-
- /**
- * Adds a configuration the set of reloaded configurations.
- * @param configurationId the configuration identifiers (Artifact)
- */
- public void addReloaded(Artifact configurationId) {
- reloaded.add(configurationId);
- }
-
- /**
- * Clears the existing reloaded set and add alls the specified configurations to the set
- * @param reloaded the configuration identifiers (Artifact)
- */
- public void setReloaded(Set reloaded) {
- this.reloaded.clear();
- this.reloaded.addAll(reloaded);
}
/**
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java?rev=395648&r1=395647&r2=395648&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java Thu Apr 20 10:24:14 2006
@@ -27,6 +27,7 @@
import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
+import java.util.HashSet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -226,10 +227,8 @@
try {
configurationData = loadConfigurationData(configurationId, monitor);
} catch (Exception e) {
- LifecycleResults results = new LifecycleResults();
- results.addFailed(configurationId, e);
monitor.finished();
- throw new LifecycleException("load", configurationId, results);
+ throw new LifecycleException("load", configurationId, e);
}
// load the configuration
@@ -251,9 +250,8 @@
try {
loadDepthFirst(configurationData, configurationsToLoad, monitor);
} catch (Exception e) {
- results.addFailed(id, e);
monitor.finished();
- throw new LifecycleException("load", id, results);
+ throw new LifecycleException("load", id, e);
}
// load and start the unloaded the gbean for each configuration (depth first)
@@ -280,9 +278,8 @@
unload(configuration);
}
- results.addFailed(id, e);
monitor.finished();
- throw new LifecycleException("load", id, results);
+ throw new LifecycleException("load", id, e);
}
// update the status of the loaded configurations
@@ -335,40 +332,40 @@
protected void addNewConfigurationToModel(Configuration configuration) throws NoSuchConfigException {
configurationModel.addConfiguation(configuration.getId(),
- getLoadParentIds(configuration),
- getStartParentIds(configuration));
+ getConfigurationIds(getLoadParents(configuration)),
+ getConfigurationIds(getStartParents(configuration)));
configurations.put(configuration.getId(), configuration);
}
- private Set getLoadParentIds(Configuration configuration) {
- Set loadParentIds = getConfigurationIds(configuration.getClassParents());
+ private LinkedHashSet getLoadParents(Configuration configuration) {
+ LinkedHashSet loadParent = new LinkedHashSet(configuration.getClassParents());
for (Iterator iterator = configuration.getChildren().iterator(); iterator.hasNext();) {
Configuration childConfiguration = (Configuration) iterator.next();
- Set childLoadParentIds = getLoadParentIds(childConfiguration);
+ LinkedHashSet childLoadParent = getLoadParents(childConfiguration);
- // remove this configuration's id from the parent Ids since it will cause an infinite loop
- childLoadParentIds.remove(configuration.getId());
+ // remove this configuration from the parent Ids since it will cause an infinite loop
+ childLoadParent.remove(configuration);
- loadParentIds.addAll(childLoadParentIds);
+ loadParent.addAll(childLoadParent);
}
- return loadParentIds;
+ return loadParent;
}
- private Set getStartParentIds(Configuration configuration) {
- Set startParentIds = getConfigurationIds(configuration.getServiceParents());
+ private LinkedHashSet getStartParents(Configuration configuration) {
+ LinkedHashSet startParent = new LinkedHashSet(configuration.getServiceParents());
for (Iterator iterator = configuration.getChildren().iterator(); iterator.hasNext();) {
Configuration childConfiguration = (Configuration) iterator.next();
- Set childStartParentIds = getStartParentIds(childConfiguration);
+ LinkedHashSet childStartParent = getStartParents(childConfiguration);
- // remove this configuration's id from the parent Ids since it will cause an infinite loop
- childStartParentIds.remove(configuration.getId());
+ // remove this configuration from the parent Ids since it will cause an infinite loop
+ childStartParent.remove(configuration);
- startParentIds.addAll(childStartParentIds);
+ startParent.addAll(childStartParent);
}
- return startParentIds;
+ return startParent;
}
- private static Set getConfigurationIds(List configurations) {
+ private static LinkedHashSet getConfigurationIds(Collection configurations) {
LinkedHashSet configurationIds = new LinkedHashSet(configurations.size());
for (Iterator iterator = configurations.iterator(); iterator.hasNext();) {
Configuration configuration = (Configuration) iterator.next();
@@ -490,8 +487,6 @@
}
} catch (Exception e) {
monitor.failed(configurationId, e);
- results.addFailed(configurationId, e);
- results.setStarted(Collections.EMPTY_SET);
configurationModel.stop(id);
for (Iterator iterator = results.getStarted().iterator(); iterator.hasNext();) {
@@ -502,7 +497,7 @@
monitor.succeeded(configurationId);
}
monitor.finished();
- throw new LifecycleException("start", id, results);
+ throw new LifecycleException("start", id, e);
}
monitor.finished();
return results;
@@ -559,24 +554,26 @@
addConfigurationsToMonitor(monitor, restartList);
// stop the configuations
+ LifecycleResults results = new LifecycleResults();
for (Iterator iterator = restartList.iterator(); iterator.hasNext();) {
Artifact configurationId = (Artifact) iterator.next();
Configuration configuration = getConfiguration(configurationId);
monitor.stopping(configurationId);
stop(configuration);
monitor.succeeded(configurationId);
+ results.addStopped(configurationId);
}
// reverse the list
restartList = reverse(restartList);
// restart the configurations
- LifecycleResults results = new LifecycleResults();
+ Set skip = new HashSet();
for (Iterator iterator = restartList.iterator(); iterator.hasNext();) {
Artifact configurationId = (Artifact) iterator.next();
- // skip the configurations that have alredy failed or were stopped
- if (results.wasFailed(configurationId) || results.wasStopped(configurationId)) {
+ // skip the configurations that have alredy failed or are children of failed configurations
+ if (skip.contains(configurationId)) {
continue;
}
@@ -586,11 +583,12 @@
monitor.starting(configurationId);
start(configuration);
monitor.succeeded(configurationId);
- results.addRestarted(configurationId);
+ results.addStarted(configurationId);
} catch (Exception e) {
// the configuraiton failed to restart
results.addFailed(configurationId, e);
monitor.failed(configurationId, e);
+ skip.add(configurationId);
// officially stop the configuration in the model (without gc)
LinkedHashSet stopList = configurationModel.stop(configurationId, false);
@@ -606,19 +604,17 @@
// if any of the failed configuration is in the restarted set, the model is
// corrupt because we started a child before a parent
- if (results.wasRestarted(failedId)) {
+ if (results.wasStarted(failedId)) {
throw new AssertionError("Configuration data model is corrupt. You must restart your server.");
}
- if (!results.wasFailed(failedId)) {
- results.addStopped(failedId);
- }
+ skip.add(failedId);
}
}
}
monitor.finished();
- if (!results.wasRestarted(id)) {
+ if (!results.wasStarted(id)) {
throw new LifecycleException("restart", id, results);
}
return results;
@@ -705,10 +701,8 @@
try {
configurationData = loadConfigurationData(newId, monitor);
} catch (Exception e) {
- LifecycleResults results = new LifecycleResults();
- results.addFailed(id, e);
monitor.finished();
- throw new LifecycleException("reload", id, results);
+ throw new LifecycleException("reload", id, e);
}
return reloadConfiguration(existingUnloadedConfiguration, configurationData, monitor);
@@ -728,41 +722,100 @@
return reloadConfiguration(existingUnloadedConfiguration, configurationData, monitor);
}
+ private boolean hasHardDependency(Artifact configurationId, ConfigurationData configurationData) {
+ for (Iterator iterator = configurationData.getEnvironment().getDependencies().iterator(); iterator.hasNext();) {
+ Dependency dependency = (Dependency) iterator.next();
+ Artifact artifact = dependency.getArtifact();
+ if (artifact.getVersion() != null && artifact.matches(configurationId)) {
+ return true;
+ }
+ }
+
+ for (Iterator iterator = configurationData.getChildConfigurations().values().iterator(); iterator.hasNext();) {
+ ConfigurationData childConfigurationData = (ConfigurationData) iterator.next();
+ if (hasHardDependency(configurationId, childConfigurationData)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ // todo this method ignores garbage collection of configurations
private LifecycleResults reloadConfiguration(UnloadedConfiguration existingUnloadedConfiguration, ConfigurationData newConfigurationData, LifecycleMonitor monitor) throws LifecycleException, NoSuchConfigException {
- LifecycleResults results = new LifecycleResults();
+ boolean force = false;
- // recursively load configurations from the reloaded child to the parents
- // this will catch any new parents
- LinkedHashMap unloadedConfigurations = new LinkedHashMap();
+ Artifact existingConfigurationId = existingUnloadedConfiguration.getConfigurationData().getId();
+ Artifact newConfigurationId = newConfigurationData.getId();
+
+ //
+ // recursively load the new configuration; this will catch any new parents
+ //
+ LinkedHashMap newConfigurations = new LinkedHashMap();
try {
- loadDepthFirst(newConfigurationData, unloadedConfigurations, monitor);
+ loadDepthFirst(newConfigurationData, newConfigurations, monitor);
} catch (Exception e) {
- results.addFailed(newConfigurationData.getId(), e);
monitor.finished();
- throw new LifecycleException("load", newConfigurationData.getId(), results);
+ throw new LifecycleException("reload", newConfigurationId, e);
}
- // get a list of the started configuration
+ //
+ // get a list of the started configuration, so we can restart them later
+ //
Set started = configurationModel.getStarted();
- // add all of the child configurations that we will need to reload to the unloaded map
+ //
+ // get a list of the child configurations that will need to reload
+ //
// note: we are iterating in reverse order
- for (Iterator iterator = reverse(configurationModel.reload(newConfigurationData.getId())).iterator(); iterator.hasNext();) {
+ LinkedHashMap existingParents = new LinkedHashMap();
+ LinkedHashMap reloadChildren = new LinkedHashMap();
+ for (Iterator iterator = reverse(configurationModel.reload(existingConfigurationId)).iterator(); iterator.hasNext();) {
Artifact configurationId = (Artifact) iterator.next();
- if (unloadedConfigurations.containsKey(configurationId)) {
+
+ if (configurationId.equals(existingConfigurationId)) {
continue;
}
+ // if new configurations contains the child something we have a circular dependency
+ if (newConfigurations.containsKey(configurationId)) {
+ throw new LifecycleException("reload", newConfigurationId,
+ new IllegalStateException("Circular depenency between " + newConfigurationId + " and " + configurationId));
+ }
+
Configuration configuration = getConfiguration(configurationId);
- ConfigurationData data = configuration.getConfigurationData();
- LinkedHashSet resolvedParentIds = getResolvedParentIds(configuration);
- unloadedConfigurations.put(configurationId, new UnloadedConfiguration(data, resolvedParentIds));
+ ConfigurationData configurationData = configuration.getConfigurationData();
+
+ // save off the exising resolved parent ids in case we need to restore this configuration
+ LinkedHashSet existingParentIds = getResolvedParentIds(configuration);
+ existingParents.put(configurationId, existingParentIds);
+
+ // check that the child doen't have a hard dependency on the old configuration
+ LinkedHashSet resolvedParentIds = null;
+ if (hasHardDependency(existingConfigurationId, configurationData)) {
+ if (force) {
+ throw new LifecycleException("reload", newConfigurationId,
+ new IllegalStateException("Existing configuration " + configurationId + " has a hard dependency on the current version of this configuration " + existingConfigurationId));
+ }
+
+ // we leave the resolved parent ids null to signal that we should not reload the configuration
+ resolvedParentIds = null;
+ } else {
+ resolvedParentIds = new LinkedHashSet(existingParentIds);
+ resolvedParentIds.remove(existingConfigurationId);
+ resolvedParentIds.add(newConfigurationId);
+ }
+
+ reloadChildren.put(configurationId, new UnloadedConfiguration(configurationData, resolvedParentIds));
monitor.addConfiguration(configurationId);
}
- // unload the configuations
- // note: we are iterating in reverse order
- for (Iterator iterator = reverse(unloadedConfigurations).keySet().iterator(); iterator.hasNext();) {
+ //
+ // unload the children
+ //
+
+ // note: we are iterating in reverse order
+ LifecycleResults results = new LifecycleResults();
+ for (Iterator iterator = reverse(reloadChildren).keySet().iterator(); iterator.hasNext();) {
Artifact configurationId = (Artifact) iterator.next();
Configuration configuration = getConfiguration(configurationId);
@@ -771,7 +824,7 @@
monitor.stopping(configurationId);
stop(configuration);
monitor.succeeded(configurationId);
- results.addRestarted(configurationId);
+ results.addStopped(configurationId);
} else {
// call stop just to be sure the beans aren't running
stop(configuration);
@@ -781,127 +834,289 @@
monitor.unloading(configurationId);
unload(configuration);
monitor.succeeded(configurationId);
+ results.addUnloaded(configurationId);
+ }
+
+ //
+ // unload the existing config
+ //
+ Configuration existingConfiguration = getConfiguration(existingConfigurationId);
+ if (started.contains(existingConfigurationId)) {
+ monitor.stopping(existingConfigurationId);
+ stop(existingConfiguration);
+ monitor.succeeded(existingConfigurationId);
+ results.addStopped(existingConfigurationId);
+ } else {
+ // call stop just to be sure the beans aren't running
+ stop(existingConfiguration);
+ }
+ monitor.unloading(existingConfigurationId);
+ unload(existingConfiguration);
+ monitor.succeeded(existingConfigurationId);
+ results.addUnloaded(existingConfigurationId);
+
+ //
+ // load the new configurations
+ //
+ boolean reinstatedExisting = false;
+ /* reduce variable scope */ {
+ Map loadedParents = new LinkedHashMap();
+ Map startedParents = new LinkedHashMap();
+ Configuration newConfiguration = null;
+ Artifact configurationId = null;
+ try {
+ //
+ // load all of the new configurations
+ //
+ for (Iterator iterator = newConfigurations.entrySet().iterator(); iterator.hasNext();) {
+ Map.Entry entry = (Map.Entry) iterator.next();
+ configurationId = (Artifact) entry.getKey();
+ UnloadedConfiguration unloadedConfiguration = (UnloadedConfiguration) entry.getValue();
+
+ monitor.loading(configurationId);
+ Configuration configuration = load(unloadedConfiguration.getConfigurationData(), unloadedConfiguration.getResolvedParentIds(), loadedParents);
+ monitor.succeeded(configurationId);
+
+ if (configurationId.equals(newConfigurationId)) {
+ newConfiguration = configuration;
+ } else {
+ loadedParents.put(configurationId, configuration);
+ }
+ }
+
+ if (newConfiguration == null) {
+ AssertionError cause = new AssertionError("Internal error: configuration was not load");
+ results.addFailed(newConfigurationId, cause);
+ throw new LifecycleException("reload", newConfigurationId, results);
+ }
+
+ //
+ // start the new configurations if the old one was running
+ //
+ if (started.contains(existingConfigurationId)) {
+
+ // determine which of the parents we need to start
+ LinkedHashSet startList = new LinkedHashSet();
+ for (Iterator iterator = getStartParents(newConfiguration).iterator(); iterator.hasNext();) {
+ Configuration serviceParent = (Configuration) iterator.next();
+ if (loadedParents.containsKey(serviceParent.getId())) {
+ startList.add(serviceParent);
+ }
+ }
+
+ // start the new parents
+ for (Iterator iterator = startList.iterator(); iterator.hasNext();) {
+ Configuration startParent = (Configuration) iterator.next();
+ monitor.starting(configurationId);
+ start(startParent);
+ monitor.succeeded(configurationId);
+
+ startedParents.put(configurationId, startParent);
+ }
+
+ // start the new configuration
+ monitor.starting(newConfigurationId);
+ start(newConfiguration);
+ monitor.succeeded(newConfigurationId);
+ }
+
+ //
+ // update the results
+ //
+ results.setLoaded(loadedParents.keySet());
+ results.addLoaded(newConfigurationId);
+ if (started.contains(existingConfigurationId)) {
+ results.setStarted(startedParents.keySet());
+ results.addStarted(newConfigurationId);
+ }
+
+ //
+ // update the model
+ //
+
+ // add all of the new configurations the model
+ addNewConfigurationsToModel(loadedParents);
+
+ // now ugrade the existing node in the model
+ configurationModel.upgradeConfiguration(existingConfigurationId,
+ newConfigurationId,
+ getConfigurationIds(getLoadParents(newConfiguration)),
+ getConfigurationIds(getStartParents(newConfiguration)));
+
+ // replace the configuraiton in he configurations map
+ configurations.remove(existingConfiguration);
+ configurations.put(newConfigurationId, newConfiguration);
+ } catch (Exception e) {
+ monitor.failed(configurationId, e);
+ results.addFailed(configurationId, e);
+
+ //
+ // stop and unload all configurations that were actually loaded
+ //
+ for (Iterator iterator = startedParents.values().iterator(); iterator.hasNext();) {
+ Configuration configuration = (Configuration) iterator.next();
+ stop(configuration);
+ }
+ for (Iterator iterator = loadedParents.values().iterator(); iterator.hasNext();) {
+ Configuration configuration = (Configuration) iterator.next();
+ unload(configuration);
+ }
+
+ // stop and unload the newConfiguration
+ if (newConfiguration != null) {
+ stop(newConfiguration);
+ unload(newConfiguration);
+ }
+
+ //
+ // atempt to reinstate the old configuation
+ //
+ Configuration configuration = null;
+ try {
+ configuration = load(existingUnloadedConfiguration.getConfigurationData(),
+ existingUnloadedConfiguration.getResolvedParentIds(),
+ Collections.EMPTY_MAP);
+
+ // if the configuration was started before restart it
+ if (started.contains(existingConfigurationId)) {
+ start(configuration);
+ results.addStarted(existingConfigurationId);
+ }
+
+ // don't mark as loded until start completes as it may thorw an exception
+ results.addLoaded(existingConfigurationId);
+
+ configurations.put(existingConfigurationId, configuration);
+
+ reinstatedExisting = true;
+ } catch (Exception ignored) {
+ monitor.failed(existingConfigurationId, e);
+
+ // we tried our best
+ if (configuration != null) {
+ unload(configuration);
+ }
+
+ //
+ // cleanup the model
+ //
+ for (Iterator iterator = results.getUnloaded().iterator(); iterator.hasNext();) {
+ Artifact childId = (Artifact) iterator.next();
+ configurationModel.unload(childId);
+ configurationModel.removeConfiguration(childId);
+ configurations.remove(childId);
+ }
+
+ throw new LifecycleException("reload", newConfigurationId, results);
+ }
+ }
}
- // reload the configurations
- Map actuallyLoaded = new LinkedHashMap(unloadedConfigurations.size());
- for (Iterator iterator = unloadedConfigurations.entrySet().iterator(); iterator.hasNext();) {
+ //
+ // reload as many child configurations as possible
+ //
+ Set skip = new HashSet();
+ for (Iterator iterator = reloadChildren.entrySet().iterator(); iterator.hasNext();) {
Map.Entry entry = (Map.Entry) iterator.next();
Artifact configurationId = (Artifact) entry.getKey();
UnloadedConfiguration unloadedConfiguration = (UnloadedConfiguration) entry.getValue();
- // skip the configurations that have alredy failed or were stopped
- if (results.wasFailed(configurationId) || results.wasStopped(configurationId)) {
+ // skip the configurations that have alredy failed or are children of failed configurations
+ if (skip.contains(configurationId)) {
continue;
}
// try to load the configuation
Configuration configuration = null;
try {
- monitor.loading(configurationId);
- configuration = load(unloadedConfiguration.getConfigurationData(), unloadedConfiguration.getResolvedParentIds(), actuallyLoaded);
- monitor.succeeded(configurationId);
-
- results.addReloaded(configurationId);
+ // get the correct resolved parent ids based on if we are loading with the new config id or the existing one
+ LinkedHashSet resolvedParentIds;
+ if (!reinstatedExisting) {
+ resolvedParentIds = unloadedConfiguration.getResolvedParentIds();
+ } else {
+ resolvedParentIds = (LinkedHashSet) existingParents.get(configurationId);
+ }
- // if the configuration was started before restart it
- if (started.contains(configurationId)) {
- monitor.starting(configurationId);
- start(configuration);
+ // if the resolved parent ids is null, then we are not supposed to reload this configuration
+ if (resolvedParentIds != null) {
+ monitor.loading(configurationId);
+ configuration = load(unloadedConfiguration.getConfigurationData(), resolvedParentIds, Collections.EMPTY_MAP);
monitor.succeeded(configurationId);
- results.addRestarted(configurationId);
- }
- actuallyLoaded.put(configurationId, configuration);
- configurations.put(configurationId, configuration);
+
+ // if the configuration was started before restart it
+ if (started.contains(configurationId)) {
+ monitor.starting(configurationId);
+ start(configuration);
+ monitor.succeeded(configurationId);
+ results.addStarted(configurationId);
+ }
+
+ // don't mark as loded until start completes as it may thow an exception
+ results.addLoaded(configurationId);
+
+ configurations.put(configurationId, configuration);
+ } else {
+ configurationModel.removeConfiguration(configurationId);
+ configurations.remove(configurationId);
+ }
} catch (Exception e) {
// the configuraiton failed to restart
results.addFailed(configurationId, e);
monitor.failed(configurationId, e);
+ skip.add(configurationId);
// unload the configuration if it was loaded and failed in start
if (configuration != null) {
unload(configuration);
}
- // if this is root configuration, attempt to reinstate the original configuration
- boolean reinstatedExisting = false;
- if (configurationId.equals(newConfigurationData.getId())) {
- configuration = null;
- try {
- configuration = load(existingUnloadedConfiguration.getConfigurationData(),
- existingUnloadedConfiguration.getResolvedParentIds(),
- actuallyLoaded);
-
- results.addReloaded(configurationId);
-
- // if the configuration was started before restart it
- if (started.contains(configurationId)) {
- start(configuration);
- results.addRestarted(configurationId);
- }
-
- actuallyLoaded.put(configurationId, configuration);
- configurations.put(configurationId, configuration);
+ // officially unload the configuration in the model (without gc)
+ LinkedHashSet unloadList = configurationModel.unload(configurationId, false);
+ configurationModel.removeConfiguration(configurationId);
- reinstatedExisting = true;
- } catch (Exception ignored) {
- // we tried our best
- if (configuration != null) {
- unload(configuration);
- }
- }
+ // all of the configurations to be unloaded must be in our unloaded list, or the model is corrupt
+ if (!reloadChildren.keySet().containsAll(unloadList)) {
+ throw new AssertionError("Configuration data model is corrupt. You must restart your server.");
}
- if (!reinstatedExisting) {
- // officially unload the configuration in the model (without gc)
- LinkedHashSet unloadList = configurationModel.unload(configurationId, false);
- configurationModel.removeConfiguration(configurationId);
+ // add the children of the failed configuration to the results as unloaded
+ for (Iterator iterator1 = unloadList.iterator(); iterator1.hasNext();) {
+ Artifact failedId = (Artifact) iterator1.next();
- // all of the configurations to be unloaded must be in our unloaded list, or the model is corrupt
- if (!unloadedConfigurations.keySet().containsAll(unloadList)) {
+ // if any of the failed configuration are in the reloaded set, the model is
+ // corrupt because we loaded a child before a parent
+ if (results.wasLoaded(failedId)) {
throw new AssertionError("Configuration data model is corrupt. You must restart your server.");
}
- // add the children of the failed configuration to the results as unloaded
- for (Iterator iterator1 = unloadList.iterator(); iterator1.hasNext();) {
- Artifact failedId = (Artifact) iterator1.next();
-
- // if any of the failed configuration is in the reloaded set, the model is
- // corrupt because we loaded a child before a parent
- if (results.wasLoaded(failedId)) {
- throw new AssertionError("Configuration data model is corrupt. You must restart your server.");
- }
-
- if (!results.wasFailed(failedId)) {
- results.addUnloaded(failedId);
- if (started.contains(configurationId)) {
- results.addStopped(failedId);
- }
- }
- }
+ skip.add(failedId);
}
}
}
monitor.finished();
- if (results.wasFailed(newConfigurationData.getId()) || !results.wasReloaded(newConfigurationData.getId())) {
- throw new LifecycleException("reload", newConfigurationData.getId(), results);
+ if (results.wasFailed(newConfigurationId) || !results.wasLoaded(newConfigurationId)) {
+ throw new LifecycleException("restart", newConfigurationId, results);
}
-
return results;
}
private static LinkedHashSet getResolvedParentIds(Configuration configuration) {
LinkedHashSet resolvedParentIds = new LinkedHashSet();
- for (Iterator iterator1 = configuration.getClassParents().iterator(); iterator1.hasNext();) {
- Configuration classParent = (Configuration) iterator1.next();
+ for (Iterator iterator = configuration.getClassParents().iterator(); iterator.hasNext();) {
+ Configuration classParent = (Configuration) iterator.next();
resolvedParentIds.add(classParent.getId());
}
- for (Iterator iterator1 = configuration.getServiceParents().iterator(); iterator1.hasNext();) {
- Configuration serviceParent = (Configuration) iterator1.next();
+ for (Iterator iterator = configuration.getServiceParents().iterator(); iterator.hasNext();) {
+ Configuration serviceParent = (Configuration) iterator.next();
resolvedParentIds.add(serviceParent.getId());
}
+ for (Iterator iterator = configuration.getChildren().iterator(); iterator.hasNext();) {
+ Configuration child = (Configuration) iterator.next();
+ resolvedParentIds.addAll(getResolvedParentIds(child));
+ }
+
return resolvedParentIds;
}
Modified: geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java?rev=395648&r1=395647&r2=395648&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java Thu Apr 20 10:24:14 2006
@@ -159,12 +159,29 @@
assertSame(g2, kernel.getGBean(gbean2));
assertSame(g3, kernel.getGBean(gbean3));
+ //
+ // restart artifact1 which should cascade to the children
+ //
LifecycleResults results = configurationManager.restartConfiguration(artifact1);
- // check the results
- assertTrue(results.wasRestarted(artifact1));
- assertTrue(results.wasRestarted(artifact2));
- assertTrue(results.wasRestarted(artifact3));
+ // all three should have been stopped and then started
+ assertTrue(results.wasStopped(artifact1));
+ assertTrue(results.wasStopped(artifact2));
+ assertTrue(results.wasStopped(artifact3));
+ assertTrue(results.wasStarted(artifact1));
+ assertTrue(results.wasStarted(artifact2));
+ assertTrue(results.wasStarted(artifact3));
+
+ // none of them should have been unloaded, loaded or failed
+ assertFalse(results.wasUnloaded(artifact1));
+ assertFalse(results.wasUnloaded(artifact2));
+ assertFalse(results.wasUnloaded(artifact3));
+ assertFalse(results.wasLoaded(artifact1));
+ assertFalse(results.wasLoaded(artifact2));
+ assertFalse(results.wasLoaded(artifact3));
+ assertFalse(results.wasFailed(artifact1));
+ assertFalse(results.wasFailed(artifact2));
+ assertFalse(results.wasFailed(artifact3));
// check the state of the kernel
assertTrue(kernel.isLoaded(Configuration.getConfigurationAbstractName(artifact3))) ;
@@ -218,10 +235,26 @@
shouldFail.add(gbean3.getObjectName().getCanonicalName());
LifecycleResults results = configurationManager.restartConfiguration(artifact1);
- // check the results
- assertTrue(results.wasRestarted(artifact1));
- assertTrue(results.wasRestarted(artifact2));
+ // 3 should have been stopped and failed, but not started
+ assertTrue(results.wasStopped(artifact3));
assertTrue(results.wasFailed(artifact3));
+ assertFalse(results.wasStarted(artifact3));
+
+ // one and two shoudld have stopped and then started and not failed
+ assertTrue(results.wasStopped(artifact1));
+ assertTrue(results.wasStopped(artifact2));
+ assertTrue(results.wasStarted(artifact1));
+ assertTrue(results.wasStarted(artifact2));
+ assertFalse(results.wasFailed(artifact1));
+ assertFalse(results.wasFailed(artifact2));
+
+ // none of them should have been unloaded or loaded
+ assertFalse(results.wasUnloaded(artifact1));
+ assertFalse(results.wasUnloaded(artifact2));
+ assertFalse(results.wasUnloaded(artifact3));
+ assertFalse(results.wasLoaded(artifact1));
+ assertFalse(results.wasLoaded(artifact2));
+ assertFalse(results.wasLoaded(artifact3));
// all configuration should be loaded
assertTrue(configurationManager.isLoaded(artifact3));
@@ -271,12 +304,24 @@
LifecycleResults results = configurationManager.reloadConfiguration(artifact1);
// check the results
- assertTrue(results.wasReloaded(artifact1));
- assertTrue(results.wasReloaded(artifact2));
- assertTrue(results.wasReloaded(artifact3));
- assertTrue(results.wasRestarted(artifact1));
- assertTrue(results.wasRestarted(artifact2));
- assertTrue(results.wasRestarted(artifact3));
+ // all three should have been stopped, unloaded, loaded and then started
+ assertTrue(results.wasStopped(artifact1));
+ assertTrue(results.wasStopped(artifact2));
+ assertTrue(results.wasStopped(artifact3));
+ assertTrue(results.wasUnloaded(artifact1));
+ assertTrue(results.wasUnloaded(artifact2));
+ assertTrue(results.wasUnloaded(artifact3));
+ assertTrue(results.wasLoaded(artifact1));
+ assertTrue(results.wasLoaded(artifact2));
+ assertTrue(results.wasLoaded(artifact3));
+ assertTrue(results.wasStarted(artifact1));
+ assertTrue(results.wasStarted(artifact2));
+ assertTrue(results.wasStarted(artifact3));
+
+ // none of them should have been failed
+ assertFalse(results.wasFailed(artifact1));
+ assertFalse(results.wasFailed(artifact2));
+ assertFalse(results.wasFailed(artifact3));
// check the state of the configuration manager
assertTrue(configurationManager.isLoaded(artifact1));
@@ -338,12 +383,23 @@
LifecycleResults results = configurationManager.reloadConfiguration(artifact1);
// check the results
- assertTrue(results.wasReloaded(artifact1));
- assertTrue(results.wasReloaded(artifact2));
- assertTrue(results.wasReloaded(artifact3));
- assertTrue(results.wasRestarted(artifact1));
- assertTrue(results.wasRestarted(artifact2));
- assertTrue(results.wasRestarted(artifact3));
+
+ // 3 should have been stopped, unloaded and then failed
+ assertTrue(results.wasStopped(artifact3));
+ assertTrue(results.wasUnloaded(artifact3));
+ assertTrue(results.wasFailed(artifact3));
+ assertFalse(results.wasLoaded(artifact3));
+ assertFalse(results.wasStarted(artifact3));
+
+ // 1 and 2 should have been stopped, unloaded, loaded and then started
+ assertTrue(results.wasStopped(artifact1));
+ assertTrue(results.wasStopped(artifact2));
+ assertTrue(results.wasUnloaded(artifact1));
+ assertTrue(results.wasUnloaded(artifact2));
+ assertTrue(results.wasLoaded(artifact1));
+ assertTrue(results.wasLoaded(artifact2));
+ assertTrue(results.wasStarted(artifact1));
+ assertTrue(results.wasStarted(artifact2));
// all configuration except 3 should be loaded
assertFalse(configurationManager.isLoaded(artifact3));
@@ -406,13 +462,23 @@
}
// check the results
+
+ // 1 should be failed
assertTrue(results.wasFailed(artifact1));
- assertTrue(results.wasReloaded(artifact1));
- assertTrue(results.wasReloaded(artifact2));
- assertTrue(results.wasReloaded(artifact3));
- assertTrue(results.wasRestarted(artifact1));
- assertTrue(results.wasRestarted(artifact2));
- assertTrue(results.wasRestarted(artifact3));
+
+ // but all three did stop, unload, load and start
+ assertTrue(results.wasStopped(artifact1));
+ assertTrue(results.wasStopped(artifact2));
+ assertTrue(results.wasStopped(artifact3));
+ assertTrue(results.wasUnloaded(artifact1));
+ assertTrue(results.wasUnloaded(artifact2));
+ assertTrue(results.wasUnloaded(artifact3));
+ assertTrue(results.wasLoaded(artifact1));
+ assertTrue(results.wasLoaded(artifact2));
+ assertTrue(results.wasLoaded(artifact3));
+ assertTrue(results.wasStarted(artifact1));
+ assertTrue(results.wasStarted(artifact2));
+ assertTrue(results.wasStarted(artifact3));
// check the state of the configuration manager
assertTrue(configurationManager.isLoaded(artifact1));
@@ -462,7 +528,7 @@
assertFalse(kernel.isLoaded(Configuration.getConfigurationAbstractName(artifact1))) ;
}
- public void DAIN_FIX_ME_testReloadNewerConfiguration() throws Exception {
+ public void testReloadNewerConfiguration() throws Exception {
configurationManager.loadConfiguration(artifact3);
configurationManager.startConfiguration(artifact3);
Object g1 = kernel.getGBean(gbean1);
@@ -483,16 +549,22 @@
LifecycleResults results = configurationManager.reloadConfiguration(artifact1);
// check the results
- assertTrue(results.wasReloaded(artifact1));
- assertTrue(results.wasReloaded(artifact2));
- assertTrue(results.wasReloaded(artifact3));
- assertTrue(results.wasRestarted(artifact1));
- assertTrue(results.wasRestarted(artifact2));
- assertTrue(results.wasRestarted(artifact3));
+ assertTrue(results.wasStopped(artifact1));
+ assertTrue(results.wasStopped(artifact2));
+ assertTrue(results.wasStopped(artifact3));
+ assertTrue(results.wasUnloaded(artifact1));
+ assertTrue(results.wasUnloaded(artifact2));
+ assertTrue(results.wasUnloaded(artifact3));
+ assertTrue(results.wasLoaded(artifact1));
+ assertTrue(results.wasLoaded(artifact2));
+ assertTrue(results.wasLoaded(artifact3));
+ assertTrue(results.wasStarted(artifact1));
+ assertTrue(results.wasStarted(artifact2));
+ assertTrue(results.wasStarted(artifact3));
assertFalse(results.wasFailed(artifact3NoVersion));
assertFalse(results.wasLoaded(artifact3NoVersion));
- assertFalse(results.wasReloaded(artifact3NoVersion));
- assertFalse(results.wasRestarted(artifact3NoVersion));
+ assertFalse(results.wasLoaded(artifact3NoVersion));
+ assertFalse(results.wasStarted(artifact3NoVersion));
assertFalse(results.wasStarted(artifact3NoVersion));
assertFalse(results.wasStopped(artifact3NoVersion));
assertFalse(results.wasUnloaded(artifact3NoVersion));
@@ -529,20 +601,33 @@
assertNotSame(g2, kernel.getGBean(gbean2));
assertNotSame(g3, kernel.getGBean(gbean3));
+ //
// Reload a newer version of artifact3 (artifact3NoVersion, which has a timestamp as the version number)
+ //
results = configurationManager.reloadConfiguration(artifact3, artifact3NoVersion.getVersion());
- assertFalse(results.wasReloaded(artifact1));
- assertFalse(results.wasReloaded(artifact2));
- // Question: should the name with the old version be listed as reloaded,
- // or the name with the new version, or both?
- assertTrue(results.wasReloaded(artifact3)); // the old version running
- assertTrue(results.wasReloaded(artifact3NoVersion)); // the new version running
- assertFalse(results.wasRestarted(artifact1));
- assertFalse(results.wasRestarted(artifact2));
- // Question: should the name with the old version be listed as restarted,
- // or the name with the new version, or both?
- assertTrue(results.wasRestarted(artifact3)); // the old version running
- assertTrue(results.wasRestarted(artifact3NoVersion)); // the new version running
+
+ // artifact 3 should be stopped, unloaded and 3noVersion should have been loaded and started in it's place
+ assertTrue(results.wasStopped(artifact3));
+ assertTrue(results.wasUnloaded(artifact3));
+ assertTrue(results.wasLoaded(artifact3NoVersion));
+ assertTrue(results.wasStarted(artifact3NoVersion));
+ assertFalse(results.wasLoaded(artifact3));
+ assertFalse(results.wasStarted(artifact3));
+
+ // artifact 1 and 2 should not have been touched
+ assertFalse(results.wasStopped(artifact1));
+ assertFalse(results.wasStopped(artifact2));
+ assertFalse(results.wasUnloaded(artifact1));
+ assertFalse(results.wasUnloaded(artifact2));
+ assertFalse(results.wasLoaded(artifact1));
+ assertFalse(results.wasLoaded(artifact2));
+ assertFalse(results.wasStarted(artifact1));
+ assertFalse(results.wasStarted(artifact2));
+
+ // nothing should have failed
+ assertFalse(results.wasFailed(artifact1));
+ assertFalse(results.wasFailed(artifact2));
+ assertFalse(results.wasFailed(artifact3));
assertFalse(results.wasFailed(artifact3NoVersion));
// check the state of the configuration manager