geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r700858 - in /geronimo/server/trunk: assemblies/geronimo-boilerplate/src/main/underlay/etc/ framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ framework/modules/geronimo-plugin/src/main/java/org/apache/geronim...
Date Wed, 01 Oct 2008 18:26:31 GMT
Author: dblevins
Date: Wed Oct  1 11:26:31 2008
New Revision: 700858

URL: http://svn.apache.org/viewvc?rev=700858&view=rev
Log:
Inroduced a MulticastLocation gbean that hold the mutlicast connection info so it can be configured
in one place yet consumed by multiple gbeans.
Added a HeartbeatMonitor ghsell command (not quite working) that will allow people to see
what is moving on the heartbeat.
Renamed FarmCommand to ClusterCommand and its flags to -c and --cluster

Added:
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ClusterCommand.groovy
      - copied, changed from r700201, geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/FarmCommand.groovy
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/HeartbeatCommand.groovy
    geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/HeartbeatMonitor.java
    geronimo/server/trunk/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastLocation.java
    geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/HeartbeatMonitor.java
Removed:
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/FarmCommand.groovy
Modified:
    geronimo/server/trunk/assemblies/geronimo-boilerplate/src/main/underlay/etc/layout.xml
    geronimo/server/trunk/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastDiscoveryAgent.java
    geronimo/server/trunk/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastSearch.java
    geronimo/server/trunk/plugins/clustering/plugin-farm-member/pom.xml
    geronimo/server/trunk/plugins/clustering/plugin-farm-member/src/main/plan/plan.xml
    geronimo/server/trunk/plugins/clustering/plugin-farm/pom.xml
    geronimo/server/trunk/plugins/clustering/plugin-farm/src/main/plan/plan.xml

Modified: geronimo/server/trunk/assemblies/geronimo-boilerplate/src/main/underlay/etc/layout.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/assemblies/geronimo-boilerplate/src/main/underlay/etc/layout.xml?rev=700858&r1=700857&r2=700858&view=diff
==============================================================================
--- geronimo/server/trunk/assemblies/geronimo-boilerplate/src/main/underlay/etc/layout.xml
(original)
+++ geronimo/server/trunk/assemblies/geronimo-boilerplate/src/main/underlay/etc/layout.xml
Wed Oct  1 11:26:31 2008
@@ -200,10 +200,21 @@
                     <name>install-plugin</name>
                     <id>geronimo-commands:install-plugin</id>
                 </command>
+            </nodes>
+        </group>
+
+        <group>
+            <name>cluster</name>
+
+            <nodes>
+                <command>
+                    <name>deploy</name>
+                    <id>geronimo-commands:cluster</id>
+                </command>
 
                 <command>
-                    <name>farm</name>
-                    <id>geronimo-commands:farm</id>
+                    <name>heartbeat</name>
+                    <id>geronimo-commands:heartbeat</id>
                 </command>
             </nodes>
         </group>

