Author: ataylor
Date: 2012-01-26 07:59:39 -0500 (Thu, 26 Jan 2012)
New Revision: 12049
Modified:
branches/Branch_2_2_AS7/src/main/org/hornetq/ra/ConnectionFactoryProperties.java
branches/Branch_2_2_AS7/src/main/org/hornetq/ra/HornetQResourceAdapter.java
branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/unit/ra/ResourceAdapterTest.java
Log:
https://issues.jboss.org/browse/HORNETQ-836 - added discovery local bind address
Modified:
branches/Branch_2_2_AS7/src/main/org/hornetq/ra/ConnectionFactoryProperties.java
===================================================================
---
branches/Branch_2_2_AS7/src/main/org/hornetq/ra/ConnectionFactoryProperties.java 2012-01-26
10:35:18 UTC (rev 12048)
+++
branches/Branch_2_2_AS7/src/main/org/hornetq/ra/ConnectionFactoryProperties.java 2012-01-26
12:59:39 UTC (rev 12049)
@@ -52,6 +52,8 @@
private Integer discoveryPort;
+ private String discoveryLocalBindAddress;
+
private Long discoveryRefreshTimeout;
private Long discoveryInitialWaitTimeout;
@@ -183,6 +185,25 @@
return discoveryPort;
}
+ public void setDiscoveryLocalBindAddress(String discoveryLocalBindAddress)
+ {
+ if (ConnectionFactoryProperties.trace)
+ {
+ ConnectionFactoryProperties.log.trace("setDiscoveryLocalBindAddress("
+ discoveryLocalBindAddress + ")");
+ }
+ hasBeenUpdated = true;
+ this.discoveryLocalBindAddress = discoveryLocalBindAddress;
+ }
+
+ public String getDiscoveryLocalBindAddress()
+ {
+ if (ConnectionFactoryProperties.trace)
+ {
+
ConnectionFactoryProperties.log.trace("getDiscoveryLocalBindAddress()");
+ }
+ return discoveryLocalBindAddress;
+ }
+
public void setDiscoveryPort(final Integer discoveryPort)
{
if (ConnectionFactoryProperties.trace)
Modified: branches/Branch_2_2_AS7/src/main/org/hornetq/ra/HornetQResourceAdapter.java
===================================================================
--- branches/Branch_2_2_AS7/src/main/org/hornetq/ra/HornetQResourceAdapter.java 2012-01-26
10:35:18 UTC (rev 12048)
+++ branches/Branch_2_2_AS7/src/main/org/hornetq/ra/HornetQResourceAdapter.java 2012-01-26
12:59:39 UTC (rev 12049)
@@ -44,7 +44,6 @@
import org.hornetq.api.jms.JMSFactoryType;
import org.hornetq.core.logging.Logger;
import org.hornetq.jms.client.HornetQConnectionFactory;
-import org.hornetq.jms.server.recovery.XARecoveryConfig;
import org.hornetq.ra.inflow.HornetQActivation;
import org.hornetq.ra.inflow.HornetQActivationSpec;
import org.hornetq.ra.recovery.RecoveryManager;
@@ -364,6 +363,36 @@
}
/**
+ * set the discovery local bind address
+ *
+ * @param discoveryLocalBindAddress the address value
+ */
+ public void setDiscoveryLocalBindAddress(final String discoveryLocalBindAddress)
+ {
+ if (HornetQResourceAdapter.trace)
+ {
+ HornetQResourceAdapter.log.trace("setDiscoveryLocalBindAddress(" +
discoveryLocalBindAddress + ")");
+ }
+
+ raProperties.setDiscoveryLocalBindAddress(discoveryLocalBindAddress);
+ }
+
+ /**
+ * get the discovery local bind address
+ *
+ * @return the address value
+ */
+ public String getDiscoveryLocalBindAddress()
+ {
+ if (HornetQResourceAdapter.trace)
+ {
+ HornetQResourceAdapter.log.trace("getDiscoveryLocalBindAddress()");
+ }
+
+ return raProperties.getDiscoveryLocalBindAddress();
+ }
+
+ /**
* Set the discovery group port
*
* @param dgp The value
@@ -1456,7 +1485,7 @@
{
Integer discoveryPort = overrideProperties.getDiscoveryPort() != null ?
overrideProperties.getDiscoveryPort()
:
getDiscoveryPort();
-
+
if(discoveryPort == null)
{
discoveryPort = HornetQClient.DEFAULT_DISCOVERY_PORT;
@@ -1488,6 +1517,11 @@
groupConfiguration.setRefreshTimeout(refreshTimeout);
+ String localBindAddress = overrideProperties.getDiscoveryLocalBindAddress() !=
null ? overrideProperties.getDiscoveryLocalBindAddress()
+ :
raProperties.getDiscoveryLocalBindAddress();
+
+ groupConfiguration.setLocalBindAdress(localBindAddress);
+
if (ha)
{
cf = HornetQJMSClient.createConnectionFactoryWithHA(groupConfiguration,
JMSFactoryType.XA_CF);
@@ -1596,6 +1630,11 @@
groupConfiguration.setRefreshTimeout(refreshTimeout);
+ String localBindAddress = overrideProperties.getDiscoveryLocalBindAddress() !=
null ? overrideProperties.getDiscoveryLocalBindAddress()
+ :
raProperties.getDiscoveryLocalBindAddress();
+
+ groupConfiguration.setLocalBindAdress(localBindAddress);
+
cf = HornetQJMSClient.createConnectionFactoryWithoutHA(groupConfiguration,
JMSFactoryType.XA_CF);
}
else
Modified:
branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/unit/ra/ResourceAdapterTest.java
===================================================================
---
branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/unit/ra/ResourceAdapterTest.java 2012-01-26
10:35:18 UTC (rev 12048)
+++
branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/unit/ra/ResourceAdapterTest.java 2012-01-26
12:59:39 UTC (rev 12049)
@@ -263,9 +263,13 @@
ConnectionFactoryProperties connectionFactoryProperties = new
ConnectionFactoryProperties();
connectionFactoryProperties.setDiscoveryAddress("myhost");
connectionFactoryProperties.setDiscoveryPort(5678);
+ connectionFactoryProperties.setDiscoveryLocalBindAddress("newAddress");
HornetQConnectionFactory factory =
ra.createHornetQConnectionFactory(connectionFactoryProperties);
HornetQConnectionFactory defaultFactory = ra.getDefaultHornetQConnectionFactory();
Assert.assertNotSame(factory, defaultFactory);
+ Assert.assertEquals(factory.getDiscoveryGroupConfiguration().getLocalBindAddress(),
"newAddress");
+ Assert.assertEquals(factory.getDiscoveryGroupConfiguration().getGroupAddress(),
"myhost");
+ Assert.assertEquals(factory.getDiscoveryGroupConfiguration().getGroupPort(),
5678);
}
public void testCreateConnectionFactoryMultipleConnectors()