[jboss-cvs] JBossAS SVN: r64040 - in trunk/cluster/src: main/org/jboss/ha/jndi and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jul 13 11:23:24 EDT 2007
Author: jerrygauth
Date: 2007-07-13 11:23:24 -0400 (Fri, 13 Jul 2007)
New Revision: 64040
Modified:
trunk/cluster/src/etc/cluster-beans.xml
trunk/cluster/src/etc/cluster-service.xml
trunk/cluster/src/main/org/jboss/ha/jndi/DetachedHANamingService.java
trunk/cluster/src/main/org/jboss/ha/jndi/DetachedHANamingServiceMBean.java
trunk/cluster/src/main/org/jboss/ha/jndi/HANamingService.java
Log:
JBAS-4276, partition injection changes for HAJNDI
Modified: trunk/cluster/src/etc/cluster-beans.xml
===================================================================
--- trunk/cluster/src/etc/cluster-beans.xml 2007-07-13 15:03:42 UTC (rev 64039)
+++ trunk/cluster/src/etc/cluster-beans.xml 2007-07-13 15:23:24 UTC (rev 64040)
@@ -167,7 +167,8 @@
<depends>HAPartition</depends>
- <property name="clusterPartition"><inject bean="HAPartition"/></property>
+ <property name="HAPartition"><inject bean="HAPartition"/></property>
+ <property name="clusteredCache"><inject bean="DefaultPartition-HAPartitionCache" property="cache"/></property>
<!-- Bind address of bootstrap and HA-JNDI RMI endpoints -->
<property name="bindAddress">${jboss.bind.address}</property>
Modified: trunk/cluster/src/etc/cluster-service.xml
===================================================================
--- trunk/cluster/src/etc/cluster-service.xml 2007-07-13 15:03:42 UTC (rev 64039)
+++ trunk/cluster/src/etc/cluster-service.xml 2007-07-13 15:23:24 UTC (rev 64040)
@@ -141,8 +141,10 @@
name="jboss:service=HAJNDI">
<!-- We now inject the partition into the HAJNDI service instead
of requiring that the partition name be passed -->
- <depends optional-attribute-name="ClusterPartition"
- proxy-type="attribute">jboss:service=${jboss.partition.name:DefaultPartition}</depends>>
+ <depends optional-attribute-name="HAPartition"
+ proxy-type="attribute">jboss:service=${jboss.partition.name:DefaultPartition}</depends>
+ <depends optional-attribute-name="cache"
+ proxy-type="attribute">jboss:service=ClusterTreeCache,partition=${jboss.partition.name:DefaultPartition}</depends>
<!-- Bind address of bootstrap and HA-JNDI RMI endpoints -->
<attribute name="BindAddress">${jboss.bind.address}</attribute>
<!-- Port on which the HA-JNDI stub is made available -->
Modified: trunk/cluster/src/main/org/jboss/ha/jndi/DetachedHANamingService.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/jndi/DetachedHANamingService.java 2007-07-13 15:03:42 UTC (rev 64039)
+++ trunk/cluster/src/main/org/jboss/ha/jndi/DetachedHANamingService.java 2007-07-13 15:23:24 UTC (rev 64040)
@@ -54,7 +54,6 @@
import org.jboss.logging.Logger;
import org.jboss.mx.util.MBeanProxyExt;
import org.jboss.system.ServiceMBeanSupport;
-import org.jboss.system.server.ServerConfigUtil;
import org.jboss.util.threadpool.BasicThreadPool;
import org.jboss.util.threadpool.BasicThreadPoolMBean;
import org.jboss.util.threadpool.ThreadPool;
@@ -95,22 +94,15 @@
*/
protected Naming stub;
/**
- * The HAPartition used for the state transfer service
+ * The HAPartition
*/
- protected HAPartition partition;
+ protected HAPartition clusterPartition;
/**
- * The ClusterPartition from which we access the HAPartition
- */
- protected ClusterPartitionMBean clusterPartition;
- /**
* The cache used to store HA-JNDI bindings
*/
protected Cache cache;
+
/**
- * The partition name used to lookup the HAPartition binding
- */
- protected String partitionName = ServerConfigUtil.getDefaultPartitionName();
- /**
* The proxy factory service that generates the Naming stub
*/
private ObjectName proxyFactory;
@@ -181,22 +173,27 @@
public String getPartitionName()
{
- return partitionName;
+ return clusterPartition.getPartitionName();
}
- public void setPartitionName(final String partitionName)
+ public HAPartition getHAPartition()
{
- this.partitionName = partitionName;
+ return clusterPartition;
}
- public ClusterPartitionMBean getClusterPartition()
+ public void setHAPartition(HAPartition clusterPartition)
{
- return clusterPartition;
+ this.clusterPartition = clusterPartition;
}
+
+ public Cache getClusteredCache()
+ {
+ return cache;
+ }
- public void setClusterPartition(ClusterPartitionMBean clusterPartition)
+ public void setClusteredCache(Cache cache)
{
- this.clusterPartition = clusterPartition;
+ this.cache = cache;
}
public ObjectName getProxyFactoryObjectName()
@@ -309,32 +306,27 @@
{
lookupPool = poolMBean.getInstance();
}
-
+/*
public void startService(HAPartition haPartition)
throws Exception
{
- this.partition = haPartition;
this.startService();
}
-
+*/
protected void createService()
throws Exception
{
- partition = clusterPartition.getHAPartition();
- partitionName = partition.getPartitionName();
+ if (clusterPartition == null)
+ throw new IllegalStateException("HAPartition property must be set before starting HAJNDI service");
- if (partition == null)
- throw new IllegalStateException("Cannot find partition '" + partitionName + "'");
-
- cache = clusterPartition.getClusteredCache();
+ if (cache == null)
+ throw new IllegalStateException("ClusteredCache property must be set before starting HAJNDI service");
if (log.isDebugEnabled())
- log.debug("Initializing HAJNDI server on partition: " + partitionName);
+ log.debug("Initializing HAJNDI server on partition: " + clusterPartition.getPartitionName());
// Start HAJNDI service
- theServer = new HAJNDI(partition, cache);
- log.debug("initialize HAJNDI");
- //theServer.init(); // moved to startService so that cache can be used
+ theServer = new HAJNDI(clusterPartition, cache);
// Build the Naming interface method map
HashMap tmpMap = new HashMap(13);
@@ -348,13 +340,13 @@
marshalledInvocationMapping = Collections.unmodifiableMap(tmpMap);
// share instance for in-vm discovery
- NamingContext.setHANamingServerForPartition(partitionName, theServer);
+ NamingContext.setHANamingServerForPartition(clusterPartition.getPartitionName(), theServer);
}
protected void startService()
throws Exception
{
- log.debug("Obtaining the transport proxy");
+ log.debug("Obtaining the HAJNDI transport proxy");
stub = this.getNamingProxy();
this.theServer.setHAStub(stub);
if (port >= 0)
@@ -377,21 +369,21 @@
log.warn("Failed to start AutomaticDiscovery", e);
}
}
- log.debug("initializing HAJNDI TreeCache");
+ log.debug("initializing HAJNDI");
theServer.init();
}
protected void stopService() throws Exception
{
// un-share instance for in-vm discovery
- NamingContext.removeHANamingServerForPartition(partitionName);
+ NamingContext.removeHANamingServerForPartition(clusterPartition.getPartitionName());
// Stop listener
ServerSocket s = bootstrapSocket;
bootstrapSocket = null;
if (s != null)
{
- log.debug("Closing the bootstrap listener");
+ log.debug("Closing the HAJNDI bootstrap listener");
s.close();
}
@@ -407,7 +399,9 @@
protected void destroyService() throws Exception
{
log.debug("Destroying the HAJNDI service");
- theServer.destroy();
+ // server may be null if service failed on startup
+ if (theServer != null)
+ theServer.destroy();
}
/**
@@ -460,13 +454,13 @@
// If an anonymous port was specified get the actual port used
if (port == 0)
port = bootstrapSocket.getLocalPort();
- String msg = "Started ha-jndi bootstrap jnpPort=" + port
+ String msg = "Started HAJNDI bootstrap; jnpPort=" + port
+ ", backlog=" + backlog + ", bindAddress=" + bindAddress;
log.info(msg);
}
catch (IOException e)
{
- log.error("Could not start on port " + port, e);
+ log.error("Could not start HAJNDI bootstrap listener on port " + port, e);
}
if (lookupPool == null)
@@ -483,32 +477,31 @@
// Class name match does not work with the AOP proxy :(
// QueryExp classEQ = Query.eq(Query.classattr(),
// Query.value(ClusterPartition.class.getName()));
- QueryExp matchName = Query.match(Query.attr("Name"),
- Query.value("ClusterPartition"));
- QueryExp matchPartitionName = Query.match(Query.attr("PartitionName"),
- Query.value(name));
- QueryExp exp = Query.and(matchName, matchPartitionName);
- Set mbeans = this.getServer().queryMBeans(null, exp);
- if (mbeans != null && mbeans.size() > 0)
- {
- for (Iterator iter = mbeans.iterator(); iter.hasNext();)
- {
- ObjectInstance inst = (ObjectInstance) iter.next();
- try
- {
- ClusterPartitionMBean cp =
- (ClusterPartitionMBean) MBeanProxyExt.create(
+ QueryExp matchName = Query.match(Query.attr("Name"),
+ Query.value("ClusterPartition"));
+ QueryExp matchPartitionName = Query.match(Query.attr("PartitionName"),
+ Query.value(name));
+ QueryExp exp = Query.and(matchName, matchPartitionName);
+ Set mbeans = this.getServer().queryMBeans(null, exp);
+ if (mbeans != null && mbeans.size() > 0)
+ {
+ for (Iterator iter = mbeans.iterator(); iter.hasNext();)
+ {
+ ObjectInstance inst = (ObjectInstance) iter.next();
+ try
+ {
+ ClusterPartitionMBean cp =
+ (ClusterPartitionMBean) MBeanProxyExt.create(
ClusterPartitionMBean.class,
inst.getObjectName(),
this.getServer());
- result = cp.getHAPartition();
- break;
- }
- catch (Exception e) {}
- }
- }
+ result = cp.getHAPartition();
+ break;
+ }
+ catch (Exception e) {}
+ }
+ }
-
return result;
}
@@ -683,7 +676,7 @@
{
// Check the partition name
String name = requestData.substring(colon + 1);
- if (name.equals(partitionName) == false)
+ if (name.equals(clusterPartition.getPartitionName()) == false)
{
log.debug("Ignoring discovery request for partition: " + name);
if( trace )
Modified: trunk/cluster/src/main/org/jboss/ha/jndi/DetachedHANamingServiceMBean.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/jndi/DetachedHANamingServiceMBean.java 2007-07-13 15:03:42 UTC (rev 64039)
+++ trunk/cluster/src/main/org/jboss/ha/jndi/DetachedHANamingServiceMBean.java 2007-07-13 15:23:24 UTC (rev 64040)
@@ -25,7 +25,8 @@
import java.util.Map;
import javax.management.ObjectName;
-import org.jboss.ha.framework.server.ClusterPartitionMBean;
+import org.jboss.cache.Cache;
+import org.jboss.ha.framework.interfaces.HAPartition;
import org.jboss.invocation.Invocation;
import org.jboss.util.threadpool.BasicThreadPoolMBean;
@@ -40,35 +41,40 @@
extends org.jboss.system.ServiceMBean
{
/**
- * Gets the name of the HAPartition used by this service.
+ * Gets the name of the partition used by this service. This is a
+ * convenience method as the partition name is an attribute of HAPartition.
*
* @return the name of the partition
- *
- * @deprecated use {@link #getClusterPartition()}
*/
String getPartitionName();
- /**
- * Sets the name of the HAPartition used by this service.
- *
- * @param name the name of the partition
- *
- * @deprecated use {@link #setClusterPartition(ClusterPartitionMBean)}
- */
- void setPartitionName(String name);
/**
* Get the underlying partition used by this service.
*
* @return the partition
*/
- ClusterPartitionMBean getClusterPartition();
+ HAPartition getHAPartition();
/**
* Sets the underlying partition used by this service.
*
* @param clusterPartition the partition
*/
- void setClusterPartition(ClusterPartitionMBean clusterPartition);
+ void setHAPartition(HAPartition clusterPartition);
+
+ /**
+ * Get the underlying cache used by this service.
+ *
+ * @return the cache
+ */
+ Cache getClusteredCache();
+
+ /**
+ * Sets the underlying cache used by this service.
+ *
+ * @param cache the cache
+ */
+ void setClusteredCache(Cache cache);
/** Get the proxy factory service name used to create the Naming transport
* proxy.
Modified: trunk/cluster/src/main/org/jboss/ha/jndi/HANamingService.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/jndi/HANamingService.java 2007-07-13 15:03:42 UTC (rev 64039)
+++ trunk/cluster/src/main/org/jboss/ha/jndi/HANamingService.java 2007-07-13 15:23:24 UTC (rev 64040)
@@ -124,7 +124,7 @@
Class clazz;
LoadBalancePolicy policy;
- rmiserver = new HARMIServerImpl(partition, "HAJNDI", Naming.class,
+ rmiserver = new HARMIServerImpl(clusterPartition, "HAJNDI", Naming.class,
theServer, rmiPort, clientSocketFactory, serverSocketFactory, bindAddress);
ClassLoader cl = Thread.currentThread().getContextClassLoader();
More information about the jboss-cvs-commits
mailing list