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/09 00:28:52 UTC
svn commit: r392614 - in /geronimo/branches/1.1:
applications/console-standard/src/java/org/apache/geronimo/console/configmanager/
applications/console-standard/src/java/org/apache/geronimo/console/util/
modules/deploy-jsr88/src/java/org/apache/geronim...
Author: dain
Date: Sat Apr 8 15:28:47 2006
New Revision: 392614
URL: http://svn.apache.org/viewcvs?rev=392614&view=rev
Log:
Cleanup after start failure.
Add method to configuration manager which can determin if a configuration is running. This is the only way to know if a configuratio is running.
Remove artifact.toURI() as it is no longer used anywhere.
Removed:
geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/util/SecurityConstants.java
geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationDump.java
Modified:
geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java
geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java
geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationInfo.java
geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManager.java
geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java
geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java
geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java
geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Artifact.java
geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java
geronimo/branches/1.1/modules/service-builder/src/test/org/apache/geronimo/deployment/service/EnvironmentBuilderTest.java
geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/FileConfigurationList.java
geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
Modified: geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java?rev=392614&r1=392613&r2=392614&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java (original)
+++ geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java Sat Apr 8 15:28:47 2006
@@ -17,19 +17,14 @@
package org.apache.geronimo.console.configmanager;
-import org.apache.geronimo.console.BasePortlet;
-import org.apache.geronimo.console.util.SecurityConstants;
-import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.KernelRegistry;
-import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.kernel.config.Configuration;
-import org.apache.geronimo.kernel.config.ConfigurationInfo;
-import org.apache.geronimo.kernel.config.ConfigurationManager;
-import org.apache.geronimo.kernel.config.ConfigurationUtil;
-import org.apache.geronimo.kernel.config.InvalidConfigException;
-import org.apache.geronimo.kernel.config.NoSuchConfigException;
-import org.apache.geronimo.kernel.config.NoSuchStoreException;
-
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
import javax.management.ObjectName;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
@@ -39,15 +34,17 @@
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.WindowState;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Comparator;
-import java.util.Collections;
+
+import org.apache.geronimo.console.BasePortlet;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.KernelRegistry;
+import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.config.ConfigurationInfo;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
+import org.apache.geronimo.kernel.config.ConfigurationUtil;
+import org.apache.geronimo.kernel.config.InvalidConfigException;
+import org.apache.geronimo.kernel.config.NoSuchConfigException;
+import org.apache.geronimo.kernel.repository.Artifact;
public class ConfigManagerPortlet extends BasePortlet {
@@ -65,8 +62,6 @@
private static final String[] UNINSTALL_SIG = {URI.class.getName()};
- private static final String QUEUETOPIC_URI = "runtimedestination/";
-
private static final String CONFIG_INIT_PARAM = "config-type";
private String messageInstalled = "";
@@ -188,39 +183,18 @@
return actionRequest.getParameter("configId");
}
- protected void doView(RenderRequest renderRequest,
- RenderResponse renderResponse) throws IOException, PortletException {
+ protected void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
if (WindowState.MINIMIZED.equals(renderRequest.getWindowState())) {
return;
}
List configInfo = new ArrayList();
- ConfigurationManager configManager = ConfigurationUtil
- .getConfigurationManager(kernel);
- List stores = configManager.listStores();
- for (Iterator i = stores.iterator(); i.hasNext();) {
- ObjectName storeName = (ObjectName) i.next();
- try {
- List infos = configManager.listConfigurations(storeName);
- for (Iterator j = infos.iterator(); j.hasNext();) {
- ConfigurationInfo info = (ConfigurationInfo) j.next();
- if (shouldListConfig(info)) {
- // TODO: Check if this is the right solution
- // Disregard JMS Queues and Topics &&
- if (!info.getConfigID().toURI().getPath().startsWith(QUEUETOPIC_URI)
- && !info
- .getConfigID().toURI()
- .getPath()
- .startsWith(SecurityConstants.SECURITY_CONFIG_PREFIX)) {
- configInfo.add(info);
- }
- }
- }
- } catch (NoSuchStoreException e) {
- // we just got this list so this should not happen
- // in the unlikely event it does, just continue
- } catch (URISyntaxException e) {
- throw new AssertionError(e);
+ ConfigurationManager configManager = ConfigurationUtil.getConfigurationManager(kernel);
+ List infos = configManager.listConfigurations();
+ for (Iterator j = infos.iterator(); j.hasNext();) {
+ ConfigurationInfo info = (ConfigurationInfo) j.next();
+ if (shouldListConfig(info)) {
+ configInfo.add(info);
}
}
Collections.sort(configInfo, new Comparator() {
Modified: geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java?rev=392614&r1=392613&r2=392614&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java (original)
+++ geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java Sat Apr 8 15:28:47 2006
@@ -28,10 +28,9 @@
import org.apache.geronimo.kernel.config.ConfigurationManager;
import org.apache.geronimo.kernel.config.ConfigurationUtil;
import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.gbean.AbstractName;
/**
- *
- *
* @version $Rev: 383519 $ $Date$
*/
public class StartCommand extends CommandSupport {
@@ -53,35 +52,38 @@
// Check to see whether the module is already started
Artifact moduleID = Artifact.create(module.getModuleID());
- if(kernel.isRunning(Configuration.getConfigurationAbstractName(moduleID))) {
- updateStatus("Module "+moduleID+" is already running");
+ AbstractName abstractName = Configuration.getConfigurationAbstractName(moduleID);
+ String objectName = abstractName.getObjectName().getCanonicalName();
+ if (kernel.isRunning(abstractName)) {
+ updateStatus("Module " + moduleID + " is already running");
Thread.sleep(100);
continue;
}
- // Load and start the module
- Configuration configuration = configurationManager.loadConfiguration(moduleID);
- // todo review this -- start is recursive, but this is doing more than a recursive start
-// for (int j = 0; j < list.size(); j++) {
-// Artifact name = (Artifact) list.get(j);
- configurationManager.startConfiguration(configuration);
- String configName = configuration.getObjectName();
- List kids = loadChildren(kernel, configName);
- TargetModuleIDImpl id = new TargetModuleIDImpl(modules[i].getTarget(), configName,
- (String[]) kids.toArray(new String[kids.size()]));
- if(isWebApp(kernel, configName)) {
- id.setType(ModuleType.WAR);
- }
- if(id.getChildTargetModuleID() != null) {
- for (int k = 0; k < id.getChildTargetModuleID().length; k++) {
- TargetModuleIDImpl child = (TargetModuleIDImpl) id.getChildTargetModuleID()[k];
- if(isWebApp(kernel, child.getModuleID())) {
- child.setType(ModuleType.WAR);
- }
+ // Load
+ configurationManager.loadConfiguration(moduleID);
+
+ // Start
+ configurationManager.startConfiguration(moduleID);
+
+ // Determine the child modules of the configuration
+ List kids = loadChildren(kernel, objectName);
+
+ // Build a response obect containg the started configuration and a list of it's contained modules
+ TargetModuleIDImpl id = new TargetModuleIDImpl(modules[i].getTarget(), objectName,
+ (String[]) kids.toArray(new String[kids.size()]));
+ if (isWebApp(kernel, objectName)) {
+ id.setType(ModuleType.WAR);
+ }
+ if (id.getChildTargetModuleID() != null) {
+ for (int k = 0; k < id.getChildTargetModuleID().length; k++) {
+ TargetModuleIDImpl child = (TargetModuleIDImpl) id.getChildTargetModuleID()[k];
+ if (isWebApp(kernel, child.getModuleID())) {
+ child.setType(ModuleType.WAR);
}
}
- addModule(id);
-// }
+ }
+ addModule(id);
}
} finally {
ConfigurationUtil.releaseConfigurationManager(kernel, configurationManager);
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationInfo.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationInfo.java?rev=392614&r1=392613&r2=392614&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationInfo.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationInfo.java Sat Apr 8 15:28:47 2006
@@ -17,8 +17,6 @@
package org.apache.geronimo.kernel.config;
import java.io.Serializable;
-import java.net.URI;
-import javax.management.ObjectName;
import org.apache.geronimo.kernel.management.State;
import org.apache.geronimo.kernel.repository.Artifact;
@@ -29,20 +27,21 @@
* @version $Rev$ $Date$
*/
public class ConfigurationInfo implements Serializable {
- private final ObjectName storeName;
+ private static final long serialVersionUID = 576134736036202445L;
private final Artifact configID;
- private final State state;
private final ConfigurationModuleType type;
+ private final State state;
- public ConfigurationInfo(ObjectName storeName, Artifact configID, State state, ConfigurationModuleType type) {
- this.storeName = storeName;
+ public ConfigurationInfo(Artifact configID, ConfigurationModuleType type) {
this.configID = configID;
- this.state = state;
this.type = type;
+ state = null;
}
- public ObjectName getStoreName() {
- return storeName;
+ public ConfigurationInfo(Artifact configID, State state, ConfigurationModuleType type) {
+ this.configID = configID;
+ this.state = state;
+ this.type = type;
}
public Artifact getConfigID() {
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManager.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManager.java?rev=392614&r1=392613&r2=392614&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManager.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManager.java Sat Apr 8 15:28:47 2006
@@ -46,6 +46,7 @@
* @param store the store to list
* @return a List<ConfigurationInfo> of all the configurations in the store
* @throws NoSuchStoreException if the store could not be located
+ * @deprecated Find a better way.... hopefully we can just use the listConfiguration with no name or the name can be an AbstractName
*/
List listConfigurations(ObjectName store) throws NoSuchStoreException;
@@ -70,12 +71,11 @@
* configurations actually loaded by this call will be returned.
*
* @param configID the id of the configuration
- * @return a list of URIs (names of configurations that were actually loaded)
* @throws NoSuchConfigException if no configuration with the given id exists in the configuration stores
* @throws IOException if there is a problem loading te configuration from the store
* @throws InvalidConfigException if the configuration is corrupt
*/
- Configuration loadConfiguration(Artifact configID) throws NoSuchConfigException, IOException, InvalidConfigException;
+ void loadConfiguration(Artifact configID) throws NoSuchConfigException, IOException, InvalidConfigException;
Configuration loadConfiguration(ConfigurationData configurationData) throws NoSuchConfigException, IOException, InvalidConfigException;
@@ -110,4 +110,7 @@
void stopConfiguration(Configuration configuration) throws InvalidConfigException;
+ boolean isRunning(Artifact configurationId);
+
+ List listConfigurations();
}
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java?rev=392614&r1=392613&r2=392614&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java Sat Apr 8 15:28:47 2006
@@ -40,6 +40,7 @@
import org.apache.geronimo.kernel.GBeanNotFoundException;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.ClassLoading;
+import org.apache.geronimo.kernel.InternalKernelException;
import org.apache.geronimo.kernel.basic.BasicKernel;
import org.apache.geronimo.kernel.management.State;
import org.apache.geronimo.kernel.repository.Artifact;
@@ -269,66 +270,100 @@
gbeans = attributeStore.applyOverrides(configuration.getId(), gbeans, configuration.getConfigurationClassLoader());
}
- // register all the GBeans
- for (Iterator iterator = gbeans.iterator(); iterator.hasNext();) {
- GBeanData gbeanData = (GBeanData) iterator.next();
-
- // copy the gbeanData object as not to mutate the original
- gbeanData = new GBeanData(gbeanData);
-
- // preprocess the gbeanData (resolve references, set base url, declare dependency, etc.)
- preprocessGBeanData(configurationName, configuration, gbeanData);
-
- try {
- kernel.loadGBean(gbeanData, configuration.getConfigurationClassLoader());
- } catch (GBeanAlreadyExistsException e) {
- throw new InvalidConfigException(e);
- }
- }
+ List loaded = new ArrayList(gbeans.size());
+ List started = new ArrayList(gbeans.size());
try {
- // start the gbeans
+ // register all the GBeans
for (Iterator iterator = gbeans.iterator(); iterator.hasNext();) {
GBeanData gbeanData = (GBeanData) iterator.next();
- AbstractName gbeanName = gbeanData.getAbstractName();
- kernel.startRecursiveGBean(gbeanName);
+
+ // copy the gbeanData object as not to mutate the original
+ gbeanData = new GBeanData(gbeanData);
+
+ // preprocess the gbeanData (resolve references, set base url, declare dependency, etc.)
+ preprocessGBeanData(configurationName, configuration, gbeanData);
+
+ try {
+ kernel.loadGBean(gbeanData, configuration.getConfigurationClassLoader());
+ loaded.add(gbeanData.getAbstractName());
+ } catch (GBeanAlreadyExistsException e) {
+ throw new InvalidConfigException(e);
+ }
}
- // assure all of the gbeans are started
- List unstarted = new ArrayList();
- for (Iterator iterator = gbeans.iterator(); iterator.hasNext();) {
- GBeanData gbeanData = (GBeanData) iterator.next();
- AbstractName gbeanName = gbeanData.getAbstractName();
- if (State.RUNNING_INDEX != kernel.getGBeanState(gbeanName)) {
- String stateReason = null;
- if (kernel instanceof BasicKernel) {
- stateReason = ((BasicKernel) kernel).getStateReason(gbeanName);
+ try {
+ // start the gbeans
+ for (Iterator iterator = gbeans.iterator(); iterator.hasNext();) {
+ GBeanData gbeanData = (GBeanData) iterator.next();
+ AbstractName gbeanName = gbeanData.getAbstractName();
+ kernel.startRecursiveGBean(gbeanName);
+ started.add(gbeanName);
+ }
+
+ // assure all of the gbeans are started
+ List unstarted = new ArrayList();
+ for (Iterator iterator = gbeans.iterator(); iterator.hasNext();) {
+ GBeanData gbeanData = (GBeanData) iterator.next();
+ AbstractName gbeanName = gbeanData.getAbstractName();
+ if (State.RUNNING_INDEX != kernel.getGBeanState(gbeanName)) {
+ String stateReason = null;
+ if (kernel instanceof BasicKernel) {
+ stateReason = ((BasicKernel) kernel).getStateReason(gbeanName);
+ }
+ String name = gbeanName.toURI().getQuery();
+ if (stateReason != null) {
+ unstarted.add("The service " + name + " did not start because " + stateReason);
+ } else {
+ unstarted.add("The service " + name + " did not start for an unknown reason");
+ }
}
- String name = gbeanName.toURI().getQuery();
- if (stateReason != null) {
- unstarted.add("The service " + name + " did not start because " + stateReason);
- } else {
- unstarted.add("The service " + name + " did not start for an unknown reason");
+ }
+ if (!unstarted.isEmpty()) {
+ StringBuffer message = new StringBuffer();
+ message.append("Configuration ").append(configuration.getId()).append(" failed to start due to the following reasons:\n");
+ for (Iterator iterator = unstarted.iterator(); iterator.hasNext();) {
+ String reason = (String) iterator.next();
+ message.append(" ").append(reason).append("\n");
}
+ throw new InvalidConfigurationException(message.toString());
+ }
+ } catch (GBeanNotFoundException e) {
+ throw new InvalidConfigException(e);
+ }
+
+ for (Iterator iterator = configuration.getChildren().iterator(); iterator.hasNext();) {
+ Configuration childConfiguration = (Configuration) iterator.next();
+ ConfigurationUtil.startConfigurationGBeans(configurationName, childConfiguration, kernel, attributeStore);
+ }
+ } catch (Throwable e) {
+ for (Iterator iterator = started.iterator(); iterator.hasNext();) {
+ AbstractName gbeanName = (AbstractName) iterator.next();
+ try {
+ kernel.stopGBean(gbeanName);
+ } catch (GBeanNotFoundException ignored) {
+ } catch (IllegalStateException ignored) {
+ } catch (InternalKernelException kernelException) {
+ log.debug("Error cleaning up after failed start of configuration " + configuration.getId() + " gbean " + gbeanName, kernelException);
}
}
- if (!unstarted.isEmpty()) {
- StringBuffer message = new StringBuffer();
- message.append("Configuration ").append(configuration.getId()).append(" failed to start due to the following reasons:\n");
- for (Iterator iterator = unstarted.iterator(); iterator.hasNext();) {
- String reason = (String) iterator.next();
- message.append(" ").append(reason).append("\n");
+ for (Iterator iterator = loaded.iterator(); iterator.hasNext();) {
+ AbstractName gbeanName = (AbstractName) iterator.next();
+ try {
+ kernel.unloadGBean(gbeanName);
+ } catch (GBeanNotFoundException ignored) {
+ } catch (IllegalStateException ignored) {
+ } catch (InternalKernelException kernelException) {
+ log.debug("Error cleaning up after failed start of configuration " + configuration.getId() + " gbean " + gbeanName, kernelException);
}
- throw new InvalidConfigurationException(message.toString());
}
- } catch (GBeanNotFoundException e) {
- throw new InvalidConfigException(e);
- }
-
- for (Iterator iterator = configuration.getChildren().iterator(); iterator.hasNext();) {
- Configuration childConfiguration = (Configuration) iterator.next();
- ConfigurationUtil.startConfigurationGBeans(configurationName, childConfiguration, kernel, attributeStore);
+ if (e instanceof Error) {
+ throw (Error) e;
+ }
+ if (e instanceof InvalidConfigException) {
+ throw (InvalidConfigException) e;
+ }
+ throw new InvalidConfigException("Unknown start exception", e);
}
- // todo clean up after failure
}
}
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java?rev=392614&r1=392613&r2=392614&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java Sat Apr 8 15:28:47 2006
@@ -88,7 +88,7 @@
return new DefaultArtifactResolver(artifactManager, repositories);
}
- public synchronized Configuration loadConfiguration(Artifact configurationId) throws NoSuchConfigException, IOException, InvalidConfigException {
+ public synchronized void loadConfiguration(Artifact configurationId) throws NoSuchConfigException, IOException, InvalidConfigException {
// todo hack for bootstrap deploy
ConfigurationStatus configurationStatus = (ConfigurationStatus) configurations.get(configurationId);
if (configurationStatus == null && kernel.isLoaded(Configuration.getConfigurationAbstractName(configurationId))) {
@@ -99,13 +99,13 @@
//even worse hack
configurationStatus.start();
configurations.put(configurationId, configurationStatus);
- return configurationStatus.getConfiguration();
+ return;
} catch (GBeanNotFoundException e) {
// configuration was unloaded, just continue as normal
}
}
- return super.loadConfiguration(configurationId);
+ super.loadConfiguration(configurationId);
}
protected Configuration load(ConfigurationData configurationData, LinkedHashSet resolvedParentIds, Map loadedConfigurations) throws InvalidConfigException {
@@ -181,14 +181,26 @@
for (Iterator iterator = gbeans.iterator(); iterator.hasNext();) {
GBeanData gbeanData = (GBeanData) iterator.next();
AbstractName gbeanName = gbeanData.getAbstractName();
- kernel.stopGBean(gbeanName);
+ try {
+ kernel.stopGBean(gbeanName);
+ } catch (GBeanNotFoundException ignored) {
+ } catch (IllegalStateException ignored) {
+ } catch (InternalKernelException kernelException) {
+ log.debug("Error cleaning up after failed start of configuration " + configuration.getId() + " gbean " + gbeanName, kernelException);
+ }
}
// unload the gbeans
for (Iterator iterator = gbeans.iterator(); iterator.hasNext();) {
GBeanData gbeanData = (GBeanData) iterator.next();
AbstractName gbeanName = gbeanData.getAbstractName();
- kernel.unloadGBean(gbeanName);
+ try {
+ kernel.unloadGBean(gbeanName);
+ } catch (GBeanNotFoundException ignored) {
+ } catch (IllegalStateException ignored) {
+ } catch (InternalKernelException kernelException) {
+ log.debug("Error cleaning up after failed start of configuration " + configuration.getId() + " gbean " + gbeanName, kernelException);
+ }
}
} catch (Exception e) {
throw new InvalidConfigException("Could not stop gbeans in configuration", e);
@@ -209,6 +221,10 @@
configurationName = Configuration.getConfigurationAbstractName(configurationId);
} catch (InvalidConfigException e) {
throw new AssertionError(e);
+ }
+
+ if (artifactManager != null) {
+ artifactManager.unloadAllArtifacts(configurationId);
}
// unload this configuration
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=392614&r1=392613&r2=392614&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 Sat Apr 8 15:28:47 2006
@@ -39,6 +39,7 @@
import org.apache.geronimo.kernel.repository.Environment;
import org.apache.geronimo.kernel.repository.ImportType;
import org.apache.geronimo.kernel.repository.MissingDependencyException;
+import org.apache.geronimo.kernel.management.State;
/**
* @version $Rev$ $Date$
@@ -69,17 +70,42 @@
return result;
}
+ public List listConfigurations() {
+ List storeSnapshot = getStores();
+ List list = new ArrayList();
+ for (int i = 0; i < storeSnapshot.size(); i++) {
+ ConfigurationStore store = (ConfigurationStore) storeSnapshot.get(i);
+ list.addAll(listConfigurations(store));
+ }
+ return list;
+ }
+
+
public List listConfigurations(ObjectName storeName) throws NoSuchStoreException {
List storeSnapshot = getStores();
for (int i = 0; i < storeSnapshot.size(); i++) {
ConfigurationStore store = (ConfigurationStore) storeSnapshot.get(i);
if (storeName.equals(JMXUtil.getObjectName(store.getObjectName()))) {
- return store.listConfigurations();
+ return listConfigurations(store);
}
}
throw new NoSuchStoreException("No such store: " + storeName);
}
+ private List listConfigurations(ConfigurationStore store) {
+ List list = store.listConfigurations();
+ for (ListIterator iterator = list.listIterator(); iterator.hasNext();) {
+ ConfigurationInfo configurationInfo = (ConfigurationInfo) iterator.next();
+ if (isRunning(configurationInfo.getConfigID())) {
+ configurationInfo = new ConfigurationInfo(configurationInfo.getConfigID(), State.RUNNING, configurationInfo.getType());
+ } else {
+ configurationInfo = new ConfigurationInfo(configurationInfo.getConfigID(), State.STOPPED, configurationInfo.getType());
+ }
+ iterator.set(configurationInfo);
+ }
+ return list;
+ }
+
public boolean isConfiguration(Artifact artifact) {
if (configurations.containsKey(artifact)) {
return true;
@@ -100,23 +126,32 @@
return configurationStatus.getConfiguration();
}
- public synchronized boolean isLoaded(Artifact configId) {
- return configurations.containsKey(configId);
+ public synchronized boolean isLoaded(Artifact configurationId) {
+ return configurations.containsKey(configurationId);
}
- public synchronized Configuration loadConfiguration(Artifact configurationId) throws NoSuchConfigException, IOException, InvalidConfigException {
+ public synchronized boolean isRunning(Artifact configurationId) {
+ ConfigurationStatus configurationStatus = (ConfigurationStatus) configurations.get(configurationId);
+ if (configurationStatus != null) {
+ return configurationStatus.getStartCount() > 0;
+ }
+ return false;
+ }
+
+ public synchronized void loadConfiguration(Artifact configurationId) throws NoSuchConfigException, IOException, InvalidConfigException {
ConfigurationStatus configurationStatus = (ConfigurationStatus) configurations.get(configurationId);
if (configurationStatus != null) {
// already loaded, so just update the load count
configurationStatus.load();
- return configurationStatus.getConfiguration();
+ configurationStatus.getConfiguration();
+ return;
}
// load the ConfigurationData for the new configuration
ConfigurationData configurationData = loadConfigurationGBeanData(configurationId);
// load the configuration
- return loadConfiguration(configurationData);
+ loadConfiguration(configurationData);
}
public synchronized Configuration loadConfiguration(ConfigurationData configurationData) throws NoSuchConfigException, IOException, InvalidConfigException {
@@ -332,6 +367,7 @@
startedConfigurations.add(configuration);
}
} catch (Exception e) {
+ configurationStatus.stop();
for (Iterator iterator = startedConfigurations.iterator(); iterator.hasNext();) {
Configuration configuration = (Configuration) iterator.next();
stop(configuration);
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Artifact.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Artifact.java?rev=392614&r1=392613&r2=392614&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Artifact.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Artifact.java Sat Apr 8 15:28:47 2006
@@ -17,8 +17,6 @@
package org.apache.geronimo.kernel.repository;
-import java.net.URI;
-import java.net.URISyntaxException;
import java.io.Serializable;
/**
@@ -129,15 +127,6 @@
result = 29 * result + (version != null ? version.hashCode() : 0);
result = 29 * result + (type != null ? type.hashCode() : 0);
return result;
- }
-
- /**
- * @deprecated for use during conversion only!
- * @return
- * @throws URISyntaxException
- */
- public URI toURI() throws URISyntaxException {
- return new URI(toString());
}
public String toString() {
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=392614&r1=392613&r2=392614&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 Sat Apr 8 15:28:47 2006
@@ -58,8 +58,7 @@
private ConfigurationManager configurationManager;
public void test() throws Exception {
- Configuration configuration = configurationManager.loadConfiguration(artifact3);
- assertEquals(artifact3, configuration.getId());
+ configurationManager.loadConfiguration(artifact3);
assertTrue(configurationManager.isLoaded(artifact3));
assertTrue(configurationManager.isLoaded(artifact2));
assertTrue(configurationManager.isLoaded(artifact1));
Modified: geronimo/branches/1.1/modules/service-builder/src/test/org/apache/geronimo/deployment/service/EnvironmentBuilderTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/service-builder/src/test/org/apache/geronimo/deployment/service/EnvironmentBuilderTest.java?rev=392614&r1=392613&r2=392614&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/service-builder/src/test/org/apache/geronimo/deployment/service/EnvironmentBuilderTest.java (original)
+++ geronimo/branches/1.1/modules/service-builder/src/test/org/apache/geronimo/deployment/service/EnvironmentBuilderTest.java Sat Apr 8 15:28:47 2006
@@ -43,7 +43,7 @@
anImport.setVersion("version");
LinkedHashSet parentId = EnvironmentBuilder.toArtifacts(new ArtifactType[] {anImport});
assertEquals(1, parentId.size());
- assertEquals("groupId/artifactId/version/type", ((Artifact)parentId.iterator().next()).toURI().getPath());
+ assertEquals(new Artifact("groupId", "artifactId", "version", "type"), parentId.iterator().next());
}
private static final String ENV_1 = "<dep:environment xmlns:dep=\"http://geronimo.apache.org/xml/ns/deployment-1.1\">\n" +
Modified: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/FileConfigurationList.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/FileConfigurationList.java?rev=392614&r1=392613&r2=392614&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/FileConfigurationList.java (original)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/FileConfigurationList.java Sat Apr 8 15:28:47 2006
@@ -16,43 +16,41 @@
*/
package org.apache.geronimo.system.configuration;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.gbean.AbstractNameQuery;
import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.config.Configuration;
import org.apache.geronimo.kernel.config.ConfigurationInfo;
import org.apache.geronimo.kernel.config.ConfigurationManager;
-import org.apache.geronimo.kernel.config.NoSuchStoreException;
import org.apache.geronimo.kernel.config.PersistentConfigurationList;
-import org.apache.geronimo.kernel.config.Configuration;
import org.apache.geronimo.kernel.lifecycle.LifecycleAdapter;
import org.apache.geronimo.kernel.lifecycle.LifecycleListener;
import org.apache.geronimo.kernel.management.State;
import org.apache.geronimo.kernel.repository.Artifact;
import org.apache.geronimo.system.serverinfo.ServerInfo;
-import javax.management.ObjectName;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
/**
* GBean that saves a list of configurations, for example to allow
* a server to restart automatically.
*
- * @version $Rev$ $Date$
+ * @version $Rev: 383682 $ $Date$
*/
public class FileConfigurationList implements GBeanLifecycle, PersistentConfigurationList {
private static final Log log = LogFactory.getLog(PersistentConfigurationList.class);
@@ -164,24 +162,15 @@
}
BufferedWriter writer = new BufferedWriter(new FileWriter(configList));
- try {
- List stores = configurationManager.listStores();
- for (Iterator i = stores.iterator(); i.hasNext();) {
- ObjectName storeName = (ObjectName) i.next();
- List configList = configurationManager.listConfigurations(storeName);
- for (Iterator j = configList.iterator(); j.hasNext();) {
- ConfigurationInfo info = (ConfigurationInfo) j.next();
- if (info.getState() == State.RUNNING) {
- writer.write(info.getConfigID().toString());
- writer.newLine();
- }
- }
+ List configList = configurationManager.listConfigurations();
+ for (Iterator j = configList.iterator(); j.hasNext();) {
+ ConfigurationInfo info = (ConfigurationInfo) j.next();
+ if (info.getState() == State.RUNNING) {
+ writer.write(info.getConfigID().toString());
+ writer.newLine();
}
- writer.close();
- } catch (NoSuchStoreException e) {
- writer.close();
- configList.delete();
}
+ writer.close();
log.info("Saved running configuration list");
}
Modified: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java?rev=392614&r1=392613&r2=392614&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java (original)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java Sat Apr 8 15:28:47 2006
@@ -31,11 +31,9 @@
import java.util.zip.ZipEntry;
import javax.management.ObjectName;
-import org.apache.geronimo.gbean.AbstractName;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.config.Configuration;
import org.apache.geronimo.kernel.config.ConfigurationAlreadyExistsException;
import org.apache.geronimo.kernel.config.ConfigurationData;
import org.apache.geronimo.kernel.config.ConfigurationInfo;
@@ -45,7 +43,6 @@
import org.apache.geronimo.kernel.config.InvalidConfigException;
import org.apache.geronimo.kernel.config.NoSuchConfigException;
import org.apache.geronimo.kernel.jmx.JMXUtil;
-import org.apache.geronimo.kernel.management.State;
import org.apache.geronimo.kernel.repository.Artifact;
import org.apache.geronimo.kernel.repository.FileWriteMonitor;
import org.apache.geronimo.kernel.repository.WritableListableRepository;
@@ -242,24 +239,12 @@
Artifact configId = (Artifact) i.next();
if (configId.getType().equals("car")) {
try {
- AbstractName configName = Configuration.getConfigurationAbstractName(configId);
- State state;
- if (kernel.isLoaded(configName)) {
- try {
- state = State.fromInt(kernel.getGBeanState(configName));
- } catch (Exception e) {
- state = null;
- }
- } else {
- // If the configuration is not loaded by the kernel
- // and defined by the store, then it is stopped.
- state = State.STOPPED;
- }
-
+ // this is super expensive just to get one small piece of info
+ // todo consider making module type the same as artifact type
ConfigurationData configurationData = loadConfiguration(configId);
ConfigurationModuleType type = configurationData.getModuleType();
- configs.add(new ConfigurationInfo(objectName, configId, state, type));
+ configs.add(new ConfigurationInfo(configId, type));
} catch (Exception e) {
}
}