geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From genspr...@apache.org
Subject svn commit: r926007 [1/2] - in /geronimo/server/branches/2.2/plugins/clustering: ./ geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/ geronimo-farm-wadi/ geronimo-farm-wadi/src/ geronimo-farm-wadi/src/main/ geronimo-farm-wadi/...
Date Mon, 22 Mar 2010 09:21:23 GMT
Author: genspring
Date: Mon Mar 22 09:21:20 2010
New Revision: 926007

URL: http://svn.apache.org/viewvc?rev=926007&view=rev
Log:
GERONIMO-4535 Alternate Node Discovery for Plugin Based Farming,  Resolved this JIRA with a WADI based plugin farm implementation:

A, Refactored geronimo-farm module to only include the commone classes that a plugin based farm needs as well as a multi-cast discovery implementation.

B, added geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManagerHolder.java  so that one can start a WADISessionManager by defining a GBean in deployment plan directly.

C, added 4 maven module:

1, geronimo-farm-wadi
   It's Jar module that includes implementions of major wadi based node discovery logic.

2, plugin-farm-wadi
   It's a config that defines the GBeans a plugin based farm controller needs.

3, plugin-farm-member-wadi
   It's a config that defines the GBeans a plugin based farm member needs.

4, geronimo-plugin-farm-node-wadi
   It's a customized assembly that includes the minimum set of plugins for plugin based farm member.

Added:
    geronimo/server/branches/2.2/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManagerHolder.java   (with props)
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/pom.xml   (with props)
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/discovery/
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/discovery/wadi/
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/discovery/wadi/WADIDiscoveryAgent.java   (with props)
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/service/
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/service/BasicNodeSerivceTracker.java   (with props)
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/service/NodeServiceTracker.java   (with props)
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/service/NodeServiceTrackerClusteredServiceHolder.java   (with props)
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/service/NodeServiceTrackerListener.java   (with props)
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/multicast/
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/multicast/MulticastDiscoveryAgent.java
      - copied, changed from r899548, geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastDiscoveryAgent.java
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/multicast/MulticastLocation.java
      - copied, changed from r899548, geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastLocation.java
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/multicast/MulticastSearch.java
      - copied, changed from r899548, geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastSearch.java
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/service/
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/service/NodeService.java   (with props)
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/service/NodeServiceVitals.java   (with props)
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/service/NodeServiceVitalsFactory.java   (with props)
    geronimo/server/branches/2.2/plugins/clustering/geronimo-plugin-farm-node-wadi/
    geronimo/server/branches/2.2/plugins/clustering/geronimo-plugin-farm-node-wadi/pom.xml   (with props)
    geronimo/server/branches/2.2/plugins/clustering/geronimo-plugin-farm-node-wadi/src/
    geronimo/server/branches/2.2/plugins/clustering/geronimo-plugin-farm-node-wadi/src/main/
    geronimo/server/branches/2.2/plugins/clustering/geronimo-plugin-farm-node-wadi/src/main/resources/
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm-member-wadi/
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm-member-wadi/pom.xml   (with props)
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm-member-wadi/src/
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm-member-wadi/src/main/
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm-member-wadi/src/main/history/
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm-member-wadi/src/main/history/dependencies.xml   (with props)
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm-member-wadi/src/main/plan/
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm-member-wadi/src/main/plan/plan.xml   (with props)
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm-member-wadi/src/main/resources/
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm-member-wadi/src/main/resources/cluster-repository/
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm-member-wadi/src/main/resources/cluster-repository/EMPTY
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm-member-wadi/src/main/resources/master-repository/
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm-member-wadi/src/main/resources/master-repository/EMPTY
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm-wadi/
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm-wadi/pom.xml   (with props)
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm-wadi/src/
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm-wadi/src/main/
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm-wadi/src/main/history/
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm-wadi/src/main/history/dependencies.xml   (with props)
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm-wadi/src/main/plan/
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm-wadi/src/main/plan/plan.xml   (with props)
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm-wadi/src/main/resources/
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm-wadi/src/main/resources/cluster-repository/
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm-wadi/src/main/resources/cluster-repository/EMPTY
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm-wadi/src/main/resources/master-repository/
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm-wadi/src/main/resources/master-repository/EMPTY
Removed:
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastDiscoveryAgent.java
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastLocation.java
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastSearch.java
Modified:
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/DiscoveryAgent.java
    geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/JmxDiscoveryPublisher.java
    geronimo/server/branches/2.2/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/HeartbeatMonitor.java
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm-member/src/main/plan/plan.xml
    geronimo/server/branches/2.2/plugins/clustering/plugin-farm/src/main/plan/plan.xml
    geronimo/server/branches/2.2/plugins/clustering/pom.xml

Added: geronimo/server/branches/2.2/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManagerHolder.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManagerHolder.java?rev=926007&view=auto
==============================================================================
--- geronimo/server/branches/2.2/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManagerHolder.java (added)
+++ geronimo/server/branches/2.2/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManagerHolder.java Mon Mar 22 09:21:20 2010
@@ -0,0 +1,96 @@
+/**
+ *  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.clustering.wadi;
+
+import java.net.URI;
+import java.util.Collection;
+
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+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.annotation.ParamSpecial;
+import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
+import org.codehaus.wadi.replication.strategy.BackingStrategyFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 
+ * @version $Rev$ $Date$
+ */
+@GBean(name = "BasicWADISessionManagerHolder", j2eeType = GBeanInfoBuilder.DEFAULT_J2EE_TYPE)
+public class BasicWADISessionManagerHolder implements GBeanLifecycle {
+
+    private static final String GBEAN_ATTR_SERVICE_SPACE_URI = "serviceSpaceURI";
+    private static final String GBEAN_ATTR_SWEEP_INTERVAL = "sweepInterval";
+    private static final String GBEAN_ATTR_SESSION_TIMEOUT = "sessionTimeout";
+    private static final String GBEAN_ATTR_NUM_PARTITIONS = "numPartitions";
+    private static final String GBEAN_ATTR_DISABLE_REPLICATION = "disableReplication";
+    private static final String GBEAN_ATTR_DELTA_REPLICATION = "deltaReplication";
+
+    private final BasicWADISessionManager basicWADISessionManager;
+
+    private static final Logger log = LoggerFactory.getLogger(BasicWADISessionManagerHolder.class);
+
+    public BasicWADISessionManagerHolder(
+            @ParamSpecial(type = SpecialAttributeType.classLoader) ClassLoader cl,
+            @ParamAttribute(name = GBEAN_ATTR_SERVICE_SPACE_URI) URI serviceSpaceURI,
+            @ParamAttribute(name = GBEAN_ATTR_SWEEP_INTERVAL) int sweepInterval,
+            @ParamAttribute(name = GBEAN_ATTR_SESSION_TIMEOUT) int sessionTimeout,
+            @ParamAttribute(name = GBEAN_ATTR_NUM_PARTITIONS) int numPartitions,
+            @ParamAttribute(name = GBEAN_ATTR_DISABLE_REPLICATION) boolean disableReplication,
+            @ParamAttribute(name = GBEAN_ATTR_DELTA_REPLICATION) boolean deltaReplication,
+            @ParamReference(name = BasicWADISessionManager.GBEAN_REF_CLUSTER) WADICluster cluster,
+            @ParamReference(name = BasicWADISessionManager.GBEAN_REF_BACKING_STRATEGY_FACTORY) BackingStrategyFactory backingStrategyFactory,
+            @ParamReference(name = BasicWADISessionManager.GBEAN_REF_SERVICE_HOLDERS) Collection<ClusteredServiceHolder> serviceHolders) {
+        if (null == cl) {
+            throw new IllegalArgumentException("cl is required");
+        } else if (null == serviceSpaceURI) {
+            throw new IllegalArgumentException("serviceSpaceURI is required");
+        } else if (null == cluster) {
+            throw new IllegalArgumentException("cluster is required");
+        } else if (null == backingStrategyFactory) {
+            throw new IllegalArgumentException("backingStrategyFactory is required");
+        }
+
+        WADISessionManagerConfigInfo configInfo = new WADISessionManagerConfigInfo(serviceSpaceURI, sweepInterval,
+                numPartitions, sessionTimeout, disableReplication, deltaReplication);
+
+        basicWADISessionManager = new BasicWADISessionManager(cl, configInfo, cluster, backingStrategyFactory,
+                serviceHolders);
+
+    }
+
+    public BasicWADISessionManager getBasicWADISessionManager() {
+        return basicWADISessionManager;
+    }
+
+    public void doStart() throws Exception {
+        basicWADISessionManager.doStart();
+    }
+
+    public void doStop() throws Exception {
+        basicWADISessionManager.doStop();
+    }
+
+    public void doFail() {
+        basicWADISessionManager.doFail();
+    }
+
+}

