geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r693703 - in /geronimo/server/trunk: framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/ framework/modules/geronimo-d...
Date Wed, 10 Sep 2008 04:20:56 GMT
Author: djencks
Date: Tue Sep  9 21:20:53 2008
New Revision: 693703

URL: http://svn.apache.org/viewvc?rev=693703&view=rev
Log:
GERONIMO-4284 fix the jpa stuff, recover better from multicast problems, add a gshell command,
restructure slightly how non-jsr88 stuff is obtained in gshell

Added:
    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
  (with props)
    geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/Farm.java
  (with props)
Modified:
    geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/GeronimoDeploymentManager.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryWithKernel.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java
    geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/GeronimoSourceRepository.java
    geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/LocalSourceRepository.java
    geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
    geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/RemoteSourceRepository.java
    geronimo/server/trunk/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastDiscoveryAgent.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/JpaClusterInfo.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
    geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/JpaPluginList.java

Added: 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=693703&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/FarmCommand.groovy
(added)
+++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/FarmCommand.groovy
Tue Sep  9 21:20:53 2008
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.commands
+
+import jline.ConsoleReader
+import org.apache.geronimo.deployment.cli.CommandInstallCAR
+import org.apache.geronimo.deployment.plugin.jmx.RemoteDeploymentManager
+import org.apache.geronimo.gshell.clp.Argument
+import org.apache.geronimo.gshell.command.annotation.CommandComponent
+import org.apache.geronimo.system.plugin.DownloadResults
+import org.apache.geronimo.system.plugin.Farm
+
+/**
+ * List plugins.
+ *
+ * @version $Rev: 580864 $ $Date: 2007-09-30 23:47:39 -0700 (Sun, 30 Sep 2007) $
+ */
+@CommandComponent (id = 'geronimo-commands:farm', description = 'administer farm')
+class FarmCommand
+    extends ConnectCommand
+{
+    @Argument
+    String action
+
+    @Argument (index = 1, multiValued = true)
+    List<String> params
+
+    protected Object doExecute() throws Exception {
+        def connection = connect()
+
+        def ConsoleReader consoleReader = new ConsoleReader(io.inputStream, io.out)
+        def repo = null
+        def plugins = null
+
+        def deploymentManager = connection.getDeploymentManager();
+        def Farm farm = ((RemoteDeploymentManager)deploymentManager).getImplementation(Farm.class);
+        def Map<String, DownloadResults> results;
+        if (action == "add-plugin-list") {
+            if (params.size == 2) {
+                results = farm.addPluginList(params[0], params[1]);
+            } else {
+                io.out.println("add-plugin-list requires 2 parameters, cluster name and plugin
list name")
+                return;
+            }
+        } else if (action == "add-plugin") {
+            if (params.size == 2) {
+                results = farm.addPlugin(params[0], params[1]);
+            } else {
+                io.out.println("add-plugin requires 2 parameters, plugin list name and the
artifact")
+                return;
+            }
+        } else if (action == "add-plugin-to-cluster") {
+            if (params.size == 3) {
+                results = farm.addPluginToCluster()(params[0], params[1], params[2]);
+            } else {
+                io.out.println("add-plugin requires 3 parameters, cluster name, plugin list
name and the artifact")
+                return;
+            }
+        } else {
+            io.out.println("unknown command, expecting add-plugin-list, add-plugin, or add-plugin-to-cluster")
+            return;
+        }
+        io.out.println("Results:")
+        for (Map.Entry<String, DownloadResults> entry in results) {
+            io.out.println("results for node: " + entry.getKey());
+            CommandInstallCAR.printResults(consoleReader, results, time);
+        }
+    }
+}

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/GeronimoDeploymentManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/GeronimoDeploymentManager.java?rev=693703&r1=693702&r2=693703&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/GeronimoDeploymentManager.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/GeronimoDeploymentManager.java
Tue Sep  9 21:20:53 2008
@@ -29,5 +29,7 @@
  * @version $Rev$ $Date$
  */
 public interface GeronimoDeploymentManager extends DeploymentManager, PluginInstaller, ServerArchiver
{
+
+    public <T> T getImplementation(Class<T> clazz);
     public URL[] getRepositories();
 }

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryWithKernel.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryWithKernel.java?rev=693703&r1=693702&r2=693703&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryWithKernel.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryWithKernel.java
Tue Sep  9 21:20:53 2008
@@ -74,7 +74,7 @@
             return remoteDeploymentManager;
         }
         try {
-            return (RemoteDeploymentManager) kernel.getGBean(RemoteDeploymentManager.class);
+            return kernel.getGBean(RemoteDeploymentManager.class);
         } catch (Exception e) {
             throw (DeploymentManagerCreationException) new DeploymentManagerCreationException("See
nested").initCause(e);
         }

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java?rev=693703&r1=693702&r2=693703&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java
Tue Sep  9 21:20:53 2008
@@ -56,6 +56,7 @@
 import org.apache.geronimo.kernel.repository.Dependency;
 import org.apache.geronimo.kernel.repository.MissingDependencyException;
 import org.apache.geronimo.kernel.InvalidGBeanException;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.system.jmx.KernelDelegate;
 import org.apache.geronimo.system.plugin.DownloadPoller;
 import org.apache.geronimo.system.plugin.DownloadResults;
@@ -169,6 +170,16 @@
         }
     }
 
+     public <T> T getImplementation(Class<T> clazz) {
+         try {
+             return kernel.getGBean(clazz);
+         } catch (GBeanNotFoundException e) {
+             throw new IllegalStateException("No implementation for " + clazz.getName(),
e);
+         }
+     }
+
+
+
     public PluginListType listPlugins(URL mavenRepository, String username, String password)
throws FailedLoginException, IOException {
         PluginInstaller installer = getPluginInstaller();
         try {
@@ -269,18 +280,10 @@
     }
 
     private PluginInstaller getPluginInstaller() {
-        Set<AbstractName> set = kernel.listGBeans(new AbstractNameQuery(PluginInstaller.class.getName()));
-        for (AbstractName name : set) {
-            return (PluginInstaller) kernel.getProxyManager().createProxy(name, PluginInstaller.class);
-        }
-        throw new IllegalStateException("No plugin installer found");
+        return getImplementation(PluginInstaller.class);
     }
     private ServerArchiver getServerArchiver() {
-        Set<AbstractName> set = kernel.listGBeans(new AbstractNameQuery(ServerArchiver.class.getName()));
-        for (AbstractName name : set) {
-            return (ServerArchiver) kernel.getProxyManager().createProxy(name, ServerArchiver.class);
-        }
-        throw new IllegalStateException("No plugin installer found");
+        return getImplementation(ServerArchiver.class);
     }
 
     //not likely to be useful remotely

Added: 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=693703&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/Farm.java
(added)
+++ geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/Farm.java
Tue Sep  9 21:20:53 2008
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.geronimo.system.plugin;
+
+import java.util.Map;
+
+/**
+ *
+ * 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:$
+ */
+public interface Farm {
+    Map<String, DownloadResults> addPluginList(String clusterName, String pluginListName);
+
+    Map<String, DownloadResults> addPlugin(String pluginListName, String artifactURI);
+
+    Map<String, DownloadResults> addPluginToCluster(String clusterName, String pluginListName,
String artifactURI);
+}

Propchange: geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/Farm.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/Farm.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/Farm.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/GeronimoSourceRepository.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/GeronimoSourceRepository.java?rev=693703&r1=693702&r2=693703&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/GeronimoSourceRepository.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/GeronimoSourceRepository.java
Tue Sep  9 21:20:53 2008
@@ -161,6 +161,10 @@
         return null;
     }
 
+    public String toString() {
+        return getClass().getName();
+    }
+
     private static class RepoWrapper implements WritableListableRepository {
 
         private final Repository repo;

Modified: geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/LocalSourceRepository.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/LocalSourceRepository.java?rev=693703&r1=693702&r2=693703&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/LocalSourceRepository.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/LocalSourceRepository.java
Tue Sep  9 21:20:53 2008
@@ -71,4 +71,8 @@
         File location = getLocation(artifact);
         return new LocalOpenResult(artifact, location);
     }
+
+    public String toString() {
+        return getClass().getName() + ":" + rootFile;
+    }
 }