Copied: geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ClusterCommand.groovy
(from r700201, 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/ClusterCommand.groovy?p2=geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ClusterCommand.groovy&p1=geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/FarmCommand.groovy&r1=700201&r2=700858&rev=700858&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/ClusterCommand.groovy
Wed Oct  1 11:26:31 2008
@@ -1,21 +1,21 @@
 /*
- * 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.
- */
+* 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
 
@@ -29,67 +29,67 @@
 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
+* List plugins.
+*
+* @version $Rev: 580864 $ $Date: 2007-09-30 23:47:39 -0700 (Sun, 30 Sep 2007) $
+*/
+@CommandComponent (id = 'geronimo-commands:cluster', description = 'administer cluster')
+class ClusterCommand
+   extends ConnectCommand
 {
-    @Option(name='-f', aliases=['--farm'], description='Farm to perform action on')
-    String farmName
+   @Option(name='-c', aliases=['--cluster'], description='Cluster to perform action on')
+   String clusterName
 
-    @Option(name='-l', aliases=['--pluginlist'], description='Plugin List to perform action
on')
-    String pluginList
+   @Option(name='-l', aliases=['--pluginlist'], description='Plugin List to perform action
on')
+   String pluginList
 
-    @Option(name='-a', aliases=['--pluginartifact'], description='Plugin Artifact to perform
action on')
-    String plugin
+   @Option(name='-a', aliases=['--pluginartifact'], description='Plugin Artifact to perform
action on')
+   String plugin
 
-    @Argument(metaVar='ACTION', required=true, index=0, description='Action (add/remove)
to perform')
-    String action
-
-    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 = (Farm)((RemoteDeploymentManager)deploymentManager).getImplementation(Farm.class);
-        def Map<String, DownloadResults> results;
-        if (action == "add") {
-            if (farmName && pluginList && plugin) {
-                results = farm.addPluginToCluster(farmName, pluginList, plugin);
-            } else if (farmName && pluginList) {
-                results = farm.addPluginList(farmName, pluginList);
-            } else if (pluginList && plugin) {
-                results = farm.addPlugin(pluginList, plugin);
-            } else {
-                io.out.println("add requires -f farm and -l plugin list, -l plugin list and
-a plugin, or all three")
-                return;
-            }
-        } else if (action == "remove") {
-            if (farmName && pluginList && plugin) {
-                io.out.println("remove requires -f farm and -l plugin list, or -l plugin
list and -a plugin, but not all three")
-                return;
-            } else if (farmName && pluginList) {
-                results = farm.removePluginListFromCluster(farmName, pluginList);
-            } else if (pluginList && plugin) {
-                results = farm.removePluginFromPluginList(pluginList, plugin);
-            } else {
-                io.out.println("remove requires -f farm and -l plugin list, or -l plugin
list and -a plugin")
-                return;
-            }
-        } else {
-            io.out.println("unknown command, expecting add or remove")
-            return;
-        }
-        io.out.println("Results:")
-        for (Map.Entry<String, DownloadResults> entry in results) {
-            io.out.println("results for node: " + entry.getKey());
-            CommandInstallCAR.printResults(consoleReader, entry.getValue(), 0);
-        }
-    }
+   @Argument(metaVar='ACTION', required=true, index=0, description='Action (add/remove) to
perform')
+   String action
+
+   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 = (Farm)((RemoteDeploymentManager)deploymentManager).getImplementation(Farm.class);
+       def Map<String, DownloadResults> results;
+       if (action == "add") {
+           if (clusterName && pluginList && plugin) {
+               results = farm.addPluginToCluster(clusterName, pluginList, plugin);
+           } else if (clusterName && pluginList) {
+               results = farm.addPluginList(clusterName, pluginList);
+           } else if (pluginList && plugin) {
+               results = farm.addPlugin(pluginList, plugin);
+           } else {
+               io.out.println("add requires -c <cluster> and -l <plugin list name>,
-l <plugin list name> and -a <plugin>, or all three")
+               return;
+           }
+       } else if (action == "remove") {
+           if (clusterName && pluginList && plugin) {
+               io.out.println("remove requires -c <cluster> and -l <plugin list
name>, or -l <plugin list name> and -a <plugin>, but not all three")
+               return;
+           } else if (clusterName && pluginList) {
+               results = farm.removePluginListFromCluster(clusterName, pluginList);
+           } else if (pluginList && plugin) {
+               results = farm.removePluginFromPluginList(pluginList, plugin);
+           } else {
+               io.out.println("remove requires -c <cluster> and -l <plugin list
name>, or -l <plugin list> and -a <plugin>")
+               return;
+           }
+       } else {
+           io.out.println("unknown command, expecting add or remove")
+           return;
+       }
+       io.out.println("Results:")
+       for (Map.Entry<String, DownloadResults> entry in results) {
+           io.out.println("results for node: " + entry.getKey());
+           CommandInstallCAR.printResults(consoleReader, entry.getValue(), 0);
+       }
+   }
 }

Added: geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/HeartbeatCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/HeartbeatCommand.groovy?rev=700858&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/HeartbeatCommand.groovy
(added)
+++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/HeartbeatCommand.groovy
Wed Oct  1 11:26:31 2008
@@ -0,0 +1,49 @@
+/*
+* 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.plugin.jmx.RemoteDeploymentManager
+import org.apache.geronimo.gshell.clp.Argument
+import org.apache.geronimo.gshell.clp.Option
+import org.apache.geronimo.gshell.command.annotation.CommandComponent
+import org.apache.geronimo.system.plugin.HeartbeatMonitor
+
+/**
+* List plugins.
+*
+* @version $Rev: 580864 $ $Date: 2007-09-30 23:47:39 -0700 (Sun, 30 Sep 2007) $
+*/
+@CommandComponent (id = 'geronimo-commands:heartbeat', description = 'monitor cluster heartbeat')
+class HeartbeatCommand
+   extends ConnectCommand
+{
+   @Option(name='-f', aliases=['--filter'], description='Regular expression to filter heartbeat
data displayed')
+   String filter
+
+   protected Object doExecute() throws Exception {
+       def connection = connect()
+
+       def deploymentManager = connection.getDeploymentManager();
+       def HeartbeatMonitor heartbeatmonitor = (HeartbeatMonitor)((RemoteDeploymentManager)deploymentManager).getImplementation(HeartbeatMonitor.class);
+
+       heartbeatmonitor.monitor(io.inputStream, io.outputStream, filter)
+   }
+}

Added: geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/HeartbeatMonitor.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/HeartbeatMonitor.java?rev=700858&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/HeartbeatMonitor.java
(added)
+++ geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/HeartbeatMonitor.java
Wed Oct  1 11:26:31 2008
@@ -0,0 +1,29 @@
+/**
+ * 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.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface HeartbeatMonitor {
+
+    void monitor(InputStream in, OutputStream output, String pattern);
+
+}

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=700858&r1=700857&r2=700858&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
Wed Oct  1 11:26:31 2008
@@ -40,6 +40,7 @@
 import org.slf4j.LoggerFactory;
 import org.apache.geronimo.gbean.annotation.GBean;
 import org.apache.geronimo.gbean.annotation.ParamAttribute;
+import org.apache.geronimo.gbean.annotation.ParamReference;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 
 /**
@@ -83,8 +84,7 @@
     private int maxReconnectAttempts = 10; // todo: check this out
     // ---------------------------------
 
-    public MulticastDiscoveryAgent(@ParamAttribute(name="host") String host,
-                                   @ParamAttribute(name="port") int port,
+    public MulticastDiscoveryAgent(@ParamReference(name="MulticastLocation")MulticastLocation
location,
                                    @ParamAttribute(name="heartRate") long heartRate,
                                    @ParamAttribute(name="maxMissedHeartbeats") int maxMissedHeartbeats,
                                    @ParamAttribute(name="loopbackMode")  boolean loopbackMode,
@@ -93,8 +93,8 @@
                                    @ParamAttribute(name="maxReconnectAttempts") int maxReconnectAttempts,
                                    @ParamAttribute(name="backOffMultiplier") long backOffMultiplier,
                                    @ParamAttribute(name="useExponentialBackOff") boolean
useExponentialBackOff) {
-        this.host = host;
-        this.port = port;
+        this.host = location.getHost();
+        this.port = location.getPort();
         this.heartRate = heartRate;
         this.maxMissedHeartbeats = maxMissedHeartbeats;
         this.loopbackMode = loopbackMode;

Added: geronimo/server/trunk/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastLocation.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastLocation.java?rev=700858&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastLocation.java
(added)
+++ geronimo/server/trunk/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastLocation.java
Wed Oct  1 11:26:31 2008
@@ -0,0 +1,47 @@
+/**
+ * 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.discovery;
+
+import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.ParamAttribute;
+
+/**
+ * Simple Gbean that holds the multicast location info so that
+ * other gbeans can consume it without the information having
+ * to be replicated in other gbeans.
+ */
+@GBean
+public class MulticastLocation {
+
+    private final String host;
+    private final int port;
+
+    public MulticastLocation(@ParamAttribute(name="host") String host,
+                             @ParamAttribute(name="port") int port) {
+        this.host = host;
+        this.port = port;
+    }
+
+    public String getHost() {
+        return host;
+    }
+
+    public int getPort() {
+        return port;
+    }
+
+}

Modified: geronimo/server/trunk/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastSearch.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastSearch.java?rev=700858&r1=700857&r2=700858&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastSearch.java
(original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastSearch.java
Wed Oct  1 11:26:31 2008
@@ -20,6 +20,7 @@
 import java.net.MulticastSocket;
 import java.net.InetAddress;
 import java.net.DatagramPacket;
+import java.net.SocketException;
 import java.util.concurrent.TimeUnit;
 import java.io.IOException;
 
@@ -74,6 +75,7 @@
                         return service;
                     }
                 }
+            } catch (SocketException e) {
             } finally {
                 long stop = System.currentTimeMillis();
                 waited += stop - start;

Added: geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/HeartbeatMonitor.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/HeartbeatMonitor.java?rev=700858&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/HeartbeatMonitor.java
(added)
+++ geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/HeartbeatMonitor.java
Wed Oct  1 11:26:31 2008
@@ -0,0 +1,92 @@
+/**
+ * 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 org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.ParamReference;
+import org.apache.geronimo.farm.discovery.MulticastLocation;
+import org.apache.geronimo.farm.discovery.MulticastSearch;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.net.URI;
+
+@GBean
+public class HeartbeatMonitor implements org.apache.geronimo.system.plugin.HeartbeatMonitor
{
+
+    private final MulticastLocation location;
+
+    public HeartbeatMonitor(@ParamReference(name = "MulticastLocation") MulticastLocation
location) {
+        this.location = location;
+    }
+
+    public void monitor(final InputStream in, final OutputStream output, String pattern)
{
+        if (pattern == null || pattern.equals("")) pattern = ".*";
+
+        final PrintStream out = new PrintStream(output);
+
+        final Pattern regex;
+        try {
+            regex = Pattern.compile(pattern);
+        } catch (Exception e) {
+            out.println("Invalid java.util.regex.Pattern \"" + pattern + "\"");
+            return;
+        }
+
+        out.println("Hit any key to stop.");
+
+        final AtomicBoolean stop = new AtomicBoolean();
+
+        Runnable runnable = new Runnable(){
+            public void run() {
+                try {
+                    in.read();
+                } catch (IOException e) {
+                } finally {
+                    stop.set(true);
+                }
+            }
+        };
+        Thread thread = new Thread(runnable);
+        thread.setDaemon(true);
+        thread.start();
+
+        try {
+            MulticastSearch multicast = new MulticastSearch(location.getHost(), location.getPort());
+
+
+            multicast.search(new MulticastSearch.Filter(){
+                public boolean accept(URI service) {
+                    String s = service.toString();
+                    Matcher matcher = regex.matcher(s);
+                    if (matcher.matches()){
+                        out.println(s);
+                    }
+                    return stop.get();
+                }
+            });
+        } catch (IOException e) {
+            e.printStackTrace(out);
+        }
+    }
+}

Modified: geronimo/server/trunk/plugins/clustering/plugin-farm-member/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/plugin-farm-member/pom.xml?rev=700858&r1=700857&r2=700858&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/plugin-farm-member/pom.xml (original)
+++ geronimo/server/trunk/plugins/clustering/plugin-farm-member/pom.xml Wed Oct  1 11:26:31
2008
@@ -82,7 +82,7 @@
                                     <attribute name="nodeName">${NodeName}</attribute>
                                     <attribute name="clusterName">${ClusterName}</attribute>
                                 </gbean>
-                                <gbean name="DiscoveryAgent">
+                                <gbean name="MulticastLocation">
                                     <attribute name="host">${MulticastDiscoveryAddress}</attribute>
                                     <attribute name="port">${MulticastDiscoveryPort}</attribute>
                                 </gbean>

Modified: geronimo/server/trunk/plugins/clustering/plugin-farm-member/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/plugin-farm-member/src/main/plan/plan.xml?rev=700858&r1=700857&r2=700858&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/plugin-farm-member/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/plugins/clustering/plugin-farm-member/src/main/plan/plan.xml Wed
Oct  1 11:26:31 2008
@@ -37,9 +37,12 @@
         </dependency>
     </gbean>
 
-    <gbean name="DiscoveryAgent" class="org.apache.geronimo.farm.discovery.MulticastDiscoveryAgent">
+    <gbean name="MulticastLocation" class="org.apache.geronimo.farm.discovery.MulticastLocation">
         <attribute name="host">239.255.3.2</attribute>
         <attribute name="port">6142</attribute>
+    </gbean>
+
+    <gbean name="DiscoveryAgent" class="org.apache.geronimo.farm.discovery.MulticastDiscoveryAgent">
         <attribute name="heartRate">500</attribute>
         <attribute name="maxMissedHeartbeats">10</attribute>
         <attribute name="loopbackMode">false</attribute>
@@ -47,6 +50,9 @@
         <attribute name="maxReconnectDelay">30000</attribute>
         <attribute name="backOffMultiplier">0</attribute>
         <attribute name="useExponentialBackOff">false</attribute>
+        <reference name="MulticastLocation">
+            <name>MulticastLocation</name>
+        </reference>
     </gbean>
 
 </module>

Modified: geronimo/server/trunk/plugins/clustering/plugin-farm/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/plugin-farm/pom.xml?rev=700858&r1=700857&r2=700858&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/plugin-farm/pom.xml (original)
+++ geronimo/server/trunk/plugins/clustering/plugin-farm/pom.xml Wed Oct  1 11:26:31 2008
@@ -89,7 +89,7 @@
                                     <attribute name="userName">system</attribute>
                                     <attribute name="password">manager</attribute>
                                 </gbean>
-                                <gbean name="DiscoveryAgent">
+                                <gbean name="MulticastLocation">
                                     <attribute name="host">${MulticastDiscoveryAddress}</attribute>
                                     <attribute name="port">${MulticastDiscoveryPort}</attribute>
                                 </gbean>

Modified: geronimo/server/trunk/plugins/clustering/plugin-farm/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/plugin-farm/src/main/plan/plan.xml?rev=700858&r1=700857&r2=700858&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/plugin-farm/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/plugins/clustering/plugin-farm/src/main/plan/plan.xml Wed Oct  1
11:26:31 2008
@@ -53,9 +53,18 @@
         </reference>
     </gbean>
 
-    <gbean name="DiscoveryAgent" class="org.apache.geronimo.farm.discovery.MulticastDiscoveryAgent">
+    <gbean name="MulticastLocation" class="org.apache.geronimo.farm.discovery.MulticastLocation">
         <attribute name="host">239.255.3.2</attribute>
         <attribute name="port">6142</attribute>
+    </gbean>
+
+    <gbean name="HeartbeatMonitor" class="org.apache.geronimo.farm.plugin.HeartbeatMonitor">
+        <reference name="MulticastLocation">
+            <name>MulticastLocation</name>
+        </reference>
+    </gbean>
+
+    <gbean name="DiscoveryAgent" class="org.apache.geronimo.farm.discovery.MulticastDiscoveryAgent">
         <attribute name="heartRate">500</attribute>
         <attribute name="maxMissedHeartbeats">10</attribute>
         <attribute name="loopbackMode">false</attribute>
@@ -63,6 +72,9 @@
         <attribute name="maxReconnectDelay">30000</attribute>
         <attribute name="backOffMultiplier">0</attribute>
         <attribute name="useExponentialBackOff">false</attribute>
+        <reference name="MulticastLocation">
+            <name>MulticastLocation</name>
+        </reference>
     </gbean>
 
     <gbean name="FarmDiscoveryListener" class="org.apache.geronimo.farm.plugin.FarmDiscoveryListener">



Mime
View raw message