Propchange: geronimo/server/branches/2.2/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManagerHolder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/pom.xml?rev=926007&view=auto
==============================================================================
--- geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/pom.xml (added)
+++ geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/pom.xml Mon Mar 22 09:21:20 2010
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+    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.
+-->
+
+<!-- $Rev: 613667 $ $Date: 2008-01-20 12:18:37 -0800 (Sun, 20 Jan 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.geronimo.plugins</groupId>
+        <artifactId>clustering</artifactId>
+        <version>2.2.1-SNAPSHOT</version>
+    </parent>
+    
+    <groupId>org.apache.geronimo.modules</groupId>
+    <artifactId>geronimo-farm-wadi</artifactId>
+    <name>Geronimo Plugins, Clustering :: Farm wadi</name>
+    
+    <dependencies>
+
+        <dependency>
+            <groupId>org.apache.geronimo.framework</groupId>
+            <artifactId>geronimo-jmx-remoting</artifactId>
+            <version>${version}</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.geronimo.framework</groupId>
+            <artifactId>geronimo-service-builder</artifactId>
+            <version>${version}</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-clustering-wadi</artifactId>
+            <version>${version}</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-farm</artifactId>
+            <version>${version}</version>
+        </dependency>
+
+    </dependencies>
+    
+</project>
+

Propchange: geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/discovery/wadi/WADIDiscoveryAgent.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/discovery/wadi/WADIDiscoveryAgent.java?rev=926007&view=auto
==============================================================================
--- geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/discovery/wadi/WADIDiscoveryAgent.java (added)
+++ geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/discovery/wadi/WADIDiscoveryAgent.java Mon Mar 22 09:21:20 2010
@@ -0,0 +1,283 @@
+/**
+ * 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.wadi;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Map;
+import java.util.Set;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.apache.geronimo.clustering.wadi.BasicWADISessionManager;
+import org.apache.geronimo.clustering.wadi.BasicWADISessionManagerHolder;
+import org.apache.geronimo.farm.discovery.DiscoveryAgent;
+import org.apache.geronimo.farm.discovery.DiscoveryListener;
+import org.apache.geronimo.farm.service.NodeServiceTracker;
+import org.apache.geronimo.farm.service.NodeServiceTrackerListener;
+import org.apache.geronimo.farm.service.NodeServiceVitals;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.ParamAttribute;
+import org.apache.geronimo.gbean.annotation.ParamReference;
+import org.codehaus.wadi.servicespace.InvocationMetaData;
+import org.codehaus.wadi.servicespace.ServiceProxy;
+import org.codehaus.wadi.servicespace.ServiceProxyFactory;
+import org.codehaus.wadi.servicespace.ServiceRegistry;
+import org.codehaus.wadi.servicespace.ServiceSpace;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@GBean(name = "WADIDiscoveryAgent", j2eeType = GBeanInfoBuilder.DEFAULT_J2EE_TYPE)
+public class WADIDiscoveryAgent implements DiscoveryAgent, GBeanLifecycle {
+
+    static final Logger log = LoggerFactory.getLogger(WADIDiscoveryAgent.class);
+
+    private final BasicWADISessionManager WADISessionManager;
+    private NodeServiceTracker localTracker;
+    private NodeServiceTracker clusterNodeServiceTrackerProxy;
+
+    private AtomicBoolean started = new AtomicBoolean(false);
+
+    private int maxMissedHeartbeats = 10;
+    private long heartRate = 500;
+
+    private final NodeServiceHandlerThread listener;
+
+    private final String localNodeName;
+
+    public WADIDiscoveryAgent(
+            @ParamReference(name = "BasicWADISessionManagerHolder") BasicWADISessionManagerHolder WADISessionManagerHolder,
+            @ParamAttribute(name = "heartRate") long heartRate,
+            @ParamAttribute(name = "maxMissedHeartbeats") int maxMissedHeartbeats) {
+
+        this.WADISessionManager = WADISessionManagerHolder.getBasicWADISessionManager();
+        this.heartRate = heartRate;
+        this.maxMissedHeartbeats = maxMissedHeartbeats;
+        this.localNodeName = WADISessionManager.getNode().getName();
+        listener = new NodeServiceHandlerThread();
+    }
+
+    public String getName() {
+        return "WADI disovery Agent";
+    }
+
+    /* start of discoveryAgent interface implementation *************** */
+    public void setDiscoveryListener(final DiscoveryListener listener) {
+        // this.listener.setDiscoveryListener(listener);
+
+        localTracker.addNodeServiceTrackerListener(new NodeServiceTrackerListener() {
+
+            public void serviceAdded(URI service) {
+                listener.serviceAdded(service);
+
+            }
+
+            public void serviceRemoved(URI service) {
+                listener.serviceRemoved(service);
+
+            }
+
+        });
+    }
+
+    public void registerService(URI serviceUri) throws IOException {
+
+        localTracker.registerLocalNodeService(serviceUri);
+
+        // register local service to remote peers
+        clusterNodeServiceTrackerProxy.registerNodeService(localNodeName, serviceUri);
+    }
+
+    public void unregisterService(URI serviceUri) throws IOException {
+
+        localTracker.unregisterNodeService(localNodeName, serviceUri);
+
+        clusterNodeServiceTrackerProxy.unregisterNodeService(localNodeName, serviceUri);
+    }
+
+    public void reportFailed(URI serviceUri) throws IOException {
+        Map<String, NodeServiceVitals> localServices = localTracker.getLocalNodeServices();
+        NodeServiceVitals vitals = localServices.get(serviceUri);
+
+        if (vitals != null && !vitals.isDead()) {
+            localServices.remove(vitals.getService().getUriString());
+        }
+    }
+
+    /* end of discoveryAgent interface implementation ************** */
+
+    /**
+     * start the discovery agent
+     * 
+     * @throws Exception
+     *             on error
+     */
+    public void doStart() throws Exception {
+
+        clusterNodeServiceTrackerProxy = getClusterNodeServiceTrackerProxy();
+        localTracker = getLocalNodeServiceTracker();
+
+        NodeServiceHandlerThread nodeServiceHandlerThread = new NodeServiceHandlerThread();
+        Timer timer = new Timer("WADIDiscoveryAgent: checkRemoteService", true);
+
+        timer.scheduleAtFixedRate(nodeServiceHandlerThread, 0, heartRate);
+
+        if (started.compareAndSet(false, true)) {
+
+            Thread listenerThread = new Thread(listener);
+            listenerThread.setName("WADIDiscoveryAgent: ListenerThread");
+            listenerThread.setDaemon(true);
+            listenerThread.start();
+        }
+    }
+
+    /**
+     * stop the channel
+     * 
+     * @throws Exception
+     *             pm error
+     */
+    public void doStop() throws Exception {
+        if (started.compareAndSet(true, false)) {
+            // multicast.close();
+        }
+    }
+
+    /**
+     * Fails the GBean. This informs the GBean that it is about to transition to the failed state.
+     */
+    public void doFail() {
+        try {
+            doStop();
+        } catch (Exception e) {
+            // ignore
+        }
+    }
+
+    class NodeServiceHandlerThread extends TimerTask {
+
+        public void run() {
+
+            checkRemoteServices();
+            broadCastLocalServicesToRemotePeers();
+        }
+
+        private void checkRemoteServices() {
+
+            Map<String, Map<String, NodeServiceVitals>> remoteServices = localTracker.getAllRemoteNodeServices();
+
+            //logAllRemoteServices(false, remoteServices);
+
+            long expireTime = System.currentTimeMillis() - (heartRate * maxMissedHeartbeats);
+
+            if (remoteServices == null || remoteServices.size() == 0)
+                return;
+
+            for (String nodeName : remoteServices.keySet()) {
+
+                Map<String, NodeServiceVitals> services = remoteServices.get(nodeName);
+
+                for (NodeServiceVitals serviceVitals : services.values()) {
+
+                    if (serviceVitals.getLastHeartbeat() < expireTime) {
+
+                        NodeServiceVitals vitals = services.remove(serviceVitals.getService().getUri());
+
+                        if (vitals != null && !vitals.isDead()) {
+
+                            localTracker.unregisterNodeService(nodeName, vitals.getService().getUri());
+
+                        }
+                    }
+                }
+
+            }
+
+        }
+
+        private void broadCastLocalServicesToRemotePeers() {
+            clusterNodeServiceTrackerProxy.registerNodeServices(localNodeName, localTracker.getLocalNodeServices());
+        }
+
+    }
+
+    private NodeServiceTracker getClusterNodeServiceTrackerProxy() {
+
+        ServiceSpace serviceSpace = WADISessionManager.getServiceSpace();
+        ServiceProxyFactory proxyFactory = serviceSpace.getServiceProxyFactory(NodeServiceTracker.NAME,
+                new Class[] { NodeServiceTracker.class });
+
+        InvocationMetaData invocationMetaData = proxyFactory.getInvocationMetaData();
+        invocationMetaData.setOneWay(true);
+
+        ServiceProxy proxy = proxyFactory.getProxy();
+
+        return (NodeServiceTracker) proxy;
+
+    }
+
+    private NodeServiceTracker getLocalNodeServiceTracker() {
+
+        ServiceSpace serviceSpace = WADISessionManager.getServiceSpace();
+        ServiceRegistry serviceRegistry = serviceSpace.getServiceRegistry();
+
+        try {
+            return (NodeServiceTracker) serviceRegistry.getStartedService(NodeServiceTracker.NAME);
+        } catch (Exception e) {
+            throw new IllegalStateException(e);
+        }
+    }
+
+    private void logAllRemoteServices(boolean isVerbose, Map<String, Map<String, NodeServiceVitals>> results) {
+
+        log.info("*" + localNodeName + " service registry:");
+
+        Set<String> NodeNameSet = results.keySet();
+        Map<String, NodeServiceVitals> services_in_node;
+        int i = 0;
+        for (String nodeName : NodeNameSet) {
+
+            i++;
+            log.info("    No." + i + ": " + nodeName);
+            services_in_node = results.get(nodeName);
+            Set<String> serviceURIs = services_in_node.keySet();
+
+            for (String serviceURI : serviceURIs) {
+                log.info("");
+                log.info("        Service:" + serviceURI);
+
+                if (isVerbose) {
+
+                    log.info("        " + services_in_node.get(serviceURI));
+
+                }
+            }
+
+        }
+
+        log.info("");
+        log.info("");
+
+    }
+
+}