Modified: geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java?rev=693703&r1=693702&r2=693703&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
Tue Sep  9 21:20:53 2008
@@ -1042,7 +1042,7 @@
                 }
             }
             if (result == null) {
-                throw new IllegalArgumentException("Could not find " + configID + " in any
repo");
+                throw new IllegalArgumentException("Could not find " + configID + " in any
repo: " + repos);
             }
             // Check if the result is already in server's repository
             if (configManager.getArtifactResolver().queryArtifacts(result.getArtifact()).length
> 0) {

Modified: geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/RemoteSourceRepository.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/RemoteSourceRepository.java?rev=693703&r1=693702&r2=693703&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/RemoteSourceRepository.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/RemoteSourceRepository.java
Tue Sep  9 21:20:53 2008
@@ -397,4 +397,9 @@
             }
         }
     }
+
+    public String toString() {
+        return getClass().getName() + ":" + base;
+    }
+
 }

Modified: geronimo/server/trunk/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastDiscoveryAgent.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastDiscoveryAgent.java?rev=693703&r1=693702&r2=693703&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastDiscoveryAgent.java
(original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastDiscoveryAgent.java
Tue Sep  9 21:20:53 2008
@@ -157,15 +157,7 @@
     public void doStart() throws Exception {
             if (started.compareAndSet(false, true)) {
 
-                InetAddress inetAddress = InetAddress.getByName(host);
-
-                this.address = new InetSocketAddress(inetAddress, port);
-
-                multicast = new MulticastSocket(port);
-                multicast.setLoopbackMode(loopbackMode);
-                multicast.setTimeToLive(timeToLive);
-                multicast.joinGroup(inetAddress);
-                multicast.setSoTimeout((int) heartRate);
+                newSocket();
 
                 Thread listenerThread = new Thread(listener);
                 listenerThread.setName("MulticastDiscovery: Listener");
@@ -179,6 +171,18 @@
             }
     }
 
+    private void newSocket() throws IOException {
+        InetAddress inetAddress = InetAddress.getByName(host);
+
+        this.address = new InetSocketAddress(inetAddress, port);
+
+        multicast = new MulticastSocket(port);
+        multicast.setLoopbackMode(loopbackMode);
+        multicast.setTimeToLive(timeToLive);
+        multicast.joinGroup(inetAddress);
+        multicast.setSoTimeout((int) heartRate);
+    }
+
     /**
      * stop the channel
      *
@@ -450,10 +454,16 @@
                     DatagramPacket packet = new DatagramPacket(data, 0, data.length, address);
 //                    System.out.println("ann = " + uri);
                     multicast.send(packet);
+                    failed = null;
                 } catch (IOException e) {
                     // If a send fails, chances are all subsequent sends will fail
                     // too.. No need to keep reporting the
                     // same error over and over.
+                    try {
+                        newSocket();
+                    } catch (IOException e1) {
+                        //ignore
+                    }
                     if (failed == null) {
                         failed = e;
 

Added: 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=693703&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/Farm.java
(added)
+++ geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/Farm.java
Tue Sep  9 21:20:53 2008
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.geronimo.farm.plugin;
+
+import java.util.Map;
+
+import org.apache.geronimo.system.plugin.DownloadResults;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public interface Farm {
+    Map<String, DownloadResults> addPluginList(String clusterName, String pluginListName);
+
+    Map<String, DownloadResults> addPlugin(String pluginListName, String artifactURI);
+
+    Map<String, DownloadResults> addPluginToCluster(String clusterName, String pluginListName,
String artifactURI);
+}

Propchange: geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/Farm.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/Farm.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/Farm.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=693703&r1=693702&r2=693703&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
Tue Sep  9 21:20:53 2008
@@ -23,6 +23,7 @@
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.List;
 
 import javax.persistence.EntityManager;
 import javax.persistence.EntityManagerFactory;
@@ -47,7 +48,7 @@
  * @version $Rev$ $Date$
  */
 @GBean
-public class FarmGBean implements NodeListener {
+public class FarmGBean implements NodeListener, org.apache.geronimo.system.plugin.Farm {
     private String defaultRepository;
     private EntityManagerFactory emf;
 
@@ -81,7 +82,17 @@
     }
 
     public void removeNode(String clusterName, String nodeName) {
-        //TODO
+        synchronized (this) {
+            JpaContext clusterContext = new JpaContext(emf);
+            JpaClusterInfo cluster = clusterContext.getClusterInfo(clusterName);
+            for (JpaNodeInfo nodeInfo: cluster.getJpaNodeInfos()) {
+                if (nodeName.equals(nodeInfo.getName())) {
+                    cluster.getJpaNodeInfos().remove(nodeInfo);
+                    break;
+                }
+            }
+            clusterContext.close();
+        }
     }
 
     public Map<String, DownloadResults> addPluginList(String clusterName, JpaPluginList
pluginList) {
@@ -108,6 +119,10 @@
         return installToCluster(pluginList, cluster);
     }
 
+    public Map<String, DownloadResults> addPlugin(String pluginListName, String artifactURI)
{
+        return addPlugin(pluginListName, new JpaPluginInstance(artifactURI));
+    }
+
     public Map<String, DownloadResults> addPlugin(String pluginListName, JpaPluginInstance
pluginInstance) {
         JpaPluginList pluginList;
         synchronized (this) {
@@ -119,6 +134,10 @@
         return installToClusters(pluginList);
     }
 
+    public Map<String, DownloadResults> addPluginToCluster(String clusterName, String
pluginListName, String artifactURI) {
+        return addPluginToCluster(clusterName, pluginListName, new JpaPluginInstance(artifactURI));
+    }
+
     public Map<String, DownloadResults> addPluginToCluster(String clusterName, String
pluginListName, JpaPluginInstance pluginInstance) {
         JpaPluginList pluginList;
         synchronized (this) {
@@ -203,15 +222,20 @@
         public JpaNodeInfo getNodeInfo(JpaClusterInfo cluster, NodeInfo nodeInfo) {
             Query query = em.createNamedQuery("nodeByName");
             query.setParameter("name", nodeInfo.getName());
+            JpaNodeInfo jpaNodeInfo;
             try {
-                return (JpaNodeInfo) query.getSingleResult();
+                jpaNodeInfo = (JpaNodeInfo) query.getSingleResult();
             } catch (NoResultException e) {
-                JpaNodeInfo jpaNodeInfo = new JpaNodeInfo(nodeInfo);
+                 jpaNodeInfo = new JpaNodeInfo(nodeInfo);
                 em.persist(jpaNodeInfo);
-                cluster.getJpaNodeInfos().add(jpaNodeInfo);
-                em.flush();
-                return jpaNodeInfo;
             }
+            if (jpaNodeInfo.getCluster() == null)  {
+                jpaNodeInfo.setCluster(cluster);
+            } else if (!jpaNodeInfo.getCluster().getName().equals(cluster.getName())){
+                throw new IllegalStateException("cannot move node to another cluster");
+            }
+            em.flush();
+            return jpaNodeInfo;
         }
 
         public JpaPluginList getPluginList(String name, String defaultRepository) {

Modified: geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/JpaClusterInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/JpaClusterInfo.java?rev=693703&r1=693702&r2=693703&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/JpaClusterInfo.java
(original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/JpaClusterInfo.java
Tue Sep  9 21:20:53 2008
@@ -45,7 +45,8 @@
     @Id
     private String name;
     @OneToMany(cascade = {CascadeType.PERSIST, CascadeType.REMOVE},
-            fetch = FetchType.EAGER)
+            fetch = FetchType.EAGER,
+            mappedBy = "cluster")
     private List<JpaNodeInfo> nodes = new ArrayList<JpaNodeInfo>();
 
     @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE},

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=693703&r1=693702&r2=693703&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
Tue Sep  9 21:20:53 2008
@@ -26,6 +26,11 @@
 import javax.persistence.Id;
 import javax.persistence.Transient;
 import javax.persistence.NamedQuery;
+import javax.persistence.GeneratedValue;
+import javax.persistence.ManyToOne;
+import javax.persistence.FetchType;
+import javax.persistence.CascadeType;
+import javax.persistence.JoinColumn;
 import javax.management.remote.JMXConnector;
 
 import org.apache.geronimo.farm.config.ExtendedJMXConnectorInfo;
@@ -44,7 +49,6 @@
 @NamedQuery(name = "nodeByName", query = "SELECT a FROM node a WHERE a.name = :name")
 public class JpaNodeInfo implements NodeInfo {
     @Id
-    private int id;
     private String name;
     private String userName;
     private String password;
@@ -54,6 +58,12 @@
     private String urlPath;
     private boolean local;
 
+    @ManyToOne(fetch= FetchType.EAGER, cascade={CascadeType.PERSIST})
+    @JoinColumn(
+        name="cluster", referencedColumnName="name"
+    )
+    private JpaClusterInfo cluster;
+
     @Transient
     private Kernel kernel;
     @Transient
@@ -76,6 +86,14 @@
         local = connectorInfo.isLocal();
     }
 
+    public JpaClusterInfo getCluster() {
+        return cluster;
+    }
+
+    public void setCluster(JpaClusterInfo cluster) {
+        this.cluster = cluster;
+    }
+
     public String getName() {
         return name;
     }

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=693703&r1=693702&r2=693703&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
Tue Sep  9 21:20:53 2008
@@ -22,6 +22,7 @@
 
 import javax.persistence.Entity;
 import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
 
 import org.apache.geronimo.system.plugin.model.PluginType;
 import org.apache.geronimo.system.plugin.model.PluginArtifactType;
@@ -29,12 +30,13 @@
 import org.apache.geronimo.kernel.repository.Artifact;
 
 /**
- * @version $Rev:$ $Date:$
+ * @version $Rev$ $Date$
  */
-@Entity
+@Entity(name="plugin")
 public class JpaPluginInstance {
 
     @Id
+    @GeneratedValue
     private int id;
     private String groupId;
     private String artifactId;

Modified: geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/JpaPluginList.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/JpaPluginList.java?rev=693703&r1=693702&r2=693703&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/JpaPluginList.java
(original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/JpaPluginList.java
Tue Sep  9 21:20:53 2008
@@ -27,6 +27,8 @@
 import javax.persistence.Entity;
 import javax.persistence.FetchType;
 import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
 import javax.persistence.ManyToMany;
 import javax.persistence.NamedQuery;
 
@@ -44,7 +46,12 @@
     @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE},
             fetch = FetchType.EAGER)
     private List<JpaPluginInstance> plugins = new ArrayList<JpaPluginInstance>();
-    @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
+    @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE},
+            fetch = FetchType.EAGER)
+    @JoinTable(name = "pluginlist_cluster",
+            joinColumns = {@JoinColumn(name = "pluginlist_name")},
+            inverseJoinColumns = {@JoinColumn(name = "cluster_name")}
+    )
     private List<JpaClusterInfo> clusters = new ArrayList<JpaClusterInfo>();
     private String defaultPluginRepository;
 



Mime
View raw message