geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r698040 - in /geronimo/server/trunk: framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ plugins/clustering/geronimo-plugin-far...
Date Mon, 22 Sep 2008 23:54:24 GMT
Author: djencks
Date: Mon Sep 22 16:54:24 2008
New Revision: 698040

URL: http://svn.apache.org/viewvc?rev=698040&view=rev
Log:
GERONIMO=4284 Add remove plugin (from plugin list) and remove plugin list (from cluster) commands

Modified:
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/FarmCommand.groovy
    geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/Farm.java
    geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/Farm.java
    geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/FarmGBean.java
    geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/JpaNodeInfo.java
    geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/JpaPluginInstance.java

Modified: geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/FarmCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/FarmCommand.groovy?rev=698040&r1=698039&r2=698040&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/FarmCommand.groovy
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/FarmCommand.groovy
Mon Sep 22 16:54:24 2008
@@ -73,8 +73,22 @@
                 io.out.println("add-plugin requires 3 parameters, cluster name, plugin list
name and the artifact")
                 return;
             }
+        } else if (action == "remove-plugin") {
+            if (params.size == 2) {
+                results = farm.removePluginFromPluginList(params[0], params[1]);
+            } else {
+                io.out.println("remove-plugin requires 2 parameters, plugin list name and
the artifact")
+                return;
+            }
+        } else if (action == "remove-plugin-list") {
+            if (params.size == 2) {
+                results = farm.removePluginListFromCluster(params[0], params[1]);
+            } else {
+                io.out.println("remove-plugin-list requires 2 parameters, cluster name and
plugin list name")
+                return;
+            }
         } else {
-            io.out.println("unknown command, expecting add-plugin-list, add-plugin, or add-plugin-to-cluster")
+            io.out.println("unknown command, expecting add-plugin-list, add-plugin, add-plugin-to-cluster,
remove-plugin, or remove-plugin-list")
             return;
         }
         io.out.println("Results:")

Modified: geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/Farm.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/Farm.java?rev=698040&r1=698039&r2=698040&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/Farm.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/Farm.java
Mon Sep 22 16:54:24 2008
@@ -26,7 +26,7 @@
  *
  * This belongs in the clustering/geronimo-plugin-farm module but is here due to current
gshell limitations with adding commands in other classloaders.
  *
- * @version $Rev:$ $Date:$
+ * @version $Rev$ $Date$
  */
 public interface Farm {
     Map<String, DownloadResults> addPluginList(String clusterName, String pluginListName);
@@ -34,4 +34,8 @@
     Map<String, DownloadResults> addPlugin(String pluginListName, String artifactURI);
 
     Map<String, DownloadResults> addPluginToCluster(String clusterName, String pluginListName,
String artifactURI);
+
+    Map<String, DownloadResults> removePluginFromPluginList(String pluginListName,
String artifactURI);
+
+    Map<String, DownloadResults> removePluginListFromCluster(String clusterName, String
pluginListName);
 }

Modified: geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/Farm.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/Farm.java?rev=698040&r1=698039&r2=698040&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/Farm.java
(original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/Farm.java
Mon Sep 22 16:54:24 2008
@@ -25,7 +25,7 @@
 import org.apache.geronimo.system.plugin.DownloadResults;
 
 /**
- * @version $Rev:$ $Date:$
+ * @version $Rev$ $Date$
  */
 public interface Farm {
     Map<String, DownloadResults> addPluginList(String clusterName, String pluginListName);
@@ -33,4 +33,8 @@
     Map<String, DownloadResults> addPlugin(String pluginListName, String artifactURI);
 
     Map<String, DownloadResults> addPluginToCluster(String clusterName, String pluginListName,
String artifactURI);
+
+    Map<String, DownloadResults> removePluginFromPluginList(String pluginListName,
String artifactURI);
+
+    Map<String, DownloadResults> removePluginListFromCluster(String clusterName, String
pluginListName);
 }

Modified: geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/FarmGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/FarmGBean.java?rev=698040&r1=698039&r2=698040&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/FarmGBean.java
(original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/FarmGBean.java
Mon Sep 22 16:54:24 2008
@@ -21,9 +21,10 @@
 package org.apache.geronimo.farm.plugin;
 
 import java.io.IOException;
+import java.util.Collections;
 import java.util.HashMap;
-import java.util.Map;
 import java.util.List;
+import java.util.Map;
 
 import javax.persistence.EntityManager;
 import javax.persistence.EntityManagerFactory;
@@ -36,6 +37,9 @@
 import org.apache.geronimo.gbean.annotation.ParamAttribute;
 import org.apache.geronimo.gbean.annotation.ParamReference;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
+import org.apache.geronimo.kernel.config.NoSuchConfigException;
+import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.persistence.PersistenceUnitGBean;
 import org.apache.geronimo.system.plugin.DownloadResults;
 import org.apache.geronimo.system.plugin.PluginInstaller;
@@ -139,6 +143,34 @@
         return installToClusters(pluginList);
     }
 
+    public Map<String, DownloadResults> removePluginFromPluginList(String pluginListName,
String artifactURI) {
+        return removePluginFromPluginList(pluginListName, new JpaPluginInstance(artifactURI));
+    }
+
+    public Map<String, DownloadResults> removePluginFromPluginList(String pluginListName,
JpaPluginInstance pluginInstance) {
+        JpaPluginList pluginList;
+        synchronized (this) {
+            JpaContext pluginListContext = new JpaContext(emf);
+            pluginList = pluginListContext.getPluginList(pluginListName, defaultRepository);
+            pluginList.getPlugins().remove(pluginInstance);
+            pluginListContext.close();
+        }
+        return removeFromClusters(pluginList, pluginInstance);
+    }
+
+    public Map<String, DownloadResults> removePluginListFromCluster(String clusterName,
String pluginListName) {
+        JpaClusterInfo cluster;
+        JpaPluginList pluginList;
+        synchronized (this) {
+            JpaContext clusterContext = new JpaContext(emf);
+            cluster = clusterContext.getClusterInfo(clusterName);
+            pluginList = clusterContext.getPluginList(pluginListName, defaultRepository);
+            cluster.getPluginLists().remove(pluginList);
+            clusterContext.close();
+        }
+        return removeFromCluster(pluginList.getPlugins(), cluster);
+    }
+
     public Map<String, DownloadResults> addPluginToCluster(String clusterName, String
pluginListName, String artifactURI) {
         return addPluginToCluster(clusterName, pluginListName, new JpaPluginInstance(artifactURI));
     }
@@ -185,6 +217,41 @@
         }
     }
 
+    private Map<String, DownloadResults> removeFromClusters(JpaPluginList clusterPluginList,
JpaPluginInstance pluginInstance) {
+        List<JpaPluginInstance> pluginList = pluginInstance == null? clusterPluginList.getPlugins():
Collections.singletonList(pluginInstance);
+        Map<String, DownloadResults> results = new HashMap<String, DownloadResults>();
+        for (JpaClusterInfo cluster : clusterPluginList.getClusters()) {
+            results.putAll(removeFromCluster(pluginList, cluster));
+        }
+        return results;
+    }
+
+    private Map<String, DownloadResults> removeFromCluster(List<JpaPluginInstance>
pluginList, JpaClusterInfo cluster) {
+        Map<String, DownloadResults> installedNodes = new HashMap<String, DownloadResults>();
+        for (JpaNodeInfo jpaNodeInfo : cluster.getJpaNodeInfos()) {
+            DownloadResults downloadResults = removeFromNode(pluginList, jpaNodeInfo);
+            installedNodes.put(jpaNodeInfo.getName(), downloadResults);
+        }
+        return installedNodes;
+    }
+
+    private DownloadResults removeFromNode(List<JpaPluginInstance> pluginList, JpaNodeInfo
jpaNodeInfo) {
+        DownloadResults downloadResults = new DownloadResults();
+        try {
+            ConfigurationManager configurationManager = jpaNodeInfo.getConfigurationManager();
+            for (JpaPluginInstance jpaPluginInstance: pluginList) {
+                Artifact artifact = jpaPluginInstance.toArtifact();
+                configurationManager.uninstallConfiguration(artifact);
+                downloadResults.addRemovedConfigID(artifact);
+            }
+        } catch (IOException e) {
+            downloadResults.setFailure(e);
+        } catch (NoSuchConfigException e) {
+            downloadResults.setFailure(e);
+        }
+        return downloadResults;
+    }
+
 
     private JpaPluginList getPluginList(JpaClusterInfo cluster, String pluginListName) {
         for (JpaPluginList pluginList : cluster.getPluginLists()) {

Modified: geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/JpaNodeInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/JpaNodeInfo.java?rev=698040&r1=698039&r2=698040&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/JpaNodeInfo.java
(original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/JpaNodeInfo.java
Mon Sep 22 16:54:24 2008
@@ -40,6 +40,7 @@
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.KernelRegistry;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
 import org.apache.geronimo.system.plugin.PluginInstaller;
 
 /**
@@ -70,6 +71,8 @@
     private PluginInstaller pluginInstaller;
     @Transient
     private JMXConnector jmxConnector;
+    @Transient
+    private ConfigurationManager configurationManager;
 
     public JpaNodeInfo() {
     }
@@ -136,12 +139,25 @@
         Kernel kernel = newKernel();
         Set<AbstractName> set = kernel.listGBeans(new AbstractNameQuery(PluginInstaller.class.getName()));
         for (AbstractName name : set) {
-            pluginInstaller = (PluginInstaller) kernel.getProxyManager().createProxy(name,
PluginInstaller.class);
+            pluginInstaller = kernel.getProxyManager().createProxy(name, PluginInstaller.class);
             return pluginInstaller;
         }
         throw new IllegalStateException("No plugin installer found");
     }
 
+    public synchronized ConfigurationManager getConfigurationManager() throws IOException
{
+        if (configurationManager != null) {
+            return configurationManager;
+        }
+        Kernel kernel = newKernel();
+        Set<AbstractName> set = kernel.listGBeans(new AbstractNameQuery(ConfigurationManager.class.getName()));
+        for (AbstractName name : set) {
+            configurationManager = kernel.getProxyManager().createProxy(name, ConfigurationManager.class);
+            return configurationManager;
+        }
+        throw new IllegalStateException("No plugin installer found");
+    }
+
     public synchronized void disconnect() throws IOException {
         if (kernel != null) {
             if (pluginInstaller != null) {

Modified: geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/JpaPluginInstance.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/JpaPluginInstance.java?rev=698040&r1=698039&r2=698040&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/JpaPluginInstance.java
(original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/JpaPluginInstance.java
Mon Sep 22 16:54:24 2008
@@ -109,4 +109,8 @@
     public String toString() {
         return groupId + "/" + artifactId + "/" + version + "/" + type;
     }
+
+    public Artifact toArtifact() {
+        return new Artifact(groupId, artifactId, version, type);
+    }
 }



Mime
View raw message