Propchange: geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/discovery/wadi/WADIDiscoveryAgent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/service/BasicNodeSerivceTracker.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/service/BasicNodeSerivceTracker.java?rev=926007&view=auto
==============================================================================
--- geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/service/BasicNodeSerivceTracker.java (added)
+++ geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/service/BasicNodeSerivceTracker.java Mon Mar 22 09:21:20 2010
@@ -0,0 +1,224 @@
+/*
+ * 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.service;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Executor;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Basic NodeServiceTracker implementation
+ * 
+ * @version $Rev:$ $Date:$
+ */
+
+public class BasicNodeSerivceTracker implements NodeServiceTracker {
+
+    private static final Logger log = LoggerFactory.getLogger(BasicNodeSerivceTracker.class);
+
+    private final Map<String, Map<String, NodeServiceVitals>> remoteNodeServices;
+
+    private final Map<String, NodeServiceVitals> localServices;
+
+    private final Set<NodeServiceTrackerListener> nodeServiceLisenters;
+
+    private NodeServiceVitalsFactory serviceVitalsFactory;
+
+    public BasicNodeSerivceTracker() {
+        remoteNodeServices = new HashMap<String, Map<String, NodeServiceVitals>>();
+        nodeServiceLisenters = new HashSet<NodeServiceTrackerListener>();
+        localServices = new HashMap<String, NodeServiceVitals>();
+    }
+
+    public void registerLocalNodeService(URI localServiceURI) {
+
+        localServices.put(localServiceURI.toString(), serviceVitalsFactory.createSerivceVitals(new NodeService(
+                localServiceURI)));
+
+    }
+
+    public void registerNodeService(String nodeName, URI serviceURI) {
+
+        log.debug("registerNodeService:" + serviceURI + " to node:" + nodeName);
+
+        Map<String, NodeServiceVitals> services = this.getNodeServicesInRemoteNode(nodeName);
+
+        if (services.containsKey(serviceURI)) {
+            
+            log.debug("service heartbeat from service" + serviceURI + " of node:" + nodeName);
+
+            services.get(serviceURI).heartbeat();
+
+        } else {
+            
+            log.debug("fire service add event for service:" + serviceURI + " of node:" + nodeName);
+
+            services.put(serviceURI.toString(), serviceVitalsFactory.createSerivceVitals(new NodeService(serviceURI)));
+            fireServiceAddEvent(serviceURI);
+        }
+
+    }
+
+    public void registerNodeServices(String nodeName, Map<String, NodeServiceVitals> newNodeServices) {
+
+        log.debug("registerNodeServices:" + newNodeServices + " to node:" + nodeName);
+
+        Map<String, NodeServiceVitals> services = this.getNodeServicesInRemoteNode(nodeName);
+
+        for (String newServiceURI : newNodeServices.keySet()) {
+
+            if (services.containsKey(newServiceURI)) {
+                log.debug("service heartbeat from service" + newServiceURI + " of node:" + nodeName);
+                services.get(newServiceURI).heartbeat();
+
+            } else {
+                log.debug("fire service add event for service:" + newServiceURI + " of node:" + nodeName);
+                services.put(newServiceURI, newNodeServices.get(newServiceURI));
+                fireServiceAddEvent(newNodeServices.get(newServiceURI).getService().getUri());
+            }
+
+        }
+
+    }
+
+    public void unregisterNodeService(String nodeName, URI serviceURI) {
+
+        log.info("unregisterNodeServices:" + serviceURI + " to node:" + nodeName);
+
+        Map<String, NodeServiceVitals> services = this.getNodeServicesInRemoteNode(nodeName);
+
+        if (services.containsKey(serviceURI.toString())) {
+            services.remove(serviceURI.toString());
+            fireServiceRemovedEvent(serviceURI);
+        }
+
+    }
+
+    public void unregisterNodeServices(String nodeName) {
+
+        log.info("unregister all NodeServices for node:" + nodeName);
+
+        synchronized (remoteNodeServices) {
+
+            Map<String, NodeServiceVitals> services = remoteNodeServices.remove(nodeName);
+
+            for (NodeServiceVitals vitals : services.values()) {
+                fireServiceRemovedEvent(vitals.getService().getUri());
+            }
+
+        }
+    }
+
+    public Map<String, NodeServiceVitals> getNodeServicesInRemoteNode(String nodeName) {
+
+        if (remoteNodeServices.get(nodeName) == null) {
+
+            remoteNodeServices.put(nodeName, new HashMap<String, NodeServiceVitals>());
+        }
+
+        return remoteNodeServices.get(nodeName);
+
+    }
+
+    public Map<String, NodeServiceVitals> getLocalNodeServices() {
+
+        return localServices;
+    }
+
+    public Map<String, Map<String, NodeServiceVitals>> getAllRemoteNodeServices() {
+
+        return remoteNodeServices;
+    }
+
+    public void addNodeServiceTrackerListener(NodeServiceTrackerListener nodeServiceListener) {
+        log.info("setNodeServiceListener "+nodeServiceListener);
+        nodeServiceLisenters.add(nodeServiceListener);
+    }
+
+    void setServiceVitalsFactory(NodeServiceVitalsFactory _serviceVitalsFactory) {
+        serviceVitalsFactory = _serviceVitalsFactory;
+    }
+
+    private final Executor executor = new ThreadPoolExecutor(1, 1, 30, TimeUnit.SECONDS,
+            new LinkedBlockingQueue<Runnable>(), new ThreadFactory() {
+                public Thread newThread(Runnable runable) {
+                    Thread t = new Thread(runable, "Multicast Discovery Agent Notifier");
+                    t.setDaemon(true);
+                    return t;
+                }
+            });
+
+    private void fireServiceRemovedEvent(final URI uri) {
+
+        if (nodeServiceLisenters == null || nodeServiceLisenters.size() == 0) {
+            return;
+        }
+
+        for (final NodeServiceTrackerListener listener : nodeServiceLisenters) {
+            // Have the listener process the event async so that
+            // he does not block this thread since we are doing time sensitive
+            // processing of events.
+            executor.execute(new Runnable() {
+                public void run() {
+                    if (listener != null) {
+                        listener.serviceRemoved(uri);
+                    }
+                }
+            });
+        }
+
+    }
+
+    private void fireServiceAddEvent(final URI uri) {
+
+
+        if (nodeServiceLisenters == null || nodeServiceLisenters.size() == 0) {
+            
+            log.info("nodeServiceLisenters is null or nodeServiceLisenters.size =0");
+            return;
+        }
+
+        for (final NodeServiceTrackerListener listener : nodeServiceLisenters) {
+
+            // Have the listener process the event async so that
+            // he does not block this thread since we are doing time sensitive
+            // processing of events.
+            executor.execute(new Runnable() {
+                public void run() {
+                    if (listener != null) {
+                        log.info("listener.serviceAdded(uri):"+uri);
+                        listener.serviceAdded(uri);
+                    }
+                }
+            });
+        }
+    }
+
+}

