You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by gd...@apache.org on 2007/07/11 01:25:34 UTC
svn commit: r555111 [1/2] - in /geronimo/server/trunk:
assemblies/geronimo-boilerplate-minimal/src/main/resources/var/config/
assemblies/geronimo-jetty6-jee5/src/main/resources/var/config/
configs/clustering/ configs/clustering/src/plan/ configs/jetty6...
Author: gdamour
Date: Tue Jul 10 16:25:31 2007
New Revision: 555111
URL: http://svn.apache.org/viewvc?view=rev&rev=555111
Log:
* Add a Cluster GBean such that we can implement cluster aware services, for
instance a cluster aware deployer;
* When a clustered Web-application is deployed, we now deploy it to a Cluster
by specifying its name. The former mechanism was to deploy it to a
DispatcherHolder;
* Add Node.getJMXConnector such that clients can get a JMXConnector connected
to the target Node instance. Host and port connection details of this
JMXConnector are retrieved via the clustered service proxying/invocation of
WADI; and
* Use a configuration substitution mechanism to simplify the configuration of
node names.
Added:
geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicNodeService.java
geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADICluster.java
geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/NodeConnectionInfo.java
geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/NodeFactory.java
geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/NodeProxyFactory.java
geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/NodeService.java
geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/NodeServiceHelper.java
geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/RemoteNode.java
geronimo/server/trunk/modules/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/BasicNodeServiceTest.java
geronimo/server/trunk/modules/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/BasicWADIClusterTest.java
- copied, changed from r553487, geronimo/server/trunk/modules/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/WADIClusterTest.java
geronimo/server/trunk/modules/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/NodeServiceHelperTest.java
geronimo/server/trunk/modules/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/RemoteNodeTest.java
geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/AbstractNode.java
geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/BasicLocalNode.java
geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/LocalNode.java
geronimo/server/trunk/modules/geronimo-jmx-remoting/src/main/java/org/apache/geronimo/jmxremoting/JMXConnectorInfo.java
Removed:
geronimo/server/trunk/modules/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/WADIClusterTest.java
geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/BasicNode.java
Modified:
geronimo/server/trunk/assemblies/geronimo-boilerplate-minimal/src/main/resources/var/config/config-substitutions.properties
geronimo/server/trunk/assemblies/geronimo-jetty6-jee5/src/main/resources/var/config/config.xml
geronimo/server/trunk/configs/clustering/pom.xml
geronimo/server/trunk/configs/clustering/src/plan/plan.xml
geronimo/server/trunk/configs/jetty6-clustering-builder-wadi/src/plan/plan.xml
geronimo/server/trunk/configs/wadi-clustering/src/plan/plan.xml
geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManager.java
geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/TribesDispatcherHolder.java
geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/WADICluster.java
geronimo/server/trunk/modules/geronimo-clustering/pom.xml
geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/Node.java
geronimo/server/trunk/modules/geronimo-jetty6-clustering-builder-wadi/src/main/java/org/apache/geronimo/jetty6/cluster/wadi/builder/WADIJettyClusteringBuilder.java
geronimo/server/trunk/modules/geronimo-jetty6-clustering-builder-wadi/src/main/schema/geronimo-clustering-wadi-1.2.xsd
geronimo/server/trunk/modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/ApplicationTest.java
geronimo/server/trunk/modules/geronimo-jmx-remoting/src/main/java/org/apache/geronimo/jmxremoting/JMXConnector.java
Modified: geronimo/server/trunk/assemblies/geronimo-boilerplate-minimal/src/main/resources/var/config/config-substitutions.properties
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/assemblies/geronimo-boilerplate-minimal/src/main/resources/var/config/config-substitutions.properties?view=diff&rev=555111&r1=555110&r2=555111
==============================================================================
--- geronimo/server/trunk/assemblies/geronimo-boilerplate-minimal/src/main/resources/var/config/config-substitutions.properties (original)
+++ geronimo/server/trunk/assemblies/geronimo-boilerplate-minimal/src/main/resources/var/config/config-substitutions.properties Tue Jul 10 16:25:31 2007
@@ -47,4 +47,5 @@
PlanHTTPPortSecondary=8090
PlanHTTPSPortSecondary=8453
PlanAJPPortSecondary=8019
-PlanJMXPort=9999
\ No newline at end of file
+PlanJMXPort=9999
+PlanNodeName=NODE1
\ No newline at end of file
Modified: geronimo/server/trunk/assemblies/geronimo-jetty6-jee5/src/main/resources/var/config/config.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/assemblies/geronimo-jetty6-jee5/src/main/resources/var/config/config.xml?view=diff&rev=555111&r1=555110&r2=555111
==============================================================================
--- geronimo/server/trunk/assemblies/geronimo-jetty6-jee5/src/main/resources/var/config/config.xml (original)
+++ geronimo/server/trunk/assemblies/geronimo-jetty6-jee5/src/main/resources/var/config/config.xml Tue Jul 10 16:25:31 2007
@@ -284,4 +284,10 @@
<module name="org.apache.geronimo.configs/ca-helper-jetty/${version}/car" load="false"/>
+ <module name="org.apache.geronimo.configs/clustering/${version}/car">
+ <gbean name="Node">
+ <attribute name="nodeName">${PlanNodeName}</attribute>
+ </gbean>
+ </module>
+
</attributes>
Modified: geronimo/server/trunk/configs/clustering/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/clustering/pom.xml?view=diff&rev=555111&r1=555110&r2=555111
==============================================================================
--- geronimo/server/trunk/configs/clustering/pom.xml (original)
+++ geronimo/server/trunk/configs/clustering/pom.xml Tue Jul 10 16:25:31 2007
@@ -45,6 +45,13 @@
<type>car</type>
</dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.configs</groupId>
+ <artifactId>j2ee-security</artifactId>
+ <version>${version}</version>
+ <type>car</type>
+ </dependency>
+
<dependency>
<groupId>org.apache.geronimo.modules</groupId>
<artifactId>geronimo-clustering</artifactId>
Modified: geronimo/server/trunk/configs/clustering/src/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/clustering/src/plan/plan.xml?view=diff&rev=555111&r1=555110&r2=555111
==============================================================================
--- geronimo/server/trunk/configs/clustering/src/plan/plan.xml (original)
+++ geronimo/server/trunk/configs/clustering/src/plan/plan.xml Tue Jul 10 16:25:31 2007
@@ -20,8 +20,9 @@
<module xmlns="http://geronimo.apache.org/xml/ns/deployment-${geronimoSchemaVersion}">
- <gbean name="Node" class="org.apache.geronimo.clustering.BasicNode">
+ <gbean name="Node" class="org.apache.geronimo.clustering.BasicLocalNode">
<attribute name="nodeName">${PlanNodeName}</attribute>
+ <reference name="JMXConnector"><name>JMXService</name></reference>
</gbean>
</module>
Modified: geronimo/server/trunk/configs/jetty6-clustering-builder-wadi/src/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/jetty6-clustering-builder-wadi/src/plan/plan.xml?view=diff&rev=555111&r1=555110&r2=555111
==============================================================================
--- geronimo/server/trunk/configs/jetty6-clustering-builder-wadi/src/plan/plan.xml (original)
+++ geronimo/server/trunk/configs/jetty6-clustering-builder-wadi/src/plan/plan.xml Tue Jul 10 16:25:31 2007
@@ -26,7 +26,7 @@
<attribute name="defaultReplicationManagerFactoryName">?name=DefaultReplicationManagerFactory</attribute>
<attribute name="defaultReplicaStorageFactoryName">?name=DefaultReplicaStorageFactory</attribute>
<attribute name="defaultBackingStrategyFactoryName">?name=DefaultBackingStrategyFactory</attribute>
- <attribute name="defaultDispatcherHolderName">?name=DefaultDispatcherHolder</attribute>
+ <attribute name="defaultClusterName">?name=DefaultCluster</attribute>
<xml-attribute name="defaultEnvironment">
<environment xmlns="http://geronimo.apache.org/xml/ns/deployment-1.1">
<dependencies>
Modified: geronimo/server/trunk/configs/wadi-clustering/src/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/wadi-clustering/src/plan/plan.xml?view=diff&rev=555111&r1=555110&r2=555111
==============================================================================
--- geronimo/server/trunk/configs/wadi-clustering/src/plan/plan.xml (original)
+++ geronimo/server/trunk/configs/wadi-clustering/src/plan/plan.xml Tue Jul 10 16:25:31 2007
@@ -38,4 +38,9 @@
</reference>
</gbean>
+ <gbean name="DefaultCluster" class="org.apache.geronimo.clustering.wadi.BasicWADICluster">
+ <reference name="Node"><name>Node</name></reference>
+ <reference name="DispatcherHolder"><name>DefaultDispatcherHolder</name></reference>
+ </gbean>
+
</module>
Added: geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicNodeService.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicNodeService.java?view=auto&rev=555111
==============================================================================
--- geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicNodeService.java (added)
+++ geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicNodeService.java Tue Jul 10 16:25:31 2007
@@ -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.clustering.wadi;
+
+import org.apache.geronimo.clustering.LocalNode;
+import org.apache.geronimo.jmxremoting.JMXConnectorInfo;
+
+
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class BasicNodeService implements NodeService {
+
+ private final LocalNode localNode;
+
+ public BasicNodeService(LocalNode node) {
+ if (null == node) {
+ throw new IllegalArgumentException("node is required");
+ }
+ this.localNode = node;
+ }
+
+ public NodeConnectionInfo getConnectionInfo() {
+ JMXConnectorInfo connectorInfo = localNode.getJMXConnectorInfo();
+ return new NodeConnectionInfo(connectorInfo.getHost(), connectorInfo.getPort());
+ }
+
+ public void start() throws Exception {
+ }
+
+ public void stop() throws Exception {
+ }
+}
Added: geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADICluster.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADICluster.java?view=auto&rev=555111
==============================================================================
--- geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADICluster.java (added)
+++ geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADICluster.java Tue Jul 10 16:25:31 2007
@@ -0,0 +1,195 @@
+/**
+ * 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.util.Collection;
+import java.util.HashSet;
+import java.util.IdentityHashMap;
+import java.util.Set;
+
+import org.apache.geronimo.clustering.Cluster;
+import org.apache.geronimo.clustering.ClusterListener;
+import org.apache.geronimo.clustering.Node;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.codehaus.wadi.group.Peer;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class BasicWADICluster implements GBeanLifecycle, WADICluster {
+ private final Node node;
+ private final DispatcherHolder dispatcherHolder;
+ private final NodeFactory nodeFactory;
+ private final IdentityHashMap<Peer, Node> peerToNode;
+ private final IdentityHashMap<ClusterListener, org.codehaus.wadi.group.ClusterListener> listenerToWADIListener;
+
+ private org.codehaus.wadi.group.Cluster cluster;
+
+ public BasicWADICluster(Node node, DispatcherHolder dispatcherHolder) {
+ this(node, dispatcherHolder, new NodeProxyFactory());
+ }
+
+ public BasicWADICluster(Node node, DispatcherHolder dispatcherHolder, NodeFactory nodeFactory) {
+ if (null == node) {
+ throw new IllegalArgumentException("node is required");
+ } else if (null == dispatcherHolder) {
+ throw new IllegalArgumentException("dispatcherHolder is required");
+ }
+ this.node = node;
+ this.dispatcherHolder = dispatcherHolder;
+ this.nodeFactory = nodeFactory;
+
+ peerToNode = new IdentityHashMap<Peer, Node>();
+ listenerToWADIListener = new IdentityHashMap<ClusterListener, org.codehaus.wadi.group.ClusterListener>();
+ }
+
+ public void doStart() throws Exception {
+ cluster = dispatcherHolder.getDispatcher().getCluster();
+ }
+
+ public void doStop() throws Exception {
+ clearListeners();
+ }
+
+ public void doFail() {
+ clearListeners();
+ }
+
+ public org.codehaus.wadi.group.Cluster getCluster() {
+ return cluster;
+ }
+
+ public String getName() {
+ return cluster.getClusterName();
+ }
+
+ public Node getLocalNode() {
+ return node;
+ }
+
+ public Set<Node> getRemoteNodes() {
+ Collection<Peer> peers = cluster.getRemotePeers().values();
+ Set<Node> nodes = wrapAsNode(peers, false);
+ return nodes;
+ }
+
+ public void addClusterListener(ClusterListener listener) {
+ if (null == listener) {
+ throw new IllegalArgumentException("listener is required");
+ }
+ GeronimoClusterListenerAdaptor wadiListener = new GeronimoClusterListenerAdaptor(listener);
+ listenerToWADIListener.put(listener, wadiListener);
+ cluster.addClusterListener(wadiListener);
+ }
+
+ public void removeClusterListener(ClusterListener listener) {
+ org.codehaus.wadi.group.ClusterListener wadiListener = listenerToWADIListener.remove(listener);
+ if (null == wadiListener) {
+ throw new IllegalArgumentException(listener + " is not registered");
+ }
+ cluster.removeClusterListener(wadiListener);
+ }
+
+ protected void clearListeners() {
+ for (org.codehaus.wadi.group.ClusterListener wadiListener : listenerToWADIListener.values()) {
+ cluster.removeClusterListener(wadiListener);
+ }
+
+ listenerToWADIListener.clear();
+ }
+
+ protected Set<Node> wrapAsNode(Collection<Peer> peers, boolean remove) {
+ Set<Node> nodes = new HashSet<Node>();
+ for (Peer peer : peers) {
+ Node node = wrapAsNode(peer, remove);
+ nodes.add(node);
+ }
+ return nodes;
+ }
+
+ protected Node wrapAsNode(Peer peer, boolean remove) {
+ Node node;
+ synchronized (peerToNode) {
+ if (remove) {
+ node = peerToNode.remove(peer);
+ if (null == node) {
+ throw new AssertionError("no node mapped to peer");
+ }
+ } else {
+ node = peerToNode.get(peer);
+ if (null == node) {
+ node = newRemoteNode(peer);
+ peerToNode.put(peer, node);
+ }
+ }
+ }
+ return node;
+ }
+
+ protected Node newRemoteNode(Peer peer) {
+ return nodeFactory.newNode(cluster, peer);
+ }
+
+ protected class GeronimoClusterListenerAdaptor implements org.codehaus.wadi.group.ClusterListener {
+ private final ClusterListener listener;
+
+ public GeronimoClusterListenerAdaptor(ClusterListener listener) {
+ this.listener = listener;
+ }
+
+ public void onListenerRegistration(org.codehaus.wadi.group.Cluster cluster, Set existing) {
+ Set<Node> existingNodes = wrapAsNode(existing, false);
+ listener.onListenerRegistration(BasicWADICluster.this, existingNodes);
+ }
+
+ public void onMembershipChanged(org.codehaus.wadi.group.Cluster cluster, Set joiners, Set leavers) {
+ Set<Node> joinerNodes = wrapAsNode(joiners, false);
+ Set<Node> leaverNodes = wrapAsNode(leavers, true);
+ listener.onMembershipChanged(BasicWADICluster.this, joinerNodes, leaverNodes);
+ }
+
+ }
+
+ public static final GBeanInfo GBEAN_INFO;
+
+ public static final String GBEAN_REF_NODE = "Node";
+ public static final String GBEAN_REF_DISPATCHER_HOLDER = "DispatcherHolder";
+
+ static {
+ GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic("WADI Cluster",
+ BasicWADICluster.class,
+ NameFactory.GERONIMO_SERVICE);
+
+ infoBuilder.addReference(GBEAN_REF_NODE, Node.class, NameFactory.GERONIMO_SERVICE);
+ infoBuilder.addReference(GBEAN_REF_DISPATCHER_HOLDER, DispatcherHolder.class, NameFactory.GERONIMO_SERVICE);
+
+ infoBuilder.addInterface(Cluster.class);
+
+ infoBuilder.setConstructor(new String[] { GBEAN_REF_NODE, GBEAN_REF_DISPATCHER_HOLDER });
+
+ GBEAN_INFO = infoBuilder.getBeanInfo();
+ }
+
+ public static GBeanInfo getGBeanInfo() {
+ return GBEAN_INFO;
+ }
+
+}
Modified: geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManager.java?view=diff&rev=555111&r1=555110&r2=555111
==============================================================================
--- geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManager.java (original)
+++ geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManager.java Tue Jul 10 16:25:31 2007
@@ -16,13 +16,15 @@
*/
package org.apache.geronimo.clustering.wadi;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.Map;
import java.util.Set;
+import java.util.concurrent.CopyOnWriteArrayList;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.geronimo.clustering.BasicNode;
import org.apache.geronimo.clustering.Node;
import org.apache.geronimo.clustering.Session;
import org.apache.geronimo.clustering.SessionAlreadyExistException;
@@ -43,8 +45,6 @@
import org.codehaus.wadi.servicespace.ServiceSpace;
import org.codehaus.wadi.servicespace.ServiceSpaceName;
-import java.util.concurrent.CopyOnWriteArrayList;
-
/**
*
* @version $Rev$ $Date$
@@ -52,33 +52,33 @@
public class BasicWADISessionManager implements GBeanLifecycle, SessionManager, WADISessionManager {
private static final Log log = LogFactory.getLog(BasicWADISessionManager.class);
+ private final WADICluster cluster;
private final WADISessionManagerConfigInfo configInfo;
private final ReplicationManagerFactory repManagerFactory;
private final ReplicaStorageFactory repStorageFactory;
private final BackingStrategyFactory backingStrategyFactory;
- private final DispatcherHolder dispatcherHolder;
- private final CopyOnWriteArrayList listeners;
+ private final CopyOnWriteArrayList<SessionListener> listeners;
private Manager manager;
private SessionMonitor sessionMonitor;
private ServiceSpace serviceSpace;
public BasicWADISessionManager(WADISessionManagerConfigInfo configInfo,
- ReplicationManagerFactory repManagerFactory,
+ WADICluster cluster,
+ ReplicationManagerFactory repManagerFactory,
ReplicaStorageFactory repStorageFactory,
- BackingStrategyFactory backingStrategyFactory,
- DispatcherHolder dispatcherHolder) {
+ BackingStrategyFactory backingStrategyFactory) {
this.configInfo = configInfo;
- this.dispatcherHolder = dispatcherHolder;
+ this.cluster = cluster;
this.repManagerFactory = repManagerFactory;
this.repStorageFactory = repStorageFactory;
this.backingStrategyFactory = backingStrategyFactory;
- listeners = new CopyOnWriteArrayList();
+ listeners = new CopyOnWriteArrayList<SessionListener>();
}
public void doStart() throws Exception {
- Dispatcher underlyingDisp = dispatcherHolder.getDispatcher();
+ Dispatcher underlyingDisp = cluster.getCluster().getDispatcher();
ServiceSpaceName serviceSpaceName = new ServiceSpaceName(configInfo.getServiceSpaceURI());
StackContext stackContext = new StackContext(serviceSpaceName,
@@ -127,14 +127,25 @@
}
public Node getNode() {
- return dispatcherHolder.getNode();
+ return cluster.getLocalNode();
}
public Set<Node> getRemoteNodes() {
+ Map<Peer, RemoteNode> peerToRemoteNode = new HashMap<Peer, RemoteNode>();
+ Set<Node> clusterNodes = cluster.getRemoteNodes();
+ for (Iterator<Node> iterator = clusterNodes.iterator(); iterator.hasNext();) {
+ RemoteNode remoteNode = (RemoteNode) iterator.next();
+ peerToRemoteNode.put(remoteNode.getPeer(), remoteNode);
+ }
+
Set<Node> nodes = new HashSet<Node>();
Set<Peer> peers = serviceSpace.getHostingPeers();
for (Peer peer : peers) {
- nodes.add(new BasicNode(peer.getName()));
+ RemoteNode remoteNode = peerToRemoteNode.get(peer);
+ if (null == remoteNode) {
+ throw new AssertionError("remoteNode is null");
+ }
+ nodes.add(remoteNode);
}
return nodes;
}
@@ -148,22 +159,19 @@
}
private void notifyInboundSessionMigration(org.codehaus.wadi.core.session.Session session) {
- for (Iterator iter = listeners.iterator(); iter.hasNext();) {
- SessionListener listener = (SessionListener) iter.next();
+ for (SessionListener listener : listeners) {
listener.notifyInboundSessionMigration(new WADISessionAdaptor(session));
}
}
private void notifyOutboundSessionMigration(org.codehaus.wadi.core.session.Session session) {
- for (Iterator iter = listeners.iterator(); iter.hasNext();) {
- SessionListener listener = (SessionListener) iter.next();
+ for (SessionListener listener : listeners) {
listener.notifyOutboundSessionMigration(new WADISessionAdaptor(session));
}
}
private void notifySessionDestruction(org.codehaus.wadi.core.session.Session session) {
- for (Iterator iter = listeners.iterator(); iter.hasNext();) {
- SessionListener listener = (SessionListener) iter.next();
+ for (SessionListener listener : listeners) {
listener.notifySessionDestruction(new WADISessionAdaptor(session));
}
}
@@ -191,10 +199,10 @@
public static final String GBEAN_ATTR_WADI_CONFIG_INFO = "wadiConfigInfo";
+ public static final String GBEAN_REF_CLUSTER = "Cluster";
public static final String GBEAN_REF_REPLICATION_MANAGER_FACTORY = "ReplicationManagerFactory";
public static final String GBEAN_REF_REPLICA_STORAGE_FACTORY = "ReplicaStorageFactory";
public static final String GBEAN_REF_BACKING_STRATEGY_FACTORY = "BackingStrategyFactory";
- public static final String GBEAN_REF_DISPATCHER_HOLDER = "DispatcherHolder";
static {
GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic("WADI Session Manager",
@@ -202,22 +210,22 @@
infoBuilder.addAttribute(GBEAN_ATTR_WADI_CONFIG_INFO, WADISessionManagerConfigInfo.class, true);
+ infoBuilder.addReference(GBEAN_REF_CLUSTER, WADICluster.class, NameFactory.GERONIMO_SERVICE);
infoBuilder.addReference(GBEAN_REF_REPLICATION_MANAGER_FACTORY, ReplicationManagerFactory.class,
- NameFactory.GERONIMO_SERVICE);
+ NameFactory.GERONIMO_SERVICE);
infoBuilder.addReference(GBEAN_REF_REPLICA_STORAGE_FACTORY, ReplicaStorageFactory.class,
NameFactory.GERONIMO_SERVICE);
infoBuilder.addReference(GBEAN_REF_BACKING_STRATEGY_FACTORY, BackingStrategyFactory.class,
NameFactory.GERONIMO_SERVICE);
- infoBuilder.addReference(GBEAN_REF_DISPATCHER_HOLDER, DispatcherHolder.class, NameFactory.GERONIMO_SERVICE);
infoBuilder.addInterface(SessionManager.class);
infoBuilder.addInterface(WADISessionManager.class);
infoBuilder.setConstructor(new String[] { GBEAN_ATTR_WADI_CONFIG_INFO,
+ GBEAN_REF_CLUSTER,
GBEAN_REF_REPLICATION_MANAGER_FACTORY,
GBEAN_REF_REPLICA_STORAGE_FACTORY,
- GBEAN_REF_BACKING_STRATEGY_FACTORY,
- GBEAN_REF_DISPATCHER_HOLDER });
+ GBEAN_REF_BACKING_STRATEGY_FACTORY });
GBEAN_INFO = infoBuilder.getBeanInfo();
}
Added: geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/NodeConnectionInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/NodeConnectionInfo.java?view=auto&rev=555111
==============================================================================
--- geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/NodeConnectionInfo.java (added)
+++ geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/NodeConnectionInfo.java Tue Jul 10 16:25:31 2007
@@ -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.clustering.wadi;
+
+import java.io.Serializable;
+
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class NodeConnectionInfo implements Serializable {
+ private final String host;
+ private final int port;
+
+ public NodeConnectionInfo(String host, int port) {
+ if (null == host) {
+ throw new IllegalArgumentException("host is required");
+ } else if (port < 1) {
+ throw new IllegalArgumentException("port must be greater than 0");
+ }
+ this.host = host;
+ this.port = port;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public int getPort() {
+ return port;
+ }
+}
Added: geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/NodeFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/NodeFactory.java?view=auto&rev=555111
==============================================================================
--- geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/NodeFactory.java (added)
+++ geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/NodeFactory.java Tue Jul 10 16:25:31 2007
@@ -0,0 +1,31 @@
+/**
+ * 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 org.apache.geronimo.clustering.Node;
+import org.codehaus.wadi.group.Cluster;
+import org.codehaus.wadi.group.Peer;
+
+
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public interface NodeFactory {
+ Node newNode(Cluster cluster, Peer peer);
+}
Added: geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/NodeProxyFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/NodeProxyFactory.java?view=auto&rev=555111
==============================================================================
--- geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/NodeProxyFactory.java (added)
+++ geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/NodeProxyFactory.java Tue Jul 10 16:25:31 2007
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.clustering.wadi;
+
+import org.apache.geronimo.clustering.Node;
+import org.codehaus.wadi.group.Cluster;
+import org.codehaus.wadi.group.Peer;
+
+
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class NodeProxyFactory implements NodeFactory {
+
+ public Node newNode(Cluster cluster, Peer peer) {
+ NodeServiceHelper serviceHelper = new NodeServiceHelper(cluster.getDispatcher());
+ NodeService nodeService = serviceHelper.getNodeServiceProxy(peer);
+ return new RemoteNode(peer, nodeService);
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/NodeService.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/NodeService.java?view=auto&rev=555111
==============================================================================
--- geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/NodeService.java (added)
+++ geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/NodeService.java Tue Jul 10 16:25:31 2007
@@ -0,0 +1,31 @@
+/**
+ * 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 org.codehaus.wadi.core.Lifecycle;
+import org.codehaus.wadi.servicespace.ServiceName;
+
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public interface NodeService extends Lifecycle {
+ ServiceName SERVICE_NAME = new ServiceName("NodeService");
+
+ NodeConnectionInfo getConnectionInfo();
+}
Added: geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/NodeServiceHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/NodeServiceHelper.java?view=auto&rev=555111
==============================================================================
--- geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/NodeServiceHelper.java (added)
+++ geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/NodeServiceHelper.java Tue Jul 10 16:25:31 2007
@@ -0,0 +1,74 @@
+/**
+ * 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 org.codehaus.wadi.group.Dispatcher;
+import org.codehaus.wadi.group.Peer;
+import org.codehaus.wadi.servicespace.InvocationMetaData;
+import org.codehaus.wadi.servicespace.ServiceAlreadyRegisteredException;
+import org.codehaus.wadi.servicespace.ServiceProxyFactory;
+import org.codehaus.wadi.servicespace.ServiceRegistry;
+import org.codehaus.wadi.servicespace.ServiceSpace;
+import org.codehaus.wadi.servicespace.admin.AdminServiceSpace;
+import org.codehaus.wadi.servicespace.admin.AdminServiceSpaceHelper;
+
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class NodeServiceHelper {
+ private final ServiceSpace serviceSpace;
+
+ public NodeServiceHelper(Dispatcher dispatcher) {
+ if (null == dispatcher) {
+ throw new IllegalArgumentException("dispatcher is required");
+ }
+ this.serviceSpace = getAdminServiceSpace(dispatcher);
+ }
+
+ public NodeServiceHelper(ServiceSpace serviceSpace) {
+ if (null == serviceSpace) {
+ throw new IllegalArgumentException("serviceSpace is required");
+ }
+ this.serviceSpace = serviceSpace;
+ }
+
+ public void registerNodeService(NodeService nodeService) {
+ ServiceRegistry serviceRegistry = serviceSpace.getServiceRegistry();
+ try {
+ serviceRegistry.register(NodeService.SERVICE_NAME, nodeService);
+ } catch (ServiceAlreadyRegisteredException e) {
+ throw new IllegalStateException("NodeService already registered.", e);
+ }
+ }
+
+ public NodeService getNodeServiceProxy(Peer peer) {
+ ServiceProxyFactory proxyFactory = serviceSpace.getServiceProxyFactory(NodeService.SERVICE_NAME,
+ new Class[] { NodeService.class });
+ InvocationMetaData invocationMetaData = proxyFactory.getInvocationMetaData();
+ invocationMetaData.setTargets(new Peer[] {peer});
+ return (NodeService) proxyFactory.getProxy();
+ }
+
+ protected ServiceSpace getAdminServiceSpace(Dispatcher dispatcher) {
+ AdminServiceSpaceHelper helper = new AdminServiceSpaceHelper();
+ AdminServiceSpace adminServiceSpace = helper.getAdminServiceSpace(dispatcher);
+ return adminServiceSpace;
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/RemoteNode.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/RemoteNode.java?view=auto&rev=555111
==============================================================================
--- geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/RemoteNode.java (added)
+++ geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/RemoteNode.java Tue Jul 10 16:25:31 2007
@@ -0,0 +1,61 @@
+/**
+ * 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 org.apache.geronimo.clustering.AbstractNode;
+import org.codehaus.wadi.group.Peer;
+
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class RemoteNode extends AbstractNode {
+ private final Peer peer;
+ private final NodeService nodeService;
+ private NodeConnectionInfo connectionInfo;
+
+ public RemoteNode(Peer peer, NodeService nodeService) {
+ super(peer.getName());
+ if (null == nodeService) {
+ throw new IllegalArgumentException("nodeService is required");
+ }
+ this.peer = peer;
+ this.nodeService = nodeService;
+ }
+
+ public Peer getPeer() {
+ return peer;
+ }
+
+ @Override
+ protected String getHost() {
+ if (null == connectionInfo) {
+ connectionInfo = nodeService.getConnectionInfo();
+ }
+ return connectionInfo.getHost();
+ }
+
+ @Override
+ protected int getPort() {
+ if (null == connectionInfo) {
+ connectionInfo = nodeService.getConnectionInfo();
+ }
+ return connectionInfo.getPort();
+ }
+
+}
Modified: geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/TribesDispatcherHolder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/TribesDispatcherHolder.java?view=diff&rev=555111&r1=555110&r2=555111
==============================================================================
--- geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/TribesDispatcherHolder.java (original)
+++ geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/TribesDispatcherHolder.java Tue Jul 10 16:25:31 2007
@@ -21,6 +21,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.clustering.LocalNode;
import org.apache.geronimo.clustering.Node;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
@@ -43,13 +44,13 @@
private final URI endPointURI;
private final String clusterName;
- private final Node node;
+ private final LocalNode node;
private final DispatcherRegistry dispatcherRegistry;
private TribesDispatcher dispatcher;
private AdminServiceSpace adminServiceSpace;
- public TribesDispatcherHolder(URI endPointURI, String clusterName, Node node) {
+ public TribesDispatcherHolder(URI endPointURI, String clusterName, LocalNode node) {
if (null == endPointURI) {
throw new IllegalArgumentException("endPointURI is required");
} else if (null == clusterName) {
@@ -72,16 +73,16 @@
dispatcher.start();
adminServiceSpace = new AdminServiceSpace(dispatcher);
+
+ registerCustomAdminServices();
+
adminServiceSpace.start();
dispatcherRegistry.register(dispatcher);
}
public void doStop() throws Exception {
- if (null != adminServiceSpace) {
- adminServiceSpace.stop();
- }
-
+ adminServiceSpace.stop();
dispatcherRegistry.unregister(dispatcher);
dispatcher.stop();
}
@@ -95,11 +96,13 @@
}
}
- dispatcherRegistry.unregister(dispatcher);
- try {
- dispatcher.stop();
- } catch (MessageExchangeException e) {
- log.error("see nested", e);
+ if (null != dispatcher) {
+ dispatcherRegistry.unregister(dispatcher);
+ try {
+ dispatcher.stop();
+ } catch (MessageExchangeException e) {
+ log.error("see nested", e);
+ }
}
}
@@ -111,6 +114,10 @@
return node;
}
+ protected void registerCustomAdminServices() {
+ NodeServiceHelper nodeServiceHelper = new NodeServiceHelper(adminServiceSpace);
+ nodeServiceHelper.registerNodeService(new BasicNodeService(node));
+ }
public static final GBeanInfo GBEAN_INFO;
@@ -127,7 +134,7 @@
infoBuilder.addAttribute(GBEAN_ATTR_END_POINT_URI, URI.class, true);
infoBuilder.addAttribute(GBEAN_ATTR_CLUSTER_NAME, String.class, true);
- infoBuilder.addReference(GBEAN_REF_NODE, Node.class, NameFactory.GERONIMO_SERVICE);
+ infoBuilder.addReference(GBEAN_REF_NODE, LocalNode.class, NameFactory.GERONIMO_SERVICE);
infoBuilder.addInterface(DispatcherHolder.class);
Modified: geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/WADICluster.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/WADICluster.java?view=diff&rev=555111&r1=555110&r2=555111
==============================================================================
--- geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/WADICluster.java (original)
+++ geronimo/server/trunk/modules/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/WADICluster.java Tue Jul 10 16:25:31 2007
@@ -16,140 +16,13 @@
*/
package org.apache.geronimo.clustering.wadi;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.IdentityHashMap;
-import java.util.Set;
-
-import org.apache.geronimo.clustering.BasicNode;
import org.apache.geronimo.clustering.Cluster;
-import org.apache.geronimo.clustering.ClusterListener;
-import org.apache.geronimo.clustering.Node;
-import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
-import org.codehaus.wadi.group.LocalPeer;
-import org.codehaus.wadi.group.Peer;
/**
*
* @version $Rev$ $Date$
*/
-public class WADICluster implements GBeanLifecycle, Cluster {
- private final DispatcherHolder dispatcherHolder;
- private org.codehaus.wadi.group.Cluster cluster;
- private final IdentityHashMap<ClusterListener, org.codehaus.wadi.group.ClusterListener> listenerToWADIListener;
-
- public WADICluster(DispatcherHolder dispatcherHolder) {
- if (null == dispatcherHolder) {
- throw new IllegalArgumentException("dispatcherHolder is required");
- }
- this.dispatcherHolder = dispatcherHolder;
-
- listenerToWADIListener = new IdentityHashMap<ClusterListener, org.codehaus.wadi.group.ClusterListener>();
- }
-
- public void doStart() throws Exception {
- cluster = dispatcherHolder.getDispatcher().getCluster();
- }
-
- public void doStop() throws Exception {
- clearListeners();
- }
-
- public void doFail() {
- clearListeners();
- }
-
- public String getName() {
- return cluster.getClusterName();
- }
-
- public Node getLocalNode() {
- LocalPeer localPeer = cluster.getLocalPeer();
- return new BasicNode(localPeer.getName());
- }
-
- public Set<Node> getRemoteNodes() {
- Collection<Peer> peers = cluster.getRemotePeers().values();
- Set<Node> nodes = wrapAsNode(peers);
- return nodes;
- }
-
- public void addClusterListener(ClusterListener listener) {
- if (null == listener) {
- throw new IllegalArgumentException("listener is required");
- }
- GeronimoClusterListenerAdaptor wadiListener = new GeronimoClusterListenerAdaptor(listener);
- listenerToWADIListener.put(listener, wadiListener);
- cluster.addClusterListener(wadiListener);
- }
-
- public void removeClusterListener(ClusterListener listener) {
- org.codehaus.wadi.group.ClusterListener wadiListener = listenerToWADIListener.remove(listener);
- if (null == wadiListener) {
- throw new IllegalArgumentException(listener + " is not registered");
- }
- cluster.removeClusterListener(wadiListener);
- }
-
- protected void clearListeners() {
- for (org.codehaus.wadi.group.ClusterListener wadiListener : listenerToWADIListener.values()) {
- cluster.removeClusterListener(wadiListener);
- }
-
- listenerToWADIListener.clear();
- }
-
- protected Set<Node> wrapAsNode(Collection<Peer> peers) {
- Set<Node> nodes = new HashSet<Node>();
- for (Peer peer : peers) {
- nodes.add(new BasicNode(peer.getName()));
- }
- return nodes;
- }
-
- protected class GeronimoClusterListenerAdaptor implements org.codehaus.wadi.group.ClusterListener {
- private final ClusterListener listener;
-
- public GeronimoClusterListenerAdaptor(ClusterListener listener) {
- this.listener = listener;
- }
-
- public void onListenerRegistration(org.codehaus.wadi.group.Cluster cluster, Set existing) {
- Set<Node> existingNodes = wrapAsNode(existing);
- listener.onListenerRegistration(WADICluster.this, existingNodes);
- }
-
- public void onMembershipChanged(org.codehaus.wadi.group.Cluster cluster, Set joiners, Set leavers) {
- Set<Node> joinerNodes = wrapAsNode(joiners);
- Set<Node> leaverNodes = wrapAsNode(leavers);
- listener.onMembershipChanged(WADICluster.this, joinerNodes, leaverNodes);
- }
-
- }
-
- public static final GBeanInfo GBEAN_INFO;
-
- public static final String GBEAN_REF_DISPATCHER_HOLDER = "DispatcherHolder";
-
- static {
- GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic("WADI Cluster",
- WADICluster.class,
- NameFactory.GERONIMO_SERVICE);
-
- infoBuilder.addReference(GBEAN_REF_DISPATCHER_HOLDER, DispatcherHolder.class, NameFactory.GERONIMO_SERVICE);
-
- infoBuilder.addInterface(Cluster.class);
-
- infoBuilder.setConstructor(new String[] {GBEAN_REF_DISPATCHER_HOLDER});
-
- GBEAN_INFO = infoBuilder.getBeanInfo();
- }
-
- public static GBeanInfo getGBeanInfo() {
- return GBEAN_INFO;
- }
+public interface WADICluster extends Cluster {
+ org.codehaus.wadi.group.Cluster getCluster();
}
Added: geronimo/server/trunk/modules/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/BasicNodeServiceTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/BasicNodeServiceTest.java?view=auto&rev=555111
==============================================================================
--- geronimo/server/trunk/modules/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/BasicNodeServiceTest.java (added)
+++ geronimo/server/trunk/modules/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/BasicNodeServiceTest.java Tue Jul 10 16:25:31 2007
@@ -0,0 +1,51 @@
+/**
+ * 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 javax.management.MBeanServer;
+
+import org.apache.geronimo.clustering.LocalNode;
+import org.apache.geronimo.jmxremoting.JMXConnector;
+
+import com.agical.rmock.extension.junit.RMockTestCase;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class BasicNodeServiceTest extends RMockTestCase {
+
+ public void testGetConnectionInfo() throws Exception {
+ LocalNode localNode = (LocalNode) mock(LocalNode.class);
+ localNode.getJMXConnectorInfo();
+
+ JMXConnector connector = new JMXConnector((MBeanServer) null, "name", null);
+ String host = "host";
+ connector.setHost(host);
+ int port = 1;
+ connector.setPort(port);
+ modify().returnValue(connector);
+
+ startVerification();
+
+ BasicNodeService nodeService = new BasicNodeService(localNode);
+ NodeConnectionInfo connectionInfo = nodeService.getConnectionInfo();
+ assertEquals(host, connectionInfo.getHost());
+ assertEquals(port, connectionInfo.getPort());
+ }
+
+}
Copied: geronimo/server/trunk/modules/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/BasicWADIClusterTest.java (from r553487, geronimo/server/trunk/modules/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/WADIClusterTest.java)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/BasicWADIClusterTest.java?view=diff&rev=555111&p1=geronimo/server/trunk/modules/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/WADIClusterTest.java&r1=553487&p2=geronimo/server/trunk/modules/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/BasicWADIClusterTest.java&r2=555111
==============================================================================
--- geronimo/server/trunk/modules/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/WADIClusterTest.java (original)
+++ geronimo/server/trunk/modules/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/BasicWADIClusterTest.java Tue Jul 10 16:25:31 2007
@@ -19,15 +19,14 @@
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import org.apache.geronimo.clustering.BasicNode;
import org.apache.geronimo.clustering.ClusterListener;
+import org.apache.geronimo.clustering.LocalNode;
import org.apache.geronimo.clustering.Node;
import org.codehaus.wadi.group.Address;
-import org.codehaus.wadi.group.LocalPeer;
+import org.codehaus.wadi.group.Dispatcher;
import org.codehaus.wadi.group.Peer;
import com.agical.rmock.core.Action;
@@ -40,27 +39,31 @@
*
* @version $Rev$ $Date$
*/
-public class WADIClusterTest extends RMockTestCase {
+public class BasicWADIClusterTest extends RMockTestCase {
+ private Dispatcher dispatcher;
private org.codehaus.wadi.group.Cluster wadiCluster;
- private LocalPeer localPeer;
+ private LocalNode localNode;
private Peer peer1;
private Peer peer2;
- private WADICluster cluster;
+ private BasicWADICluster cluster;
private ClusterListener listener;
+ private NodeFactory nodeFactory;
+ private Node nodePeer1;
+ private Node nodePeer2;
@Override
protected void setUp() throws Exception {
DispatcherHolder dispatcherHolder = (DispatcherHolder) mock(DispatcherHolder.class);
- wadiCluster = dispatcherHolder.getDispatcher().getCluster();
+ dispatcher = dispatcherHolder.getDispatcher();
+
+ wadiCluster = dispatcher.getCluster();
wadiCluster.getClusterName();
modify().multiplicity(expect.from(0)).returnValue("name");
- localPeer = wadiCluster.getLocalPeer();
- modify().multiplicity(expect.from(0));
- localPeer.getName();
- modify().multiplicity(expect.from(0)).returnValue("localPeerName");
+ wadiCluster.getDispatcher();
+ modify().multiplicity(expect.from(0)).returnValue(dispatcher);
Map<Address, Peer> remotePeers = new HashMap<Address, Peer>();
peer1 = addPeer("peer1", remotePeers);
@@ -69,7 +72,15 @@
wadiCluster.getRemotePeers();
modify().multiplicity(expect.from(0)).returnValue(remotePeers);
- cluster = new WADICluster(dispatcherHolder);
+ localNode = (LocalNode) mock(LocalNode.class);
+
+ nodeFactory = (NodeFactory) mock(NodeFactory.class);
+ nodePeer1 = nodeFactory.newNode(wadiCluster, peer1);
+ modify().multiplicity(expect.from(0));
+ nodePeer2 = nodeFactory.newNode(wadiCluster, peer2);
+ modify().multiplicity(expect.from(0));
+
+ cluster = new BasicWADICluster(localNode, dispatcherHolder, nodeFactory);
listener = (ClusterListener) mock(ClusterListener.class);
}
@@ -87,27 +98,24 @@
}
public void testGetName() throws Exception {
- startVerification();
- cluster.doStart();
+ startVerificationAndInitWADICluster();
assertEquals(wadiCluster.getClusterName(), cluster.getName());
}
public void testGetLocalNode() throws Exception {
- startVerification();
- cluster.doStart();
+ startVerificationAndInitWADICluster();
- assertEquals(localPeer.getName(), cluster.getLocalNode().getName());
+ assertEquals(localNode, cluster.getLocalNode());
}
public void testGetRemotePeers() throws Exception {
- startVerification();
- cluster.doStart();
-
+ startVerificationAndInitWADICluster();
+
Set<Node> remoteNodes = cluster.getRemoteNodes();
assertEquals(2, remoteNodes.size());
- assertTrue(remoteNodes.contains(new BasicNode(peer1.getName())));
- assertTrue(remoteNodes.contains(new BasicNode(peer2.getName())));
+ assertTrue(remoteNodes.contains(nodePeer1));
+ assertTrue(remoteNodes.contains(nodePeer2));
}
public void testAddClusterListener() throws Exception {
@@ -124,15 +132,13 @@
});
- startVerification();
- cluster.doStart();
+ startVerificationAndInitWADICluster();
cluster.addClusterListener(listener);
}
public void testAddNullClusterListenerThrowsException() throws Exception {
- startVerification();
- cluster.doStart();
+ startVerificationAndInitWADICluster();
try {
cluster.addClusterListener(null);
@@ -148,16 +154,14 @@
wadiCluster.removeClusterListener(null);
modify().args(assertSame);
- startVerification();
- cluster.doStart();
+ startVerificationAndInitWADICluster();
cluster.addClusterListener(listener);
cluster.removeClusterListener(listener);
}
public void testRemoveUndefinedClusterListenerThrowsException() throws Exception {
- startVerification();
- cluster.doStart();
+ startVerificationAndInitWADICluster();
try {
cluster.removeClusterListener(listener);
@@ -167,10 +171,6 @@
}
public void testClusterListenerRegistrationCallback() throws Exception {
- Set<Node> existing = new HashSet<Node>();
- existing.add(new BasicNode("peer1"));
- listener.onListenerRegistration(cluster, existing);
-
wadiCluster.addClusterListener(null);
modify().args(is.ANYTHING).perform(new Action() {
@@ -182,19 +182,14 @@
});
- startVerification();
- cluster.doStart();
+ listener.onListenerRegistration(cluster, Collections.singleton(nodePeer1));
+
+ startVerificationAndInitWADICluster();
cluster.addClusterListener(listener);
}
public void testClusterListenerMembershipChangeCallback() throws Exception {
- Set<Node> joiners = new HashSet<Node>();
- joiners.add(new BasicNode("peer1"));
- Set<Node> leavers = new HashSet<Node>();
- leavers.add(new BasicNode("peer2"));
- listener.onMembershipChanged(cluster, joiners, leavers);
-
wadiCluster.addClusterListener(null);
modify().args(is.ANYTHING).perform(new Action() {
@@ -206,8 +201,9 @@
});
- startVerification();
- cluster.doStart();
+ listener.onMembershipChanged(cluster, Collections.singleton(nodePeer1), Collections.singleton(nodePeer2));
+
+ startVerificationAndInitWADICluster();
cluster.addClusterListener(listener);
}
@@ -219,19 +215,24 @@
wadiCluster.removeClusterListener(null);
modify().args(assertSame);
- startVerification();
- cluster.doStart();
+ startVerificationAndInitWADICluster();
cluster.addClusterListener(listener);
cluster.doStop();
}
+
+ private void startVerificationAndInitWADICluster() throws Exception {
+ startVerification();
+ cluster.doStart();
+ cluster.getRemoteNodes();
+ }
private final class AssertSameWADIListener extends AbstractExpression {
private org.codehaus.wadi.group.ClusterListener wadiListener;
-
+
public void describeWith(ExpressionDescriber arg0) throws IOException {
}
-
+
public boolean passes(Object arg0) {
if (null == wadiListener) {
wadiListener = (org.codehaus.wadi.group.ClusterListener) arg0;
@@ -241,5 +242,5 @@
return true;
}
}
-
+
}
Added: geronimo/server/trunk/modules/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/NodeServiceHelperTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/NodeServiceHelperTest.java?view=auto&rev=555111
==============================================================================
--- geronimo/server/trunk/modules/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/NodeServiceHelperTest.java (added)
+++ geronimo/server/trunk/modules/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/NodeServiceHelperTest.java Tue Jul 10 16:25:31 2007
@@ -0,0 +1,76 @@
+/**
+ * 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 org.codehaus.wadi.group.Peer;
+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 com.agical.rmock.extension.junit.RMockTestCase;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class NodeServiceHelperTest extends RMockTestCase {
+
+ private ServiceSpace serviceSpace;
+ private NodeServiceHelper serviceHelper;
+ private NodeService nodeService;
+
+ @Override
+ protected void setUp() throws Exception {
+ nodeService = (NodeService) mock(NodeServiceProxy.class);
+ serviceSpace = (ServiceSpace) mock(ServiceSpace.class);
+ serviceHelper = new NodeServiceHelper(serviceSpace);
+ }
+
+ public void testNodeServiceRegistration() throws Exception {
+ ServiceRegistry serviceRegistry = serviceSpace.getServiceRegistry();
+ serviceRegistry.register(NodeService.SERVICE_NAME, nodeService);
+
+ startVerification();
+
+ serviceHelper.registerNodeService(nodeService);
+ }
+
+ public void testGetNodeServiceProxy() throws Exception {
+ Peer peer = (Peer) mock(Peer.class);
+ ServiceProxyFactory proxyFactory =
+ serviceSpace.getServiceProxyFactory(NodeService.SERVICE_NAME, new Class[] {NodeService.class});
+ proxyFactory.getInvocationMetaData();
+
+ InvocationMetaData invMetaData = (InvocationMetaData) intercept(InvocationMetaData.class, "InvocationMetaData");
+ modify().returnValue(invMetaData);
+
+ invMetaData.setTargets(new Peer[] {peer});
+
+ proxyFactory.getProxy();
+ modify().returnValue(nodeService);
+
+ startVerification();
+
+ assertSame(nodeService, serviceHelper.getNodeServiceProxy(peer));
+ }
+
+ public static interface NodeServiceProxy extends NodeService, ServiceProxy {
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/RemoteNodeTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/RemoteNodeTest.java?view=auto&rev=555111
==============================================================================
--- geronimo/server/trunk/modules/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/RemoteNodeTest.java (added)
+++ geronimo/server/trunk/modules/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/RemoteNodeTest.java Tue Jul 10 16:25:31 2007
@@ -0,0 +1,82 @@
+/**
+ * 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 org.codehaus.wadi.group.Peer;
+
+import com.agical.rmock.extension.junit.RMockTestCase;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class RemoteNodeTest extends RMockTestCase {
+
+ private Peer peer;
+ private NodeService nodeService;
+ private NodeConnectionInfo connectionInfo;
+
+ @Override
+ protected void setUp() throws Exception {
+ peer = (Peer) mock(Peer.class);
+ peer.getName();
+ modify().multiplicity(expect.from(0)).returnValue("name");
+
+ nodeService = (NodeService) mock(NodeService.class);
+
+ connectionInfo = new NodeConnectionInfo("host", 1);
+ }
+
+ public void testGetName() throws Exception {
+ startVerification();
+ RemoteNode remoteNode = new RemoteNode(peer, nodeService);
+
+ assertEquals(peer.getName(), remoteNode.getName());
+ }
+
+ public void testGetHost() throws Exception {
+ nodeService.getConnectionInfo();
+ modify().returnValue(connectionInfo);
+
+ startVerification();
+ RemoteNode remoteNode = new RemoteNode(peer, nodeService);
+
+ assertEquals(connectionInfo.getHost(), remoteNode.getHost());
+ }
+
+ public void testGetPort() throws Exception {
+ nodeService.getConnectionInfo();
+ modify().returnValue(connectionInfo);
+
+ startVerification();
+ RemoteNode remoteNode = new RemoteNode(peer, nodeService);
+
+ assertEquals(connectionInfo.getPort(), remoteNode.getPort());
+ }
+
+ public void testConnectionInfoIsInitializedOnlyOnce() throws Exception {
+ nodeService.getConnectionInfo();
+ modify().returnValue(connectionInfo);
+
+ startVerification();
+ RemoteNode remoteNode = new RemoteNode(peer, nodeService);
+
+ assertEquals(connectionInfo.getHost(), remoteNode.getHost());
+ assertEquals(connectionInfo.getPort(), remoteNode.getPort());
+ }
+
+}
Modified: geronimo/server/trunk/modules/geronimo-clustering/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-clustering/pom.xml?view=diff&rev=555111&r1=555110&r2=555111
==============================================================================
--- geronimo/server/trunk/modules/geronimo-clustering/pom.xml (original)
+++ geronimo/server/trunk/modules/geronimo-clustering/pom.xml Tue Jul 10 16:25:31 2007
@@ -44,6 +44,12 @@
<artifactId>geronimo-j2ee</artifactId>
<version>${version}</version>
</dependency>
+
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>geronimo-jmx-remoting</artifactId>
+ <version>${version}</version>
+ </dependency>
</dependencies>
</project>
Added: geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/AbstractNode.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/AbstractNode.java?view=auto&rev=555111
==============================================================================
--- geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/AbstractNode.java (added)
+++ geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/AbstractNode.java Tue Jul 10 16:25:31 2007
@@ -0,0 +1,70 @@
+/**
+ * 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;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractNode implements Node {
+ private final String name;
+
+ public AbstractNode(String name) {
+ if (null == name) {
+ throw new IllegalArgumentException("name is required");
+ }
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public JMXConnector getJMXConnector() throws IOException {
+ Map<String, Object> environment = new HashMap<String, Object>();
+ environment.put(JMXConnectorFactory.DEFAULT_CLASS_LOADER, AbstractNode.class.getClassLoader());
+ JMXServiceURL address = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + getHost() + ":" + getPort() + "/JMXConnector");
+ return JMXConnectorFactory.connect(address, environment);
+ }
+
+ protected abstract String getHost();
+
+ protected abstract int getPort();
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof AbstractNode)) {
+ return false;
+ }
+ AbstractNode other = (AbstractNode) obj;
+ return name.equals(other.name);
+ }
+
+ @Override
+ public int hashCode() {
+ return name.hashCode();
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/BasicLocalNode.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/BasicLocalNode.java?view=auto&rev=555111
==============================================================================
--- geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/BasicLocalNode.java (added)
+++ geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/BasicLocalNode.java Tue Jul 10 16:25:31 2007
@@ -0,0 +1,77 @@
+/**
+ * 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;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.jmxremoting.JMXConnectorInfo;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class BasicLocalNode extends AbstractNode implements LocalNode {
+ private final JMXConnectorInfo connectorInfo;
+
+ public BasicLocalNode(String name, JMXConnectorInfo connectorInfo) {
+ super(name);
+ if (null == connectorInfo) {
+ throw new IllegalArgumentException("connectorInfo is required");
+ }
+ this.connectorInfo = connectorInfo;
+ }
+
+ public JMXConnectorInfo getJMXConnectorInfo() {
+ return connectorInfo;
+ }
+
+ @Override
+ protected String getHost() {
+ return connectorInfo.getHost();
+ }
+
+ @Override
+ protected int getPort() {
+ return connectorInfo.getPort();
+ }
+
+ public static final GBeanInfo GBEAN_INFO;
+
+ public static final String GBEAN_ATTR_NODE_NAME = "nodeName";
+ public static final String GBEAN_REF_JMX_CONNECTOR = "JMXConnector";
+
+ static {
+ GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(BasicLocalNode.class, NameFactory.GERONIMO_SERVICE);
+
+ infoBuilder.addAttribute(GBEAN_ATTR_NODE_NAME, String.class, true);
+
+ infoBuilder.addReference(GBEAN_REF_JMX_CONNECTOR, JMXConnectorInfo.class, NameFactory.GERONIMO_SERVICE);
+
+ infoBuilder.addInterface(LocalNode.class);
+
+ infoBuilder.setConstructor(new String[] { GBEAN_ATTR_NODE_NAME,
+ GBEAN_REF_JMX_CONNECTOR });
+
+ GBEAN_INFO = infoBuilder.getBeanInfo();
+ }
+
+ public static GBeanInfo getGBeanInfo() {
+ return GBEAN_INFO;
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/LocalNode.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/LocalNode.java?view=auto&rev=555111
==============================================================================
--- geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/LocalNode.java (added)
+++ geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/LocalNode.java Tue Jul 10 16:25:31 2007
@@ -0,0 +1,27 @@
+/**
+ * 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;
+
+import org.apache.geronimo.jmxremoting.JMXConnectorInfo;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public interface LocalNode extends Node {
+ JMXConnectorInfo getJMXConnectorInfo();
+}
Modified: geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/Node.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/Node.java?view=diff&rev=555111&r1=555110&r2=555111
==============================================================================
--- geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/Node.java (original)
+++ geronimo/server/trunk/modules/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/Node.java Tue Jul 10 16:25:31 2007
@@ -16,6 +16,11 @@
*/
package org.apache.geronimo.clustering;
+import java.io.IOException;
+
+import javax.management.remote.JMXConnector;
+
+
/**
* Represents a node.
*
@@ -30,4 +35,5 @@
*/
String getName();
+ JMXConnector getJMXConnector() throws IOException;
}
Modified: geronimo/server/trunk/modules/geronimo-jetty6-clustering-builder-wadi/src/main/java/org/apache/geronimo/jetty6/cluster/wadi/builder/WADIJettyClusteringBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6-clustering-builder-wadi/src/main/java/org/apache/geronimo/jetty6/cluster/wadi/builder/WADIJettyClusteringBuilder.java?view=diff&rev=555111&r1=555110&r2=555111
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6-clustering-builder-wadi/src/main/java/org/apache/geronimo/jetty6/cluster/wadi/builder/WADIJettyClusteringBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-jetty6-clustering-builder-wadi/src/main/java/org/apache/geronimo/jetty6/cluster/wadi/builder/WADIJettyClusteringBuilder.java Tue Jul 10 16:25:31 2007
@@ -64,7 +64,7 @@
private final AbstractNameQuery defaultRepManagerFactoryName;
private final AbstractNameQuery defaultRepStorageFactoryName;
private final AbstractNameQuery defaultBackingStrategyFactoryName;
- private final AbstractNameQuery defaultDispatcherHolderName;
+ private final AbstractNameQuery defaultClusterName;
private final Environment defaultEnvironment;
public WADIJettyClusteringBuilder(int defaultSweepInterval,
@@ -72,16 +72,19 @@
AbstractNameQuery defaultRepManagerFactoryName,
AbstractNameQuery defaultRepStorageFactoryName,
AbstractNameQuery defaultBackingStrategyFactoryName,
- AbstractNameQuery defaultDispatcherHolderName,
+ AbstractNameQuery defaultClusterName,
Environment defaultEnvironment) {
this.defaultSweepInterval = defaultSweepInterval;
this.defaultNumPartitions = defaultNumPartitions;
this.defaultRepManagerFactoryName = defaultRepManagerFactoryName;
this.defaultRepStorageFactoryName = defaultRepStorageFactoryName;
this.defaultBackingStrategyFactoryName = defaultBackingStrategyFactoryName;
- this.defaultDispatcherHolderName = defaultDispatcherHolderName;
+ this.defaultClusterName = defaultClusterName;
this.defaultEnvironment = defaultEnvironment;
- SchemaConversionUtils.registerNamespaceConversions(Collections.singletonMap(CLUSTERING_WADI_QNAME.getLocalPart(), new NamespaceElementConverter(CLUSTERING_WADI_QNAME.getNamespaceURI())));
+
+ SchemaConversionUtils.registerNamespaceConversions(
+ Collections.singletonMap(CLUSTERING_WADI_QNAME.getLocalPart(),
+ new NamespaceElementConverter(CLUSTERING_WADI_QNAME.getNamespaceURI())));
}
public void buildEnvironment(XmlObject container, Environment environment) throws DeploymentException {
@@ -133,7 +136,8 @@
return null;
}
- private AbstractName addSessionManager(GerClusteringWadiType clustering, GBeanData webModuleData,
+ private AbstractName addSessionManager(GerClusteringWadiType clustering,
+ GBeanData webModuleData,
DeploymentContext moduleContext) throws GBeanAlreadyExistsException {
AbstractName name = moduleContext.getNaming().createChildName(moduleContext.getModuleName(),
"WADISessionManager", NameFactory.GERONIMO_SERVICE);
@@ -141,10 +145,10 @@
GBeanData beanData = new GBeanData(name, BasicWADISessionManager.GBEAN_INFO);
setConfigInfo(clustering, webModuleData, beanData);
+ setCluster(clustering, beanData);
setReplicationManagerFactory(clustering, beanData);
setReplicaStorageFactory(clustering, beanData);
setBackingStrategyFactory(clustering, beanData);
- setDispatcher(clustering, beanData);
moduleContext.addGBean(beanData);
@@ -173,14 +177,14 @@
beanData.setAttribute(BasicWADISessionManager.GBEAN_ATTR_WADI_CONFIG_INFO, configInfo);
}
- private void setDispatcher(GerClusteringWadiType clustering, GBeanData beanData) {
+ private void setCluster(GerClusteringWadiType clustering, GBeanData beanData) {
Set patterns = new HashSet();
- if (clustering.isSetDispatcher()) {
- addAbstractNameQueries(patterns, clustering.getDispatcher().getPatternArray());
+ if (clustering.isSetCluster()) {
+ addAbstractNameQueries(patterns, clustering.getCluster().getPatternArray());
} else {
- patterns.add(defaultDispatcherHolderName);
+ patterns.add(defaultClusterName);
}
- beanData.setReferencePatterns(BasicWADISessionManager.GBEAN_REF_DISPATCHER_HOLDER, patterns);
+ beanData.setReferencePatterns(BasicWADISessionManager.GBEAN_REF_CLUSTER, patterns);
}
private void setBackingStrategyFactory(GerClusteringWadiType clustering, GBeanData beanData) {
@@ -257,7 +261,7 @@
public static final String GBEAN_ATTR_DFT_REP_MANAGER_FACTORY_NAME = "defaultReplicationManagerFactoryName";
public static final String GBEAN_ATTR_DFT_REP_STORAGE_FACTORY_NAME = "defaultReplicaStorageFactoryName";
public static final String GBEAN_ATTR_DFT_BACKING_STRATEGY_FACTORY_NAME = "defaultBackingStrategyFactoryName";
- public static final String GBEAN_ATTR_DFT_DISPATCHER_HOLDER_NAME = "defaultDispatcherHolderName";
+ public static final String GBEAN_ATTR_DFT_CLUSTER_NAME = "defaultClusterName";
public static final String GBEAN_ATTR_DFT_ENVIRONMENT = "defaultEnvironment";
static {
@@ -270,7 +274,7 @@
infoBuilder.addAttribute(GBEAN_ATTR_DFT_REP_MANAGER_FACTORY_NAME, AbstractNameQuery.class, true);
infoBuilder.addAttribute(GBEAN_ATTR_DFT_REP_STORAGE_FACTORY_NAME, AbstractNameQuery.class, true);
infoBuilder.addAttribute(GBEAN_ATTR_DFT_BACKING_STRATEGY_FACTORY_NAME, AbstractNameQuery.class, true);
- infoBuilder.addAttribute(GBEAN_ATTR_DFT_DISPATCHER_HOLDER_NAME, AbstractNameQuery.class, true);
+ infoBuilder.addAttribute(GBEAN_ATTR_DFT_CLUSTER_NAME, AbstractNameQuery.class, true);
infoBuilder.addAttribute(GBEAN_ATTR_DFT_ENVIRONMENT, Environment.class, true);
infoBuilder.setConstructor(new String[]{GBEAN_ATTR_DFT_SWEEP_INTERVAL,
@@ -278,7 +282,7 @@
GBEAN_ATTR_DFT_REP_MANAGER_FACTORY_NAME,
GBEAN_ATTR_DFT_REP_STORAGE_FACTORY_NAME,
GBEAN_ATTR_DFT_BACKING_STRATEGY_FACTORY_NAME,
- GBEAN_ATTR_DFT_DISPATCHER_HOLDER_NAME,
+ GBEAN_ATTR_DFT_CLUSTER_NAME,
GBEAN_ATTR_DFT_ENVIRONMENT});
GBEAN_INFO = infoBuilder.getBeanInfo();
Modified: geronimo/server/trunk/modules/geronimo-jetty6-clustering-builder-wadi/src/main/schema/geronimo-clustering-wadi-1.2.xsd
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6-clustering-builder-wadi/src/main/schema/geronimo-clustering-wadi-1.2.xsd?view=diff&rev=555111&r1=555110&r2=555111
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6-clustering-builder-wadi/src/main/schema/geronimo-clustering-wadi-1.2.xsd (original)
+++ geronimo/server/trunk/modules/geronimo-jetty6-clustering-builder-wadi/src/main/schema/geronimo-clustering-wadi-1.2.xsd Tue Jul 10 16:25:31 2007
@@ -36,14 +36,14 @@
<xs:complexType name="clustering-wadiType">
<xs:complexContent>
<xs:extension base="app:abstract-clusteringType">
- <xs:sequence>
- <xs:element name="sweepInterval" type="xs:integer" minOccurs="0"/>
- <xs:element name="numPartitions" type="xs:integer" minOccurs="0"/>
- <xs:element name="dispatcher" type="naming:gbean-refType" minOccurs="0"/>
- <xs:element name="replication-manager-factory" type="naming:gbean-refType" minOccurs="0"/>
- <xs:element name="replica-storage-factory" type="naming:gbean-refType" minOccurs="0"/>
- <xs:element name="backing-strategy-factory" type="naming:gbean-refType" minOccurs="0"/>
- </xs:sequence>
+ <xs:sequence>
+ <xs:element name="sweepInterval" type="xs:integer" minOccurs="0"/>
+ <xs:element name="numPartitions" type="xs:integer" minOccurs="0"/>
+ <xs:element name="cluster" type="naming:gbean-refType" minOccurs="0"/>
+ <xs:element name="replication-manager-factory" type="naming:gbean-refType" minOccurs="0"/>
+ <xs:element name="replica-storage-factory" type="naming:gbean-refType" minOccurs="0"/>
+ <xs:element name="backing-strategy-factory" type="naming:gbean-refType" minOccurs="0"/>
+ </xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>