Propchange: geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/service/BasicNodeSerivceTracker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/service/NodeServiceTracker.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/service/NodeServiceTracker.java?rev=926007&view=auto
==============================================================================
--- geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/service/NodeServiceTracker.java (added)
+++ geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/service/NodeServiceTracker.java Mon Mar 22 09:21:20 2010
@@ -0,0 +1,109 @@
+/*
+ * 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.service;
+
+import java.net.URI;
+import java.util.Map;
+
+import org.codehaus.wadi.servicespace.ServiceName;
+
+/**
+ * A tracker used to track all services in cluster.
+ * 
+ * 1, It's a cluster service registry to keep all local services as well as remote node services.
+ * 2, It will notify nodeServiceListener when services are added/removed.
+ * 
+ * @version $Rev:$ $Date:$
+ */
+public interface NodeServiceTracker {
+    
+    /**
+     * The name to identify this service in NodeServiceTrackerClusteredServiceHolder
+     */
+    ServiceName NAME = new ServiceName("NodeServiceTracker");
+
+    /**
+     * To register a service to a Node identified by nodeName, Usually used to register local service when server starts up.
+     * 
+     * @param serviceURI The service URI to register
+     */
+    void registerLocalNodeService(URI localServiceURI);
+    
+    /**
+     * To register a service to a Node identified by nodeName, Usually used to register local service to remote tracker when server starts up.
+     * 
+     * @param nodeName The node name to register the service.
+     * @param serviceURI The service URI to register
+     */
+    void registerNodeService(String nodeName, URI serviceURI);
+    
+    
+    /**
+     * Usually used in repeated task/thread to register local services to all remote nodes in cluster.
+     * @param nodeName The node name to register the services.
+     * @param nodeServices The services to register
+     */
+    void registerNodeServices(String nodeName, Map<String, NodeServiceVitals> nodeServices);
+
+    /**
+     * To unregister a service from a Node identified by nodeName, Usually used to unregister service from all nodes in cluster when the service is removed.
+     * @param nodeName nodeName The node name to unregister the service.
+     * @param serviceURI serviceURI The service URI to unregister
+     */
+    void unregisterNodeService(String nodeName, URI serviceURI);
+    
+    
+    /**
+     * To unregister all service from a Node identified by nodeName, Usually used to unregister services from all nodes in cluster when the current node is stopped/shutdown.
+     * @param nodeName The node name to unregister the services.
+     */
+    void unregisterNodeServices(String nodeName);
+    
+    /**
+     * To get all services in a peer Node in cluster .
+     * 
+     * @param nodeName the target node to get the services
+     * @return all services in a cluster Node identified by nodeName
+     */
+    Map<String, NodeServiceVitals> getNodeServicesInRemoteNode(String nodeName);
+    
+    
+    /**
+     * To get all local services in current node .
+     * 
+     * @return all local services in current Node
+     */
+    Map<String, NodeServiceVitals> getLocalNodeServices();
+    
+    /**
+     * To get all services in remote nodes.
+     * 
+     * @return all services in remote nodes.
+     */
+    Map<String, Map<String, NodeServiceVitals>>  getAllRemoteNodeServices();
+      
+    /**
+     * Set node listener to the tracker. the listeners will be notified when service are added or removed.
+     * 
+     * @return all services in remote nodes.
+     */
+    void addNodeServiceTrackerListener(NodeServiceTrackerListener nodeServiceListener);
+
+}

Propchange: geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/service/NodeServiceTracker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/service/NodeServiceTrackerClusteredServiceHolder.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/service/NodeServiceTrackerClusteredServiceHolder.java?rev=926007&view=auto
==============================================================================
--- geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/service/NodeServiceTrackerClusteredServiceHolder.java (added)
+++ geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/service/NodeServiceTrackerClusteredServiceHolder.java Mon Mar 22 09:21:20 2010
@@ -0,0 +1,55 @@
+/*
+ * 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.service;
+
+import org.apache.geronimo.clustering.wadi.ClusteredServiceHolder;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.ParamAttribute;
+import org.apache.geronimo.gbean.annotation.ParamReference;
+import org.codehaus.wadi.servicespace.ServiceName;
+
+/**
+ * 
+ * @version $Rev:$ $Date:$
+ */
+@GBean(name = "NodeServiceTrackerClusteredServiceHolder", j2eeType = GBeanInfoBuilder.DEFAULT_J2EE_TYPE)
+public class NodeServiceTrackerClusteredServiceHolder implements ClusteredServiceHolder {
+
+    private final NodeServiceVitalsFactory serviceVitalsFactory;
+
+    public NodeServiceTrackerClusteredServiceHolder(
+            @ParamAttribute(name = "localNodeName") String localNodeName,
+            @ParamReference(name = "NodeServiceVitalsFactory") NodeServiceVitalsFactory serviceVitalsFactory) {
+        super();
+        this.serviceVitalsFactory = serviceVitalsFactory;
+    }
+
+    public Object getService() {
+        BasicNodeSerivceTracker basicNodeServiceTracker = new BasicNodeSerivceTracker();
+        basicNodeServiceTracker.setServiceVitalsFactory(serviceVitalsFactory);
+        return basicNodeServiceTracker;
+    }
+
+    public ServiceName getServiceName() {
+        return NodeServiceTracker.NAME;
+    }
+
+}
\ No newline at end of file

Propchange: geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/service/NodeServiceTrackerClusteredServiceHolder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/service/NodeServiceTrackerListener.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/service/NodeServiceTrackerListener.java?rev=926007&view=auto
==============================================================================
--- geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/service/NodeServiceTrackerListener.java (added)
+++ geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/service/NodeServiceTrackerListener.java Mon Mar 22 09:21:20 2010
@@ -0,0 +1,30 @@
+/**
+ * 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.service;
+
+
+import java.net.URI;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface NodeServiceTrackerListener {
+    
+    public void serviceAdded(URI service);
+    public void serviceRemoved(URI service);
+
+}

Propchange: geronimo/server/branches/2.2/plugins/clustering/geronimo-farm-wadi/src/main/java/org/apache/geronimo/farm/service/NodeServiceTrackerListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/DiscoveryAgent.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/DiscoveryAgent.java?rev=926007&r1=926006&r2=926007&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/DiscoveryAgent.java (original)
+++ geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/DiscoveryAgent.java Mon Mar 22 09:21:20 2010
@@ -31,7 +31,10 @@ public interface DiscoveryAgent {
 
     /**
      * register a service
-     * @param serviceUri uri for new service
+     * @param serviceUri uri for new service. sample service uri:
+     *    farm:rmi://localhost:1109/JMXConnector?cluster=cluster1
+     *    cluster1:ejb:ejbd://localhost:4201
+     * 
      * @throws java.io.IOException on error
      */
     void registerService(URI serviceUri) throws IOException;

Modified: geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/JmxDiscoveryPublisher.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/JmxDiscoveryPublisher.java?rev=926007&r1=926006&r2=926007&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/JmxDiscoveryPublisher.java (original)
+++ geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/JmxDiscoveryPublisher.java Mon Mar 22 09:21:20 2010
@@ -29,6 +29,8 @@ import org.apache.geronimo.gbean.annotat
 import org.apache.geronimo.gbean.annotation.ParamReference;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.kernel.rmi.RMIRegistryService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * @version $Rev$ $Date$
@@ -36,6 +38,7 @@ import org.apache.geronimo.kernel.rmi.RM
 @GBean
 public class JmxDiscoveryPublisher implements GBeanLifecycle {
 
+    private static final Logger log = LoggerFactory.getLogger(JmxDiscoveryPublisher.class);
     private final URI service;
     private final DiscoveryAgent discoveryAgent;
 
@@ -56,6 +59,8 @@ public class JmxDiscoveryPublisher imple
             query = (query == null? "": query + "&") + "cluster=" + clusterName;
         }
         service = new URI(discoveryType + ":" + protocol, null,  rmiRegistryService.getHost(), rmiRegistryService.getPort(), "/" + urlPath , query, null);
+        
+        log.info("Register service:"+service + " to discoveryAgent");
         discoveryAgent.registerService(service);
     }
 

Copied: geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/multicast/MulticastDiscoveryAgent.java (from r899548, geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastDiscoveryAgent.java)
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/multicast/MulticastDiscoveryAgent.java?p2=geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/multicast/MulticastDiscoveryAgent.java&p1=geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastDiscoveryAgent.java&r1=899548&r2=926007&rev=926007&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastDiscoveryAgent.java (original)
+++ geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/multicast/MulticastDiscoveryAgent.java Mon Mar 22 09:21:20 2010
@@ -14,7 +14,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-package org.apache.geronimo.farm.discovery;
+package org.apache.geronimo.farm.discovery.multicast;
 
 import java.io.IOException;
 import java.net.DatagramPacket;
@@ -36,12 +36,17 @@ import java.util.concurrent.ThreadPoolEx
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.geronimo.farm.discovery.DiscoveryAgent;
+import org.apache.geronimo.farm.discovery.DiscoveryListener;
+import org.apache.geronimo.farm.service.NodeService;
+import org.apache.geronimo.farm.service.NodeServiceVitals;
+import org.apache.geronimo.farm.service.NodeServiceVitalsFactory;
+import org.apache.geronimo.gbean.GBeanLifecycle;
 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;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * @version $Rev$ $Date$
@@ -64,45 +69,30 @@ public class MulticastDiscoveryAgent imp
     private boolean loopbackMode = false;
     private SocketAddress address;
 
-    private Map<String, Service> registeredServices = new ConcurrentHashMap<String, Service>();
+    private Map<String, NodeService> registeredServices = new ConcurrentHashMap<String, NodeService>();
 
     private int maxMissedHeartbeats = 10;
     private long heartRate = 500;
 
     private final Listener listener;
 
-    public MulticastDiscoveryAgent() {
-        listener = new Listener();
-    }
+    private final NodeServiceVitalsFactory serviceVitalsFactory;
+
 
-    // ---------------------------------
-    // Listenting specific settings
-    private long initialReconnectDelay = 1000 * 5;
-    private long maxReconnectDelay = 1000 * 30;
-    private long backOffMultiplier = 0;
-    private boolean useExponentialBackOff;
-    private int maxReconnectAttempts = 10; // todo: check this out
-    // ---------------------------------
 
     public MulticastDiscoveryAgent(@ParamReference(name="MulticastLocation")MulticastLocation location,
                                    @ParamAttribute(name="heartRate") long heartRate,
                                    @ParamAttribute(name="maxMissedHeartbeats") int maxMissedHeartbeats,
                                    @ParamAttribute(name="loopbackMode")  boolean loopbackMode,
-                                   @ParamAttribute(name="initialReconnectDelay") long initialReconnectDelay,
-                                   @ParamAttribute(name="maxReconnectDelay") long maxReconnectDelay,
-                                   @ParamAttribute(name="maxReconnectAttempts") int maxReconnectAttempts,
-                                   @ParamAttribute(name="backOffMultiplier") long backOffMultiplier,
-                                   @ParamAttribute(name="useExponentialBackOff") boolean useExponentialBackOff) {
+                                   @ParamReference(name="NodeServiceVitalsFactory") NodeServiceVitalsFactory serviceVitalsFactory
+) {
+        this.serviceVitalsFactory = serviceVitalsFactory;
         this.host = location.getHost();
         this.port = location.getPort();
         this.heartRate = heartRate;
         this.maxMissedHeartbeats = maxMissedHeartbeats;
         this.loopbackMode = loopbackMode;
-        this.initialReconnectDelay = initialReconnectDelay;
-        this.maxReconnectDelay = maxReconnectDelay;
-        this.maxReconnectAttempts = maxReconnectAttempts;
-        this.backOffMultiplier = backOffMultiplier;
-        this.useExponentialBackOff = useExponentialBackOff;
+
         listener = new Listener();
     }
 
@@ -124,13 +114,13 @@ public class MulticastDiscoveryAgent imp
     }
 
     public void registerService(URI serviceUri) throws IOException {
-        Service service = new Service(serviceUri);
-        this.registeredServices.put(service.uriString, service);
+        NodeService service = new NodeService(serviceUri);
+        this.registeredServices.put(service.getUriString(), service);
     }
 
     public void unregisterService(URI serviceUri) throws IOException {
-        Service service = new Service(serviceUri);
-        this.registeredServices.remove(service.uriString);
+        NodeService service = new NodeService(serviceUri);
+        this.registeredServices.remove(service.getUriString());
     }
 
     public void reportFailed(URI serviceUri) throws IOException {
@@ -138,8 +128,8 @@ public class MulticastDiscoveryAgent imp
     }
 
 
-    private boolean isSelf(Service service) {
-        return isSelf(service.uriString);
+    private boolean isSelf(NodeService service) {
+        return isSelf(service.getUriString());
     }
 
     private boolean isSelf(String service) {
@@ -206,116 +196,11 @@ public class MulticastDiscoveryAgent imp
     }
 
 
-    class Service {
-        private final URI uri;
-        private final String uriString;
-
-        public Service(URI uri) {
-            this.uri = uri;
-            this.uriString = uri.toString();
-        }
-
-        public Service(String uriString) throws URISyntaxException {
-            this(new URI(uriString));
-        }
-    }
-
-    private class ServiceVitals {
-
-        private final Service service;
-
-        private long lastHeartBeat;
-        private long recoveryTime;
-        private int failureCount;
-        private boolean dead;
-
-        public ServiceVitals(Service service) {
-            this.service = service;
-            this.lastHeartBeat = System.currentTimeMillis();
-        }
-
-        public synchronized void heartbeat() {
-            lastHeartBeat = System.currentTimeMillis();
-
-            // Consider that the service recovery has succeeded if it has not
-            // failed in 60 seconds.
-            if (!dead && failureCount > 0 && (lastHeartBeat - recoveryTime) > 1000 * 60) {
-                if (log.isDebugEnabled()) {
-                    log.debug("I now think that the " + service + " service has recovered.");
-                }
-                failureCount = 0;
-                recoveryTime = 0;
-            }
-        }
-
-        public synchronized long getLastHeartbeat() {
-            return lastHeartBeat;
-        }
-
-        public synchronized boolean pronounceDead() {
-            if (!dead) {
-                dead = true;
-                failureCount++;
-
-                long reconnectDelay;
-                if (useExponentialBackOff) {
-                    reconnectDelay = (long) Math.pow(backOffMultiplier, failureCount);
-                    if (reconnectDelay > maxReconnectDelay) {
-                        reconnectDelay = maxReconnectDelay;
-                    }
-                } else {
-                    reconnectDelay = initialReconnectDelay;
-                }
-
-                if (log.isDebugEnabled()) {
-                    log.debug("Remote failure of " + service + " while still receiving multicast advertisements.  " +
-                            "Advertising events will be suppressed for " + reconnectDelay
-                            + " ms, the current failure count is: " + failureCount);
-                }
-
-                recoveryTime = System.currentTimeMillis() + reconnectDelay;
-                return true;
-            }
-            return false;
-        }
-
-        /**
-         * @return true if this broker is marked failed and it is now the right
-         *         time to start recovery.
-         */
-        public synchronized boolean doRecovery() {
-            if (!dead) {
-                return false;
-            }
-
-            // Are we done trying to recover this guy?
-            if (maxReconnectAttempts > 0 && failureCount > maxReconnectAttempts) {
-                if (log.isDebugEnabled()) {
-                    log.debug("Max reconnect attempts of the " + service + " service has been reached.");
-                }
-                return false;
-            }
-
-            // Is it not yet time?
-            if (System.currentTimeMillis() < recoveryTime) {
-                return false;
-            }
-
-            if (log.isDebugEnabled()) {
-                log.debug("Resuming event advertisement of the " + service + " service.");
-            }
-            dead = false;
-            return true;
-        }
-
-        public boolean isDead() {
-            return dead;
-        }
-    }
+  
 
 
     class Listener implements Runnable {
-        private Map<String, ServiceVitals> discoveredServices = new ConcurrentHashMap<String, ServiceVitals>();
+        private Map<String, NodeServiceVitals> discoveredServices = new ConcurrentHashMap<String, NodeServiceVitals>();
         private DiscoveryListener discoveryListener;
 
         public void setDiscoveryListener(DiscoveryListener discoveryListener) {
@@ -331,7 +216,7 @@ public class MulticastDiscoveryAgent imp
                     multicast.receive(packet);
                     if (packet.getLength() > 0) {
                         String str = new String(packet.getData(), packet.getOffset(), packet.getLength());
-//                        System.out.println("read = " + str);
+                       System.out.println("read = " + str);
                         processData(str);
                     }
                 } catch (SocketTimeoutException se) {
@@ -352,15 +237,15 @@ public class MulticastDiscoveryAgent imp
                 return;
             }
 
-            ServiceVitals vitals = discoveredServices.get(uriString);
+            NodeServiceVitals vitals = discoveredServices.get(uriString);
 
             if (vitals == null) {
                 try {
-                    vitals = new ServiceVitals(new Service(uriString));
+                    vitals = serviceVitalsFactory.createSerivceVitals(new NodeService(uriString));
 
                     discoveredServices.put(uriString, vitals);
 
-                    fireServiceAddEvent(vitals.service.uri);
+                    fireServiceAddEvent(vitals.getService().getUri());
                 } catch (URISyntaxException e) {
                     // don't continuously log this
                 }
@@ -369,19 +254,19 @@ public class MulticastDiscoveryAgent imp
                 vitals.heartbeat();
 
                 if (vitals.doRecovery()) {
-                    fireServiceAddEvent(vitals.service.uri);
+                    fireServiceAddEvent(vitals.getService().getUri());
                 }
             }
         }
 
         private void checkServices() {
             long expireTime = System.currentTimeMillis() - (heartRate * maxMissedHeartbeats);
-            for (ServiceVitals serviceVitals : discoveredServices.values()) {
-                if (serviceVitals.getLastHeartbeat() < expireTime && !isSelf(serviceVitals.service)) {
+            for (NodeServiceVitals serviceVitals : discoveredServices.values()) {
+                if (serviceVitals.getLastHeartbeat() < expireTime && !isSelf(serviceVitals.getService())) {
 
-                    ServiceVitals vitals = discoveredServices.remove(serviceVitals.service.uriString);
+                    NodeServiceVitals vitals = discoveredServices.remove(serviceVitals.getService().getUriString());
                     if (vitals != null && !vitals.isDead()) {
-                        fireServiceRemovedEvent(vitals.service.uri);
+                        fireServiceRemovedEvent(vitals.getService().getUri());
                     }
                 }
             }
@@ -413,6 +298,7 @@ public class MulticastDiscoveryAgent imp
         }
 
         private void fireServiceAddEvent(final URI uri) {
+            System.out.println("discoveryAgent.fireServiceAddEvent");
             if (discoveryListener != null) {
                 final DiscoveryListener discoveryListener = this.discoveryListener;
 
@@ -430,10 +316,10 @@ public class MulticastDiscoveryAgent imp
         }
 
         public void reportFailed(URI serviceUri) {
-            final Service service = new Service(serviceUri);
-            ServiceVitals serviceVitals = discoveredServices.get(service.uriString);
+            final NodeService service = new NodeService(serviceUri);
+            NodeServiceVitals serviceVitals = discoveredServices.get(service.getUriString());
             if (serviceVitals != null && serviceVitals.pronounceDead()) {
-                fireServiceRemovedEvent(service.uri);
+                fireServiceRemovedEvent(service.getUri());
             }
         }
     }
@@ -452,7 +338,7 @@ public class MulticastDiscoveryAgent imp
                 try {
                     byte[] data = uri.getBytes();
                     DatagramPacket packet = new DatagramPacket(data, 0, data.length, address);
-//                    System.out.println("ann = " + uri);
+                    System.out.println("heart beat  = " + uri);
                     multicast.send(packet);
                     failed = null;
                 } catch (IOException e) {

Copied: geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/multicast/MulticastLocation.java (from r899548, geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastLocation.java)
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/multicast/MulticastLocation.java?p2=geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/multicast/MulticastLocation.java&p1=geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastLocation.java&r1=899548&r2=926007&rev=926007&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastLocation.java (original)
+++ geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/multicast/MulticastLocation.java Mon Mar 22 09:21:20 2010
@@ -14,7 +14,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-package org.apache.geronimo.farm.discovery;
+package org.apache.geronimo.farm.discovery.multicast;
 
 import org.apache.geronimo.gbean.annotation.GBean;
 import org.apache.geronimo.gbean.annotation.ParamAttribute;

Copied: geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/multicast/MulticastSearch.java (from r899548, geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastSearch.java)
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/multicast/MulticastSearch.java?p2=geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/multicast/MulticastSearch.java&p1=geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastSearch.java&r1=899548&r2=926007&rev=926007&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/MulticastSearch.java (original)
+++ geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/multicast/MulticastSearch.java Mon Mar 22 09:21:20 2010
@@ -14,7 +14,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-package org.apache.geronimo.farm.discovery;
+package org.apache.geronimo.farm.discovery.multicast;
 
 import java.net.URI;
 import java.net.MulticastSocket;

Added: geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/service/NodeService.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/service/NodeService.java?rev=926007&view=auto
==============================================================================
--- geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/service/NodeService.java (added)
+++ geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/service/NodeService.java Mon Mar 22 09:21:20 2010
@@ -0,0 +1,32 @@
+/**
+ * 
+ */
+package org.apache.geronimo.farm.service;
+
+import java.io.Serializable;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+public class NodeService implements Serializable {
+
+    private static final long serialVersionUID = 8329271824511964537L;
+    private final URI uri;
+    private final String uriString;
+
+    public URI getUri() {
+        return uri;
+    }
+
+    public String getUriString() {
+        return uriString;
+    }
+
+    public NodeService(URI uri) {
+        this.uri = uri;
+        this.uriString = uri.toString();
+    }
+
+    public NodeService(String uriString) throws URISyntaxException {
+        this(new URI(uriString));
+    }
+}

Propchange: geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/service/NodeService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/service/NodeServiceVitals.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/service/NodeServiceVitals.java?rev=926007&view=auto
==============================================================================
--- geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/service/NodeServiceVitals.java (added)
+++ geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/service/NodeServiceVitals.java Mon Mar 22 09:21:20 2010
@@ -0,0 +1,142 @@
+/**
+ * 
+ */
+package org.apache.geronimo.farm.service;
+
+import java.io.Serializable;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NodeServiceVitals implements Serializable {
+
+    static final Logger log = LoggerFactory.getLogger(NodeServiceVitals.class);
+
+    private static final long serialVersionUID = -7874058757277568424L;
+
+    private long initialReconnectDelay;
+    private long maxReconnectDelay;
+    private long backOffMultiplier;
+    private boolean useExponentialBackOff;
+    private int maxReconnectAttempts;
+
+    private final NodeService service;
+
+    public NodeService getService() {
+        return service;
+    }
+
+    long lastHeartBeat;
+    long recoveryTime;
+    int failureCount;
+    boolean dead;
+
+    NodeServiceVitals(NodeService service) {
+        this.service = service;
+        this.lastHeartBeat = System.currentTimeMillis();
+    }
+
+    public synchronized void heartbeat() {
+        lastHeartBeat = System.currentTimeMillis();
+
+        // Consider that the service recovery has succeeded if it has not
+        // failed in 60 seconds.
+        if (!dead && failureCount > 0 && (lastHeartBeat - recoveryTime) > 1000 * 60) {
+
+            log.debug("I now think that the " + service + " service has recovered.");
+
+            failureCount = 0;
+            recoveryTime = 0;
+        }
+    }
+
+    public synchronized long getLastHeartbeat() {
+        return lastHeartBeat;
+    }
+
+    public synchronized boolean pronounceDead() {
+        if (!dead) {
+            dead = true;
+            failureCount++;
+
+            long reconnectDelay;
+            if (useExponentialBackOff) {
+                reconnectDelay = (long) Math.pow(backOffMultiplier, failureCount);
+                if (reconnectDelay > maxReconnectDelay) {
+                    reconnectDelay = maxReconnectDelay;
+                }
+            } else {
+                reconnectDelay = initialReconnectDelay;
+            }
+
+            log.debug("Remote failure of " + service + " while still receiving multicast advertisements.  "
+                    + "Advertising events will be suppressed for " + reconnectDelay
+                    + " ms, the current failure count is: " + failureCount);
+
+            recoveryTime = System.currentTimeMillis() + reconnectDelay;
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * @return true if this broker is marked failed and it is now the right time to start recovery.
+     */
+    public synchronized boolean doRecovery() {
+        if (!dead) {
+            return false;
+        }
+
+        // Are we done trying to recover this guy?
+        if (maxReconnectAttempts > 0 && failureCount > maxReconnectAttempts) {
+
+            log.debug("Max reconnect attempts of the " + service + " service has been reached.");
+
+            return false;
+        }
+
+        // Is it not yet time?
+        if (System.currentTimeMillis() < recoveryTime) {
+            return false;
+        }
+
+        log.debug("Resuming event advertisement of the " + service + " service.");
+
+        dead = false;
+        return true;
+    }
+
+    public boolean isDead() {
+        return dead;
+    }
+
+    void setInitialReconnectDelay(long initialReconnectDelay) {
+        this.initialReconnectDelay = initialReconnectDelay;
+    }
+
+    void setMaxReconnectDelay(long maxReconnectDelay) {
+        this.maxReconnectDelay = maxReconnectDelay;
+    }
+
+    void setBackOffMultiplier(long backOffMultiplier) {
+        this.backOffMultiplier = backOffMultiplier;
+    }
+
+    void setUseExponentialBackOff(boolean useExponentialBackOff) {
+        this.useExponentialBackOff = useExponentialBackOff;
+    }
+
+    void setMaxReconnectAttempts(int maxReconnectAttempts) {
+        this.maxReconnectAttempts = maxReconnectAttempts;
+    }
+
+    @Override
+    public String toString() {
+        return "ServiceVitals [backOffMultiplier=" + backOffMultiplier + ", dead=" + dead + ", failureCount="
+                + failureCount + ", initialReconnectDelay=" + initialReconnectDelay + ", lastHeartBeat="
+                + lastHeartBeat + ", maxReconnectAttempts=" + maxReconnectAttempts + ", maxReconnectDelay="
+                + maxReconnectDelay + ", recoveryTime=" + recoveryTime + ", useExponentialBackOff="
+                + useExponentialBackOff + "]";
+    }
+
+}
\ No newline at end of file

Propchange: geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/service/NodeServiceVitals.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/service/NodeServiceVitalsFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/service/NodeServiceVitalsFactory.java?rev=926007&view=auto
==============================================================================
--- geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/service/NodeServiceVitalsFactory.java (added)
+++ geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/service/NodeServiceVitalsFactory.java Mon Mar 22 09:21:20 2010
@@ -0,0 +1,51 @@
+/**
+ * 
+ */
+package org.apache.geronimo.farm.service;
+
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.ParamAttribute;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@GBean(name="NodeServiceVitalsFactory",j2eeType=GBeanInfoBuilder.DEFAULT_J2EE_TYPE)
+public class NodeServiceVitalsFactory {
+
+    static final Logger log = LoggerFactory.getLogger(NodeServiceVitalsFactory.class);
+
+    // specific settings
+    private final long initialReconnectDelay;
+    private final long maxReconnectDelay;
+    private final long backOffMultiplier;
+    private final boolean useExponentialBackOff;
+    private final int maxReconnectAttempts;
+
+    public NodeServiceVitalsFactory(@ParamAttribute(name = "initialReconnectDelay") long initialReconnectDelay,
+            @ParamAttribute(name = "maxReconnectDelay") long maxReconnectDelay,
+            @ParamAttribute(name = "maxReconnectAttempts") int maxReconnectAttempts,
+            @ParamAttribute(name = "backOffMultiplier") long backOffMultiplier,
+            @ParamAttribute(name = "useExponentialBackOff") boolean useExponentialBackOff) {
+
+        this.initialReconnectDelay = initialReconnectDelay;
+        this.maxReconnectDelay = maxReconnectDelay;
+        this.maxReconnectAttempts = maxReconnectAttempts;
+        this.backOffMultiplier = backOffMultiplier;
+        this.useExponentialBackOff = useExponentialBackOff;
+
+    }
+
+    public NodeServiceVitals createSerivceVitals(NodeService nodeService) {
+
+        NodeServiceVitals serviceVitals = new NodeServiceVitals(nodeService);
+        
+        serviceVitals.setBackOffMultiplier(backOffMultiplier);
+        serviceVitals.setInitialReconnectDelay(initialReconnectDelay);
+        serviceVitals.setMaxReconnectAttempts(maxReconnectAttempts);
+        serviceVitals.setMaxReconnectDelay(maxReconnectDelay);
+        serviceVitals.setUseExponentialBackOff(useExponentialBackOff);
+
+        return serviceVitals;
+    }
+
+}
\ No newline at end of file

Propchange: geronimo/server/branches/2.2/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/service/NodeServiceVitalsFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/server/branches/2.2/plugins/clustering/geronimo-plugin-farm-node-wadi/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/clustering/geronimo-plugin-farm-node-wadi/pom.xml?rev=926007&view=auto
==============================================================================
--- geronimo/server/branches/2.2/plugins/clustering/geronimo-plugin-farm-node-wadi/pom.xml (added)
+++ geronimo/server/branches/2.2/plugins/clustering/geronimo-plugin-farm-node-wadi/pom.xml Mon Mar 22 09:21:20 2010
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+
+<!-- $Rev: 888222 $ $Date: 2009-12-08 09:57:50 +0800 (Tue, 08 Dec 2009) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <parent>
+        <artifactId>clustering</artifactId>
+        <groupId>org.apache.geronimo.plugins</groupId>
+        <version>2.2.1-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.apache.geronimo.assemblies</groupId>
+    <artifactId>geronimo-plugin-farm-node-wadi</artifactId>
+    <name>Geronim Plugin WADI Farm Node Server Assembly</name>
+    <packaging>server-assembly</packaging>
+
+    <description>An assembly that extends the framework assembly with the plugin WADI farm node plugin.</description>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.geronimo.buildsupport</groupId>
+                <artifactId>car-maven-plugin</artifactId>
+                <configuration>
+                    <servers>
+                        <serverInstance>
+                            <name>default</name>
+                            <configFile>var/config/config.xml</configFile>
+                            <configSubstitutionsFile>var/config/config-substitutions.properties</configSubstitutionsFile>
+                            <configSubstitutionsPrefix>org.apache.geronimo.config.substitution.</configSubstitutionsPrefix>
+                            <artifactAliasesFile>var/config/artifact_aliases.properties</artifactAliasesFile>
+                        </serverInstance>
+                        <serverInstance>
+                            <name>client</name>
+                            <attributeManagerFrom>default</attributeManagerFrom>
+                            <artifactAliasesFile>var/config/client_artifact_aliases.properties</artifactAliasesFile>
+                        </serverInstance>
+                        <serverInstance>
+                            <name>offline</name>
+                            <configFile>var/config/offline-deployer-config.xml</configFile>
+                            <configSubstitutionsFile>var/config/config-substitutions.properties</configSubstitutionsFile>
+                            <configSubstitutionsPrefix>org.apache.geronimo.config.substitution.</configSubstitutionsPrefix>
+                            <artifactAliasesFile>var/config/artifact_aliases.properties</artifactAliasesFile>
+                        </serverInstance>
+                        <serverInstance>
+                            <name>jsr88</name>
+                            <configFile>var/config/jsr88-configurer-config.xml</configFile>
+                            <configSubstitutionsFile>var/config/config-substitutions.properties</configSubstitutionsFile>
+                            <configSubstitutionsPrefix>org.apache.geronimo.config.substitution.</configSubstitutionsPrefix>
+                            <artifactAliasesFile>var/config/artifact_aliases.properties</artifactAliasesFile>
+                        </serverInstance>
+                    </servers>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.geronimo.framework.plugingroups</groupId>
+            <artifactId>framework</artifactId>
+            <version>${version}</version>
+            <type>car</type>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.configs</groupId>
+            <artifactId>plugin-farm-member-wadi</artifactId>
+            <version>${version}</version>
+            <type>car</type>
+        </dependency>
+    </dependencies>
+</project>
\ No newline at end of file

Propchange: geronimo/server/branches/2.2/plugins/clustering/geronimo-plugin-farm-node-wadi/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/server/branches/2.2/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/HeartbeatMonitor.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/HeartbeatMonitor.java?rev=926007&r1=926006&r2=926007&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/HeartbeatMonitor.java (original)
+++ geronimo/server/branches/2.2/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/HeartbeatMonitor.java Mon Mar 22 09:21:20 2010
@@ -19,8 +19,8 @@ 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 org.apache.geronimo.farm.discovery.multicast.MulticastLocation;
+import org.apache.geronimo.farm.discovery.multicast.MulticastSearch;
 
 import java.io.InputStream;
 import java.io.OutputStream;



Mime
View raw message