[jboss-cvs] JBoss Messaging SVN: r1518 - in branches/Branch_Client_Failover_Experiment: . docs/clustering/en/modules src/etc/server/default/deploy src/etc/xmdesc src/main/org/jboss/jms/server src/main/org/jboss/jms/server/destination src/main/org/jboss/jms/server/endpoint src/main/org/jboss/jms/tx src/main/org/jboss/messaging/core src/main/org/jboss/messaging/core/local src/main/org/jboss/messaging/core/message src/main/org/jboss/messaging/core/plugin src/main/org/jboss/messaging/core/plugin/contract src/main/org/jboss/messaging/core/plugin/postoffice src/main/org/jboss/messaging/core/plugin/postoffice/cluster src/main/org/jboss/messaging/core/tx tests tests/src/org/jboss/test/messaging/core tests/src/org/jboss/test/messaging/core/local/base tests/src/org/jboss/test/messaging/core/paging tests/src/org/jboss/test/messaging/core/paging/base tests/src/org/jboss/test/messaging/core/plugin tests/src/org/jboss/test/messaging/core/plugin/base tests/src/org/jboss/test/messaging/core/p! lugin/postoffice tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster tests/src/org/jboss/test/messaging/jms tests/src/org/jboss/test/messaging/jms/crash tests/src/org/jboss/test/messaging/jms/manual tests/src/org/jboss/test/messaging/jms/persistence tests/src/org/jboss/test/messaging/jms/server/destination tests/src/org/jboss/test/messaging/tools/jmx tests/src/org/jboss/test/messaging/tools/jmx/rmi
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 25 16:30:52 EDT 2006
Author: clebert.suconic at jboss.com
Date: 2006-10-25 16:30:08 -0400 (Wed, 25 Oct 2006)
New Revision: 1518
Added:
branches/Branch_Client_Failover_Experiment/readme-ha-experiment.txt
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/PullMessageResultRequest.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/RollbackPullRequest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/base/PostOfficeTestBase.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOfficeWithDefaultRouterTest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/RecoveryTest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/RedistributionWithDefaultMessagePullPolicyTest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/manual/
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/manual/ManualClusteringTest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/manual/ManualPagingSoakTest.java
Removed:
branches/Branch_Client_Failover_Experiment/src/etc/xmdesc/JDBCShutdownLogger-xmbean.xml
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/JDBCShutdownLogger.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/JDBCShutdownLoggerService.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/contract/ShutdownLogger.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/PullMessagesResponse.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/base/ClusteringTestBase.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/RedistributionTest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/ManualClusteringTest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/manual/ManualClusteringTest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/manual/ManualPagingSoakTest.java
Modified:
branches/Branch_Client_Failover_Experiment/.classpath
branches/Branch_Client_Failover_Experiment/docs/clustering/en/modules/configuration.xml
branches/Branch_Client_Failover_Experiment/src/etc/server/default/deploy/clustered-mysql-persistence-service.xml
branches/Branch_Client_Failover_Experiment/src/etc/server/default/deploy/hsqldb-persistence-service.xml
branches/Branch_Client_Failover_Experiment/src/etc/server/default/deploy/messaging-service.xml
branches/Branch_Client_Failover_Experiment/src/etc/server/default/deploy/mysql-persistence-service.xml
branches/Branch_Client_Failover_Experiment/src/etc/xmdesc/ClusteredPostOffice-xmbean.xml
branches/Branch_Client_Failover_Experiment/src/etc/xmdesc/ServerPeer-xmbean.xml
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/server/ServerPeer.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/server/destination/TopicService.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/tx/AckInfo.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/tx/ResourceManagerFactory.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/ChannelSupport.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/PagingChannelSupport.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/SimpleDelivery.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/local/RoundRobinPointToPointRouter.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/message/RoutableSupport.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/ClusteredPostOfficeService.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/JDBCPersistenceManager.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/LockMap.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/contract/ClusteredPostOffice.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/DefaultPostOffice.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/CastMessagesCallback.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusterRequest.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusterRouter.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOffice.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultMessagePullPolicy.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultRouter.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/LocalClusteredQueue.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/PostOfficeInternal.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/PullMessagesRequest.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/RemoteQueueStub.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/StatsSender.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/TransactionId.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/TransactionRequest.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/tx/Transaction.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/tx/TransactionRepository.java
branches/Branch_Client_Failover_Experiment/tests/build.xml
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/SimpleDeliveryTest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/SimpleReceiver.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/local/base/PagingFilteredQueueTestBase.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/paging/ChannelShare_NP_NTTest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/paging/PagingTest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/paging/SingleChannel_ReloadTest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/paging/base/PagingStateTestBase.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/IdManagerTest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/JDBCPersistenceManagerTest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/postoffice/DefaultPostOfficeTest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOfficeTest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/DefaultRouterTest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/BrowserTest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/MessageConsumerTest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/TransactedSessionTest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/crash/ManualCrashTest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/persistence/MessagePersistenceManagerTest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/server/destination/QueueManagementTest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java
Log:
These updates were executed to this branch:
svn merge https://svn.jboss.org/repos/messaging/trunk@1451 https://svn.jboss.org/repos/messaging/trunk
(when trunk was at 1517)
Modified: branches/Branch_Client_Failover_Experiment/.classpath
===================================================================
--- branches/Branch_Client_Failover_Experiment/.classpath 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/.classpath 2006-10-25 20:30:08 UTC (rev 1518)
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry excluding="**/.svn/**/*" kind="src" path="perf/src"/>
<classpathentry kind="src" path="output/gen-parsers"/>
<classpathentry excluding="**/.svn/**/*" kind="src" path="src/main"/>
<classpathentry excluding="**/.svn/**/*" kind="src" path="tests/src"/>
@@ -21,8 +20,6 @@
<classpathentry kind="lib" path="tests/lib/jms-ra.jar"/>
<classpathentry kind="lib" path="tests/lib/mysql-connector-java-3.1.13-bin.jar"/>
<classpathentry kind="lib" path="thirdparty/jgroups/lib/jgroups.jar"/>
- <classpathentry kind="lib" path="perf/resources/jcommon-1.0.0-rc1.jar"/>
- <classpathentry kind="lib" path="perf/resources/jfreechart-1.0.0-rc1.jar"/>
<classpathentry kind="lib" path="thirdparty/apache-log4j/lib/log4j.jar"/>
<classpathentry kind="lib" path="thirdparty/junit/lib/junit.jar"/>
<classpathentry kind="lib" path="thirdparty/jboss/profiler/jvmti/lib/jboss-profiler-jvmti.jar"/>
Modified: branches/Branch_Client_Failover_Experiment/docs/clustering/en/modules/configuration.xml
===================================================================
--- branches/Branch_Client_Failover_Experiment/docs/clustering/en/modules/configuration.xml 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/docs/clustering/en/modules/configuration.xml 2006-10-25 20:30:08 UTC (rev 1518)
@@ -78,7 +78,6 @@
<attribute name="GroupName">Topic</attribute>
<attribute name="StateTimeout">5000</attribute>
<attribute name="CastTimeout">5000</attribute>
- <attribute name="PullSize">1</attribute>
<attribute name="StatsSendPeriod">10000</attribute>
<attribute name="MessagePullPolicy">org.jboss.messaging.core.plugin.postoffice.cluster.NullMessagePullPolicy</attribute>
<attribute name="ClusterRouterFactory">org.jboss.messaging.core.plugin.postoffice.cluster.DefaultRouterFactory</attribute>
@@ -150,13 +149,6 @@
</para>
</section>
- <section id="conf.pullsize">
- <title>PullSize</title>
- <para>
- The maximum number of messages to pull from one node to another when the local node is starving. Defaults to 1.
- </para>
- </section>
-
<section id="conf.statssend">
<title>StatsSendPeriod</title>
<para>
Added: branches/Branch_Client_Failover_Experiment/readme-ha-experiment.txt
===================================================================
--- branches/Branch_Client_Failover_Experiment/readme-ha-experiment.txt 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/readme-ha-experiment.txt 2006-10-25 20:30:08 UTC (rev 1518)
@@ -0,0 +1,8 @@
+#Do not commit this file into trunk, it has information pertinent only to Branch_Client_Failover_Experiment
+
+
+These updates were executed to this branch:
+
+svn merge https://svn.jboss.org/repos/messaging/trunk@1451 https://svn.jboss.org/repos/messaging/trunk
+
+(when trunk was at 1517)
Modified: branches/Branch_Client_Failover_Experiment/src/etc/server/default/deploy/clustered-mysql-persistence-service.xml
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/etc/server/default/deploy/clustered-mysql-persistence-service.xml 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/etc/server/default/deploy/clustered-mysql-persistence-service.xml 2006-10-25 20:30:08 UTC (rev 1518)
@@ -43,7 +43,7 @@
INSERT_MESSAGE=INSERT INTO JMS_MESSAGE (MESSAGEID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, COREHEADERS, PAYLOAD, CHANNELCOUNT, TYPE, JMSTYPE, CORRELATIONID, CORRELATIONID_BYTES, DESTINATION, REPLYTO, JMSPROPERTIES) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
INC_CHANNELCOUNT=UPDATE JMS_MESSAGE SET CHANNELCOUNT = CHANNELCOUNT + 1 WHERE MESSAGEID=?
DEC_CHANNELCOUNT=UPDATE JMS_MESSAGE SET CHANNELCOUNT = CHANNELCOUNT - 1 WHERE MESSAGEID=?
-DELETE_MESSAGE=DELETE FROM JMS_MESSAGE WHERE MESSAGEID=?
+DELETE_MESSAGE=DELETE FROM JMS_MESSAGE WHERE MESSAGEID=? AND CHANNELCOUNT=0
MESSAGEID_COLUMN=MESSAGEID
MESSAGE_EXISTS=SELECT MESSAGEID FROM JMS_MESSAGE WHERE MESSAGEID = ? FOR UPDATE
INSERT_TRANSACTION=INSERT INTO JMS_TRANSACTION (TRANSACTIONID, BRANCH_QUAL, FORMAT_ID, GLOBAL_TXID) VALUES(?, ?, ?, ?)
@@ -75,7 +75,6 @@
<attribute name="GroupName">Queue</attribute>
<attribute name="StateTimeout">5000</attribute>
<attribute name="CastTimeout">5000</attribute>
- <attribute name="PullSize">1</attribute>
<attribute name="StatsSendPeriod">10000</attribute>
<attribute name="MessagePullPolicy">org.jboss.messaging.core.plugin.postoffice.cluster.NullMessagePullPolicy</attribute>
<attribute name="ClusterRouterFactory">org.jboss.messaging.core.plugin.postoffice.cluster.DefaultRouterFactory</attribute>
@@ -140,7 +139,6 @@
<attribute name="GroupName">Topic</attribute>
<attribute name="StateTimeout">5000</attribute>
<attribute name="CastTimeout">5000</attribute>
- <attribute name="PullSize">1</attribute>
<attribute name="StatsSendPeriod">10000</attribute>
<attribute name="MessagePullPolicy">org.jboss.messaging.core.plugin.postoffice.cluster.NullMessagePullPolicy</attribute>
<attribute name="ClusterRouterFactory">org.jboss.messaging.core.plugin.postoffice.cluster.DefaultRouterFactory</attribute>
@@ -201,19 +199,4 @@
]]></attribute>
</mbean>
- <mbean code="org.jboss.messaging.core.plugin.JDBCShutdownLoggerService"
- name="jboss.messaging:service=ShutdownLogger"
- xmbean-dd="xmdesc/JDBCShutdownLogger-xmbean.xml">
- <depends>jboss.jca:service=DataSourceBinding,name=DefaultDS</depends>
- <depends optional-attribute-name="TransactionManager">jboss:service=TransactionManager</depends>
- <attribute name="DataSource">java:/DefaultDS</attribute>
- <attribute name="CreateTablesOnStartup">true</attribute>
- <attribute name="SqlProperties"><![CDATA[
- CREATE_STARTUP=CREATE TABLE JMS_STARTUP (NODE_ID INTEGER PRIMARY KEY)
- SELECT_STARTUP=SELECT NODE_ID FROM JMS_STARTUP WHERE NODE_ID = ?
- DELETE_STARTUP=DELETE FROM JMS_STARTUP WHERE NODE_ID = ?
- INSERT_STARTUP=INSERT INTO JMS_STARTUP (NODE_ID) VALUES (?)
- ]]></attribute>
- </mbean>
-
</server>
\ No newline at end of file
Modified: branches/Branch_Client_Failover_Experiment/src/etc/server/default/deploy/hsqldb-persistence-service.xml
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/etc/server/default/deploy/hsqldb-persistence-service.xml 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/etc/server/default/deploy/hsqldb-persistence-service.xml 2006-10-25 20:30:08 UTC (rev 1518)
@@ -52,13 +52,4 @@
<attribute name="CreateTablesOnStartup">true</attribute>
</mbean>
- <mbean code="org.jboss.messaging.core.plugin.JDBCShutdownLoggerService"
- name="jboss.messaging:service=ShutdownLogger"
- xmbean-dd="xmdesc/JDBCShutdownLogger-xmbean.xml">
- <depends>jboss.jca:service=DataSourceBinding,name=DefaultDS</depends>
- <depends optional-attribute-name="TransactionManager">jboss:service=TransactionManager</depends>
- <attribute name="DataSource">java:/DefaultDS</attribute>
- <attribute name="CreateTablesOnStartup">true</attribute>
- </mbean>
-
</server>
\ No newline at end of file
Modified: branches/Branch_Client_Failover_Experiment/src/etc/server/default/deploy/messaging-service.xml
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/etc/server/default/deploy/messaging-service.xml 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/etc/server/default/deploy/messaging-service.xml 2006-10-25 20:30:08 UTC (rev 1518)
@@ -23,7 +23,6 @@
<depends optional-attribute-name="PersistenceManager">jboss.messaging:service=PersistenceManager</depends>
<depends optional-attribute-name="JMSUserManager">jboss.messaging:service=JMSUserManager</depends>
- <depends optional-attribute-name="ShutdownLogger">jboss.messaging:service=ShutdownLogger</depends>
<attribute name="QueuePostOffice">jboss.messaging:service=QueuePostOffice</attribute>
<attribute name="TopicPostOffice">jboss.messaging:service=TopicPostOffice</attribute>
Modified: branches/Branch_Client_Failover_Experiment/src/etc/server/default/deploy/mysql-persistence-service.xml
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/etc/server/default/deploy/mysql-persistence-service.xml 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/etc/server/default/deploy/mysql-persistence-service.xml 2006-10-25 20:30:08 UTC (rev 1518)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!--
MySql persistence deployment descriptor.
@@ -43,7 +43,7 @@
INSERT_MESSAGE=INSERT INTO JMS_MESSAGE (MESSAGEID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, COREHEADERS, PAYLOAD, CHANNELCOUNT, TYPE, JMSTYPE, CORRELATIONID, CORRELATIONID_BYTES, DESTINATION, REPLYTO, JMSPROPERTIES) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
INC_CHANNELCOUNT=UPDATE JMS_MESSAGE SET CHANNELCOUNT = CHANNELCOUNT + 1 WHERE MESSAGEID=?
DEC_CHANNELCOUNT=UPDATE JMS_MESSAGE SET CHANNELCOUNT = CHANNELCOUNT - 1 WHERE MESSAGEID=?
- DELETE_MESSAGE=DELETE FROM JMS_MESSAGE WHERE MESSAGEID=?
+ DELETE_MESSAGE=DELETE FROM JMS_MESSAGE WHERE MESSAGEID=? AND CHANNELCOUNT=0
MESSAGEID_COLUMN=MESSAGEID
MESSAGE_EXISTS=SELECT MESSAGEID FROM JMS_MESSAGE WHERE MESSAGEID = ? FOR UPDATE
INSERT_TRANSACTION=INSERT INTO JMS_TRANSACTION (TRANSACTIONID, BRANCH_QUAL, FORMAT_ID, GLOBAL_TXID) VALUES(?, ?, ?, ?)
@@ -105,19 +105,4 @@
]]></attribute>
</mbean>
- <mbean code="org.jboss.messaging.core.plugin.JDBCShutdownLoggerService"
- name="jboss.messaging:service=ShutdownLogger"
- xmbean-dd="xmdesc/JDBCShutdownLogger-xmbean.xml">
- <depends>jboss.jca:service=DataSourceBinding,name=DefaultDS</depends>
- <depends optional-attribute-name="TransactionManager">jboss:service=TransactionManager</depends>
- <attribute name="DataSource">java:/DefaultDS</attribute>
- <attribute name="CreateTablesOnStartup">true</attribute>
- <attribute name="SqlProperties"><![CDATA[
- CREATE_STARTUP=CREATE TABLE JMS_STARTUP (NODE_ID INTEGER PRIMARY KEY)
- SELECT_STARTUP=SELECT NODE_ID FROM JMS_STARTUP WHERE NODE_ID = ?
- DELETE_STARTUP=DELETE FROM JMS_STARTUP WHERE NODE_ID = ?
- INSERT_STARTUP=INSERT INTO JMS_STARTUP (NODE_ID) VALUES (?)
- ]]></attribute>
- </mbean>
-
</server>
\ No newline at end of file
Modified: branches/Branch_Client_Failover_Experiment/src/etc/xmdesc/ClusteredPostOffice-xmbean.xml
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/etc/xmdesc/ClusteredPostOffice-xmbean.xml 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/etc/xmdesc/ClusteredPostOffice-xmbean.xml 2006-10-25 20:30:08 UTC (rev 1518)
@@ -83,12 +83,6 @@
<type>long</type>
</attribute>
- <attribute access="read-write" getMethod="getPullSize" setMethod="setPullSize">
- <description>The maximum number of message to pull in one go from a remote queue when the local queue consumers are starving</description>
- <name>PullSize</name>
- <type>int</type>
- </attribute>
-
<attribute access="read-write" getMethod="getStatsSendPeriod" setMethod="setStatsSendPeriod">
<description>The period in milliseconds between a post office casting it's statistics across the cluster</description>
<name>StatsSendPeriod</name>
Deleted: branches/Branch_Client_Failover_Experiment/src/etc/xmdesc/JDBCShutdownLogger-xmbean.xml
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/etc/xmdesc/JDBCShutdownLogger-xmbean.xml 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/etc/xmdesc/JDBCShutdownLogger-xmbean.xml 2006-10-25 20:30:08 UTC (rev 1518)
@@ -1,66 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mbean PUBLIC
- "-//JBoss//DTD JBOSS XMBEAN 1.2//EN"
- "http://www.jboss.org/j2ee/dtd/jboss_xmbean_1_2.dtd">
-
-<mbean>
- <description>A JDBC Shutdown Logger</description>
- <class>org.jboss.server.plugin.JDBCShutdownLoggerService</class>
-
- <!-- Managed constructors -->
-
- <!-- Managed attributes -->
-
- <attribute access="read-only" getMethod="getInstance">
- <description>The instance to plug into the server peer</description>
- <name>Instance</name>
- <type>org.jboss.messaging.core.plugin.contract.MessagingComponent</type>
- </attribute>
-
- <attribute access="read-write" getMethod="getDataSource" setMethod="setDataSource">
- <description>The JNDI name of the DataSource used by this ChannelMapper instance</description>
- <name>DataSource</name>
- <type>java.lang.String</type>
- </attribute>
-
- <attribute access="read-write" getMethod="getTransactionManager" setMethod="setTransactionManager">
- <description>The ObjectName of the TransactionManager used by this ChannelMaper instance</description>
- <name>TransactionManager</name>
- <type>javax.management.ObjectName</type>
- </attribute>
-
- <attribute access="read-write" getMethod="getSqlProperties" setMethod="setSqlProperties">
- <description>DML and DDL overrides</description>
- <name>SqlProperties</name>
- <type>java.lang.String</type>
- </attribute>
-
- <attribute access="read-write" getMethod="isCreateTablesOnStartup" setMethod="setCreateTablesOnStartup">
- <description>Should database tables be created on startup?</description>
- <name>CreateTablesOnStartup</name>
- <type>boolean</type>
- </attribute>
-
- <!-- Managed operations -->
-
- <operation>
- <description>JBoss Service lifecycle operation</description>
- <name>create</name>
- </operation>
-
- <operation>
- <description>JBoss Service lifecycle operation</description>
- <name>start</name>
- </operation>
-
- <operation>
- <description>JBoss Service lifecycle operation</description>
- <name>stop</name>
- </operation>
-
- <operation>
- <description>JBoss Service lifecycle operation</description>
- <name>destroy</name>
- </operation>
-
-</mbean>
\ No newline at end of file
Modified: branches/Branch_Client_Failover_Experiment/src/etc/xmdesc/ServerPeer-xmbean.xml
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/etc/xmdesc/ServerPeer-xmbean.xml 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/etc/xmdesc/ServerPeer-xmbean.xml 2006-10-25 20:30:08 UTC (rev 1518)
@@ -58,12 +58,6 @@
<type>javax.management.ObjectName</type>
</attribute>
- <attribute access="read-write" getMethod="getShutdownLogger" setMethod="setShutdownLogger">
- <description>The ObjectName of the shutdown logger</description>
- <name>ShutdownLogger</name>
- <type>javax.management.ObjectName</type>
- </attribute>
-
<!-- instance access -->
<attribute access="read-only" getMethod="getInstance">
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/server/ServerPeer.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/server/ServerPeer.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/server/ServerPeer.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -49,7 +49,6 @@
import org.jboss.messaging.core.plugin.contract.MessageStore;
import org.jboss.messaging.core.plugin.contract.PersistenceManager;
import org.jboss.messaging.core.plugin.contract.PostOffice;
-import org.jboss.messaging.core.plugin.contract.ShutdownLogger;
import org.jboss.messaging.core.plugin.postoffice.DefaultPostOffice;
import org.jboss.messaging.core.tx.TransactionRepository;
import org.jboss.messaging.util.Util;
@@ -78,7 +77,7 @@
private static final Logger log = Logger.getLogger(ServerPeer.class);
- //public static final String RECOVERABLE_CTX_NAME = "jms-recoverables";
+ public static final String RECOVERABLE_CTX_NAME = "jms-recoverables";
// The "subsystem" label this ServerPeer uses to register its ServerInvocationHandler with the
// Remoting connector
@@ -101,8 +100,6 @@
private int objectIDSequence = 1;
- private boolean crashed;
-
// wired components
private DestinationJNDIMapper destinationJNDIMapper;
@@ -132,9 +129,6 @@
protected ObjectName jmsUserManagerObjectName;
protected JMSUserManager jmsUserManager;
- protected ObjectName shutdownLoggerObjectName;
- protected ShutdownLogger shutdownLogger;
-
//Other stuff
private JMSServerInvocationHandler handler;
@@ -202,9 +196,6 @@
jmsUserManager = (JMSUserManager)mbeanServer.
getAttribute(jmsUserManagerObjectName, "Instance");
- shutdownLogger = (ShutdownLogger)mbeanServer.
- getAttribute(shutdownLoggerObjectName, "Instance");
-
//We get references to some plugins lazily to avoid problems with circular
//MBean dependencies
@@ -234,11 +225,6 @@
securityStore.start();
txRepository.start();
- //Did the server crash last time?
-
- //TODO do we need this?
- crashed = shutdownLogger.startup(serverPeerID);
-
initializeRemoting(mbeanServer);
//createRecoverable();
@@ -268,9 +254,7 @@
started = false;
//removeRecoverable();
-
- shutdownLogger.shutdown(serverPeerID);
-
+
// Stop the wired components
messageIdManager.stop();
@@ -352,16 +336,6 @@
jmsUserManagerObjectName = on;
}
- public ObjectName getShutdownLogger()
- {
- return shutdownLoggerObjectName;
- }
-
- public void setShutdownLogger(ObjectName on)
- {
- shutdownLoggerObjectName = on;
- }
-
public Object getInstance()
{
return this;
@@ -577,11 +551,6 @@
return version;
}
- public boolean crashedLastTime()
- {
- return crashed;
- }
-
// access to hard-wired server extensions
public SecurityManager getSecurityManager()
@@ -653,11 +622,6 @@
return topicPostOffice;
}
- public ShutdownLogger getShutdownLoggerInstance()
- {
- return shutdownLogger;
- }
-
public synchronized int getNextObjectID()
{
return objectIDSequence++;
@@ -701,8 +665,8 @@
* order to obtain an XAResource so it can perform XA recovery.
*/
-// //Commented out until XA Recovery is complete
-//
+ //Commented out until XA Recovery is complete
+
// private void createRecoverable() throws Exception
// {
// //Disabled until XA Recovery is complete with Arjuna transaction integration
@@ -733,7 +697,7 @@
//
// recCtx.rebind(this.serverPeerID, recoverable);
// }
-
+//
// private void removeRecoverable() throws Exception
// {
// InitialContext ic = new InitialContext();
@@ -821,7 +785,7 @@
// <path refid="jboss.jmx.classpath"/> from jms/build.xml dependentmodule.classpath
//
- //FIXME - Yes this is super-ugly - there must be an easier way of doing it
+ //TODO - Yes this is super-ugly - there must be an easier way of doing it
//also in LocalTestServer is doing the same thing in a slightly different way
//this should be combined
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/server/destination/TopicService.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/server/destination/TopicService.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/server/destination/TopicService.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -15,8 +15,10 @@
import org.jboss.jms.util.ExceptionUtil;
import org.jboss.jms.util.XMLUtil;
+import org.jboss.messaging.core.Queue;
import org.jboss.messaging.core.local.PagingFilteredQueue;
import org.jboss.messaging.core.plugin.postoffice.Binding;
+import org.jboss.messaging.core.plugin.postoffice.cluster.ClusteredQueue;
/**
* A deployable JBoss Messaging topic.
@@ -24,6 +26,8 @@
* @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
* @author <a href="mailto:alex.fu at novell.com">Alex Fu</a>
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>
+ *
* @version <tt>$Revision$</tt>
*
* $Id$
@@ -61,7 +65,10 @@
try
{
postOffice = serverPeer.getTopicPostOfficeInstance();
-
+
+ if (postOffice == null)
+ throw new IllegalArgumentException("Post Office instance not found. Check your destination configuration.");
+
destination.setPostOffice(postOffice);
// We deploy any queues corresponding to pre-existing durable subscriptions
@@ -72,10 +79,10 @@
Binding binding = (Binding)iter.next();
PagingFilteredQueue queue = (PagingFilteredQueue)binding.getQueue();
-
+
queue.setPagingParams(destination.getFullSize(), destination.getPageSize(), destination.getDownCacheSize());
queue.load();
- queue.activate();
+ queue.activate();
}
dm.registerDestination(destination);
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -176,7 +176,7 @@
if (trace) log.trace("created selector");
}
- //FIXME -
+ //TODO -
//We really need to get rid of this delivery list - it's only purpose in life is to solve
//the race condition where acks or cancels can come in before handle has returned - and
//that can be solved in a simpler way anyway.
@@ -350,7 +350,7 @@
// it. This is because it may still contain deliveries that may well be acknowledged
// after the consumer has closed. This is perfectly valid.
- // FIXME - The deliveries should really be stored in the session endpoint, not here
+ // TODO - The deliveries should really be stored in the session endpoint, not here
// that is their natural place, that would mean we wouldn't have to mess around with
// keeping deliveries after this is closed.
@@ -499,7 +499,7 @@
}
else
{
- throw new IllegalStateException("Failed to acknowledge delivery " + d);
+ throw new IllegalStateException("Could not find delivery to acknowledge");
}
}
@@ -575,8 +575,7 @@
{
Delivery del = (Delivery)deliveries.remove(messageID);
if (del != null)
- {
- del.getReference().decrementDeliveryCount();
+ {
del.cancel();
}
else
@@ -799,7 +798,7 @@
* QueueExecutor might be share by other consumers and we don't want to wait for their
* tasks to complete
*/
- private class Waiter implements Runnable
+ private static class Waiter implements Runnable
{
Future result;
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/tx/AckInfo.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/tx/AckInfo.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/tx/AckInfo.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -48,8 +48,7 @@
// One of Session.AUTO_ACKNOWLEDGE, Session.CLIENT_ACKNOWLEDGE, etc.
private int ackMode;
- // The actual proxy must not get serialized
- protected transient MessageProxy msg;
+ protected MessageProxy msg;
// Static --------------------------------------------------------
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/tx/ResourceManagerFactory.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/tx/ResourceManagerFactory.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/tx/ResourceManagerFactory.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -41,7 +41,7 @@
*/
public class ResourceManagerFactory
{
- public static ResourceManagerFactory instance = new ResourceManagerFactory();
+ public static final ResourceManagerFactory instance = new ResourceManagerFactory();
private Map holders;
@@ -97,7 +97,7 @@
}
}
- private class Holder
+ private static class Holder
{
ResourceManager rm = new ResourceManager();
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/ChannelSupport.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/ChannelSupport.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/ChannelSupport.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -51,10 +51,6 @@
* and deliver to receivers are not executed concurrently but placed on an event
* queue and executed serially by a single thread.
*
- * This prevents lock contention since requests are
- * executed serially, resulting in better scalability and higher throughput at the expense of some
- * latency.
- *
* Currently remoting does not support a non blocking API so a full SEDA approach is not possible at this stage.
*
* @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
@@ -99,7 +95,7 @@
protected Object deliveryLock;
protected boolean active = true;
-
+
// Constructors --------------------------------------------------
protected ChannelSupport(long channelID, MessageStore ms,
@@ -189,7 +185,13 @@
public void cancel(Delivery d) throws Throwable
{
// TODO We should also consider executing cancels on the event queue
- cancelInternal(d);
+ synchronized (deliveryLock)
+ {
+ synchronized (refLock)
+ {
+ cancelInternal(d);
+ }
+ }
}
// Distributor implementation ------------------------------------
@@ -382,6 +384,7 @@
del.acknowledge(null);
}
+
}
}
}
@@ -491,6 +494,7 @@
// Public --------------------------------------------------------
+ //Only used for testing
public int memoryRefCount()
{
synchronized (refLock)
@@ -499,6 +503,7 @@
}
}
+ //Only used for testing
public int memoryDeliveryCount()
{
synchronized (deliveryLock)
@@ -515,7 +520,7 @@
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
-
+
/*
* This methods delivers as many messages as possible to the router until no
* more deliveries are returned. This method should never be called at the
@@ -523,7 +528,7 @@
*
* @see org.jboss.messaging.core.Channel#deliver()
*/
- protected void deliverInternal(boolean handle) throws Throwable
+ protected void deliverInternal() throws Throwable
{
try
{
@@ -535,47 +540,16 @@
while (true)
{
- synchronized (refLock)
- {
- if (iter == null)
- {
- ref = (MessageReference) messageRefs.peekFirst();
- }
- else
- {
- if (iter.hasNext())
- {
- ref = (MessageReference)iter.next();
- }
- else
- {
- ref = null;
- }
- }
+ synchronized (deliveryLock)
+ {
+ ref = nextReference(iter);
}
-
if (ref != null)
{
- // Check if message is expired (we also do this on the client
- // side)
- // If so ack it from the channel
+ // Check if message is expired (we also do this on the clientside) If so ack it from the channel
if (ref.isExpired())
{
- if (trace) { log.trace("Message reference: " + ref + " has expired"); }
-
- // remove and acknowledge it
- if (iter == null)
- {
- removeFirstInMemory();
- }
- else
- {
- iter.remove();
- }
-
- Delivery delivery = new SimpleDelivery(this, ref, true);
-
- acknowledgeInternal(delivery, null, true, false);
+ expireRef(ref, iter);
}
else
{
@@ -585,37 +559,28 @@
ref.incrementDeliveryCount();
Delivery del = router.handle(this, ref, null);
+
+ receiversReady = del != null;
if (del == null)
{
// No receiver, broken receiver or full receiver so we stop delivering; also
- // we need to decrement the delivery count, as no real delivery has been
- // actually performed
+ // we need to decrement the delivery count, as no real delivery has been actually performed
if (trace) { log.trace(this + ": no delivery returned for message" + ref + " so no receiver got the message. Delivery is now complete"); }
ref.decrementDeliveryCount();
- receiversReady = false;
- return;
+
+ break;
}
else if (!del.isSelectorAccepted())
{
// No receiver accepted the message because no selectors matched, so we create
// an iterator (if we haven't already created it) to iterate through the refs
- // in the channel. No delivery was really performed, so we decrement the
- // delivery count
+ // in the channel. No delivery was really performed, so we decrement the delivery count
ref.decrementDeliveryCount();
- // TODO Note that this is only a partial solution since if there are messages
- // paged to storage it won't try those - i.e. it will only iterate through
- // those refs in memory. Dealing with refs in storage is somewhat tricky since
- // we can't just load them and iterate through them since we might run out of
- // memory, so we will need to load individual refs from storage given the
- // selector expressions. Secondly we should also introduce some in memory
- // indexes here to prevent having to iterate through all the refs every time.
- // Having said all that, having consumers on a queue that don't match many
- // messages is an antipattern and should be avoided by the user.
if (iter == null)
{
iter = messageRefs.iterator();
@@ -626,8 +591,8 @@
if (trace) { log.trace(this + ": " + del + " returned for message:" + ref); }
// Receiver accepted the reference
-
- // We must synchronize here to cope with another race condition where message
+
+ // We must synchronize here to cope with a race condition where message
// is cancelled/acked in flight while the following few actions are being
// performed. e.g. delivery could be cancelled acked after being removed from
// state but before delivery being added (observed).
@@ -635,29 +600,13 @@
{
if (trace) { log.trace(this + " incrementing delivery count for " + del); }
- // FIXME - It's actually possible the delivery could be
- // cancelled before it reaches
- // here, in which case we wouldn't get a delivery but we
- // still need to increment the
- // delivery count
- // All the problems related to these race conditions and
- // fiddly edge cases will disappear
- // once we do
- // http://jira.jboss.com/jira/browse/JBMESSAGING-355
- // This will make life a lot easier
+ // FIXME - It's actually possible the delivery could be cancelled before it reaches
+ // here, in which case we wouldn't get a delivery but we still need to increment the
+ // delivery count. TODO http://jira.jboss.com/jira/browse/JBMESSAGING-355
- del.getReference().incrementDeliveryCount();
-
if (!del.isCancelled())
{
- if (iter == null)
- {
- removeFirstInMemory();
- }
- else
- {
- iter.remove();
- }
+ removeReference(iter);
// delivered
if (!del.isDone())
@@ -677,6 +626,7 @@
{
// No more refs in channel or only ones that don't match any selectors
if (trace) { log.trace(this + " no more refs to deliver "); }
+
break;
}
}
@@ -716,12 +666,9 @@
if (tx == null)
{
// Don't even attempt synchronous delivery for a reliable message
- // when we have an
- // non-recoverable state that doesn't accept reliable messages. If
- // we do, we may get
- // into the situation where we need to reliably store an active
- // delivery of a reliable
- // message, which in these conditions cannot be done.
+ // when we have an non-recoverable state that doesn't accept reliable messages. If
+ // we do, we may get into the situation where we need to reliably store an active
+ // delivery of a reliable message, which in these conditions cannot be done.
if (ref.isReliable() && !acceptReliableMessages)
{
@@ -738,14 +685,17 @@
pm.addReference(channelID, ref, null);
}
- addReferenceInMemory(ref);
+ synchronized (refLock)
+ {
+ addReferenceInMemory(ref);
+ }
// We only do delivery if there are receivers that haven't said they don't want
// any more references.
if (receiversReady)
{
// Prompt delivery
- deliverInternal(true);
+ deliverInternal();
}
}
else
@@ -793,7 +743,8 @@
return new SimpleDelivery(this, ref, true);
}
- protected void acknowledgeInternal(Delivery d, Transaction tx, boolean persist, boolean synchronous) throws Exception
+ protected void acknowledgeInternal(Delivery d, Transaction tx, boolean persist,
+ boolean synchronous) throws Exception
{
if (tx == null)
{
@@ -861,14 +812,118 @@
return callback;
}
- protected abstract boolean cancelInternal(Delivery del) throws Exception;
+ protected boolean cancelInternal(Delivery del) throws Exception
+ {
+ if (trace) { log.trace(this + " cancelling " + del + " in memory"); }
+
+ boolean removed = deliveries.remove(del);
+
+ if (!removed)
+ {
+ // This can happen if the message is cancelled before the result of
+ // ServerConsumerDelegate.handle has returned, in which case we won't have a record of the delivery
+ // In this case we don't want to add the message reference back into
+ // the state since it was never removed in the first place
+
+ if (trace) { log.trace(this + " can't find delivery " + del + " in state so not replacing messsage ref"); }
+ }
+ else
+ {
+ messageRefs.addFirst(del.getReference(), del.getReference().getPriority());
+
+ if (trace) { log.trace(this + " added " + del.getReference() + " back into state"); }
+ }
+
+ return removed;
+ }
- protected abstract MessageReference removeFirstInMemory() throws Exception;
+ protected MessageReference removeFirstInMemory() throws Exception
+ {
+ MessageReference result = (MessageReference) messageRefs.removeFirst();
+
+ return (MessageReference) result;
+ }
- protected abstract void addReferenceInMemory(MessageReference ref) throws Exception;
+ protected void addReferenceInMemory(MessageReference ref) throws Exception
+ {
+ if (ref.isReliable() && !acceptReliableMessages)
+ {
+ throw new IllegalStateException("Reliable reference " + ref +
+ " cannot be added to non-recoverable state");
+ }
+
+ messageRefs.addLast(ref, ref.getPriority());
+
+ if (trace){ log.trace(this + " added " + ref + " non-transactionally in memory"); }
+ }
// Private -------------------------------------------------------
+
+ private void expireRef(MessageReference ref, ListIterator iter) throws Exception
+ {
+ if (trace) { log.trace("Message reference: " + ref + " has expired"); }
+ // remove and acknowledge it
+ synchronized (refLock)
+ {
+ if (iter == null)
+ {
+ removeFirstInMemory();
+ }
+ else
+ {
+ iter.remove();
+ }
+ }
+
+ Delivery delivery = new SimpleDelivery(this, ref, true);
+
+ acknowledgeInternal(delivery, null, true, false);
+ }
+
+ private void removeReference(ListIterator iter) throws Exception
+ {
+ synchronized (refLock)
+ {
+ if (iter == null)
+ {
+ removeFirstInMemory();
+ }
+ else
+ {
+ iter.remove();
+ }
+ }
+ }
+
+ private MessageReference nextReference(ListIterator iter) throws Throwable
+ {
+ MessageReference ref;
+
+ if (iter == null)
+ {
+ //We just get the next ref from the head of the queue
+ ref = (MessageReference) messageRefs.peekFirst();
+ }
+ else
+ {
+ // TODO This will not work with paged refs - see http://jira.jboss.com/jira/browse/JBMESSAGING-275
+ // We need to extend it to work with refs from the db
+
+ //We have an iterator - this means we are iterating through the queue to find a ref that matches
+ if (iter.hasNext())
+ {
+ ref = (MessageReference)iter.next();
+ }
+ else
+ {
+ ref = null;
+ }
+ }
+
+ return ref;
+ }
+
// Inner classes -------------------------------------------------
private class InMemoryCallback implements TxCallback, Runnable
@@ -878,7 +933,7 @@
private List deliveriesToRemove;
private boolean synchronous;
-
+
private boolean committing;
private Future result;
@@ -1034,7 +1089,7 @@
private void doAfterCommit() throws Throwable
{
// We add the references to the state
-
+
Iterator iter = refsToAdd.iterator();
while (iter.hasNext())
@@ -1045,7 +1100,10 @@
try
{
- addReferenceInMemory(ref);
+ synchronized (refLock)
+ {
+ addReferenceInMemory(ref);
+ }
}
catch (Throwable t)
{
@@ -1054,7 +1112,7 @@
}
// Remove deliveries
-
+
iter = this.deliveriesToRemove.iterator();
while (iter.hasNext())
@@ -1081,7 +1139,7 @@
//prompt delivery
if (receiversReady)
{
- deliverInternal(true);
+ deliverInternal();
}
}
@@ -1138,9 +1196,7 @@
{
if (router.numberOfReceivers() > 0)
{
- receiversReady = true;
-
- deliverInternal(false);
+ deliverInternal();
}
if (result != null)
{
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/PagingChannelSupport.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/PagingChannelSupport.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/PagingChannelSupport.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -22,6 +22,7 @@
package org.jboss.messaging.core;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -181,6 +182,7 @@
// Public --------------------------------------------------------
+ //Only used in testing
public int downCacheCount()
{
synchronized (refLock)
@@ -189,6 +191,7 @@
}
}
+ //Only used in testing
public boolean isPaging()
{
synchronized (refLock)
@@ -344,12 +347,11 @@
protected void loadPagedReferences(long number) throws Exception
{
if (trace) { log.trace(this + " Loading " + number + " paged references from storage"); }
-
+
// Must flush the down cache first
flushDownCache();
+ List refInfos = pm.getPagedReferenceInfos(channelID, firstPagingOrder, number);
- List refInfos = pm.getPagedReferenceInfos(channelID, firstPagingOrder, number);
-
Map refMap = processReferences(refInfos);
boolean loadedReliable = false;
@@ -378,7 +380,7 @@
unreliableNumber++;
}
}
-
+
if (!toRemove.isEmpty())
{
// Now we remove the references we loaded (only the non persistent or persistent in a non-recoverable store)
@@ -408,70 +410,47 @@
}
}
}
-
+
protected boolean cancelInternal(Delivery del) throws Exception
{
if (trace) { log.trace(this + " cancelling " + del + " in memory"); }
- boolean removed;
-
- synchronized (deliveryLock)
+ boolean removed = super.cancelInternal(del);
+
+ if (removed && paging)
{
- removed = deliveries.remove(del);
- }
-
- if (!removed)
- {
- // This can happen if the message is cancelled before the result of
- // ServerConsumerDelegate.handle has returned, in which case we won't have a record of the delivery
- // In this case we don't want to add the message reference back into
- // the state since it was never removed in the first place
-
- if (trace) { log.trace(this + " can't find delivery " + del + " in state so not replacing messsage ref"); }
- }
- else
- {
- synchronized (refLock)
+ // if paging and the in memory queue is exactly full we need to evict the end reference to storage to
+ // preserve the number of refs in the queue
+ if (messageRefs.size() == fullSize + 1)
{
- messageRefs.addFirst(del.getReference(), del.getReference().getPriority());
-
- if (paging)
- {
- // if paging we need to evict the end reference to storage to
- // preserve the number of refs in the queue
-
- MessageReference ref = (MessageReference)messageRefs.removeLast();
+ MessageReference ref = (MessageReference)messageRefs.removeLast();
- addToDownCache(ref, true);
- }
+ addToDownCache(ref, true);
}
-
- if (trace) { log.trace(this + " added " + del.getReference() + " back into state"); }
}
+
+ if (trace) { log.trace(this + " added " + del.getReference() + " back into state"); }
return removed;
}
-
+
protected MessageReference removeFirstInMemory() throws Exception
{
- synchronized (refLock)
- {
- MessageReference result = (MessageReference) messageRefs.removeFirst();
+ MessageReference result = super.removeFirstInMemory();
- checkLoad();
+ checkLoad();
- return (MessageReference) result;
- }
+ return result;
}
private boolean checkLoad() throws Exception
{
- long refNum = downCache.size() + nextPagingOrder - firstPagingOrder;
+ long refNum = nextPagingOrder - firstPagingOrder;
if (refNum > 0)
{
long numberLoadable = Math.min(refNum, pageSize);
-
+
if (messageRefs.size() <= fullSize - numberLoadable)
{
//This will flush the down cache too
@@ -491,36 +470,30 @@
return false;
}
}
-
+
protected void addReferenceInMemory(MessageReference ref) throws Exception
- {
- if (ref.isReliable() && !acceptReliableMessages)
+ {
+ if (paging)
{
- throw new IllegalStateException("Reliable reference " + ref +
- " cannot be added to non-recoverable state");
+ if (ref.isReliable() && !acceptReliableMessages)
+ {
+ throw new IllegalStateException("Reliable reference " + ref +
+ " cannot be added to non-recoverable state");
+ }
+ addToDownCache(ref, false);
}
-
- synchronized (refLock)
+ else
{
- if (paging)
+ super.addReferenceInMemory(ref);
+
+ if (messageRefs.size() == fullSize)
{
- addToDownCache(ref, false);
- }
- else
- {
- messageRefs.addLast(ref, ref.getPriority());
+ // We are full in memory - go into paging mode
+ if (trace) { log.trace(this + " going into paging mode"); }
- if (trace){ log.trace(this + " added " + ref + " non-transactionally in memory"); }
-
- if (messageRefs.size() == fullSize)
- {
- // We are full in memory - go into paging mode
- if (trace) { log.trace(this + " going into paging mode"); }
-
- paging = true;
- }
+ paging = true;
}
- }
+ }
}
protected void addToDownCache(MessageReference ref, boolean cancelling) throws Exception
@@ -536,7 +509,7 @@
//If cancelling then the ref is supposed to go back on the front of the queue segment in storage
//so we set the page ordering to be firstPageOrdering - 1
- //If not cancelling, then the ref should go on the end of the quueue in storage so
+ //If not cancelling, then the ref should go on the end of the queue in storage so
//we set the page ordering to be nextPageOrdering
if (cancelling)
@@ -569,8 +542,7 @@
if (trace) { log.trace(this + " flushing " + downCache.size() + " refs from downcache"); }
// Non persistent refs won't already be in the db so they need to be inserted
- // Persistent refs in a recoverable state will already be there so need to
- // be updated
+ // Persistent refs in a recoverable state will already be there so need to be updated
List toUpdate = new ArrayList();
@@ -581,7 +553,7 @@
while (iter.hasNext())
{
MessageReference ref = (MessageReference) iter.next();
-
+
if (ref.isReliable() && recoverable)
{
toUpdate.add(ref);
@@ -591,7 +563,7 @@
toAdd.add(ref);
}
}
-
+
if (!toAdd.isEmpty())
{
pm.pageReferences(channelID, toAdd, true);
@@ -617,9 +589,7 @@
if (trace) { log.trace(this + " cleared downcache"); }
}
-
-
-
+
// Private ------------------------------------------------------------------------------
private MessageReference addFromRefInfo(ReferenceInfo info, Map refMap)
@@ -682,9 +652,10 @@
if (messages.size() != msgIdsToLoad.size())
{
// Sanity check
+
throw new IllegalStateException("Did not load correct number of messages, wanted:" +
msgIdsToLoad.size() + " but got:" +
- messages.size());
+ messages.size());
}
// Create references for these messages and add them to the reference map
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/SimpleDelivery.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/SimpleDelivery.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/SimpleDelivery.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -108,7 +108,7 @@
return cancelled;
}
- public synchronized boolean isSelectorAccepted()
+ public boolean isSelectorAccepted()
{
return selectorAccepted;
}
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/local/RoundRobinPointToPointRouter.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/local/RoundRobinPointToPointRouter.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/local/RoundRobinPointToPointRouter.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -87,7 +87,7 @@
// try to release the lock as quickly as possible and make a copy of the receivers array
// to avoid deadlock (http://jira.jboss.org/jira/browse/JBMESSAGING-491)
- //FIXME - we shouldn't be cloning an ArrayList for the delivery of each message
+ //TODO - we shouldn't be cloning an ArrayList for the delivery of each message
//on the primary execution path!
receiversCopy = new ArrayList(receivers.size());
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/message/RoutableSupport.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/message/RoutableSupport.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/message/RoutableSupport.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -178,7 +178,7 @@
public void incrementDeliveryCount()
{
- deliveryCount++;
+ deliveryCount++;
}
public void decrementDeliveryCount()
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/ClusteredPostOfficeService.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/ClusteredPostOfficeService.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/ClusteredPostOfficeService.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -69,8 +69,6 @@
private String groupName;
- private int pullSize = 1;
-
private long statsSendPeriod = 1000;
private String clusterRouterFactory;
@@ -172,16 +170,6 @@
return groupName;
}
- public void setPullSize(int size)
- {
- this.pullSize = size;
- }
-
- public int getPullSize()
- {
- return pullSize;
- }
-
public void setStatsSendPeriod(long period)
{
this.statsSendPeriod = period;
@@ -256,7 +244,6 @@
syncChannelConfig, asyncChannelConfig,
stateTimeout, castTimeout,
pullPolicy, rf,
- pullSize,
statsSendPeriod);
postOffice.start();
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/JDBCPersistenceManager.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/JDBCPersistenceManager.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/JDBCPersistenceManager.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -138,7 +138,10 @@
}
finally
{
- conn.close();
+ if (conn != null)
+ {
+ conn.close();
+ }
}
//We can't remnove unreliable data since it might introduce holes into the paging order
@@ -155,7 +158,7 @@
// PersistenceManager implementation -------------------------
// Related to counters
- // ==================
+ // ===================
public long reserveIDBlock(String counterName, int size) throws Exception
{
@@ -261,103 +264,7 @@
}
// Related to paging functionality
- // ===============================
-
- public void updateReliableReferencesNotPagedInRange(long channelID, long orderStart, long orderEnd, long num) throws Exception
- {
- if (trace) { log.trace("Updating reliable references for channel " + channelID + " between " + orderStart + " and " + orderEnd); }
-
- Connection conn = null;
- PreparedStatement ps = null;
- TransactionWrapper wrap = new TransactionWrapper();
-
- final int MAX_TRIES = 25;
-
- try
- {
- conn = ds.getConnection();
-
- ps = conn.prepareStatement(getSQLStatement("UPDATE_RELIABLE_REFS_NOT_PAGED"));
-
- ps.setLong(1, orderStart);
-
- ps.setLong(2, orderEnd);
-
- ps.setLong(3, channelID);
-
- int tries = 0;
-
- while (true)
- {
- try
- {
- int rows = ps.executeUpdate();
-
- if (trace) { log.trace(JDBCUtil.statementToString(getSQLStatement("UPDATE_RELIABLE_REFS_NOT_PAGED"), new Long(channelID),
- new Long(orderStart), new Long(orderEnd)) + " updated " + rows + " rows"); }
- if (tries > 0)
- {
- log.warn("Update worked after retry");
- }
-
- //Sanity check
- if (rows != num)
- {
- throw new IllegalStateException("Did not update correct number of rows");
- }
-
- break;
- }
- catch (SQLException e)
- {
- log.warn("SQLException caught - assuming deadlock detected, try:" + (tries + 1), e);
-
- tries++;
-
- if (tries == MAX_TRIES)
- {
- log.error("Retried " + tries + " times, now giving up");
-
- throw new IllegalStateException("Failed to update references");
- }
-
- log.warn("Trying again after a pause");
-
- //Now we wait for a random amount of time to minimise risk of deadlock occurring again
- Thread.sleep((long)(Math.random() * 500));
- }
- }
- }
- catch (Exception e)
- {
- wrap.exceptionOccurred();
- throw e;
- }
- finally
- {
- if (ps != null)
- {
- try
- {
- ps.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (conn != null)
- {
- try
- {
- conn.close();
- }
- catch (Throwable e)
- {
- }
- }
- wrap.end();
- }
- }
+ // ===============================
/*
* Retrieve a List of messages corresponding to the specified List of message ids.
@@ -561,7 +468,8 @@
wrap.end();
}
}
-
+
+
public void pageReferences(long channelID, List references, boolean paged) throws Exception
{
Connection conn = null;
@@ -635,7 +543,7 @@
//Maybe we need to persist the message itself
Message m = ref.getMessage();
- //In a paging situation, we cannot use the persisted flag on the messager to determine whether
+ //In a paging situation, we cannot use the persisted flag on the message to determine whether
//to insert the message or not.
//This is because a channel (possibly on another node) may be paging too and referencing
//the same message, and might have removed the message independently, the other
@@ -655,23 +563,22 @@
//this, this is another reason why we cannot use HSQL in a clustered environment
//since it does not have a for update equivalent
+ boolean added;
+
psMessageExists = conn.prepareStatement(getSQLStatement("MESSAGE_EXISTS"));
psMessageExists.setLong(1, m.getMessageID());
rsMessageExists = psMessageExists.executeQuery();
-
- boolean added;
-
+
if (rsMessageExists.next())
{
//Message exists
// Update the message with the new channel count
incrementChannelCount(m, psUpdateMessage);
-
- added = false;
-
+
+ added = false;
}
else
{
@@ -679,7 +586,7 @@
storeMessage(m, psInsertMessage);
added = true;
- }
+ }
if (usingBatchUpdates)
{
@@ -706,9 +613,9 @@
}
}
else
- {
+ {
int rows = psUpdateMessage.executeUpdate();
-
+
if (trace)
{
log.trace("Updated " + rows + " rows");
@@ -816,7 +723,7 @@
PreparedStatement psDeleteMessage = null;
PreparedStatement psUpdateMessage = null;
TransactionWrapper wrap = new TransactionWrapper();
-
+
//We order the references
orderReferences(references);
@@ -870,10 +777,11 @@
Message m = ref.getMessage();
//Maybe we need to delete the message itself
-
+
//Update the message with the new channel count
decrementChannelCount(m, psUpdateMessage);
+
//Run the remove message update
removeMessage(m, psDeleteMessage);
@@ -884,20 +792,21 @@
psDeleteMessage.addBatch();
}
else
- {
+ {
int rows = psUpdateMessage.executeUpdate();
-
+
if (trace) { log.trace("Updated " + rows + " rows"); }
rows = psDeleteMessage.executeUpdate();
-
+
if (trace) { log.trace("Deleted " + rows + " rows"); }
psDeleteMessage.close();
psDeleteMessage = null;
psUpdateMessage.close();
psUpdateMessage = null;
- }
+ }
+
}
if (usingBatchUpdates)
@@ -980,11 +889,197 @@
}
}
}
+
+ public void updateReliableReferencesNotPagedInRange(long channelID, long orderStart, long orderEnd, long num) throws Exception
+ {
+ if (trace) { log.trace("Updating reliable references for channel " + channelID + " between " + orderStart + " and " + orderEnd); }
+ Connection conn = null;
+ PreparedStatement ps = null;
+ TransactionWrapper wrap = new TransactionWrapper();
+
+ final int MAX_TRIES = 25;
+
+ try
+ {
+ conn = ds.getConnection();
+
+ ps = conn.prepareStatement(getSQLStatement("UPDATE_RELIABLE_REFS_NOT_PAGED"));
+
+ ps.setLong(1, orderStart);
+
+ ps.setLong(2, orderEnd);
+
+ ps.setLong(3, channelID);
+
+ int tries = 0;
+
+ while (true)
+ {
+ try
+ {
+ int rows = ps.executeUpdate();
+
+ if (trace) { log.trace(JDBCUtil.statementToString(getSQLStatement("UPDATE_RELIABLE_REFS_NOT_PAGED"), new Long(channelID),
+ new Long(orderStart), new Long(orderEnd)) + " updated " + rows + " rows"); }
+ if (tries > 0)
+ {
+ log.warn("Update worked after retry");
+ }
+
+ //Sanity check
+ if (rows != num)
+ {
+ throw new IllegalStateException("Did not update correct number of rows");
+ }
+
+ break;
+ }
+ catch (SQLException e)
+ {
+ log.warn("SQLException caught - assuming deadlock detected, try:" + (tries + 1), e);
+
+ tries++;
+
+ if (tries == MAX_TRIES)
+ {
+ log.error("Retried " + tries + " times, now giving up");
+
+ throw new IllegalStateException("Failed to update references");
+ }
+
+ log.warn("Trying again after a pause");
+
+ //Now we wait for a random amount of time to minimise risk of deadlock occurring again
+ Thread.sleep((long)(Math.random() * 500));
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ wrap.exceptionOccurred();
+ throw e;
+ }
+ finally
+ {
+ if (ps != null)
+ {
+ try
+ {
+ ps.close();
+ }
+ catch (Throwable e)
+ {
+ }
+ }
+ if (conn != null)
+ {
+ try
+ {
+ conn.close();
+ }
+ catch (Throwable e)
+ {
+ }
+ }
+ wrap.end();
+ }
+ }
+
+ public void updatePageOrder(long channelID, List references) throws Exception
+ {
+ Connection conn = null;
+ PreparedStatement psUpdateReference = null;
+ TransactionWrapper wrap = new TransactionWrapper();
+
+ if (trace) { log.trace("Updating page order for channel:" + channelID); }
+
+ try
+ {
+ conn = ds.getConnection();
+
+ Iterator iter = references.iterator();
+
+ if (usingBatchUpdates)
+ {
+ psUpdateReference = conn.prepareStatement(getSQLStatement("UPDATE_PAGE_ORDER"));
+ }
+
+ while (iter.hasNext())
+ {
+ MessageReference ref = (MessageReference) iter.next();
+
+ if (!usingBatchUpdates)
+ {
+ psUpdateReference = conn.prepareStatement(getSQLStatement("UPDATE_PAGE_ORDER"));
+ }
+
+ psUpdateReference.setLong(1, ref.getPagingOrder());
+
+ psUpdateReference.setLong(2, ref.getMessageID());
+
+ psUpdateReference.setLong(3, channelID);
+
+ if (usingBatchUpdates)
+ {
+ psUpdateReference.addBatch();
+ }
+ else
+ {
+ int rows = psUpdateReference.executeUpdate();
+
+ if (trace) { log.trace("Updated " + rows + " rows"); }
+
+ psUpdateReference.close();
+ psUpdateReference = null;
+ }
+ }
+
+ if (usingBatchUpdates)
+ {
+ int[] rowsReference = psUpdateReference.executeBatch();
+
+ if (trace) { logBatchUpdate(getSQLStatement("UPDATE_PAGE_ORDER"), rowsReference, "updated"); }
+
+ psUpdateReference.close();
+ psUpdateReference = null;
+ }
+ }
+ catch (Exception e)
+ {
+ wrap.exceptionOccurred();
+ throw e;
+ }
+ finally
+ {
+ if (psUpdateReference != null)
+ {
+ try
+ {
+ psUpdateReference.close();
+ }
+ catch (Throwable t)
+ {
+ }
+ }
+ if (conn != null)
+ {
+ try
+ {
+ conn.close();
+ }
+ catch (Throwable t)
+ {
+ }
+ }
+ wrap.end();
+ }
+ }
+
public List getPagedReferenceInfos(long channelID, long orderStart, long number) throws Exception
{
if (trace) { log.trace("loading message reference info for channel " + channelID + " from " + orderStart + " number " + number); }
-
+
List refs = new ArrayList();
Connection conn = null;
@@ -1192,96 +1287,8 @@
}
}
- public void updatePageOrder(long channelID, List references) throws Exception
- {
- Connection conn = null;
- PreparedStatement psUpdateReference = null;
- TransactionWrapper wrap = new TransactionWrapper();
-
- if (trace) { log.trace("Updating page order for channel:" + channelID); }
-
- try
- {
- conn = ds.getConnection();
-
- Iterator iter = references.iterator();
-
- if (usingBatchUpdates)
- {
- psUpdateReference = conn.prepareStatement(getSQLStatement("UPDATE_PAGE_ORDER"));
- }
-
- while (iter.hasNext())
- {
- MessageReference ref = (MessageReference) iter.next();
-
- if (!usingBatchUpdates)
- {
- psUpdateReference = conn.prepareStatement(getSQLStatement("UPDATE_PAGE_ORDER"));
- }
-
- psUpdateReference.setLong(1, ref.getPagingOrder());
-
- psUpdateReference.setLong(2, ref.getMessageID());
-
- psUpdateReference.setLong(3, channelID);
-
- if (usingBatchUpdates)
- {
- psUpdateReference.addBatch();
- }
- else
- {
- int rows = psUpdateReference.executeUpdate();
-
- if (trace) { log.trace("Updated " + rows + " rows"); }
-
- psUpdateReference.close();
- psUpdateReference = null;
- }
- }
-
- if (usingBatchUpdates)
- {
- int[] rowsReference = psUpdateReference.executeBatch();
-
- if (trace) { logBatchUpdate(getSQLStatement("UPDATE_PAGE_ORDER"), rowsReference, "updated"); }
-
- psUpdateReference.close();
- psUpdateReference = null;
- }
- }
- catch (Exception e)
- {
- wrap.exceptionOccurred();
- throw e;
- }
- finally
- {
- if (psUpdateReference != null)
- {
- try
- {
- psUpdateReference.close();
- }
- catch (Throwable t)
- {
- }
- }
- if (conn != null)
- {
- try
- {
- conn.close();
- }
- catch (Throwable t)
- {
- }
- }
- wrap.end();
- }
- }
+
// End of paging functionality
// ===========================
@@ -2925,6 +2932,8 @@
ps.setLong(1, m.getMessageID());
}
+
+
protected void decrementChannelCount(Message m, PreparedStatement ps) throws Exception
{
ps.setLong(1, m.getMessageID());
@@ -2970,7 +2979,7 @@
//Now set the fields from org.joss.jms.message.JBossMessage if appropriate
- //FIXME - We are mixing concerns here
+ //TODO - We are mixing concerns here
//The basic JDBCPersistencManager should *only* know about core messages - not
//JBossMessages - we should subclass JBDCPersistenceManager and the JBossMessage
//specific code in a subclass
Deleted: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/JDBCShutdownLogger.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/JDBCShutdownLogger.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/JDBCShutdownLogger.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -1,273 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.core.plugin;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.sql.DataSource;
-import javax.transaction.TransactionManager;
-
-import org.jboss.logging.Logger;
-import org.jboss.messaging.core.plugin.contract.ShutdownLogger;
-
-/**
- *
- * A JDBCShutdownLogger
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 1.1 $</tt>
- *
- * $Id$
- *
- */
-public class JDBCShutdownLogger extends JDBCSupport implements ShutdownLogger
-{
- private static final Logger log = Logger.getLogger(JDBCShutdownLogger.class);
-
- // Constructors ----------------------------------------------------
-
- public JDBCShutdownLogger(DataSource ds, TransactionManager tm, Properties sqlProperties,
- boolean createTablesOnStartup)
- {
- super(ds, tm, sqlProperties, createTablesOnStartup);
- }
-
- // ShutdownLogger implementation ---------------------------------------------
-
- public boolean shutdown(int nodeId) throws Exception
- {
- boolean exists = existsStartup(nodeId);
-
- if (!exists)
- {
- //This shouldn't really happen
- log.warn("It appears the server did not start up properly!");
- return false;
- }
- else
- {
- removeStartup(nodeId);
-
- return true;
- }
- }
-
- public boolean startup(int nodeId) throws Exception
- {
- boolean crashed = existsStartup(nodeId);
-
- if (crashed)
- {
- //These means the server didn't shutdown cleanly last time -
- //we must assume it crashed
-
- log.warn("It appears the server was not shutdown cleanly last time. We assume that the server crashed");
-
- //Remove the old startup row
- removeStartup(nodeId);
- }
-
- //Insert a new startup row
- insertStartup(nodeId);
-
- return crashed;
- }
-
- private boolean existsStartup(int nodeId) throws Exception
- {
- Connection conn = null;
- PreparedStatement ps = null;
- ResultSet rs = null;
- TransactionWrapper wrap = new TransactionWrapper();
-
- try
- {
- conn = ds.getConnection();
- ps = conn.prepareStatement(getSQLStatement("SELECT_STARTUP"));
- ps.setInt(1, nodeId);
-
- rs = ps.executeQuery();
-
- return rs.next();
-
- }
- catch (Exception e)
- {
- wrap.exceptionOccurred();
- throw e;
- }
- finally
- {
- if (rs != null)
- {
- try
- {
- rs.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (ps != null)
- {
- try
- {
- ps.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (conn != null)
- {
- try
- {
- conn.close();
- }
- catch (Throwable e)
- {
- }
- }
- wrap.end();
- }
- }
-
- private void removeStartup(int nodeId) throws Exception
- {
- Connection conn = null;
- PreparedStatement ps = null;
- TransactionWrapper wrap = new TransactionWrapper();
-
- try
- {
- conn = ds.getConnection();
- ps = conn.prepareStatement(getSQLStatement("DELETE_STARTUP"));
- ps.setInt(1, nodeId);
-
- ps.executeUpdate();
-
- }
- catch (Exception e)
- {
- wrap.exceptionOccurred();
- throw e;
- }
- finally
- {
- if (ps != null)
- {
- try
- {
- ps.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (conn != null)
- {
- try
- {
- conn.close();
- }
- catch (Throwable e)
- {
- }
- }
- wrap.end();
- }
- }
-
- // Private ------------------------------------------------------------
-
- private void insertStartup(int nodeId) throws Exception
- {
- Connection conn = null;
- PreparedStatement ps = null;
- TransactionWrapper wrap = new TransactionWrapper();
-
- try
- {
- conn = ds.getConnection();
- ps = conn.prepareStatement(getSQLStatement("INSERT_STARTUP"));
- ps.setInt(1, nodeId);
-
- ps.executeUpdate();
-
- }
- catch (Exception e)
- {
- wrap.exceptionOccurred();
- throw e;
- }
- finally
- {
- if (ps != null)
- {
- try
- {
- ps.close();
- }
- catch (Throwable e)
- {
- }
- }
- if (conn != null)
- {
- try
- {
- conn.close();
- }
- catch (Throwable e)
- {
- }
- }
- wrap.end();
- }
- }
-
- protected Map getDefaultDDLStatements()
- {
- Map sql = new LinkedHashMap();
-
- sql.put("CREATE_STARTUP", "CREATE TABLE JMS_STARTUP (NODE_ID INTEGER PRIMARY KEY)");
-
- return sql;
- }
-
- protected Map getDefaultDMLStatements()
- {
- Map sql = new LinkedHashMap();
-
- sql.put("SELECT_STARTUP", "SELECT NODE_ID FROM JMS_STARTUP WHERE NODE_ID = ?");
- sql.put("DELETE_STARTUP", "DELETE FROM JMS_STARTUP WHERE NODE_ID = ?");
- sql.put("INSERT_STARTUP", "INSERT INTO JMS_STARTUP (NODE_ID) VALUES (?)");
-
- return sql;
- }
-
-}
Deleted: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/JDBCShutdownLoggerService.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/JDBCShutdownLoggerService.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/JDBCShutdownLoggerService.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -1,101 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.core.plugin;
-
-import javax.transaction.TransactionManager;
-
-import org.jboss.jms.util.ExceptionUtil;
-import org.jboss.messaging.core.plugin.contract.MessagingComponent;
-import org.jboss.messaging.core.plugin.contract.ShutdownLogger;
-
-/**
- * A JDBCShutdownLoggerService
- *
- * MBean wrapper around a ShutDownLogger
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 1.1 $</tt>
- *
- * $Id$
- *
- */
-public class JDBCShutdownLoggerService extends JDBCServiceSupport
-{
- private ShutdownLogger shutdownLogger;
-
- private boolean started;
-
- // Constructors ---------------------------------------------------------
-
- public JDBCShutdownLoggerService()
- {
- }
-
- // ServerPlugin implementation ------------------------------------------
-
- public MessagingComponent getInstance()
- {
- return shutdownLogger;
- }
-
- // ServiceMBeanSupport overrides ---------------------------------
-
- protected synchronized void startService() throws Exception
- {
- if (started)
- {
- throw new IllegalStateException("Service is already started");
- }
-
- super.startService();
-
- try
- {
- TransactionManager tm = getTransactionManagerReference();
-
- shutdownLogger = new JDBCShutdownLogger(ds, tm, sqlProperties, createTablesOnStartup);
-
- shutdownLogger.start();
-
- started = true;
- }
- catch (Throwable t)
- {
- throw ExceptionUtil.handleJMXInvocation(t, this + " startService");
- }
- }
-
- protected void stopService() throws Exception
- {
- if (!started)
- {
- throw new IllegalStateException("Service is not started");
- }
-
- shutdownLogger.stop();
- shutdownLogger = null;
-
- started = false;
-
- log.debug(this + " stopped");
- }
-}
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/LockMap.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/LockMap.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/LockMap.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -49,7 +49,7 @@
int refCount;
}
- public static LockMap instance = new LockMap();
+ public static final LockMap instance = new LockMap();
private LockMap()
{
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/contract/ClusteredPostOffice.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/contract/ClusteredPostOffice.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/contract/ClusteredPostOffice.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -21,6 +21,8 @@
*/
package org.jboss.messaging.core.plugin.contract;
+import java.util.Collection;
+
import org.jboss.messaging.core.plugin.postoffice.Binding;
import org.jboss.messaging.core.plugin.postoffice.cluster.LocalClusteredQueue;
@@ -52,5 +54,7 @@
* @return
* @throws Throwable
*/
- Binding unbindClusteredQueue(String queueName) throws Throwable;
+ Binding unbindClusteredQueue(String queueName) throws Throwable;
+
+ Collection listAllBindingsForCondition(String condition) throws Exception;
}
Deleted: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/contract/ShutdownLogger.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/contract/ShutdownLogger.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/contract/ShutdownLogger.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.core.plugin.contract;
-
-/**
- * A ShutdownLogger
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 1.1 $</tt>
- *
- * $Id$
- *
- */
-public interface ShutdownLogger extends MessagingComponent
-{
- boolean startup(int nodeId) throws Exception;
-
- boolean shutdown(int nodeId) throws Exception;
-}
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/DefaultPostOffice.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/DefaultPostOffice.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/DefaultPostOffice.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -25,10 +25,12 @@
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Types;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -211,7 +213,7 @@
}
lock.writeLock().acquire();
-
+
try
{
Binding binding = removeBinding(this.nodeId, queueName);
@@ -235,32 +237,12 @@
public Collection listBindingsForCondition(String condition) throws Exception
{
- if (condition == null)
- {
- throw new IllegalArgumentException("Condition is null");
- }
-
- lock.readLock().acquire();
-
- try
- {
- Bindings cb = (Bindings)conditionMap.get(condition);
-
- if (cb == null)
- {
- return Collections.EMPTY_LIST;
- }
- else
- {
- return cb.getAllBindings();
- }
- }
- finally
- {
- lock.readLock().release();
- }
- }
+ return listBindingsForConditionInternal(condition, true);
+ }
+
+
+
public Binding getBindingForQueueName(String queueName) throws Exception
{
if (queueName == null)
@@ -269,7 +251,7 @@
}
lock.readLock().acquire();
-
+
try
{
Map nameMap = (Map)nameMaps.get(new Integer(this.nodeId));
@@ -382,11 +364,57 @@
}
// Protected -----------------------------------------------------
+
+ protected Collection listBindingsForConditionInternal(String condition, boolean localOnly) throws Exception
+ {
+ if (condition == null)
+ {
+ throw new IllegalArgumentException("Condition is null");
+ }
+
+ lock.readLock().acquire();
+
+ try
+ {
+ //We should only list the bindings for the local node
+
+ Bindings cb = (Bindings)conditionMap.get(condition);
+
+ if (cb == null)
+ {
+ return Collections.EMPTY_LIST;
+ }
+ else
+ {
+ List list = new ArrayList();
+
+ Collection bindings = cb.getAllBindings();
+
+ Iterator iter = bindings.iterator();
+
+ while (iter.hasNext())
+ {
+ Binding binding = (Binding)iter.next();
+
+ if (!localOnly || (binding.getNodeId() == this.nodeId))
+ {
+ list.add(binding);
+ }
+ }
+
+ return list;
+ }
+ }
+ finally
+ {
+ lock.readLock().release();
+ }
+ }
protected void loadBindings() throws Exception
{
lock.writeLock().acquire();
-
+
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
@@ -428,7 +456,7 @@
finally
{
lock.writeLock().release();
-
+
if (rs != null)
{
rs.close();
@@ -573,7 +601,7 @@
nameMaps.put(new Integer(binding.getNodeId()), nameMap);
}
- nameMap.put(binding.getQueue().getName(), binding);
+ nameMap.put(binding.getQueue().getName(), binding);
}
protected void addToConditionMap(Binding binding)
@@ -647,7 +675,7 @@
conditionMap.remove(binding.getCondition());
}
}
-
+
protected Map getDefaultDMLStatements()
{
Map map = new LinkedHashMap();
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/CastMessagesCallback.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/CastMessagesCallback.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/CastMessagesCallback.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -27,6 +27,7 @@
import org.jboss.logging.Logger;
import org.jboss.messaging.core.Message;
+import org.jboss.messaging.core.tx.TransactionException;
import org.jboss.messaging.core.tx.TxCallback;
/**
@@ -52,6 +53,35 @@
* CastMessagesCallback.beforeCommit() - cast message(s) to holding areas
* JDBCPersistenceManager.TransactionCallback.beforeCommit() - persist message(s) in database
* CastMessagesCallback.afterCommit() - send "commit" message to holding areas
+ *
+ * Failure handling:
+ *
+ * If failure of the remote node occurs after casting the message to the holding area
+ * but before the message is persisted locally, then no recovery is necessary since the message wasn't persisted.
+ * In this case an exception should be propagated to the client.
+ *
+ * If failure of the remote node occurs after casting the message to the holding area
+ * and after the message has been persisted locally then, when the failover node takes
+ * over it will load the message from the db.
+ *
+ * If failure of the local node occurs before casting the message, no recovery is necessary and an exception
+ * should be thrown to the client.
+ *
+ * If failure of the local node occurs after casting the message, but before persisting the message.
+ * Then failure of the local node casues the remote node to check it's holding area - it will then check
+ * if the message has been persisted - in this case it has not so it will discard the tx from the holding area.
+ * (TODO is it possible that the cast of the original hold arrives *after* the receiving node knows the sending
+ * node has failed - we must be able to guarantee this never happens)
+ *
+ * If failure of the local node occurs after casting the message and after persisting the message in the database.
+ * Then failure of the local node casues the remote node to check it's holding area - it will then check
+ * if the message has been persisted - in this case it has so it will excute the transaction in memory which will add the
+ * message to the in memory queue.
+ *
+ *
+ *
+ *
+ *
*
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
* @version <tt>$Revision: 1.1 $</tt>
@@ -78,6 +108,10 @@
private boolean multicast;
private int toNodeId;
+
+ //Used in failure testing
+ private boolean failBeforeCommit;
+ private boolean failAfterCommit;
/*
* We store the id of one of the channels that the ref was inserted into
@@ -129,13 +163,17 @@
}
}
- CastMessagesCallback(int nodeId, long txId, PostOfficeInternal office)
+ CastMessagesCallback(int nodeId, long txId, PostOfficeInternal office, boolean failBeforeCommit, boolean failAfterCommit)
{
this.nodeId = nodeId;
this.txId = txId;
this.office = office;
+
+ this.failBeforeCommit = failBeforeCommit;
+
+ this.failAfterCommit = failAfterCommit;
}
public void afterCommit(boolean onePhase) throws Exception
@@ -150,6 +188,12 @@
if (persistent != null)
{
+ //Only used in testing
+ if (failAfterCommit)
+ {
+ throw new TransactionException("Forced failure for testing");
+ }
+
// Cast a commit message
ClusterRequest req = new SendTransactionRequest(nodeId, txId);
@@ -177,6 +221,12 @@
sendRequest(req);
}
+
+ //Only used in testing
+ if (failBeforeCommit)
+ {
+ throw new TransactionException("Forced failure for testing");
+ }
}
public void beforePrepare() throws Exception
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusterRequest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusterRequest.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusterRequest.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -54,6 +54,11 @@
request = new BindRequest();
break;
}
+ case PullMessageResultRequest.TYPE:
+ {
+ request = new PullMessageResultRequest();
+ break;
+ }
case MessageRequest.TYPE:
{
request = new MessageRequest();
@@ -89,6 +94,11 @@
request = new UnbindRequest();
break;
}
+ case RollbackPullRequest.TYPE:
+ {
+ request = new RollbackPullRequest();
+ break;
+ }
default:
{
throw new IllegalArgumentException("Invalid type: " + type);
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusterRouter.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusterRouter.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusterRouter.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -38,5 +38,5 @@
{
List getQueues();
- LocalClusteredQueue getLocalQueue();
+ ClusteredQueue getLocalQueue();
}
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOffice.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOffice.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOffice.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -81,6 +81,11 @@
{
private static final Logger log = Logger.getLogger(DefaultClusteredPostOffice.class);
+ //Used for failure testing
+ private boolean failBeforeCommit;
+ private boolean failAfterCommit;
+ private boolean failHandleResult;
+
private boolean trace = log.isTraceEnabled();
private Channel syncChannel;
@@ -126,8 +131,6 @@
private ClusterRouterFactory routerFactory;
- private int pullSize;
-
private Map routerMap;
private StatsSender statsSender;
@@ -162,12 +165,11 @@
long stateTimeout, long castTimeout,
MessagePullPolicy redistributionPolicy,
ClusterRouterFactory rf,
- int pullSize,
long statsSendPeriod) throws Exception
{
this(ds, tm, sqlProperties, createTablesOnStartup, nodeId, officeName, ms,
pm, tr, filterFactory, pool, groupName, stateTimeout, castTimeout, redistributionPolicy,
- rf, pullSize, statsSendPeriod);
+ rf, statsSendPeriod);
this.syncChannelConfigE = syncChannelConfig;
this.asyncChannelConfigE = asyncChannelConfig;
@@ -189,12 +191,11 @@
long stateTimeout, long castTimeout,
MessagePullPolicy redistributionPolicy,
ClusterRouterFactory rf,
- int pullSize,
long statsSendPeriod) throws Exception
{
this(ds, tm, sqlProperties, createTablesOnStartup, nodeId, officeName, ms,
pm, tr, filterFactory, pool, groupName, stateTimeout, castTimeout, redistributionPolicy,
- rf, pullSize, statsSendPeriod);
+ rf, statsSendPeriod);
this.syncChannelConfigS = syncChannelConfig;
this.asyncChannelConfigS = asyncChannelConfig;
@@ -211,7 +212,6 @@
long stateTimeout, long castTimeout,
MessagePullPolicy redistributionPolicy,
ClusterRouterFactory rf,
- int pullSize,
long statsSendPeriod)
{
super (ds, tm, sqlProperties, createTablesOnStartup, nodeId, officeName, ms, pm, tr, filterFactory,
@@ -229,8 +229,6 @@
this.routerFactory = rf;
- this.pullSize = pullSize;
-
routerMap = new HashMap();
statsSender = new StatsSender(this, statsSendPeriod);
@@ -243,6 +241,11 @@
public synchronized void start() throws Exception
{
+ if (started)
+ {
+ log.warn("Attempt to start() but " + this + " is already started");
+ }
+
if (syncChannelConfigE != null)
{
this.syncChannel = new JChannel(syncChannelConfigE);
@@ -297,6 +300,11 @@
public synchronized void stop() throws Exception
{
+ if (!started)
+ {
+ log.warn("Attempt to stop() but " + this + " is not started");
+ }
+
super.stop();
statsSender.stop();
@@ -318,7 +326,7 @@
{
log.trace(this.nodeId + " binding clustered queue: " + queue + " with condition: " + condition);
}
-
+
if (queue.getNodeId() != this.nodeId)
{
throw new IllegalArgumentException("Queue node id does not match office node id");
@@ -341,7 +349,7 @@
{
log.trace(this.nodeId + " unbind clustered queue: " + queueName);
}
-
+
Binding binding = (Binding)super.unbindQueue(queueName);
UnbindRequest request = new UnbindRequest(nodeId, queueName);
@@ -371,7 +379,7 @@
boolean routed = false;
lock.readLock().acquire();
-
+
try
{
ClusteredBindings cb = (ClusteredBindings)conditionMap.get(condition);
@@ -471,15 +479,14 @@
if (numberRemote == 1)
{
if (trace) { log.trace(this.nodeId + " unicasting message to " + lastNodeId); }
- //Unicast - only one node is interested in the message
-
+
+ //Unicast - only one node is interested in the message
asyncSendRequest(new MessageRequest(condition, ref.getMessage(), null), lastNodeId);
-
- //syncSendRequest(new MessageRequest(condition, ref.getMessage(), null), lastNodeId, false);
}
else
{
if (trace) { log.trace(this.nodeId + " multicasting message to group"); }
+
//Multicast - more than one node is interested
asyncSendRequest(new MessageRequest(condition, ref.getMessage(), queueNameNodeIdMap));
}
@@ -490,7 +497,7 @@
if (callback == null)
{
- callback = new CastMessagesCallback(nodeId, tx.getId(), DefaultClusteredPostOffice.this);
+ callback = new CastMessagesCallback(nodeId, tx.getId(), DefaultClusteredPostOffice.this, failBeforeCommit, failAfterCommit);
//This callback MUST be executed first
@@ -530,6 +537,11 @@
return false;
}
+ public Collection listAllBindingsForCondition(String condition) throws Exception
+ {
+ return listBindingsForConditionInternal(condition, false);
+ }
+
// PostOfficeInternal implementation ------------------------------------------------------------------
/*
@@ -540,7 +552,7 @@
throws Exception
{
lock.writeLock().acquire();
-
+
if (trace)
{
log.trace(this.nodeId + " adding binding from node: " + nodeId + " queue: " + queueName + " with condition: " + condition);
@@ -611,7 +623,7 @@
public void handleAddressNodeMapping(NodeAddressInfo info, int nodeId) throws Exception
{
lock.writeLock().acquire();
-
+
if (trace)
{
log.trace(this.nodeId + " Adding address node mapping for " + info.getSyncChannelAddress() +
@@ -638,7 +650,7 @@
}
lock.readLock().acquire();
-
+
// Need to reference the message
MessageReference ref = null;
try
@@ -744,40 +756,6 @@
}
/*
- * Unicast a sync request
- */
- public Object syncSendRequest(ClusterRequest request, int nodeId, boolean ignoreNoAddress) throws Exception
- {
- if (trace) { log.trace(this.nodeId + " sending synch request to single node, request: " + request + " node " + nodeId); }
-
- Address address = this.getAddressForNodeId(nodeId, true);
-
- if (trace) { log.trace(this.nodeId + " sending to address " + address); }
-
- if (address == null)
- {
- if (ignoreNoAddress)
- {
- return null;
- }
- else
- {
- throw new IllegalArgumentException("Cannot find address for node " + nodeId);
- }
- }
-
- byte[] bytes = writeRequest(request);
-
- Message message = new Message(address, null, bytes);
-
- Object result = controlMessageDispatcher.sendMessage(message, GroupRequest.GET_FIRST, castTimeout);
-
- if (trace) { log.trace(this.nodeId + " received response: " + result); }
-
- return result;
- }
-
- /*
* We put the transaction in the holding area
*/
public void holdTransaction(TransactionId id, ClusterTransaction tx) throws Exception
@@ -795,10 +773,10 @@
if (trace) { log.trace(this.nodeId + " committing transaction " + id ); }
ClusterTransaction tx = null;
-
+
synchronized (holdingArea)
{
- tx = (ClusterTransaction)holdingArea.remove(id);
+ tx = (ClusterTransaction)holdingArea.remove(id);
}
if (tx == null)
@@ -811,6 +789,27 @@
if (trace) { log.trace(this.nodeId + " committed transaction " + id ); }
}
+ public void rollbackTransaction(TransactionId id) throws Throwable
+ {
+ if (trace) { log.trace(this.nodeId + " rolling back transaction " + id ); }
+
+ ClusterTransaction tx = null;
+
+ synchronized (holdingArea)
+ {
+ tx = (ClusterTransaction)holdingArea.remove(id);
+ }
+
+ if (tx == null)
+ {
+ throw new IllegalStateException("Cannot find transaction transaction id: " + id);
+ }
+
+ tx.rollback(this);
+
+ if (trace) { log.trace(this.nodeId + " committed transaction " + id ); }
+ }
+
/**
* Check for any transactions that need to be committed or rolled back
*/
@@ -832,10 +831,10 @@
if (id.getNodeId() == nodeId.intValue())
{
- ClusterTransaction tx = (ClusterTransaction)iter.next();
+ ClusterTransaction tx = (ClusterTransaction)entry.getValue();
if (trace) { log.trace("Found transaction " + tx + " in holding area"); }
-
+
boolean commit = tx.check(this);
if (trace) { log.trace(this.nodeId + " transaction " + tx + " will be committed?: " + commit); }
@@ -849,7 +848,7 @@
tx.rollback(this);
}
- toRemove.add(tx);
+ toRemove.add(id);
if (trace) { log.trace(this.nodeId + " resolved " + tx); }
}
@@ -869,7 +868,7 @@
if (trace) { log.trace(this.nodeId + " check complete"); }
}
- public synchronized void sendQueueStats() throws Exception
+ public void sendQueueStats() throws Exception
{
if (!started)
{
@@ -877,7 +876,7 @@
}
lock.readLock().acquire();
-
+
List statsList = null;
try
@@ -897,10 +896,8 @@
if (q.isActive())
{
QueueStats stats = q.getStats();
-
- //We don't bother sending the stats if there's no significant change in the values
-
- if (q.changedSignificantly())
+
+ if (stats != null)
{
if (statsList == null)
{
@@ -933,7 +930,7 @@
public void updateQueueStats(int nodeId, List statsList) throws Exception
{
lock.readLock().acquire();
-
+
if (trace) { log.trace(this.nodeId + " updating queue stats from node " + nodeId + " stats size: " + statsList.size()); }
try
@@ -978,21 +975,24 @@
//Maybe the local queue now wants to pull message(s) from the remote queue given that the
//stats for the remote queue have changed
- LocalClusteredQueue localQueue = router.getLocalQueue();
+ LocalClusteredQueue localQueue = (LocalClusteredQueue)router.getLocalQueue();
if (localQueue != null)
{
+ //TODO - the call to getQueues is too slow since it creates a new list and adds the local queue!!!
RemoteQueueStub toQueue = (RemoteQueueStub)messagePullPolicy.chooseQueue(router.getQueues());
if (trace) { log.trace(this.nodeId + " recalculated pull queue for queue " + st.getQueueName() + " to be " + toQueue); }
+
+ localQueue.setPullQueue(toQueue);
- if (toQueue != null)
+ if (toQueue != null && localQueue.getRefCount() == 0)
{
- localQueue.setPullInfo(toQueue, pullSize);
+ //We now trigger delivery - this may cause a pull event
+ //We only do this if there are no refs in the local queue
- //We now trigger delivery - this may cause a pull event
localQueue.deliver(false);
-
+
if (trace) { log.trace(this.nodeId + " triggered delivery for " + localQueue.getName()); }
}
}
@@ -1010,31 +1010,87 @@
{
return pm.referenceExists(channelID, messageID);
}
+
- public List getDeliveries(String queueName, int numMessages) throws Exception
+ public void handleMessagePullResult(int remoteNodeId, long holdingTxId,
+ String queueName, org.jboss.messaging.core.Message message) throws Throwable
{
- if (trace) { log.trace(this.nodeId + " getting max " + numMessages + " deliveries for " + queueName); }
-
+ if (trace) { log.trace(this.nodeId + " handling pull result " + message + " for " + queueName); }
+
Binding binding = getBindingForQueueName(queueName);
- if (binding == null)
- {
- throw new IllegalArgumentException("Cannot find binding for queue " + queueName);
- }
+ //The binding might be null if the queue was unbound
- LocalClusteredQueue queue = (LocalClusteredQueue)binding.getQueue();
+ boolean handled = false;
- List dels = queue.getDeliveries(numMessages);
+ if (!failHandleResult && binding != null)
+ {
+ LocalClusteredQueue localQueue = (LocalClusteredQueue)binding.getQueue();
+
+ RemoteQueueStub remoteQueue = localQueue.getPullQueue();
+
+ if (remoteNodeId != remoteQueue.getNodeId())
+ {
+ //It might have changed since the request was sent
+ Map bindings = (Map)nameMaps.get(new Integer(remoteNodeId));
+
+ if (bindings != null)
+ {
+ binding = (Binding)bindings.get(queueName);
+
+ if (binding != null)
+ {
+ remoteQueue = (RemoteQueueStub)binding.getQueue();
+ }
+ }
+ }
+
+ if (remoteQueue != null)
+ {
+ localQueue.handlePullMessagesResult(remoteQueue, message, holdingTxId,
+ failBeforeCommit, failAfterCommit);
+
+ handled = true;
+ }
+ }
- if (trace) { log.trace(this.nodeId + " retrieved " + dels.size() + " deliveries from " + queueName); }
-
- return dels;
+ if (!handled)
+ {
+ //If we didn't handle it for what ever reason, then we might have to send a rollback
+ //message to the other node otherwise the transaction might end up in the holding
+ //area for ever
+ if (message.isReliable())
+ {
+ //Only reliable messages will be in holding area
+ this.asyncSendRequest(new RollbackPullRequest(this.nodeId, holdingTxId), remoteNodeId);
+
+ if (trace) { log.trace(this.nodeId + " send rollback pull request"); }
+ }
+ }
}
-
+ public int getNodeId()
+ {
+ return nodeId;
+ }
+
// Public ------------------------------------------------------------------------------------------
+ //Used for testing only
+ public void setFail(boolean beforeCommit, boolean afterCommit, boolean handleResult)
+ {
+ this.failBeforeCommit = beforeCommit;
+ this.failAfterCommit = afterCommit;
+ this.failHandleResult = handleResult;
+ }
+
+ //Used for testing only
+ public Collection getHoldingTransactions()
+ {
+ return holdingArea.values();
+ }
+
// Protected ---------------------------------------------------------------------------------------
protected void addToConditionMap(Binding binding)
@@ -1065,7 +1121,7 @@
bindings.addRouter(queueName, router);
}
- router.add(binding.getQueue());
+ router.add(binding.getQueue());
}
protected void removeFromConditionMap(Binding binding)
@@ -1115,7 +1171,6 @@
{
if (trace) { log.trace(this.nodeId + " loading bindings"); }
- // TODO I need to know whether this call times out - how do I know this??
boolean isState = syncChannel.getState(null, stateTimeout);
if (!isState)
@@ -1217,7 +1272,7 @@
private void removeBindingsForAddress(Integer nodeId) throws Exception
{
lock.writeLock().acquire();
-
+
try
{
Map nameMap = (Map)nameMaps.get(nodeId);
@@ -1363,9 +1418,9 @@
}
private Address getAddressForNodeId(int nodeId, boolean sync) throws Exception
- {
+ {
lock.readLock().acquire();
-
+
try
{
NodeAddressInfo info = (NodeAddressInfo)nodeIdAddressesMap.get(new Integer(nodeId));
@@ -1431,7 +1486,7 @@
}
public void setState(byte[] bytes)
- {
+ {
if (bytes != null)
{
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultMessagePullPolicy.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultMessagePullPolicy.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultMessagePullPolicy.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -49,13 +49,13 @@
ClusteredQueue chosenQueue = null;
int maxMessages = 0;
-
+
while (iter.hasNext())
{
ClusteredQueue queue = (ClusteredQueue)iter.next();
if (!queue.isLocal())
- {
+ {
QueueStats stats = queue.getStats();
if (stats != null)
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultRouter.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultRouter.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultRouter.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -38,19 +38,8 @@
*
* This router always favours the local queue.
*
- * If there is no local queue it will round robin between the others.
+ * If there is no local queue, then it will round robin between the non local queues.
*
- * In the case of a distributed point to point queue deployed at each node in the cluster
- * there will always be a local queue.
- *
- * In this case, with the assumption that producers and consumers are distributed evenly across the cluster
- * then sending the message to the local queue is the most efficient policy.
- *
- * In the case of a durable subscription, there may well be no local queue since the durable subscription lives
- * only on the number of nodes that it is looked up at.
- *
- * In this case the round robin routing will kick in
- *
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
* @version <tt>$Revision: 1.1 $</tt>
*
@@ -64,23 +53,23 @@
private boolean trace = log.isTraceEnabled();
//MUST be an arraylist for fast index access
- private ArrayList queues;
+ private ArrayList nonLocalQueues;
- private LocalClusteredQueue localQueue;
+ private ClusteredQueue localQueue;
private int target;
public DefaultRouter()
{
- queues = new ArrayList();
+ nonLocalQueues = new ArrayList();
}
public int size()
{
- return queues.size();
+ return nonLocalQueues.size() + (localQueue == null ? 0 : 1);
}
- public LocalClusteredQueue getLocalQueue()
+ public ClusteredQueue getLocalQueue()
{
return localQueue;
}
@@ -95,19 +84,19 @@
{
throw new IllegalStateException("Already has local queue");
}
- localQueue = (LocalClusteredQueue)queue;
+ localQueue = queue;
}
+ else
+ {
+ nonLocalQueues.add(queue);
+ }
- queues.add(queue);
-
- target = 0;
-
return true;
}
public void clear()
{
- queues.clear();
+ nonLocalQueues.clear();
localQueue = null;
@@ -116,31 +105,46 @@
public boolean contains(Receiver queue)
{
- return queues.contains(queue);
+ return localQueue == queue || nonLocalQueues.contains(queue);
}
public Iterator iterator()
{
+ List queues = new ArrayList();
+
+ if (localQueue != null)
+ {
+ queues.add(localQueue);
+ }
+
+ queues.addAll(nonLocalQueues);
+
return queues.iterator();
}
public boolean remove(Receiver queue)
{
- if (queues.remove(queue))
+ if (localQueue == queue)
{
- if (localQueue == queue)
- {
- localQueue = null;
- }
+ localQueue = null;
- target = 0;
-
return true;
}
else
{
- return false;
- }
+ if (nonLocalQueues.remove(queue))
+ {
+ if (target >= nonLocalQueues.size() - 1)
+ {
+ target = nonLocalQueues.size() - 1;
+ }
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
}
public Delivery handle(DeliveryObserver observer, MessageReference reference, Transaction tx)
@@ -148,7 +152,7 @@
if (trace) { log.trace(this + " routing ref " + reference); }
//Favour the local queue
-
+
if (localQueue != null)
{
//The only time the local queue won't accept is if the selector doesn't
@@ -163,24 +167,21 @@
}
else
{
- //There is no local shared queue
+ //There is no local shared queue
+ //We round robin among the rest
- //We round robin among the rest
- if (!queues.isEmpty())
+ if (!nonLocalQueues.isEmpty())
{
- ClusteredQueue queue = (ClusteredQueue)queues.get(target);
+ ClusteredQueue queue = (ClusteredQueue)nonLocalQueues.get(target);
+ queue = (ClusteredQueue)nonLocalQueues.get(target);
+
Delivery del = queue.handle(observer, reference, tx);
-
+
if (trace) { log.trace(this + " routed to remote queue, it returned " + del); }
- target++;
-
- if (target == queues.size())
- {
- target = 0;
- }
-
+ incTarget();
+
//Again, if the selector doesn't match then it won't on any others so no point trying them
return del;
}
@@ -191,13 +192,34 @@
return null;
}
+ private void incTarget()
+ {
+ target++;
+
+ if (target == nonLocalQueues.size())
+ {
+ target = 0;
+ }
+ }
+
public List getQueues()
{
+ List queues = new ArrayList();
+
+ if (localQueue != null)
+ {
+ queues.add(localQueue);
+ }
+
+ queues.addAll(nonLocalQueues);
+
return queues;
}
public int numberOfReceivers()
{
- return queues.size();
+ return nonLocalQueues.size() + (localQueue != null ? 1 : 0);
}
}
+
+
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/LocalClusteredQueue.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/LocalClusteredQueue.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/LocalClusteredQueue.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -29,6 +29,7 @@
import org.jboss.logging.Logger;
import org.jboss.messaging.core.Delivery;
import org.jboss.messaging.core.Filter;
+import org.jboss.messaging.core.Message;
import org.jboss.messaging.core.MessageReference;
import org.jboss.messaging.core.SimpleDelivery;
import org.jboss.messaging.core.local.PagingFilteredQueue;
@@ -38,7 +39,6 @@
import org.jboss.messaging.core.tx.Transaction;
import org.jboss.messaging.core.tx.TransactionRepository;
import org.jboss.messaging.util.Future;
-import org.jboss.messaging.util.StreamUtils;
import EDU.oswego.cs.dl.util.concurrent.QueuedExecutor;
@@ -62,19 +62,12 @@
private volatile int lastCount;
- private volatile boolean changedSignificantly;
+ private volatile RemoteQueueStub pullQueue;
- private RemoteQueueStub pullQueue;
-
private int nodeId;
- //TODO Make configurable
- private int pullSize;
-
private TransactionRepository tr;
- private Object pullLock = new Object();
-
//TODO - we shouldn't have to specify office AND nodeId
public LocalClusteredQueue(PostOffice office, int nodeId, String name, long id, MessageStore ms, PersistenceManager pm,
boolean acceptReliableMessages, boolean recoverable, QueuedExecutor executor,
@@ -87,7 +80,7 @@
this.tr = tr;
- //FIXME - this cast is a hack
+ //TODO - This cast is potentially unsafe - handle better
this.office = (PostOfficeInternal)office;
}
@@ -101,44 +94,44 @@
this.tr = tr;
- //FIXME - this cast is a hack
+ //TODO - This cast is potentially unsafe - handle better
this.office = (PostOfficeInternal)office;
}
- public void setPullInfo(RemoteQueueStub queue, int pullSize)
+ public void setPullQueue(RemoteQueueStub queue)
{
- synchronized (pullLock)
- {
- this.pullQueue = queue;
-
- this.pullSize = pullSize;
- }
+ this.pullQueue = queue;
}
+ public RemoteQueueStub getPullQueue()
+ {
+ return pullQueue;
+ }
+
public QueueStats getStats()
{
- int cnt = messageCount();
+ //Currently we only return the current message reference count for the channel
+ //Note we are only interested in the number of refs in the main queue, not
+ //in any deliveries
+ //Also we are only interested in the value obtained after delivery is complete.
+ //This is so we don't end up with transient values since delivery is half way through
+ int cnt = getRefCount();
+
if (cnt != lastCount)
{
- changedSignificantly = true;
+ lastCount = cnt;
- lastCount = cnt;
+ //We only return stats if it has changed since last time - this is so when we only
+ //broadcast data when necessary
+ return new QueueStats(name, cnt);
}
else
{
- changedSignificantly = false;
- }
-
- return new QueueStats(name, cnt);
+ return null;
+ }
}
-
- //Have the stats changed significantly since the last time we request them?
- public boolean changedSignificantly()
- {
- return changedSignificantly;
- }
-
+
public boolean isLocal()
{
return true;
@@ -148,45 +141,6 @@
{
return nodeId;
}
-
- /*
- * Used when pulling messages from a remote queue
- */
- public List getDeliveries(int number) throws Exception
- {
- List dels = new ArrayList();
-
- synchronized (refLock)
- {
- synchronized (deliveryLock)
- {
- //We only get the refs if receiversReady = false so as not to steal messages that
- //might be consumed by local receivers
- if (!receiversReady)
- {
- int count = 0;
-
- MessageReference ref;
-
- while (count < number && (ref = removeFirstInMemory()) != null)
- {
- SimpleDelivery del = new SimpleDelivery(this, ref);
-
- deliveries.add(del);
-
- dels.add(del);
-
- count++;
- }
- return dels;
- }
- else
- {
- return Collections.EMPTY_LIST;
- }
- }
- }
- }
/*
* This is the same as the normal handle() method on the Channel except it doesn't
@@ -225,173 +179,354 @@
acknowledgeInternal(d, null, false, false);
}
- protected void deliverInternal(boolean handle) throws Throwable
- {
- int beforeSize = -1;
+ public void handlePullMessagesResult(RemoteQueueStub remoteQueue, Message message,
+ long holdingTxId, boolean failBeforeCommit, boolean failAfterCommit) throws Exception
+ {
+ //This needs to be run on a different thread to the one used by JGroups to deliver the message
+ //to avoid deadlock
+ Runnable runnable = new MessagePullResultRunnable(remoteQueue, message, holdingTxId,
+ failBeforeCommit, failAfterCommit);
- if (!handle)
+ executor.execute(runnable);
+ }
+
+ //TODO it's not ideal that we need to pass in a PullMessagesRequest
+ public void handleGetDeliveriesRequest(int returnNodeId, int number, TransactionId txId, PullMessagesRequest tx) throws Exception
+ {
+ //This needs to be run on a different thread to the one used by JGroups to deliver the message
+ //to avoid deadlock
+ Runnable runnable = new MessagePullRequestRunnable(returnNodeId, number, txId, tx);
+
+ executor.execute(runnable);
+ }
+
+ public boolean isClustered()
+ {
+ return true;
+ }
+
+ public int getRefCount()
+ {
+ //We are only interested in getting the reference count when delivery is not in progress
+ //since we don't want mid delivery transient spurious values, so we execute the request
+ //on the same thread.
+
+ Future result = new Future();
+
+ try
{
- beforeSize = messageRefs.size();
- }
+ this.executor.execute(new GetRefCountRunnable(result));
+ }
+ catch (InterruptedException e)
+ {
+ log.warn("Thread interrupted", e);
+ }
+
+ return ((Integer)result.getResult()).intValue();
+ }
+
+ protected void deliverInternal() throws Throwable
+ {
+ super.deliverInternal();
+
+ //If the receivers are still ready to accept more refs then we might pull messages
+ //from a remote queue
+ if (receiversReady && pullQueue != null)
+ {
+ //We send a message to the remote queue to pull a message - the remote queue will then send back
+ //another message asynchronously with the result.
+ //We don't do this synchronously with a message dispatcher since that can lead to distributed
+ //deadlock
+
+ sendPullMessage();
+ }
+ }
+
+ private void sendPullMessage() throws Exception
+ {
+ if (pullQueue == null)
+ {
+ //Nothing to do
+ return;
+ }
- super.deliverInternal(handle);
+ //Avoid synchronization
+ RemoteQueueStub theQueue = pullQueue;
+
+ if (theQueue == null)
+ {
+ return;
+ }
+
+ executor.execute(new SendPullRequestRunnable(theQueue));
+ }
+
+ /*
+ * Get the ref count - executed on event queue
+ */
+ private class GetRefCountRunnable implements Runnable
+ {
+ Future result;
+
+ public GetRefCountRunnable(Future result)
+ {
+ this.result = result;
+ }
+
+ public void run()
+ {
+ int refCount = messageRefs.size();
+
+ result.setResult(new Integer(refCount));
+ }
+ }
+
+ private class SendPullRequestRunnable implements Runnable
+ {
+ private RemoteQueueStub theQueue;
+
+ private SendPullRequestRunnable(RemoteQueueStub theQueue)
+ {
+ this.theQueue = theQueue;
+ }
- if (!handle)
+ public void run()
{
- int afterSize = messageRefs.size();
-
- if (trace)
+ try
{
- log.trace(this + " Deciding whether to pull messages. " +
- "receiversready:" + receiversReady + " before size:" + beforeSize + " afterSize: " + afterSize);
+ //TODO
+ //We create a tx just so we get the id - we could just get the id directly from the id
+ //manager
+ Transaction tx = tr.createTransaction();
+
+ ClusterRequest req = new PullMessagesRequest(nodeId, tx.getId(), theQueue.getChannelID(),
+ name, 1);
+
+ office.asyncSendRequest(req, theQueue.getNodeId());
}
-
- if (receiversReady && beforeSize == 0 && afterSize == 0)
+ catch (Exception e)
{
- //Delivery has been prompted (not from handle call)
- //and has run, and there are consumers that are still interested in receiving more
- //refs but there are none available in the channel (either the channel is empty
- //or there are only refs that don't match any selectors)
- //then we should perhaps pull some messages from a remote queue
- pullMessages();
+ log.error("Failed to pull message", e);
}
}
+
}
- public boolean isClustered()
- {
- return true;
- }
-
/**
- * Pull messages from a remote queue to this queue.
+ * This is how we "pull" messages from one node to another
* If any of the messages are reliable then this needs to be done reliable (i.e. without loss or redelivery)
* Normally this would require 2PC which would make performance suck.
* However since we know both queues share the same DB then we can do the persistence locally in the same
- * tx thus avoiding 2PC and maintaining reliability:)
+ * tx thus avoiding 2PC and maintaining reliability :)
* We do the following:
*
- * 1. A tx is started locally
- * 2. Create deliveries for message(s) on the remote node - bring messages back to the local node
- * We send a message to the remote node to retrieve a set of deliveries from the queue - it gets a max of num
- * deliveries.
- * The unreliable ones can be acknowledged immediately, the reliable ones are not acknowledged and a holding transaction
- * is placed in the holding area on the remote node, which contains knowledge of the deliveries.
- * The messages corresponding to the deliveries are returned to the local node
- * 3. The retrieved messages are added to the local queue in the tx
- * 4. Deliveries corresponding to the messages retrieved are acknowledged LOCALLY for the remote queue.
+ * 1. Send a PullMessagesRequest to the remote node, on receipt it will create a delivery for the message, and
+ * possibly add a holding tx (if there are any persistent messages), the messages will then be returned in
+ * a PullMessagesResultRequest which is sent asynchronously from the remote node back to here to avoid
+ * distributed deadlock.
+ * 2. When the result is returned it hits this method.
+ * 3. The retrieved message is added to the local queue in the tx
+ * 4. Delivery corresponding to the message is acknowledged LOCALLY for the remote queue.
* 5. The local tx is committed.
* 6. Send "commit" message to remote node
- * 7. "Commit" message is received and deliveries in the holding transaction are acknowledged IN MEMORY only.
- * On failure, commit or rollback will be called on the holding transaction causing the deliveries to be acked or cancelled
- * depending on whether they exist in the database
+ * 7. "Commit" message is received and delivery in the holding transaction is acknowledged IN MEMORY only.
+ * On failure, commit or rollback will be called on the holding transaction causing the delivery to be acked or cancelled
+ * depending on whether it exists in the database
*
- * This method will always be executed on the channel's event queue (via the deliver method)
- * so no need to do any handles or acks inside another event message
- */
- private void pullMessages() throws Throwable
- {
- RemoteQueueStub theQueue;
- int thePullSize;
+ * Recovery is handled in the same way as CastMessagesCallback
+ *
+ */
+
+ private class MessagePullRequestRunnable implements Runnable
+ {
+ int returnNodeId;
- synchronized (pullLock)
- {
- if (pullQueue == null)
- {
- return;
- }
- theQueue = pullQueue;
- thePullSize = pullSize;
- }
-
- Transaction tx = tr.createTransaction();
+ int number;
+
+ TransactionId txId;
+
+ PullMessagesRequest tx;
+
+ public MessagePullRequestRunnable(int returnNodeId, int number, TransactionId txId, PullMessagesRequest tx)
+ {
+ this.returnNodeId = returnNodeId;
- ClusterRequest req = new PullMessagesRequest(this.nodeId, tx.getId(), theQueue.getChannelID(),
- name, thePullSize);
-
- if (trace)
- {
- log.trace(System.identityHashCode(this) + " Executing pull messages request for queue " + name +
- " pulling from node " + theQueue.getNodeId() + " to node " + this.nodeId);
+ this.number = number;
+
+ this.txId = txId;
+
+ this.tx = tx;
}
- byte[] bytes = (byte[])office.syncSendRequest(req, theQueue.getNodeId(), true);
-
- if (bytes == null)
+ public void run()
{
- //Ok - node might have left the group
- return;
+ try
+ {
+ Delivery del = null;
+
+ //We only get the delivery if receiversReady = false so as not to steal messages that
+ //might be consumed by local receivers
+ if (!receiversReady)
+ {
+ MessageReference ref;
+
+ synchronized (refLock)
+ {
+ synchronized (deliveryLock)
+ {
+ ref = removeFirstInMemory();
+
+ if (ref != null)
+ {
+ del = new SimpleDelivery(LocalClusteredQueue.this, ref);
+
+ deliveries.add(del);
+ }
+ }
+ }
+ }
+
+ if (trace) { log.trace("PullMessagesRunnable got " + del); }
+
+ if (del != null)
+ {
+ PullMessageResultRequest response =
+ new PullMessageResultRequest(LocalClusteredQueue.this.nodeId, txId.getTxId(),
+ name,
+ del.getReference().getMessage());
+
+ if (!del.getReference().isReliable())
+ {
+ //We can ack it now
+ del.acknowledge(null);
+ }
+ else
+ {
+ //Add this to the holding area
+ tx.setReliableDelivery(del);
+
+ office.holdTransaction(txId, tx);
+ }
+
+ //We send the messages asynchronously to avoid a deadlock situation which can occur
+ //if we were using MessageDispatcher to get the messages.
+
+ office.asyncSendRequest(response, returnNodeId);
+ }
+ }
+ catch (Throwable e)
+ {
+ log.error("Failed to get deliveries", e);
+ }
}
+ }
+
+ private class MessagePullResultRunnable implements Runnable
+ {
+ private RemoteQueueStub remoteQueue;
- PullMessagesResponse response = new PullMessagesResponse();
+ private Message message;
- StreamUtils.fromBytes(response, bytes);
-
- List msgs = response.getMessages();
+ private long holdingTxId;
- if (trace) { log.trace(System.identityHashCode(this) + " I retrieved " + msgs.size() + " messages from pull"); }
-
- Iterator iter = msgs.iterator();
-
- boolean containsReliable = false;
-
- while (iter.hasNext())
+ //for testing only
+ private boolean failBeforeCommit;
+ private boolean failAfterCommit;
+
+ private MessagePullResultRunnable(RemoteQueueStub remoteQueue,
+ Message message, long holdingTxId,
+ boolean failBeforeCommit, boolean failAfterCommit)
{
- org.jboss.messaging.core.Message msg = (org.jboss.messaging.core.Message)iter.next();
+ this.remoteQueue = remoteQueue;
- if (msg.isReliable())
- {
- //It will already have been persisted on the other node
- msg.setPersisted(true);
-
- containsReliable = true;
- }
+ this.message = message;
- MessageReference ref = null;
+ this.holdingTxId = holdingTxId;
+ this.failBeforeCommit = failBeforeCommit;
+ this.failAfterCommit = failAfterCommit;
+ }
+
+ public void run()
+ {
try
{
- ref = ms.reference(msg);
+ Transaction tx = null;
- Delivery delRet = handleInternal(null, ref, tx, true, true);
+ boolean handleTransactionally = message.isReliable() && isRecoverable();
- if (delRet == null || !delRet.isSelectorAccepted())
+ if (handleTransactionally)
{
- //This should never happen
- throw new IllegalStateException("Aaarrgg queue did not accept reference");
+ tx = tr.createTransaction();
+
+ //It will already have been persisted on the other node
+ //so we need to set the persisted flag here
+ message.setPersisted(true);
}
- }
- finally
- {
- if (ref != null)
+
+ MessageReference ref = null;
+
+ try
{
- ref.releaseMemoryReference();
+ ref = ms.reference(message);
+
+ //Should be executed synchronously since we already in the event queue
+ Delivery delRet = handleInternal(null, ref, tx, true, true);
+
+ if (delRet == null || !delRet.isSelectorAccepted())
+ {
+ //This should never happen
+ throw new IllegalStateException("Queue did not accept reference!");
+ }
}
+ finally
+ {
+ if (ref != null)
+ {
+ ref.releaseMemoryReference();
+ }
+ }
+
+ //Acknowledge on the remote queue stub
+ Delivery del = new SimpleDelivery(remoteQueue, ref);
+
+ del.acknowledge(tx);
+
+ //For testing to simulate failures
+ if (failBeforeCommit)
+ {
+ throw new Exception("Test failure before commit");
+ }
+
+ if (handleTransactionally)
+ {
+ tx.commit();
+ }
+
+ //For testing to simulate failures
+ if (failAfterCommit)
+ {
+ throw new Exception("Test failure after commit");
+ }
+
+ //TODO what if commit throws an exception - this means the commit message doesn't hit the
+ //remote node so the holding transaction stays in the holding area
+ //Need to catch the exception and throw a check message
+ //What we need to do is catch any exceptions at the top of the call, i.e. just after the interface
+ //and send a checkrequest
+ //This applies to a normal message and messages requests too
+
+ if (handleTransactionally)
+ {
+ ClusterRequest req = new PullMessagesRequest(nodeId, holdingTxId);
+
+ office.asyncSendRequest(req, remoteQueue.getNodeId());
+ }
+ }
+ catch (Throwable e)
+ {
+ log.error("Failed to handle pulled message", e);
}
-
- //Acknowledge on the remote queue stub
- Delivery del = new SimpleDelivery(theQueue, ref);
-
- del.acknowledge(tx);
- }
-
- tx.commit();
-
- //TODO what if commit throws an exception - this means the commit message doesn't hit the
- //remote node so the holding transaction stays in the holding area
- //Need to catch the exception and throw a check message
- //What we need to do is catch any exceptions at the top of the call, i.e. just after the interface
- //and send a checkrequest
- //This applies to a normal message and messages requests too
-
- //We only need to send a commit message if there were reliable messages since otherwise
- //the transaction wouldn't have been added in the holding area
- if (containsReliable && isRecoverable())
- {
- req = new PullMessagesRequest(this.nodeId, tx.getId());
-
- office.asyncSendRequest(req, theQueue.getNodeId());
- }
-
- }
+ }
+ }
}
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/PostOfficeInternal.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/PostOfficeInternal.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/PostOfficeInternal.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -58,17 +58,17 @@
void asyncSendRequest(ClusterRequest request, int nodeId) throws Exception;
- Object syncSendRequest(ClusterRequest request, int nodeId, boolean ignoreNoAddress) throws Exception;
-
void holdTransaction(TransactionId id, ClusterTransaction tx) throws Throwable;
void commitTransaction(TransactionId id) throws Throwable;
+ void rollbackTransaction(TransactionId id) throws Throwable;
+
void updateQueueStats(int nodeId, List stats) throws Exception;
void sendQueueStats() throws Exception;
boolean referenceExistsInStorage(long channelID, long messageID) throws Exception;
- List getDeliveries(String queueName, int numMessages) throws Exception;
+ void handleMessagePullResult(int remoteNodeId, long holdingTxId, String queueName, Message message) throws Throwable;
}
Copied: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/PullMessageResultRequest.java (from rev 1517, trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/PullMessageResultRequest.java)
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/PullMessagesRequest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/PullMessagesRequest.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/PullMessagesRequest.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -23,13 +23,12 @@
import java.io.DataInputStream;
import java.io.DataOutputStream;
-import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.jboss.logging.Logger;
import org.jboss.messaging.core.Delivery;
-import org.jboss.messaging.util.StreamUtils;
+import org.jboss.messaging.core.plugin.postoffice.Binding;
/**
* A PullMessagesRequest
@@ -50,7 +49,7 @@
private int numMessages;
- private List reliableDels;
+ private Delivery reliableDelivery;
static final int TYPE = 5;
@@ -80,47 +79,18 @@
if (hold)
{
- List dels = office.getDeliveries(queueName, numMessages);
+ Binding binding = office.getBindingForQueueName(queueName);
- if (trace) { log.trace("PullMessagesRequest got " + dels.size() + " deliveries"); }
-
- PullMessagesResponse response = new PullMessagesResponse(dels.size());
-
- if (!dels.isEmpty())
+ if (binding == null)
{
- Iterator iter = dels.iterator();
-
- Delivery del = (Delivery)iter.next();
-
- if (del.getReference().isReliable())
- {
- //Add it to internal list
- if (reliableDels == null)
- {
- reliableDels = new ArrayList();
- }
-
- reliableDels.add(del);
- }
- else
- {
- //We can ack it now
- del.acknowledge(null);
- }
-
- response.addMessage(del.getReference().getMessage());
+ throw new IllegalStateException("Cannot find binding for queue: " + queueName);
}
-
- if (reliableDels != null)
- {
- //Add this to the holding area
- office.holdTransaction(id, this);
- }
-
- //Convert to bytes since the response isn't serializable (nor do we want it to be)
- byte[] bytes = StreamUtils.toBytes(response);
- return bytes;
+ LocalClusteredQueue queue = (LocalClusteredQueue)binding.getQueue();
+
+ queue.handleGetDeliveriesRequest(nodeId, numMessages, id, this);
+
+ return null;
}
else
{
@@ -129,6 +99,12 @@
return null;
}
}
+
+ //TODO this is a bit messsy - must be a nicer way of setting this
+ void setReliableDelivery(Delivery del)
+ {
+ this.reliableDelivery = del;
+ }
byte getType()
{
@@ -137,21 +113,15 @@
public boolean check(PostOfficeInternal office) throws Exception
{
- // If the messages DON'T exist in the database then we should commit the transaction
- // Since the acks have already been processed persistently
+ // If the message doesn't exist in the database then we should commit the transaction
+ // Since the ack has already been processed persistently
// otherwise we should roll it back
-
- Iterator iter = reliableDels.iterator();
-
- //We only need to check one of them since they would all have been acked in a tx
-
- Delivery del = (Delivery)iter.next();
-
+
//We store the channelID of one of the channels that the message was persisted in
//it doesn't matter which one since they were all inserted in the same tx
- if (office.referenceExistsInStorage(checkChannelID, del.getReference().getMessageID()))
+ if (office.referenceExistsInStorage(checkChannelID, reliableDelivery.getReference().getMessageID()))
{
//We should rollback
return false;
@@ -165,34 +135,20 @@
public void commit(PostOfficeInternal office) throws Throwable
{
- //We need to ack the deliveries
+ //We need to ack the delivery
- Iterator iter = reliableDels.iterator();
-
- while (iter.hasNext())
- {
- Delivery del = (Delivery)iter.next();
-
- //We need to ack them in memory only
- //since they would have been acked on the pulling node
- LocalClusteredQueue queue = (LocalClusteredQueue)del.getObserver();
-
- queue.acknowledgeFromCluster(del);
- }
+ //We need to ack it in memory only
+ //since it would have been acked on the pulling node
+ LocalClusteredQueue queue = (LocalClusteredQueue)reliableDelivery.getObserver();
+
+ queue.acknowledgeFromCluster(reliableDelivery);
}
public void rollback(PostOfficeInternal office) throws Throwable
{
- //We need to cancel the deliveries
+ //We need to cancel the delivery
- Iterator iter = reliableDels.iterator();
-
- while (iter.hasNext())
- {
- Delivery del = (Delivery)iter.next();
-
- del.cancel();
- }
+ reliableDelivery.cancel();
}
public void read(DataInputStream in) throws Exception
Deleted: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/PullMessagesResponse.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/PullMessagesResponse.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/PullMessagesResponse.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -1,99 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.core.plugin.postoffice.cluster;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.jboss.messaging.core.Message;
-import org.jboss.messaging.core.message.MessageFactory;
-import org.jboss.messaging.util.Streamable;
-
-/**
- * A PullMessagesResponse
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 1.1 $</tt>
- *
- * $Id$
- *
- */
-public class PullMessagesResponse implements Streamable
-{
- private List messages;
-
- PullMessagesResponse()
- {
- }
-
- PullMessagesResponse(int size)
- {
- messages = new ArrayList(size);
- }
-
- void addMessage(Message msg)
- {
- messages.add(msg);
- }
-
- List getMessages()
- {
- return messages;
- }
-
- public void read(DataInputStream in) throws Exception
- {
- int num = in.readInt();
-
- messages = new ArrayList(num);
-
- for (int i = 0; i < num; i++)
- {
- byte type = in.readByte();
-
- Message msg = MessageFactory.createMessage(type);
-
- msg.read(in);
-
- messages.add(msg);
- }
- }
-
- public void write(DataOutputStream out) throws Exception
- {
- out.writeInt(messages.size());
-
- Iterator iter = messages.iterator();
-
- while (iter.hasNext())
- {
- Message msg = (Message)iter.next();
-
- out.writeByte(msg.getType());
-
- msg.write(out);
- }
- }
-}
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/RemoteQueueStub.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/RemoteQueueStub.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/RemoteQueueStub.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -47,7 +47,7 @@
* $Id$
*
*/
-class RemoteQueueStub implements ClusteredQueue
+public class RemoteQueueStub implements ClusteredQueue
{
private static final Logger log = Logger.getLogger(RemoteQueueStub.class);
@@ -65,7 +65,8 @@
private QueueStats stats;
- RemoteQueueStub(int nodeId, String name, long id, boolean recoverable, PersistenceManager pm, Filter filter)
+ public RemoteQueueStub(int nodeId, String name, long id, boolean recoverable,
+ PersistenceManager pm, Filter filter)
{
this.nodeId = nodeId;
Copied: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/RollbackPullRequest.java (from rev 1517, trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/RollbackPullRequest.java)
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/StatsSender.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/StatsSender.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/StatsSender.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -98,6 +98,7 @@
class SendStatsTimerTask extends TimerTask
{
private boolean stopping;
+
private boolean stopped;
private Object stopLock = new Object();
@@ -125,8 +126,11 @@
if (stopping)
{
cancel();
+
stopped = true;
+
stopLock.notify();
+
return;
}
}
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/TransactionId.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/TransactionId.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/TransactionId.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -87,7 +87,7 @@
TransactionId tother = (TransactionId)other;
- return tother.txId == this.txId && tother.nodeId == this.nodeId;
+ return (tother.txId == this.txId) && (tother.nodeId == this.nodeId);
}
public String toString()
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/TransactionRequest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/TransactionRequest.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/TransactionRequest.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -24,8 +24,10 @@
import java.io.DataInputStream;
import java.io.DataOutputStream;
+import org.jboss.logging.Logger;
+
/**
* A TransactionRequest
*
@@ -37,6 +39,8 @@
*/
abstract class TransactionRequest extends ClusterRequest implements ClusterTransaction
{
+ private static final Logger log = Logger.getLogger(TransactionRequest.class);
+
protected int nodeId;
protected long txId;
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/tx/Transaction.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/tx/Transaction.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/tx/Transaction.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -208,7 +208,7 @@
if (trace) { log.trace("executing after commit hooks " + this); }
if (firstCallback != null)
- {
+ {
firstCallback.afterCommit(onePhase);
}
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/tx/TransactionRepository.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/tx/TransactionRepository.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/tx/TransactionRepository.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -179,7 +179,7 @@
public Transaction createTransaction() throws Exception
{
Transaction tx = new Transaction(idManager.getId());
-
+
if (trace) { log.trace("created transaction " + tx); }
return tx;
Modified: branches/Branch_Client_Failover_Experiment/tests/build.xml
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/build.xml 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/tests/build.xml 2006-10-25 20:30:08 UTC (rev 1518)
@@ -91,7 +91,7 @@
<property name="junit.haltonfailure" value="false"/>
<property name="junit.fork" value="true"/>
<property name="junit.includeantruntime" value="true"/>
- <property name="junit.timeout" value="300000"/>
+ <property name="junit.timeout" value="1200000"/>
<property name="stress.timeout" value="4800000"/>
<property name="junit.showoutput" value="true"/>
@@ -343,7 +343,7 @@
<exclude name="**/jms/stress/**"/>
<exclude name="**/jms/crash/*Test.class"/>
<exclude name="**/jms/MemLeakTest.class"/>
- <exclude name="**/jms/ManualClusteringTest.class"/>
+ <exclude name="**/jms/manual/**/*Test.class"/>
</fileset>
</batchtest>
</junit>
@@ -456,7 +456,8 @@
haltonerror="${junit.batchtest.haltonerror}">
<formatter type="plain" usefile="${junit.formatter.usefile}"/>
<fileset dir="${build.tests.classes}">
- <include name="**/jms/stress/**/*Test.class"/>
+ <!-- <include name="**/jms/stress/**/*Test.class"/> -->
+ <include name="**/jms/stress/StressTest.class"/>
</fileset>
</batchtest>
</junit>
@@ -527,11 +528,10 @@
<exclude name="org/jboss/test/messaging/jms/ReferencingTest.class"/>
<exclude name="org/jboss/test/messaging/jms/PersistenceTest.class"/>
<exclude name="org/jboss/test/messaging/jms/crash/*Test.class"/>
- <exclude name="org/jboss/test/messaging/jms/ManualCrashTest.class"/>
<exclude name="org/jboss/test/messaging/jms/MemLeakTest.class"/>
<exclude name="org/jboss/test/messaging/jms/ManifestTest.class"/>
<exclude name="org/jboss/test/messaging/jms/JCAWrapperTest.class"/>
- <exclude name="**/jms/ManualClusteringTest.class"/>
+ <exclude name="**/jms/manual/**/*Test.class"/>
</fileset>
</batchtest>
</junit>
Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/SimpleDeliveryTest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/SimpleDeliveryTest.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/SimpleDeliveryTest.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -112,8 +112,9 @@
sc.start();
PersistenceManager pm =
- new JDBCPersistenceManager(sc.getDataSource(), sc.getTransactionManager(), null,
- true, true, true, 100);
+ new JDBCPersistenceManager(sc.getDataSource(), sc.getTransactionManager(),
+ sc.getPersistenceManagerSQLProperties(),
+ true, true, true, 100);
pm.start();
IdManager idm = new IdManager("TRANSACTION_ID", 10, pm);
Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/SimpleReceiver.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/SimpleReceiver.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/SimpleReceiver.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -61,6 +61,7 @@
public static final String BROKEN = "BROKEN";
public static final String REJECTING = "REJECTING";
public static final String SELECTOR_REJECTING = "SELECTOR_REJECTING";
+ public static final String ACCEPTING_TO_MAX = "ACCEPTING_TO_MAX";
private static final String INVOCATION_COUNT = "INVOCATION_COUNT";
@@ -77,6 +78,7 @@
private int invocationsToFutureStateCount;
private Map waitingArea;
private boolean immediateAsynchronousAcknowledgment;
+ private int maxRefs;
// Constructors --------------------------------------------------
@@ -102,6 +104,7 @@
{
this(name, state, null);
}
+
public SimpleReceiver(String name, String state, Channel channel)
{
@@ -142,8 +145,16 @@
log.trace(this + " is rejecting reference " + ref);
return null;
}
+
+ if (ACCEPTING_TO_MAX.equals(state))
+ {
+ //Only accept up to maxRefs references
+ if (messages.size() == maxRefs)
+ {
+ return null;
+ }
+ }
-
if (BROKEN.equals(state))
{
throw new RuntimeException("THIS IS AN EXCEPTION THAT SIMULATES "+
@@ -192,6 +203,11 @@
}
// Public --------------------------------------------------------
+
+ public void setMaxRefs(int max)
+ {
+ this.maxRefs = max;
+ }
public void setImmediateAsynchronousAcknowledgment(boolean b)
{
@@ -392,7 +408,8 @@
!ACCEPTING.equals(state) &&
!BROKEN.equals(state) &&
!REJECTING.equals(state) &&
- !SELECTOR_REJECTING.equals(state))
+ !SELECTOR_REJECTING.equals(state) &&
+ !ACCEPTING_TO_MAX.equals(state))
{
throw new IllegalArgumentException("Unknown receiver state: " + state);
}
Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/local/base/PagingFilteredQueueTestBase.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/local/base/PagingFilteredQueueTestBase.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/local/base/PagingFilteredQueueTestBase.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -115,8 +115,9 @@
sc.start();
pm =
- new JDBCPersistenceManager(sc.getDataSource(), sc.getTransactionManager(), null,
- true, true, true, 100);
+ new JDBCPersistenceManager(sc.getDataSource(), sc.getTransactionManager(),
+ sc.getPersistenceManagerSQLProperties(),
+ true, true, true, 100);
pm.start();
idm = new IdManager("TRANSACTION_ID", 10, pm);
Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/paging/ChannelShare_NP_NTTest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/paging/ChannelShare_NP_NTTest.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/paging/ChannelShare_NP_NTTest.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -291,10 +291,8 @@
//Now consume them all
- log.info("Consuming them all from 1");
this.consume(queue1, 0, refs1, 150);
- log.info("Consuming them all from 2");
this.consume(queue2, 0, refs2, 150);
// Queue1
Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/paging/PagingTest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/paging/PagingTest.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/paging/PagingTest.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -86,8 +86,9 @@
sc.start();
pm =
- new JDBCPersistenceManager(sc.getDataSource(), sc.getTransactionManager(), null,
- true, true, true, 100);
+ new JDBCPersistenceManager(sc.getDataSource(), sc.getTransactionManager(),
+ sc.getPersistenceManagerSQLProperties(),
+ true, true, true, 100);
pm.start();
ms = new SimpleMessageStore();
Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/paging/SingleChannel_ReloadTest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/paging/SingleChannel_ReloadTest.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/paging/SingleChannel_ReloadTest.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -116,8 +116,9 @@
ms.stop();
pm =
- new JDBCPersistenceManager(sc.getDataSource(), sc.getTransactionManager(), null,
- true, true, true, 100);
+ new JDBCPersistenceManager(sc.getDataSource(), sc.getTransactionManager(),
+ sc.getPersistenceManagerSQLProperties(),
+ true, true, true, 100);
pm.start();
tr = new TransactionRepository(pm, idm);
@@ -213,8 +214,9 @@
ms.stop();
pm =
- new JDBCPersistenceManager(sc.getDataSource(), sc.getTransactionManager(), null,
- true, true, true, 100);
+ new JDBCPersistenceManager(sc.getDataSource(), sc.getTransactionManager(),
+ sc.getPersistenceManagerSQLProperties(),
+ true, true, true, 100);
pm.start();
tr = new TransactionRepository(pm, idm);
Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/paging/base/PagingStateTestBase.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/paging/base/PagingStateTestBase.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/paging/base/PagingStateTestBase.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -95,8 +95,9 @@
sc.start();
pm =
- new JDBCPersistenceManager(sc.getDataSource(), sc.getTransactionManager(), null,
- true, true, true, 100);
+ new JDBCPersistenceManager(sc.getDataSource(), sc.getTransactionManager(),
+ sc.getPersistenceManagerSQLProperties(),
+ true, true, true, 100);
pm.start();
idm = new IdManager("TRANSACTION_ID", 10, pm);
@@ -465,9 +466,7 @@
Connection conn = ds.getConnection();
List msgIds = new ArrayList();
-
- //log.info("channel id:" + channelId);
-
+
String sql = "SELECT MESSAGEID, ORD, PAGE_ORD FROM JMS_MESSAGE_REFERENCE WHERE CHANNELID=? ORDER BY PAGE_ORD";
PreparedStatement ps = conn.prepareStatement(sql);
ps.setLong(1, channelId);
@@ -478,9 +477,7 @@
{
long msgId = rs.getLong(1);
long pageOrd = rs.getLong(3);
-
- //log.info("Exists " + msgId + " with page ord " + pageOrd);
-
+
msgIds.add(new Long(msgId));
}
rs.close();
Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/IdManagerTest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/IdManagerTest.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/IdManagerTest.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -67,8 +67,9 @@
sc.start();
pm =
- new JDBCPersistenceManager(sc.getDataSource(), sc.getTransactionManager(), null,
- true, true, true, 100);
+ new JDBCPersistenceManager(sc.getDataSource(), sc.getTransactionManager(),
+ sc.getPersistenceManagerSQLProperties(),
+ true, true, true, 100);
pm.start();
pm.start();
Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/JDBCPersistenceManagerTest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/JDBCPersistenceManagerTest.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/JDBCPersistenceManagerTest.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -102,8 +102,9 @@
protected JDBCPersistenceManager createPM(boolean batch, int maxParams) throws Throwable
{
JDBCPersistenceManager p =
- new JDBCPersistenceManager(sc.getDataSource(), sc.getTransactionManager(), null,
- true, batch, true, maxParams);
+ new JDBCPersistenceManager(sc.getDataSource(), sc.getTransactionManager(),
+ sc.getPersistenceManagerSQLProperties(),
+ true, batch, true, maxParams);
p.start();
return p;
}
@@ -685,9 +686,6 @@
//First load exactly 10
PersistenceManager.InitialLoadInfo info = pm.getInitialReferenceInfos(channel.getChannelID(), 10);
- log.info("min:" + info.getMinPageOrdering());
- log.info("max:" + info.getMaxPageOrdering());
-
assertNull(info.getMinPageOrdering());
assertNull(info.getMaxPageOrdering());
Deleted: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/base/ClusteringTestBase.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/base/ClusteringTestBase.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/base/ClusteringTestBase.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -1,331 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.messaging.core.plugin.base;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.naming.InitialContext;
-import javax.sql.DataSource;
-import javax.transaction.TransactionManager;
-
-import org.jboss.jms.server.QueuedExecutorPool;
-import org.jboss.messaging.core.FilterFactory;
-import org.jboss.messaging.core.Message;
-import org.jboss.messaging.core.MessageReference;
-import org.jboss.messaging.core.Queue;
-import org.jboss.messaging.core.plugin.IdManager;
-import org.jboss.messaging.core.plugin.JDBCPersistenceManager;
-import org.jboss.messaging.core.plugin.SimpleMessageStore;
-import org.jboss.messaging.core.plugin.contract.MessageStore;
-import org.jboss.messaging.core.plugin.contract.PersistenceManager;
-import org.jboss.messaging.core.plugin.contract.PostOffice;
-import org.jboss.messaging.core.plugin.postoffice.DefaultPostOffice;
-import org.jboss.messaging.core.tx.Transaction;
-import org.jboss.messaging.core.tx.TransactionRepository;
-import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.core.SimpleFilterFactory;
-import org.jboss.test.messaging.core.SimpleReceiver;
-import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
-import org.jboss.test.messaging.util.CoreMessageFactory;
-import org.jboss.tm.TransactionManagerService;
-
-/**
- *
- * A PostOfficeTestBase
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 1.1 $</tt>
- *
- * $Id$
- *
- */
-public class ClusteringTestBase extends MessagingTestCase
-{
- // Constants -----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- protected ServiceContainer sc;
-
- protected IdManager channelIdManager;
-
- protected IdManager transactionIdManager;
-
- protected PersistenceManager pm;
-
- protected MessageStore ms;
-
- protected TransactionRepository tr;
-
- protected QueuedExecutorPool pool;
-
- // Constructors --------------------------------------------------
-
- public ClusteringTestBase(String name)
- {
- super(name);
- }
-
- // Public --------------------------------------------------------
-
- public void setUp() throws Exception
- {
- super.setUp();
-
- sc = new ServiceContainer("all");
-
- sc.start();
-
- pm =
- new JDBCPersistenceManager(sc.getDataSource(), sc.getTransactionManager(), null,
- true, false, true, 100);
- pm.start();
-
- transactionIdManager = new IdManager("TRANSACTION_ID", 10, pm);
- transactionIdManager.start();
-
- tr = new TransactionRepository(pm, transactionIdManager);
- tr.start();
-
- ms = new SimpleMessageStore();
- ms.start();
-
- pool = new QueuedExecutorPool(10);
-
- channelIdManager = new IdManager("CHANNEL_ID", 10, pm);
- channelIdManager.start();
-
- log.debug("setup done");
- }
-
- public void tearDown() throws Exception
- {
- if (!ServerManagement.isRemote())
- {
- sc.stop();
- sc = null;
- }
- pm.stop();
- tr.stop();
- ms.stop();
- transactionIdManager.stop();
- channelIdManager.stop();
-
- super.tearDown();
- }
-
- // Public --------------------------------------------------------
-
- protected PostOffice createPostOffice() throws Exception
- {
- FilterFactory ff = new SimpleFilterFactory();
-
- DefaultPostOffice postOffice =
- new DefaultPostOffice(sc.getDataSource(), sc.getTransactionManager(),
- null, true, 1, "Simple", ms, pm, tr, ff, pool);
-
- postOffice.start();
-
- return postOffice;
- }
-
- protected boolean checkNoBindingData() throws Exception
- {
- InitialContext ctx = new InitialContext();
-
- TransactionManager mgr = (TransactionManager)ctx.lookup(TransactionManagerService.JNDI_NAME);
- DataSource ds = (DataSource)ctx.lookup("java:/DefaultDS");
-
- javax.transaction.Transaction txOld = mgr.suspend();
- mgr.begin();
-
- Connection conn = null;
-
- PreparedStatement ps = null;
-
- ResultSet rs = null;
-
- try
- {
- conn = ds.getConnection();
- String sql = "SELECT * FROM JMS_POSTOFFICE";
- ps = conn.prepareStatement(sql);
-
- rs = ps.executeQuery();
-
- return rs.next();
- }
- finally
- {
- if (rs != null) rs.close();
-
- if (ps != null) ps.close();
-
- if (conn != null) conn.close();
-
- mgr.commit();
-
- if (txOld != null)
- {
- mgr.resume(txOld);
- }
-
- }
- }
-
- protected boolean checkNoMessageData() throws Exception
- {
- InitialContext ctx = new InitialContext();
-
- TransactionManager mgr = (TransactionManager)ctx.lookup(TransactionManagerService.JNDI_NAME);
- DataSource ds = (DataSource)ctx.lookup("java:/DefaultDS");
-
- javax.transaction.Transaction txOld = mgr.suspend();
- mgr.begin();
-
- Connection conn = null;
-
- PreparedStatement ps = null;
-
- ResultSet rs = null;
-
- try
- {
- conn = ds.getConnection();
- String sql = "SELECT * FROM JMS_MESSAGE_REFERENCE";
- ps = conn.prepareStatement(sql);
-
- rs = ps.executeQuery();
-
- boolean exists = rs.next();
-
- if (!exists)
- {
- rs.close();
-
- ps.close();
-
- ps = conn.prepareStatement("SELECT * FROM JMS_MESSAGE");
-
- rs = ps.executeQuery();
-
- exists = rs.next();
- }
-
- return exists;
- }
- finally
- {
- if (rs != null) rs.close();
-
- if (ps != null) ps.close();
-
- if (conn != null) conn.close();
-
- mgr.commit();
-
- if (txOld != null)
- {
- mgr.resume(txOld);
- }
-
- }
- }
-
- private static long msgCount;
-
- protected List sendMessages(String condition, boolean persistent, PostOffice office, int num, Transaction tx) throws Exception
- {
- List list = new ArrayList();
-
- for (int i = 0; i < num; i++)
- {
- Message msg = CoreMessageFactory.createCoreMessage(msgCount++, persistent, null);
-
- MessageReference ref = ms.reference(msg);
-
- boolean routed = office.route(ref, condition, null);
-
- assertTrue(routed);
-
- list.add(msg);
- }
-
- Thread.sleep(1000);
-
- return list;
- }
-
- protected void checkContainsAndAcknowledge(Message msg, SimpleReceiver receiver, Queue queue) throws Throwable
- {
- List msgs = receiver.getMessages();
- assertNotNull(msgs);
- assertEquals(1, msgs.size());
- Message msgRec = (Message)msgs.get(0);
- assertEquals(msg.getMessageID(), msgRec.getMessageID());
- receiver.acknowledge(msgRec, null);
- msgs = queue.browse();
- assertNotNull(msgs);
- assertTrue(msgs.isEmpty());
- receiver.clear();
- }
-
- protected void checkContainsAndAcknowledge(List msgList, SimpleReceiver receiver, Queue queue) throws Throwable
- {
- List msgs = receiver.getMessages();
- assertNotNull(msgs);
- assertEquals(msgList.size(), msgs.size());
-
- for (int i = 0; i < msgList.size(); i++)
- {
- Message msgRec = (Message)msgs.get(i);
- Message msgCheck = (Message)msgList.get(i);
- assertEquals(msgCheck.getMessageID(), msgRec.getMessageID());
- receiver.acknowledge(msgRec, null);
- }
-
- msgs = queue.browse();
- assertNotNull(msgs);
- assertTrue(msgs.isEmpty());
- receiver.clear();
- }
-
- protected void checkEmpty(SimpleReceiver receiver) throws Throwable
- {
- List msgs = receiver.getMessages();
- assertNotNull(msgs);
- assertTrue(msgs.isEmpty());
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
-
-
Copied: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/base/PostOfficeTestBase.java (from rev 1517, trunk/tests/src/org/jboss/test/messaging/core/plugin/base/PostOfficeTestBase.java)
Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/postoffice/DefaultPostOfficeTest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/postoffice/DefaultPostOfficeTest.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/postoffice/DefaultPostOfficeTest.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -54,7 +54,7 @@
import org.jboss.test.messaging.core.SimpleFilter;
import org.jboss.test.messaging.core.SimpleFilterFactory;
import org.jboss.test.messaging.core.SimpleReceiver;
-import org.jboss.test.messaging.core.plugin.base.ClusteringTestBase;
+import org.jboss.test.messaging.core.plugin.base.PostOfficeTestBase;
import org.jboss.test.messaging.tools.ServerManagement;
import org.jboss.test.messaging.tools.jmx.ServiceContainer;
import org.jboss.test.messaging.util.CoreMessageFactory;
@@ -72,7 +72,7 @@
* $Id$
*
*/
-public class DefaultPostOfficeTest extends ClusteringTestBase
+public class DefaultPostOfficeTest extends PostOfficeTestBase
{
// Constants -----------------------------------------------------
@@ -212,7 +212,10 @@
office2.stop();
}
- checkNoBindingData();
+ if (checkNoBindingData())
+ {
+ fail("Binding data still in database");
+ }
}
}
@@ -321,9 +324,6 @@
routeWithFilter(true);
}
-
-
-
public final void testRoutePersistent() throws Throwable
{
route(true);
@@ -490,8 +490,10 @@
postOffice.stop();
}
- checkNoMessageData();
- checkNoBindingData();
+ if (checkNoMessageData())
+ {
+ fail("data still in database");
+ }
}
}
@@ -533,8 +535,10 @@
postOffice.stop();
}
- checkNoMessageData();
- checkNoBindingData();
+ if (checkNoMessageData())
+ {
+ fail("data still in database");
+ }
}
}
@@ -641,8 +645,10 @@
postOffice.stop();
}
- checkNoMessageData();
- checkNoBindingData();
+ if (checkNoMessageData())
+ {
+ fail("data still in database");
+ }
}
}
@@ -813,8 +819,10 @@
postOffice.stop();
}
- checkNoMessageData();
- checkNoBindingData();
+ if (checkNoMessageData())
+ {
+ fail("data still in database");
+ }
}
}
@@ -1068,6 +1076,8 @@
msgRec2 = (Message)msgs.get(1);
assertTrue(msgRec1 == msg7);
assertTrue(msgRec2 == msg8);
+ receiver1.acknowledge(msgRec1, null);
+ receiver1.acknowledge(msgRec2, null);
msgs = queue2.browse();
assertNotNull(msgs);
@@ -1075,7 +1085,9 @@
msgRec1 = (Message)msgs.get(0);
msgRec2 = (Message)msgs.get(1);
assertTrue(msgRec1 == msg7);
- assertTrue(msgRec2 == msg8);
+ assertTrue(msgRec2 == msg8);
+ receiver2.acknowledge(msgRec1, null);
+ receiver2.acknowledge(msgRec2, null);
}
finally
{
@@ -1084,8 +1096,10 @@
postOffice.stop();
}
- checkNoMessageData();
- checkNoBindingData();
+ if (checkNoMessageData())
+ {
+ fail("data still in database");
+ };
}
}
Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOfficeTest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOfficeTest.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOfficeTest.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -99,12 +99,11 @@
//Add a couple of bindings
- LocalClusteredQueue queue1 = new LocalClusteredQueue(office1, 1, "sub1", channelIdManager.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);
-
+ LocalClusteredQueue queue1 = new LocalClusteredQueue(office1, 1, "sub1", channelIdManager.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);
Binding binding1 =
office1.bindClusteredQueue("topic1", queue1);
+
LocalClusteredQueue queue2 = new LocalClusteredQueue(office1, 1, "sub2", channelIdManager.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);
-
Binding binding2 =
office1.bindClusteredQueue("topic1", queue2);
@@ -112,7 +111,7 @@
office2 = createClusteredPostOffice(2, "testgroup");
- Collection bindings = office2.listBindingsForCondition("topic1");
+ Collection bindings = office2.listAllBindingsForCondition("topic1");
assertNotNull(bindings);
assertEquals(2, bindings.size());
@@ -129,7 +128,7 @@
//Make sure both nodes pick it up
- bindings = office1.listBindingsForCondition("topic1");
+ bindings = office1.listAllBindingsForCondition("topic1");
assertNotNull(bindings);
assertEquals(3, bindings.size());
@@ -138,7 +137,7 @@
assertEquivalent(binding2, (Binding)iter.next());
assertEquivalent(binding3, (Binding)iter.next());
- bindings = office2.listBindingsForCondition("topic1");
+ bindings = office2.listAllBindingsForCondition("topic1");
assertNotNull(bindings);
assertEquals(3, bindings.size());
@@ -155,7 +154,7 @@
// Make sure both nodes pick it up
- bindings = office1.listBindingsForCondition("topic1");
+ bindings = office1.listAllBindingsForCondition("topic1");
assertNotNull(bindings);
assertEquals(4, bindings.size());
@@ -165,7 +164,7 @@
assertEquivalent(binding3, (Binding)iter.next());
assertEquivalent(binding4, (Binding)iter.next());
- bindings = office2.listBindingsForCondition("topic1");
+ bindings = office2.listAllBindingsForCondition("topic1");
assertNotNull(bindings);
assertEquals(4, bindings.size());
@@ -181,7 +180,7 @@
//Make sure bindings are not longer available on either node
- bindings = office1.listBindingsForCondition("topic1");
+ bindings = office1.listAllBindingsForCondition("topic1");
assertNotNull(bindings);
assertEquals(2, bindings.size());
@@ -189,7 +188,7 @@
assertEquivalent(binding3, (Binding)iter.next());
assertEquivalent(binding4, (Binding)iter.next());
- bindings = office2.listBindingsForCondition("topic1");
+ bindings = office2.listAllBindingsForCondition("topic1");
assertNotNull(bindings);
assertEquals(2, bindings.size());
@@ -203,7 +202,7 @@
//Maks sure it picks up the bindings
- bindings = office3.listBindingsForCondition("topic1");
+ bindings = office3.listAllBindingsForCondition("topic1");
assertNotNull(bindings);
assertEquals(2, bindings.size());
@@ -220,7 +219,7 @@
// Make sure all nodes pick it up
- bindings = office1.listBindingsForCondition("topic1");
+ bindings = office1.listAllBindingsForCondition("topic1");
assertNotNull(bindings);
assertEquals(3, bindings.size());
@@ -229,7 +228,7 @@
assertEquivalent(binding4, (Binding)iter.next());
assertEquivalent(binding5, (Binding)iter.next());
- bindings = office2.listBindingsForCondition("topic1");
+ bindings = office2.listAllBindingsForCondition("topic1");
assertNotNull(bindings);
assertEquals(3, bindings.size());
@@ -238,7 +237,7 @@
assertEquivalent(binding4, (Binding)iter.next());
assertEquivalent(binding5, (Binding)iter.next());
- bindings = office3.listBindingsForCondition("topic1");
+ bindings = office3.listAllBindingsForCondition("topic1");
assertNotNull(bindings);
assertEquals(3, bindings.size());
@@ -261,7 +260,7 @@
// Make sure all nodes pick them up
- bindings = office1.listBindingsForCondition("topic1");
+ bindings = office1.listAllBindingsForCondition("topic1");
assertNotNull(bindings);
assertEquals(5, bindings.size());
@@ -272,7 +271,7 @@
assertEquivalent(binding6, (Binding)iter.next());
assertEquivalent(binding7, (Binding)iter.next());
- bindings = office2.listBindingsForCondition("topic1");
+ bindings = office2.listAllBindingsForCondition("topic1");
assertNotNull(bindings);
assertEquals(5, bindings.size());
@@ -283,7 +282,7 @@
assertEquivalent(binding6, (Binding)iter.next());
assertEquivalent(binding7, (Binding)iter.next());
- bindings = office3.listBindingsForCondition("topic1");
+ bindings = office3.listAllBindingsForCondition("topic1");
assertNotNull(bindings);
assertEquals(5, bindings.size());
@@ -305,7 +304,7 @@
//All it's non durable bindings should be removed from the other nodes
//Durable bindings should remain
- bindings = office2.listBindingsForCondition("topic1");
+ bindings = office2.listAllBindingsForCondition("topic1");
assertNotNull(bindings);
assertEquals(4, bindings.size());
@@ -315,7 +314,7 @@
assertEquivalent(binding5, (Binding)iter.next());
assertEquivalent(binding6, (Binding)iter.next());
- bindings = office3.listBindingsForCondition("topic1");
+ bindings = office3.listAllBindingsForCondition("topic1");
assertNotNull(bindings);
assertEquals(4, bindings.size());
@@ -328,7 +327,7 @@
//Stop office 2
office2.stop();
- bindings = office3.listBindingsForCondition("topic1");
+ bindings = office3.listAllBindingsForCondition("topic1");
assertNotNull(bindings);
assertEquals(2, bindings.size());
@@ -341,7 +340,7 @@
office2 = createClusteredPostOffice(2, "testgroup");
- bindings = office1.listBindingsForCondition("topic1");
+ bindings = office1.listAllBindingsForCondition("topic1");
assertNotNull(bindings);
assertEquals(2, bindings.size());
@@ -349,7 +348,7 @@
assertEquivalent(binding5, (Binding)iter.next());
assertEquivalent(binding6, (Binding)iter.next());
- bindings = office2.listBindingsForCondition("topic1");
+ bindings = office2.listAllBindingsForCondition("topic1");
assertNotNull(bindings);
assertEquals(2, bindings.size());
@@ -357,7 +356,7 @@
assertEquivalent(binding5, (Binding)iter.next());
assertEquivalent(binding6, (Binding)iter.next());
- bindings = office3.listBindingsForCondition("topic1");
+ bindings = office3.listAllBindingsForCondition("topic1");
assertNotNull(bindings);
assertEquals(2, bindings.size());
@@ -378,21 +377,21 @@
//Only the durable queue should survive
- bindings = office1.listBindingsForCondition("topic1");
+ bindings = office1.listAllBindingsForCondition("topic1");
assertNotNull(bindings);
assertEquals(1, bindings.size());
iter = bindings.iterator();
assertEquivalent(binding6, (Binding)iter.next());
- bindings = office2.listBindingsForCondition("topic1");
+ bindings = office2.listAllBindingsForCondition("topic1");
assertNotNull(bindings);
assertEquals(1, bindings.size());
iter = bindings.iterator();
assertEquivalent(binding6, (Binding)iter.next());
- bindings = office3.listBindingsForCondition("topic1");
+ bindings = office3.listAllBindingsForCondition("topic1");
assertNotNull(bindings);
assertEquals(1, bindings.size());
@@ -425,7 +424,10 @@
office3.stop();
}
- checkNoBindingData();
+ if (checkNoBindingData())
+ {
+ fail("data still in database");
+ }
}
}
@@ -540,11 +542,11 @@
LocalClusteredQueue queue1 = new LocalClusteredQueue(office1, 1, "queue1", channelIdManager.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);
Binding binding1 = office1.bindClusteredQueue("queue1", queue1);
-
+
LocalClusteredQueue queue2 = new LocalClusteredQueue(office2, 2, "queue1", channelIdManager.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);
-
+
Binding binding2 = office2.bindClusteredQueue("queue1", queue2);
-
+
LocalClusteredQueue queue3 = new LocalClusteredQueue(office1, 1, "queue1", channelIdManager.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);
try
@@ -568,10 +570,10 @@
//Ok
}
+ office2.unbindClusteredQueue("queue1");
+
office1.unbindClusteredQueue("queue1");
-
- office2.unbindClusteredQueue("queue1");
-
+
LocalClusteredQueue queue5 = new LocalClusteredQueue(office1, 1, "queue1", channelIdManager.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);
Binding binding5 = office1.bindClusteredQueue("queue1", queue5);
@@ -621,9 +623,7 @@
}
}
}
-
-
-
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@@ -663,9 +663,7 @@
Message msg1 = CoreMessageFactory.createCoreMessage(1);
MessageReference ref1 = ms.reference(msg1);
- log.info("Sending message 1");
boolean routed = office1.route(ref1, "topic1", null);
- log.info("Sent message 1");
assertTrue(routed);
@@ -730,7 +728,10 @@
office2.stop();
}
- checkNoMessageData();
+ if (checkNoMessageData())
+ {
+ fail("Message data still in database");
+ }
}
}
@@ -907,7 +908,10 @@
office2.stop();
}
- checkNoMessageData();
+ if (checkNoMessageData())
+ {
+ fail("Message data still in database");
+ }
}
}
@@ -1065,7 +1069,10 @@
office6.stop();
}
- checkNoMessageData();
+ if (checkNoMessageData())
+ {
+ fail("Message data still in database");
+ }
}
}
@@ -1150,7 +1157,10 @@
}
- checkNoMessageData();
+ if (checkNoMessageData())
+ {
+ fail("Message data still in database");
+ }
}
}
@@ -1323,7 +1333,7 @@
checkContainsAndAcknowledge(msgs, receiver13, nonDurable7);
//n7
- checkEmpty(receiver12);
+ checkEmpty(receiver14);
//Send 1 message at node2
@@ -1355,7 +1365,7 @@
checkContainsAndAcknowledge(msgs, receiver13, nonDurable7);
//n7
- checkEmpty(receiver12);
+ checkEmpty(receiver14);
//Send 1 message at node3
//========================
@@ -1386,12 +1396,12 @@
checkContainsAndAcknowledge(msgs, receiver13, nonDurable7);
//n7
- checkEmpty(receiver12);
+ checkEmpty(receiver14);
//Send 1 message at node4
//========================
-
- msgs = sendMessages("topic", persistent, office4, 1, null);
+
+ msgs = sendMessages("topic", persistent, office4, 1, null);
//n2
checkContainsAndAcknowledge(msgs, receiver1, nonDurable1);
@@ -1402,22 +1412,22 @@
checkContainsAndAcknowledge(msgs, receiver4, nonDurable3);
//n4
- checkContainsAndAcknowledge(msgs, receiver5, sharedDurable1);
+ checkContainsAndAcknowledge(msgs, receiver5, sharedDurable1); // shared durable 1
checkContainsAndAcknowledge(msgs, receiver6, nonSharedDurable2);
checkContainsAndAcknowledge(msgs, receiver7, nonDurable4);
checkContainsAndAcknowledge(msgs, receiver8, nonDurable5);
checkContainsAndAcknowledge(msgs, receiver9, nonDurable6);
//n5
- checkEmpty(receiver10);
- checkContainsAndAcknowledge(msgs, receiver11, sharedDurable3);
+ checkEmpty(receiver10); //shared durable 1
+ checkContainsAndAcknowledge(msgs, receiver11, sharedDurable3); //shared durable 2
//n6
- checkEmpty(receiver12);
- checkContainsAndAcknowledge(msgs, receiver13, nonDurable7);
+ checkEmpty(receiver12); // shared durable 2
+ checkContainsAndAcknowledge(msgs, receiver13, nonDurable7);
//n7
- checkEmpty(receiver12);
+ checkEmpty(receiver14);
//Send 1 message at node5
//========================
@@ -1593,7 +1603,10 @@
office7.stop();
}
- checkNoMessageData();
+ if (checkNoMessageData())
+ {
+ fail("Message data still in database");
+ }
}
}
@@ -2214,7 +2227,10 @@
office2.stop();
}
- checkNoMessageData();
+ if (checkNoMessageData())
+ {
+ fail("Message data still in database");
+ }
}
}
@@ -2228,11 +2244,11 @@
DefaultClusteredPostOffice postOffice =
new DefaultClusteredPostOffice(sc.getDataSource(), sc.getTransactionManager(),
- null, true, nodeId, "Clustered", ms, pm, tr, ff, pool,
+ sc.getClusteredPostOfficeSQLProperties(), true, nodeId, "Clustered", ms, pm, tr, ff, pool,
groupName,
JGroupsUtil.getControlStackProperties(),
JGroupsUtil.getDataStackProperties(),
- 5000, 5000, pullPolicy, rf, 1, 1000);
+ 5000, 5000, pullPolicy, rf, 1000);
postOffice.start();
Copied: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOfficeWithDefaultRouterTest.java (from rev 1517, trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOfficeWithDefaultRouterTest.java)
Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/DefaultRouterTest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/DefaultRouterTest.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/DefaultRouterTest.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -21,23 +21,35 @@
*/
package org.jboss.test.messaging.core.plugin.postoffice.cluster;
+import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
+import org.jboss.messaging.core.Delivery;
+import org.jboss.messaging.core.DeliveryObserver;
+import org.jboss.messaging.core.Filter;
import org.jboss.messaging.core.FilterFactory;
+import org.jboss.messaging.core.Message;
+import org.jboss.messaging.core.MessageReference;
+import org.jboss.messaging.core.Queue;
+import org.jboss.messaging.core.Receiver;
+import org.jboss.messaging.core.SimpleDelivery;
import org.jboss.messaging.core.plugin.contract.ClusteredPostOffice;
-import org.jboss.messaging.core.plugin.postoffice.Binding;
+import org.jboss.messaging.core.plugin.postoffice.cluster.ClusterRouter;
import org.jboss.messaging.core.plugin.postoffice.cluster.ClusterRouterFactory;
+import org.jboss.messaging.core.plugin.postoffice.cluster.ClusteredQueue;
import org.jboss.messaging.core.plugin.postoffice.cluster.DefaultClusteredPostOffice;
+import org.jboss.messaging.core.plugin.postoffice.cluster.DefaultRouter;
import org.jboss.messaging.core.plugin.postoffice.cluster.DefaultRouterFactory;
-import org.jboss.messaging.core.plugin.postoffice.cluster.LocalClusteredQueue;
import org.jboss.messaging.core.plugin.postoffice.cluster.MessagePullPolicy;
import org.jboss.messaging.core.plugin.postoffice.cluster.NullMessagePullPolicy;
+import org.jboss.messaging.core.plugin.postoffice.cluster.QueueStats;
+import org.jboss.messaging.core.tx.Transaction;
import org.jboss.test.messaging.core.SimpleFilterFactory;
import org.jboss.test.messaging.core.SimpleReceiver;
-import org.jboss.test.messaging.core.plugin.base.ClusteringTestBase;
+import org.jboss.test.messaging.core.plugin.base.PostOfficeTestBase;
+import org.jboss.test.messaging.util.CoreMessageFactory;
-import EDU.oswego.cs.dl.util.concurrent.QueuedExecutor;
-
/**
*
* A DefaultRouterTest
@@ -48,7 +60,7 @@
* $Id$
*
*/
-public class DefaultRouterTest extends ClusteringTestBase
+public class DefaultRouterTest extends PostOfficeTestBase
{
// Constants -----------------------------------------------------
@@ -75,299 +87,264 @@
super.tearDown();
}
- public void testNotLocalPersistent() throws Throwable
+ public void testSize() throws Exception
{
- notLocal(true);
+ DefaultRouter dr = new DefaultRouter();
+
+ ClusteredQueue queue1 = new SimpleQueue(true);
+ dr.add(queue1);
+
+ assertEquals(1, dr.numberOfReceivers());
+ assertEquals(1, dr.getQueues().size());
+
+ ClusteredQueue queue2 = new SimpleQueue(false);
+ dr.add(queue2);
+
+ assertEquals(2, dr.numberOfReceivers());
+ assertEquals(2, dr.getQueues().size());
+
+ ClusteredQueue queue3 = new SimpleQueue(false);
+ dr.add(queue3);
+
+ assertEquals(3, dr.numberOfReceivers());
+ assertEquals(3, dr.getQueues().size());
+
+ dr.remove(queue3);
+
+ assertEquals(2, dr.numberOfReceivers());
+ assertEquals(2, dr.getQueues().size());
+
+ dr.remove(queue2);
+
+ assertEquals(1, dr.numberOfReceivers());
+ assertEquals(1, dr.getQueues().size());
+
+ dr.remove(queue1);
+
+ assertEquals(0, dr.numberOfReceivers());
+ assertTrue(dr.getQueues().isEmpty());
+
}
- public void testNotLocalNonPersistent() throws Throwable
+ // The router only has a local queue
+ public void testRouterOnlyLocal() throws Exception
{
- notLocal(false);
+ DefaultRouter dr = new DefaultRouter();
+
+ ClusteredQueue queue = new SimpleQueue(true);
+
+ SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+
+ queue.add(receiver1);
+
+ dr.add(queue);
+
+ sendAndCheck(dr, receiver1);
+
+ sendAndCheck(dr, receiver1);
+
+ sendAndCheck(dr, receiver1);
}
- public void testLocalPersistent() throws Throwable
+ //The router has only one non local queues
+ public void testRouterOnlyOneNonLocal() throws Exception
{
- local(true);
+ DefaultRouter dr = new DefaultRouter();
+
+ ClusteredQueue queue = new SimpleQueue(false);
+
+ SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+
+ queue.add(receiver1);
+
+ dr.add(queue);
+
+ sendAndCheck(dr, receiver1);
+
+ sendAndCheck(dr, receiver1);
+
+ sendAndCheck(dr, receiver1);
}
- public void testLocalNonPersistent() throws Throwable
+ //The router has multiple non local queues and no local queue
+ public void testRouterMultipleNonLocal() throws Exception
{
- local(false);
+ DefaultRouter dr = new DefaultRouter();
+
+ ClusteredQueue remote1 = new SimpleQueue(false);
+
+ SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+
+ remote1.add(receiver1);
+
+ dr.add(remote1);
+
+
+ ClusteredQueue remote2 = new SimpleQueue(false);
+
+ SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+
+ remote2.add(receiver2);
+
+ dr.add(remote2);
+
+
+ ClusteredQueue remote3 = new SimpleQueue(false);
+
+ SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+
+ remote3.add(receiver3);
+
+ dr.add(remote3);
+
+ sendAndCheck(dr, receiver1);
+
+ sendAndCheck(dr, receiver2);
+
+ sendAndCheck(dr, receiver3);
+
+ sendAndCheck(dr, receiver1);
+
+ sendAndCheck(dr, receiver2);
+
+ sendAndCheck(dr, receiver3);
}
- protected void notLocal(boolean persistent) throws Throwable
+
+ // The router has one local with consumer and one non local queue with consumer
+ public void testRouterOneLocalOneNonLocal() throws Exception
{
- ClusteredPostOffice office1 = null;
+ DefaultRouter dr = new DefaultRouter();
+
+ ClusteredQueue remote1 = new SimpleQueue(false);
+
+ SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
- ClusteredPostOffice office2 = null;
+ remote1.add(receiver1);
- ClusteredPostOffice office3 = null;
+ dr.add(remote1);
- ClusteredPostOffice office4 = null;
+ ClusteredQueue queue = new SimpleQueue(true);
- ClusteredPostOffice office5 = null;
+ SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
- ClusteredPostOffice office6 = null;
-
- try
- {
- office1 = createClusteredPostOffice(1, "testgroup");
-
- office2 = createClusteredPostOffice(2, "testgroup");
-
- office3 = createClusteredPostOffice(3, "testgroup");
-
- office4 = createClusteredPostOffice(4, "testgroup");
-
- office5 = createClusteredPostOffice(5, "testgroup");
-
- office6 = createClusteredPostOffice(6, "testgroup");
-
- LocalClusteredQueue queue1 = new LocalClusteredQueue(office2, 2, "queue1", channelIdManager.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);
- Binding binding1 = office2.bindClusteredQueue("topic", queue1);
- SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
- queue1.add(receiver1);
-
- LocalClusteredQueue queue2 = new LocalClusteredQueue(office3, 3, "queue1", channelIdManager.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);
- Binding binding2 = office3.bindClusteredQueue("topic", queue2);
- SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
- queue2.add(receiver2);
-
- LocalClusteredQueue queue3 = new LocalClusteredQueue(office4, 4, "queue1", channelIdManager.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);
- Binding binding3 = office4.bindClusteredQueue("topic", queue3);
- SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
- queue3.add(receiver3);
-
- LocalClusteredQueue queue4 = new LocalClusteredQueue(office5, 5, "queue1", channelIdManager.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);
- Binding binding4 = office5.bindClusteredQueue("topic", queue4);
- SimpleReceiver receiver4 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
- queue4.add(receiver4);
-
- LocalClusteredQueue queue5 = new LocalClusteredQueue(office6, 6, "queue1", channelIdManager.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);
- Binding binding5 = office6.bindClusteredQueue("topic", queue5);
- SimpleReceiver receiver5 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
- queue5.add(receiver5);
-
- List msgs = sendMessages("topic", persistent, office1, 1, null);
- checkContainsAndAcknowledge(msgs, receiver1, queue1);
- checkEmpty(receiver2);
- checkEmpty(receiver3);
- checkEmpty(receiver4);
- checkEmpty(receiver5);
-
- msgs = sendMessages("topic", persistent, office1, 1, null);
- checkEmpty(receiver1);
- checkContainsAndAcknowledge(msgs, receiver2, queue1);
- checkEmpty(receiver3);
- checkEmpty(receiver4);
- checkEmpty(receiver5);
-
- msgs = sendMessages("topic", persistent, office1, 1, null);
- checkEmpty(receiver1);
- checkEmpty(receiver2);
- checkContainsAndAcknowledge(msgs, receiver3, queue1);
- checkEmpty(receiver4);
- checkEmpty(receiver5);
-
- msgs = sendMessages("topic", persistent, office1, 1, null);
- checkEmpty(receiver1);
- checkEmpty(receiver2);
- checkEmpty(receiver3);
- checkContainsAndAcknowledge(msgs, receiver4, queue1);
- checkEmpty(receiver5);
-
- msgs = sendMessages("topic", persistent, office1, 1, null);
- checkEmpty(receiver1);
- checkEmpty(receiver2);
- checkEmpty(receiver3);
- checkEmpty(receiver4);
- checkContainsAndAcknowledge(msgs, receiver5, queue1);
-
- msgs = sendMessages("topic", persistent, office1, 1, null);
- checkContainsAndAcknowledge(msgs, receiver1, queue1);
- checkEmpty(receiver2);
- checkEmpty(receiver3);
- checkEmpty(receiver4);
- checkEmpty(receiver5);
-
- msgs = sendMessages("topic", persistent, office1, 1, null);
- checkEmpty(receiver1);
- checkContainsAndAcknowledge(msgs, receiver2, queue1);
- checkEmpty(receiver3);
- checkEmpty(receiver4);
- checkEmpty(receiver5);
-
-
- }
- finally
- {
- if (office1 != null)
- {
- office1.stop();
- }
-
- if (office2 != null)
- {
- office2.stop();
- }
-
- if (office3 != null)
- {
- office3.stop();
- }
-
- if (office4 != null)
- {
- office4.stop();
- }
-
- if (office5 != null)
- {
- office5.stop();
- }
-
- if (office6 != null)
- {
- office6.stop();
- }
- }
+ queue.add(receiver2);
+
+ dr.add(queue);
+
+ sendAndCheck(dr, receiver2);
+
+ sendAndCheck(dr, receiver2);
+
+ sendAndCheck(dr, receiver2);
}
+ // The router has multiple non local queues with consumers and one local queue
+ public void testRouterMultipleNonLocalOneLocal() throws Exception
+ {
+ DefaultRouter dr = new DefaultRouter();
+
+ ClusteredQueue remote1 = new SimpleQueue(false);
+
+ SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+
+ remote1.add(receiver1);
+
+ dr.add(remote1);
+
+
+ ClusteredQueue remote2 = new SimpleQueue(false);
+
+ SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+
+ remote2.add(receiver2);
+
+ dr.add(remote2);
+
+
+ ClusteredQueue remote3 = new SimpleQueue(false);
+
+ SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+
+ remote3.add(receiver3);
+
+ dr.add(remote3);
+
+
+ ClusteredQueue queue = new SimpleQueue(true);
+
+ SimpleReceiver receiver4 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
+
+ queue.add(receiver4);
+
+ dr.add(queue);
+
+
+ sendAndCheck(dr, receiver4);
+
+ sendAndCheck(dr, receiver4);
+
+ sendAndCheck(dr, receiver4);
+ }
- protected void local(boolean persistent) throws Throwable
+ private long nextId;
+
+ private void sendAndCheck(ClusterRouter router, SimpleReceiver receiver) throws Exception
{
- ClusteredPostOffice office1 = null;
+ Message msg = CoreMessageFactory.createCoreMessage(nextId++, false, null);
- ClusteredPostOffice office2 = null;
+ MessageReference ref = ms.reference(msg);
- ClusteredPostOffice office3 = null;
+ Delivery del = router.handle(null, ref, null);
- ClusteredPostOffice office4 = null;
+ assertNotNull(del);
- ClusteredPostOffice office5 = null;
+ assertTrue(del.isSelectorAccepted());
+
+ Thread.sleep(250);
- ClusteredPostOffice office6 = null;
-
- try
- {
- office1 = createClusteredPostOffice(1, "testgroup");
-
- office2 = createClusteredPostOffice(2, "testgroup");
-
- office3 = createClusteredPostOffice(3, "testgroup");
-
- office4 = createClusteredPostOffice(4, "testgroup");
-
- office5 = createClusteredPostOffice(5, "testgroup");
-
- office6 = createClusteredPostOffice(6, "testgroup");
-
- LocalClusteredQueue queue1 = new LocalClusteredQueue(office2, 2, "queue1", channelIdManager.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);
- Binding binding1 = office2.bindClusteredQueue("topic", queue1);
- SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
- queue1.add(receiver1);
-
- LocalClusteredQueue queue2 = new LocalClusteredQueue(office3, 3, "queue1", channelIdManager.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);
- Binding binding2 = office3.bindClusteredQueue("topic", queue2);
- SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
- queue2.add(receiver2);
-
- LocalClusteredQueue queue3 = new LocalClusteredQueue(office4, 4, "queue1", channelIdManager.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);
- Binding binding3 = office4.bindClusteredQueue("topic", queue3);
- SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
- queue3.add(receiver3);
-
- LocalClusteredQueue queue4 = new LocalClusteredQueue(office5, 5, "queue1", channelIdManager.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);
- Binding binding4 = office5.bindClusteredQueue("topic", queue4);
- SimpleReceiver receiver4 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
- queue4.add(receiver4);
-
- LocalClusteredQueue queue5 = new LocalClusteredQueue(office6, 6, "queue1", channelIdManager.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);
- Binding binding5 = office6.bindClusteredQueue("topic", queue5);
- SimpleReceiver receiver5 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
- queue5.add(receiver5);
-
- List msgs = sendMessages("topic", persistent, office2, 3, null);
- checkContainsAndAcknowledge(msgs, receiver1, queue1);
- checkEmpty(receiver2);
- checkEmpty(receiver3);
- checkEmpty(receiver4);
- checkEmpty(receiver5);
-
- msgs = sendMessages("topic", persistent, office2, 3, null);
- checkContainsAndAcknowledge(msgs, receiver1, queue1);
- checkEmpty(receiver2);
- checkEmpty(receiver3);
- checkEmpty(receiver4);
- checkEmpty(receiver5);
-
- msgs = sendMessages("topic", persistent, office2, 3, null);
- checkContainsAndAcknowledge(msgs, receiver1, queue1);
- checkEmpty(receiver2);
- checkEmpty(receiver3);
- checkEmpty(receiver4);
- checkEmpty(receiver5);
-
-
- msgs = sendMessages("topic", persistent, office3, 3, null);
- checkEmpty(receiver1);
- checkContainsAndAcknowledge(msgs, receiver2, queue1);
- checkEmpty(receiver3);
- checkEmpty(receiver4);
- checkEmpty(receiver5);
-
- msgs = sendMessages("topic", persistent, office3, 3, null);
- checkEmpty(receiver1);
- checkContainsAndAcknowledge(msgs, receiver2, queue1);
- checkEmpty(receiver3);
- checkEmpty(receiver4);
- checkEmpty(receiver5);
-
- msgs = sendMessages("topic", persistent, office3, 3, null);
- checkEmpty(receiver1);
- checkContainsAndAcknowledge(msgs, receiver2, queue1);
- checkEmpty(receiver3);
- checkEmpty(receiver4);
- checkEmpty(receiver5);
-
-
- }
- finally
- {
- if (office1 != null)
- {
- office1.stop();
- }
-
- if (office2 != null)
- {
- office2.stop();
- }
-
- if (office3 != null)
- {
- office3.stop();
- }
-
- if (office4 != null)
- {
- office4.stop();
- }
-
- if (office5 != null)
- {
- office5.stop();
- }
-
- if (office6 != null)
- {
- office6.stop();
- }
- }
+ List msgs = receiver.getMessages();
+
+ assertNotNull(msgs);
+
+ assertEquals(1, msgs.size());
+
+ Message msgRec = (Message)msgs.get(0);
+
+ assertTrue(msg == msgRec);
+
+ receiver.clear();
}
+ private void sendAndCheck(ClusterRouter router, Queue queue) throws Throwable
+ {
+ Message msg = CoreMessageFactory.createCoreMessage(nextId++, false, null);
+
+ MessageReference ref = ms.reference(msg);
+
+ Delivery del = router.handle(null, ref, null);
+
+ assertNotNull(del);
+
+ assertTrue(del.isSelectorAccepted());
+
+ Thread.sleep(250);
+
+ List msgs = queue.browse();
+
+ assertNotNull(msgs);
+
+ assertEquals(1, msgs.size());
+
+ Message msgRec = (Message)msgs.get(0);
+
+ assertTrue(msg == msgRec);
+
+ queue.removeAllReferences();
+ }
+
protected ClusteredPostOffice createClusteredPostOffice(int nodeId, String groupName) throws Exception
{
MessagePullPolicy redistPolicy = new NullMessagePullPolicy();
@@ -378,11 +355,11 @@
DefaultClusteredPostOffice postOffice =
new DefaultClusteredPostOffice(sc.getDataSource(), sc.getTransactionManager(),
- null, true, nodeId, "Clustered", ms, pm, tr, ff, pool,
+ sc.getClusteredPostOfficeSQLProperties(), true, nodeId, "Clustered", ms, pm, tr, ff, pool,
groupName,
JGroupsUtil.getControlStackProperties(),
JGroupsUtil.getDataStackProperties(),
- 5000, 5000, redistPolicy, rf, 1, 1000);
+ 5000, 5000, redistPolicy, rf, 1000);
postOffice.start();
@@ -394,7 +371,239 @@
// Inner classes -------------------------------------------------
+ class SimpleQueue implements ClusteredQueue
+ {
+ private boolean local;
+
+ private Receiver receiver;
+
+ private List refs = new ArrayList();
+
+ SimpleQueue(boolean local)
+ {
+ this.local = local;
+ }
+ public int getNodeId()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public QueueStats getStats()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isLocal()
+ {
+ return local;
+ }
+
+ public Filter getFilter()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getName()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isClustered()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean acceptReliableMessages()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void activate()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public List browse()
+ {
+ List msgs = new ArrayList();
+
+ Iterator iter = refs.iterator();
+
+ while (iter.hasNext())
+ {
+ MessageReference ref = (MessageReference)iter.next();
+
+ msgs.add(ref);
+ }
+
+ return msgs;
+ }
+
+ public List browse(Filter filter)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void clear()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void close()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void deactivate()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void deliver(boolean synchronous)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public List delivering(Filter filter)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public long getChannelID()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public boolean isActive()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isRecoverable()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void load() throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public int messageCount()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public void removeAllReferences() throws Throwable
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public List undelivered(Filter filter)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void unload() throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Delivery handle(DeliveryObserver observer, MessageReference reference, Transaction tx)
+ {
+ if (receiver != null)
+ {
+ //Send to receiver
+
+ Delivery del = receiver.handle(observer, reference, tx);
+
+ return del;
+ }
+ else
+ {
+ //Store internally
+ refs.add(reference);
+
+ return new SimpleDelivery(observer, reference);
+ }
+
+
+ }
+
+ public void acknowledge(Delivery d, Transaction tx) throws Throwable
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void cancel(Delivery d) throws Throwable
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean add(Receiver receiver)
+ {
+ this.receiver = receiver;
+
+ return true;
+ }
+
+ public boolean contains(Receiver receiver)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public Iterator iterator()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int numberOfReceivers()
+ {
+ if (receiver != null)
+ {
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+ public boolean remove(Receiver receiver)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ }
+
+
}
Copied: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/RecoveryTest.java (from rev 1517, trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/RecoveryTest.java)
Deleted: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/RedistributionTest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/RedistributionTest.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/RedistributionTest.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -1,422 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.messaging.core.plugin.postoffice.cluster;
-
-import org.jboss.messaging.core.Delivery;
-import org.jboss.messaging.core.DeliveryObserver;
-import org.jboss.messaging.core.FilterFactory;
-import org.jboss.messaging.core.MessageReference;
-import org.jboss.messaging.core.Receiver;
-import org.jboss.messaging.core.SimpleDelivery;
-import org.jboss.messaging.core.plugin.contract.ClusteredPostOffice;
-import org.jboss.messaging.core.plugin.postoffice.Binding;
-import org.jboss.messaging.core.plugin.postoffice.cluster.ClusterRouterFactory;
-import org.jboss.messaging.core.plugin.postoffice.cluster.DefaultClusteredPostOffice;
-import org.jboss.messaging.core.plugin.postoffice.cluster.DefaultMessagePullPolicy;
-import org.jboss.messaging.core.plugin.postoffice.cluster.DefaultRouterFactory;
-import org.jboss.messaging.core.plugin.postoffice.cluster.LocalClusteredQueue;
-import org.jboss.messaging.core.plugin.postoffice.cluster.MessagePullPolicy;
-import org.jboss.messaging.core.tx.Transaction;
-import org.jboss.test.messaging.core.SimpleFilterFactory;
-import org.jboss.test.messaging.core.plugin.base.ClusteringTestBase;
-
-import EDU.oswego.cs.dl.util.concurrent.QueuedExecutor;
-
-
-public class RedistributionTest extends ClusteringTestBase
-{
- // Constants -----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- public RedistributionTest(String name)
- {
- super(name);
- }
-
- // Public --------------------------------------------------------
-
- public void setUp() throws Exception
- {
- super.setUp();
- }
-
- public void tearDown() throws Exception
- {
- super.tearDown();
- }
-
- public void testRedistNonPersistentNonRecoverable() throws Throwable
- {
- redistTest(false, false);
- }
-
- public void testRedistPersistentNonRecoverable() throws Throwable
- {
- redistTest(true, false);
- }
-
- public void testRedistNonPersistentRecoverable() throws Throwable
- {
- redistTest(false, true);
- }
-
- public void testRedistPersistentRecoverable() throws Throwable
- {
- redistTest(true, true);
- }
-
- public void redistTest(boolean persistent, boolean recoverable) throws Throwable
- {
- ClusteredPostOffice office1 = null;
-
- ClusteredPostOffice office2 = null;
-
- ClusteredPostOffice office3 = null;
-
- ClusteredPostOffice office4 = null;
-
- ClusteredPostOffice office5 = null;
-
- try
- {
- office1 = createClusteredPostOffice(1, "testgroup");
-
- office2 = createClusteredPostOffice(2, "testgroup");
-
- office3 = createClusteredPostOffice(3, "testgroup");
-
- office4 = createClusteredPostOffice(4, "testgroup");
-
- office5 = createClusteredPostOffice(5, "testgroup");
-
- log.info("Started offices");
-
- LocalClusteredQueue queue1 = new LocalClusteredQueue(office1, 1, "queue1", channelIdManager.getId(), ms, pm, true, recoverable, (QueuedExecutor)pool.get(), null, tr);
- Binding binding1 = office1.bindClusteredQueue("queue1", queue1);
-
- LocalClusteredQueue queue2 = new LocalClusteredQueue(office2, 2, "queue1", channelIdManager.getId(), ms, pm, true, recoverable, (QueuedExecutor)pool.get(), null, tr);
- Binding binding2 = office2.bindClusteredQueue("queue1", queue2);
-
- LocalClusteredQueue queue3 = new LocalClusteredQueue(office3, 3, "queue1", channelIdManager.getId(), ms, pm, true, recoverable, (QueuedExecutor)pool.get(), null, tr);
- Binding binding3 = office3.bindClusteredQueue("queue1", queue3);
-
- LocalClusteredQueue queue4 = new LocalClusteredQueue(office4, 4, "queue1", channelIdManager.getId(), ms, pm, true, recoverable, (QueuedExecutor)pool.get(), null, tr);
- Binding binding4 = office4.bindClusteredQueue("queue1", queue4);
-
- LocalClusteredQueue queue5 = new LocalClusteredQueue(office5, 5, "queue1", channelIdManager.getId(), ms, pm, true, recoverable, (QueuedExecutor)pool.get(), null, tr);
- Binding binding5 = office5.bindClusteredQueue("queue1", queue5);
-
- log.info("bound queues");
-
- //Send 30 messages to each queue
- this.sendMessages("queue1", persistent, office1, 30, null);
- this.sendMessages("queue1", persistent, office2, 30, null);
- this.sendMessages("queue1", persistent, office3, 30, null);
- this.sendMessages("queue1", persistent, office4, 30, null);
- this.sendMessages("queue1", persistent, office5, 30, null);
-
- log.info("sent messages");
-
- Thread.sleep(1000);
-
- //Check the sizes
-
- assertEquals(30, queue1.memoryRefCount());
- assertEquals(0, queue1.memoryDeliveryCount());
-
- assertEquals(30, queue2.memoryRefCount());
- assertEquals(0, queue2.memoryDeliveryCount());
-
- assertEquals(30, queue3.memoryRefCount());
- assertEquals(0, queue3.memoryDeliveryCount());
-
- assertEquals(30, queue4.memoryRefCount());
- assertEquals(0, queue4.memoryDeliveryCount());
-
- assertEquals(30, queue5.memoryRefCount());
- assertEquals(0, queue5.memoryDeliveryCount());
-
- //Now we add the receivers
- //Note that we did not do this before the send.
- //If we had done so then it's likely that the automatic redistribution
- //would have moved some around and there wouldn't be 30 in each queue
-
- PullingReceiver receiver1 = new PullingReceiver();
- queue1.add(receiver1);
-
- PullingReceiver receiver2 = new PullingReceiver();
- queue2.add(receiver2);
-
- PullingReceiver receiver3 = new PullingReceiver();
- queue3.add(receiver3);
-
- PullingReceiver receiver4 = new PullingReceiver();
- queue4.add(receiver4);
-
- PullingReceiver receiver5 = new PullingReceiver();
- queue5.add(receiver5);
-
- log.info("Added receivers");
-
- //Prompt delivery so a message pops into each receiver
- queue1.deliver(true);
- queue2.deliver(true);
- queue3.deliver(true);
- queue4.deliver(true);
- queue5.deliver(true);
-
- Thread.sleep(1000);
-
- //Now we check the sizes again in case automatic balancing has erroneously
- //kicked in
-
- assertEquals(29, queue1.memoryRefCount());
- assertEquals(1, queue1.memoryDeliveryCount());
-
- assertEquals(29, queue2.memoryRefCount());
- assertEquals(1, queue2.memoryDeliveryCount());
-
- assertEquals(29, queue3.memoryRefCount());
- assertEquals(1, queue3.memoryDeliveryCount());
-
- assertEquals(29, queue4.memoryRefCount());
- assertEquals(1, queue4.memoryDeliveryCount());
-
- assertEquals(29, queue5.memoryRefCount());
- assertEquals(1, queue5.memoryDeliveryCount());
-
- Thread.sleep(5000);
-
- //And again - should still be no redistribution
-
- assertEquals(29, queue1.memoryRefCount());
- assertEquals(1, queue1.memoryDeliveryCount());
-
- assertEquals(29, queue2.memoryRefCount());
- assertEquals(1, queue2.memoryDeliveryCount());
-
- assertEquals(29, queue3.memoryRefCount());
- assertEquals(1, queue3.memoryDeliveryCount());
-
- assertEquals(29, queue4.memoryRefCount());
- assertEquals(1, queue4.memoryDeliveryCount());
-
- assertEquals(29, queue5.memoryRefCount());
- assertEquals(1, queue5.memoryDeliveryCount());
-
- Thread.sleep(2000);
-
- log.info("Here are the sizes:");
- log.info("queue1, refs:" + queue1.memoryRefCount() + " dels:" + queue1.memoryDeliveryCount());
- log.info("queue2, refs:" + queue2.memoryRefCount() + " dels:" + queue2.memoryDeliveryCount());
- log.info("queue3, refs:" + queue3.memoryRefCount() + " dels:" + queue3.memoryDeliveryCount());
- log.info("queue4, refs:" + queue4.memoryRefCount() + " dels:" + queue4.memoryDeliveryCount());
- log.info("queue5, refs:" + queue5.memoryRefCount() + " dels:" + queue5.memoryDeliveryCount());
-
- log.info("trying to consume");
-
- //So we have 150 messages in total - 30 on each node.
-
- //If redistribution works ok, we should be able to do something like the following:
-
- //Consume 10 on node 1
-
- //Consume 50 on node 2
-
- //Consume 75 on node 3
-
- //Consume 10 on node 4
-
- //We leave the last 5 since they will be as deliveries in the receivers probably
-
- Delivery del;
-
- log.info("consuming queue1");
- for (int i = 0; i < 10; i++)
- {
- queue1.deliver(true);
- del = receiver1.getDelivery();
- log.info("Got delivery: " + del.getReference().getMessageID());
- del.acknowledge(null);
- }
- log.info("consumed queue1");
-
- log.info("Here are the sizes:");
-
- log.info("queue1, refs:" + queue1.memoryRefCount() + " dels:" + queue1.memoryDeliveryCount());
- log.info("queue2, refs:" + queue2.memoryRefCount() + " dels:" + queue2.memoryDeliveryCount());
- log.info("queue3, refs:" + queue3.memoryRefCount() + " dels:" + queue3.memoryDeliveryCount());
- log.info("queue4, refs:" + queue4.memoryRefCount() + " dels:" + queue4.memoryDeliveryCount());
- log.info("queue5, refs:" + queue5.memoryRefCount() + " dels:" + queue5.memoryDeliveryCount());
-
- log.info("consuming queue2");
- for (int i = 0; i < 50; i++)
- {
- queue2.deliver(true);
- del = receiver2.getDelivery();
- log.info("Got delivery: " + del.getReference().getMessageID());
- del.acknowledge(null);
- }
- log.info("consumed queue2");
-
- log.info("Here are the sizes:");
- log.info("queue1, refs:" + queue1.memoryRefCount() + " dels:" + queue1.memoryDeliveryCount());
- log.info("queue2, refs:" + queue2.memoryRefCount() + " dels:" + queue2.memoryDeliveryCount());
- log.info("queue3, refs:" + queue3.memoryRefCount() + " dels:" + queue3.memoryDeliveryCount());
- log.info("queue4, refs:" + queue4.memoryRefCount() + " dels:" + queue4.memoryDeliveryCount());
- log.info("queue5, refs:" + queue5.memoryRefCount() + " dels:" + queue5.memoryDeliveryCount());
-
- log.info("consuming queue3");
- for (int i = 0; i < 75; i++)
- {
- queue3.deliver(true);
- del = receiver3.getDelivery();
- log.info("Got delivery: " + del.getReference().getMessageID());
- del.acknowledge(null);
- }
- log.info("consumed queue3");
-
- log.info("Here are the sizes:");
- log.info("queue1, refs:" + queue1.memoryRefCount() + " dels:" + queue1.memoryDeliveryCount());
- log.info("queue2, refs:" + queue2.memoryRefCount() + " dels:" + queue2.memoryDeliveryCount());
- log.info("queue3, refs:" + queue3.memoryRefCount() + " dels:" + queue3.memoryDeliveryCount());
- log.info("queue4, refs:" + queue4.memoryRefCount() + " dels:" + queue4.memoryDeliveryCount());
- log.info("queue5, refs:" + queue5.memoryRefCount() + " dels:" + queue5.memoryDeliveryCount());
-
- log.info("consuming queue4");
- for (int i = 0; i < 10; i++)
- {
- queue4.deliver(true);
- del = receiver4.getDelivery();
- log.info("Got delivery: " + del.getReference().getMessageID());
- del.acknowledge(null);
- }
- log.info("consumed queue4");
-
- log.info("Here are the sizes:");
- log.info("queue1, refs:" + queue1.memoryRefCount() + " dels:" + queue1.memoryDeliveryCount());
- log.info("queue2, refs:" + queue2.memoryRefCount() + " dels:" + queue2.memoryDeliveryCount());
- log.info("queue3, refs:" + queue3.memoryRefCount() + " dels:" + queue3.memoryDeliveryCount());
- log.info("queue4, refs:" + queue4.memoryRefCount() + " dels:" + queue4.memoryDeliveryCount());
- log.info("queue5, refs:" + queue5.memoryRefCount() + " dels:" + queue5.memoryDeliveryCount());
-
- }
- finally
- {
- if (office1 != null)
- {
- office1.stop();
- }
-
- if (office2 != null)
- {
- office2.stop();
- }
-
- if (office3 != null)
- {
- office3.stop();
- }
-
- if (office4 != null)
- {
- office4.stop();
- }
-
- if (office5 != null)
- {
- office5.stop();
- }
- }
- }
-
- class PullingReceiver implements Receiver
- {
- private Delivery del;
-
- public synchronized Delivery handle(DeliveryObserver observer, MessageReference reference, Transaction tx)
- {
- if (del != null)
- {
- return null;
- }
-
- del = new SimpleDelivery(observer, reference, false);
-
- this.notify();
-
- return del;
- }
-
- public synchronized Delivery getDelivery()
- {
- while (del == null)
- {
- try
- {
- this.wait();
- }
- catch (InterruptedException e)
- {
- }
- }
- Delivery ret = del;
- del = null;
- return ret;
- }
-
- }
-
- protected ClusteredPostOffice createClusteredPostOffice(int nodeId, String groupName) throws Exception
- {
- MessagePullPolicy pullPolicy = new DefaultMessagePullPolicy();
-
- FilterFactory ff = new SimpleFilterFactory();
-
- ClusterRouterFactory rf = new DefaultRouterFactory();
-
- DefaultClusteredPostOffice postOffice =
- new DefaultClusteredPostOffice(sc.getDataSource(), sc.getTransactionManager(),
- null, true, nodeId, "Clustered", ms, pm, tr, ff, pool,
- groupName,
- JGroupsUtil.getControlStackProperties(),
- JGroupsUtil.getDataStackProperties(),
- 5000, 5000, pullPolicy, rf, 1, 1000);
-
- postOffice.start();
-
- return postOffice;
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
-
-
-
Copied: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/RedistributionWithDefaultMessagePullPolicyTest.java (from rev 1517, trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/RedistributionWithDefaultMessagePullPolicyTest.java)
Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/BrowserTest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/BrowserTest.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/BrowserTest.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -100,8 +100,7 @@
{
ServerManagement.undeployQueue("Queue");
- connection.stop();
- connection = null;
+ connection.close();
super.tearDown();
}
Deleted: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/ManualClusteringTest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/ManualClusteringTest.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/ManualClusteringTest.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -1,995 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.messaging.jms;
-
-import java.util.Properties;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-
-import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.jms.client.JBossConnection;
-
-/**
- *
- * A ManualClusteringTest
- *
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- *
- * @version <tt>$Revision: 1.1 $</tt>
- *
- * $Id$
- *
- */
-public class ManualClusteringTest extends MessagingTestCase
-{
- protected Context ic1;
-
- protected Context ic2;
-
- protected Context ic3;
-
- protected Queue queue1;
-
- protected Topic topic1;
-
- protected Queue queue2;
-
- protected Topic topic2;
-
- protected Queue queue3;
-
- protected Topic topic3;
-
- protected ConnectionFactory cf1;
-
- protected ConnectionFactory cf2;
-
- protected ConnectionFactory cf3;
-
- public ManualClusteringTest(String name)
- {
- super(name);
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- Properties props1 = new Properties();
-
- props1.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
- props1.put(Context.PROVIDER_URL, "jnp://localhost:1199");
- props1.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
-
- ic1 = new InitialContext(props1);
-
- Properties props2 = new Properties();
-
- props2.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
- props2.put(Context.PROVIDER_URL, "jnp://localhost:1299");
- props2.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
-
- ic2 = new InitialContext(props2);
-
-// Properties props3 = new Properties();
-//
-// props3.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
-// props3.put(Context.PROVIDER_URL, "jnp://localhost:1399");
-// props3.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
-//
-// ic3 = new InitialContext(props3);
-
- queue1 = (Queue)ic1.lookup("queue/testDistributedQueue");
-
- queue2 = (Queue)ic2.lookup("queue/testDistributedQueue");
-
- //queue3 = (Queue)ic3.lookup("queue/ClusteredQueue1");
-
- topic1 = (Topic)ic1.lookup("topic/testDistributedTopic");
-
- topic2 = (Topic)ic2.lookup("topic/testDistributedTopic");
-
- //topic3 = (Topic)ic3.lookup("topic/ClusteredTopic1");
-
- cf1 = (ConnectionFactory)ic1.lookup("/ConnectionFactory");
-
- cf2 = (ConnectionFactory)ic2.lookup("/ConnectionFactory");
-
- //cf3 = (ConnectionFactory)ic3.lookup("/ConnectionFactory");
-
- log.info("setup done");
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
-
- ic1.close();
-
- ic2.close();
- }
-
- /*
- * Each node had consumers, send message at node, make sure local consumer gets message
- */
- public void testClusteredQueueLocalConsumerNonPersistent() throws Exception
- {
- log.info("starting test");
-
- Connection conn1 = null;
-
- Connection conn2 = null;
- try
- {
- conn1 = cf1.createConnection();
-
- conn2 = cf2.createConnection();
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons1 = sess1.createConsumer(queue1);
-
- MessageConsumer cons2 = sess2.createConsumer(queue2);
-
- conn1.start();
-
- conn2.start();
-
- MessageProducer prod1 = sess1.createProducer(queue1);
-
- prod1.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
- final int NUM_MESSAGES = 100;
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sess1.createTextMessage("message" + i);
-
- prod1.send(tm);
- }
-
- log.info("sent messages");
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- log.info("i is " + i);
-
- TextMessage tm = (TextMessage)cons1.receive(1000);
-
- assertNotNull(tm);
-
- log.info("Got message:" + tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- Message m = cons2.receive(2000);
-
- assertNull(m);
- }
- finally
- {
- try
- {
- if (conn1 != null) conn1.close();
-
- if (conn2 != null) conn2.close();
- }
- catch (Exception ignore)
- {
-
- }
- }
- }
-
- public void testClusteredQueueLocalConsumerPersistent() throws Exception
- {
- Connection conn1 = null;
-
- Connection conn2 = null;
- try
- {
- conn1 = cf1.createConnection();
-
- conn2 = cf2.createConnection();
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons1 = sess1.createConsumer(queue1);
-
- MessageConsumer cons2 = sess2.createConsumer(queue2);
-
- conn1.start();
-
- conn2.start();
-
- MessageProducer prod1 = sess1.createProducer(queue1);
-
- prod1.setDeliveryMode(DeliveryMode.PERSISTENT);
-
- final int NUM_MESSAGES = 100;
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sess1.createTextMessage("message" + i);
-
- prod1.send(tm);
- }
-
- log.info("sent messages");
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- log.info("i is " + i);
-
- TextMessage tm = (TextMessage)cons1.receive(1000);
-
- assertNotNull(tm);
-
- log.info("Got message:" + tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- Message m = cons2.receive(2000);
-
- assertNull(m);
- }
- finally
- {
- try
- {
- if (conn1 != null) conn1.close();
-
- if (conn2 != null) conn2.close();
- }
- catch (Exception ignore)
- {
-
- }
- }
- }
-
-// /*
-// * No consumer on local node, send message at node, make sure remote consumer gets messages
-// */
-// public void testClusteredQueueNoLocalConsumerNonPersistent() throws Exception
-// {
-// Connection conn1 = null;
-//
-// Connection conn2 = null;
-// try
-// {
-// conn1 = cf1.createConnection();
-//
-// conn2 = cf2.createConnection();
-//
-// Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-//
-// Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-//
-// MessageConsumer cons2 = sess2.createConsumer(queue2);
-//
-// conn1.start();
-//
-// conn2.start();
-//
-// MessageProducer prod1 = sess1.createProducer(queue1);
-//
-// prod1.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-//
-// final int NUM_MESSAGES = 100;
-//
-// for (int i = 0; i < NUM_MESSAGES; i++)
-// {
-// TextMessage tm = sess1.createTextMessage("message" + i);
-//
-// prod1.send(tm);
-// }
-//
-// log.info("sent messages");
-//
-// for (int i = 0; i < NUM_MESSAGES; i++)
-// {
-// log.info("i is " + i);
-//
-// TextMessage tm = (TextMessage)cons2.receive(10000);
-//
-// assertNotNull(tm);
-//
-// log.info("Got message:" + tm);
-//
-// assertEquals("message" + i, tm.getText());
-// }
-//
-// }
-// finally
-// {
-// try
-// {
-// if (conn1 != null) conn1.close();
-//
-// if (conn2 != null) conn2.close();
-// }
-// catch (Exception ignore)
-// {
-//
-// }
-// }
-// }
-//
-//
-//
-// public void testClusteredQueueNoLocalConsumerPersistent() throws Exception
-// {
-// Connection conn1 = null;
-//
-// Connection conn2 = null;
-// try
-// {
-// conn1 = cf1.createConnection();
-//
-// conn2 = cf2.createConnection();
-//
-// Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-//
-// Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-//
-// MessageConsumer cons2 = sess2.createConsumer(queue2);
-//
-// conn1.start();
-//
-// conn2.start();
-//
-// MessageProducer prod1 = sess1.createProducer(queue1);
-//
-// prod1.setDeliveryMode(DeliveryMode.PERSISTENT);
-//
-// final int NUM_MESSAGES = 100;
-//
-// for (int i = 0; i < NUM_MESSAGES; i++)
-// {
-// TextMessage tm = sess1.createTextMessage("message" + i);
-//
-// prod1.send(tm);
-// }
-//
-// log.info("sent messages");
-//
-// for (int i = 0; i < NUM_MESSAGES; i++)
-// {
-// log.info("i is " + i);
-//
-// TextMessage tm = (TextMessage)cons2.receive(1000);
-//
-// assertNotNull(tm);
-//
-// log.info("Got message:" + tm);
-//
-// assertEquals("message" + i, tm.getText());
-// }
-//
-// }
-// finally
-// {
-// try
-// {
-// if (conn1 != null) conn1.close();
-//
-// if (conn2 != null) conn2.close();
-// }
-// catch (Exception ignore)
-// {
-//
-// }
-// }
-// }
-//
-
- public void testClusteredTopicNonDurableNonPersistent() throws Exception
- {
- Connection conn1 = null;
-
- Connection conn2 = null;
- try
- {
- conn1 = cf1.createConnection();
-
- conn2 = cf2.createConnection();
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons1 = sess1.createConsumer(topic1);
-
- MessageConsumer cons2 = sess2.createConsumer(topic2);
-
- conn1.start();
-
- conn2.start();
-
- MessageProducer prod1 = sess1.createProducer(topic1);
-
- prod1.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
- final int NUM_MESSAGES = 100;
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sess1.createTextMessage("message" + i);
-
- prod1.send(tm);
- }
-
- log.info("sent messages");
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- log.info("i is " + i);
-
- TextMessage tm = (TextMessage)cons1.receive(1000);
-
- assertNotNull(tm);
-
- log.info("Got message:" + tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- log.info("i is " + i);
-
- TextMessage tm = (TextMessage)cons2.receive(1000);
-
- assertNotNull(tm);
-
- log.info("Got message:" + tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
-
- }
- finally
- {
- try
- {
- if (conn1 != null) conn1.close();
-
- if (conn2 != null) conn2.close();
- }
- catch (Exception ignore)
- {
-
- }
- }
- }
-
-
- public void testClusteredTopicNonDurablePersistent() throws Exception
- {
- Connection conn1 = null;
-
- Connection conn2 = null;
- try
- {
- conn1 = cf1.createConnection();
-
- conn2 = cf2.createConnection();
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons1 = sess1.createConsumer(topic1);
-
- MessageConsumer cons2 = sess2.createConsumer(topic2);
-
- conn1.start();
-
- conn2.start();
-
- MessageProducer prod1 = sess1.createProducer(topic1);
-
- prod1.setDeliveryMode(DeliveryMode.PERSISTENT);
-
- final int NUM_MESSAGES = 100;
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sess1.createTextMessage("message" + i);
-
- prod1.send(tm);
- }
-
- log.info("sent messages");
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- log.info("i is " + i);
-
- TextMessage tm = (TextMessage)cons1.receive(1000);
-
- assertNotNull(tm);
-
- log.info("Got message:" + tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- log.info("i is " + i);
-
- TextMessage tm = (TextMessage)cons2.receive(1000);
-
- assertNotNull(tm);
-
- log.info("Got message:" + tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
-
- }
- finally
- {
- try
- {
- if (conn1 != null) conn1.close();
-
- if (conn2 != null) conn2.close();
- }
- catch (Exception ignore)
- {
-
- }
- }
- }
-
-
- public void testClusteredTopicDurableNonPersistentLocal() throws Exception
- {
- Connection conn1 = null;
-
- Connection conn2 = null;
- try
- {
- conn1 = cf1.createConnection();
-
- conn1.setClientID("id1");
-
- conn2 = cf2.createConnection();
-
- conn2.setClientID("id1");
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer durable1 = sess1.createDurableSubscriber(topic1, "sub1");
-
- MessageConsumer durable2 = sess2.createDurableSubscriber(topic2, "sub1");
-
- conn1.start();
-
- conn2.start();
-
- MessageProducer prod1 = sess1.createProducer(topic1);
-
- prod1.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
- final int NUM_MESSAGES = 100;
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sess1.createTextMessage("message" + i);
-
- prod1.send(tm);
- }
-
- log.info("sent messages");
-
- //All the messages should be on the local sub
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- log.info("i is " + i);
-
- TextMessage tm = (TextMessage)durable1.receive(1000);
-
- assertNotNull(tm);
-
- log.info("Got message:" + tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- Message m = durable2.receive(2000);
-
- assertNull(m);
-
- durable1.close();
-
- durable2.close();
-
- sess1.unsubscribe("sub1");
-
- sess2.unsubscribe("sub1");
-
- }
- finally
- {
- try
- {
- if (conn1 != null) conn1.close();
-
- if (conn2 != null) conn2.close();
- }
- catch (Exception ignore)
- {
-
- }
- }
- }
-
- public void testClusteredTopicDurablePersistentLocal() throws Exception
- {
- Connection conn1 = null;
-
- Connection conn2 = null;
- try
- {
- conn1 = cf1.createConnection();
-
- conn1.setClientID("id1");
-
- conn2 = cf2.createConnection();
-
- conn2.setClientID("id1");
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- try
- {
- sess1.unsubscribe("sub1");
-
- sess2.unsubscribe("sub1");
- }
- catch (Exception ignore)
- {
- }
-
- MessageConsumer durable1 = sess1.createDurableSubscriber(topic1, "sub1");
-
- MessageConsumer durable2 = sess2.createDurableSubscriber(topic2, "sub1");
-
- conn1.start();
-
- conn2.start();
-
- MessageProducer prod1 = sess1.createProducer(topic1);
-
- prod1.setDeliveryMode(DeliveryMode.PERSISTENT);
-
- final int NUM_MESSAGES = 100;
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sess1.createTextMessage("message" + i);
-
- prod1.send(tm);
- }
-
- log.info("sent messages");
-
- //All the messages should be on the local sub
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- log.info("i is " + i);
-
- TextMessage tm = (TextMessage)durable1.receive(1000);
-
- assertNotNull(tm);
-
- log.info("Got message:" + tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- Message m = durable2.receive(2000);
-
- assertNull(m);
-
- sess1.unsubscribe("sub1");
-
- sess2.unsubscribe("sub1");
-
- }
- finally
- {
- try
- {
- if (conn1 != null) conn1.close();
-
- if (conn2 != null) conn2.close();
- }
- catch (Exception ignore)
- {
-
- }
- }
- }
-
-
- public void testClusteredTopicDurableNonPersistentNotLocal() throws Exception
- {
- Connection conn1 = null;
-
- Connection conn2 = null;
- try
- {
- conn1 = cf1.createConnection();
-
- conn1.setClientID("id1");
-
- conn2 = cf2.createConnection();
-
- conn2.setClientID("id1");
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer durable2 = sess2.createDurableSubscriber(topic2, "sub1");
-
- conn1.start();
-
- conn2.start();
-
- MessageProducer prod1 = sess1.createProducer(topic1);
-
- prod1.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
- final int NUM_MESSAGES = 100;
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sess1.createTextMessage("message" + i);
-
- prod1.send(tm);
- }
-
- log.info("sent messages");
-
- //All the messages should be on the non local sub
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- log.info("i is " + i);
-
- TextMessage tm = (TextMessage)durable2.receive(1000);
-
- assertNotNull(tm);
-
- log.info("Got message:" + tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- durable2.close();
-
- sess2.unsubscribe("sub1");
-
- }
- finally
- {
- try
- {
- if (conn1 != null) conn1.close();
-
- if (conn2 != null) conn2.close();
- }
- catch (Exception ignore)
- {
-
- }
- }
- }
-
- public void testClusteredTopicDurablePersistentNotLocal() throws Exception
- {
- Connection conn1 = null;
-
- Connection conn2 = null;
- try
- {
- conn1 = cf1.createConnection();
-
- conn1.setClientID("id1");
-
- conn2 = cf2.createConnection();
-
- conn2.setClientID("id1");
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer durable2 = sess2.createDurableSubscriber(topic2, "sub1");
-
- conn1.start();
-
- conn2.start();
-
- MessageProducer prod1 = sess1.createProducer(topic1);
-
- prod1.setDeliveryMode(DeliveryMode.PERSISTENT);
-
- final int NUM_MESSAGES = 100;
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sess1.createTextMessage("message" + i);
-
- prod1.send(tm);
- }
-
- log.info("sent messages");
-
- //All the messages should be on the non local sub
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- log.info("i is " + i);
-
- TextMessage tm = (TextMessage)durable2.receive(1000);
-
- assertNotNull(tm);
-
- log.info("Got message:" + tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- durable2.close();
-
- sess2.unsubscribe("sub1");
-
- }
- finally
- {
- try
- {
- if (conn1 != null) conn1.close();
-
- if (conn2 != null) conn2.close();
- }
- catch (Exception ignore)
- {
-
- }
- }
- }
-
- public void testSimpleFailover() throws Exception
- {
-
- Connection conn = null;
- Connection conn2 = null;
-
- try
- {
- // Create a consumer on a distributed queue
-
- conn = cf1.createConnection();
- conn.setClientID("cid");
-
- Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer c = s.createConsumer(queue1);
-
- conn.start();
-
- // Fail it over
-
- // Create by hand the "failover" connection
- Connection failOverConn = cf2.createConnection();
- ((JBossConnection)conn).getDelegate().
- failOver(((JBossConnection)failOverConn).getDelegate());
-
- // Send a message to the distributed queue, specifically on the "valid" node.
-
- conn2 = cf2.createConnection();
- Session s2 = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer p = s2.createProducer(queue1);
- p.send(s2.createTextMessage("test0"));
-
- // I should be able to receive the message using the first connection
-
- TextMessage tm = (TextMessage)c.receive(2000);
- assertEquals("test0", tm.getText());
-
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
-
- if (conn2 != null)
- {
- conn2.close();
- }
- }
- }
-
-
- class MyListener implements MessageListener
- {
- private int i;
-
- MyListener(int i)
- {
- this.i = i;
- }
-
- public void onMessage(Message m)
- {
- try
- {
- int count = m.getIntProperty("count");
-
- log.info("Listener " + i + " received message " + count);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- }
-
-}
Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/MessageConsumerTest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/MessageConsumerTest.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/MessageConsumerTest.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -1786,12 +1786,12 @@
{
try
{
- log.info("(ThreadCloser)Waiting on monitor to close thread");
+ log.trace("(ThreadCloser)Waiting on monitor to close thread");
synchronized (waitMonitor)
{
waitMonitor.wait();
}
- log.info("(ThreadCloser)Notification received");
+ log.trace("(ThreadCloser)Notification received");
Thread.sleep(timeToSleep);
topicConsumer.close();
@@ -1824,12 +1824,12 @@
{
try
{
- log.info("(ThreadReceiver)Waiting on monitor to close thread");
+ log.trace("(ThreadReceiver)Waiting on monitor to close thread");
synchronized(waitMonitor)
{
waitMonitor.wait();
}
- log.info("(ThreadReceiver)Notification received");
+ log.trace("(ThreadReceiver)Notification received");
t1=System.currentTimeMillis();
receivedObject=topicConsumer.receive(timeToWait);
t2=System.currentTimeMillis();
@@ -1868,7 +1868,7 @@
assertNull(receiver.receivedObject);
- log.info("Elapsed time was " + (receiver.t2-receiver.t1));
+ log.trace("Elapsed time was " + (receiver.t2-receiver.t1));
// We need to make sure the
assertTrue("Receive was supposed to receive a notification before 2 seconds",receiver.t2-receiver.t1<=1500);
Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/TransactedSessionTest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/TransactedSessionTest.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/TransactedSessionTest.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -573,6 +573,8 @@
TextMessage tm = (TextMessage)cons.receive();
assertEquals("a message", tm.getText());
+
+ log.info("del count1:" + tm.getIntProperty("JMSXDeliveryCount"));
assertFalse(tm.getJMSRedelivered());
assertEquals(1, tm.getIntProperty("JMSXDeliveryCount"));
@@ -587,6 +589,8 @@
tm = (TextMessage)cons.receive();
assertEquals("a message", tm.getText());
+
+ log.info("del count2:" + tm.getIntProperty("JMSXDeliveryCount"));
assertTrue(tm.getJMSRedelivered());
assertEquals(2, tm.getIntProperty("JMSXDeliveryCount"));
Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/crash/ManualCrashTest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/crash/ManualCrashTest.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/crash/ManualCrashTest.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -173,8 +173,6 @@
assertEquals(count, c);
- log.info("Received message:" + count);
-
count++;
if (count == i)
Copied: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/manual (from rev 1517, trunk/tests/src/org/jboss/test/messaging/jms/manual)
Deleted: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/manual/ManualClusteringTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/manual/ManualClusteringTest.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/manual/ManualClusteringTest.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -1,1297 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.messaging.jms.manual;
-
-import java.util.Properties;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-
-import org.jboss.test.messaging.MessagingTestCase;
-
-/**
- *
- * A ManualClusteringTest
- *
- * Nodes must be started up in order node1, node2, node3
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 1.1 $</tt>
- *
- * $Id$
- *
- */
-public class ManualClusteringTest extends MessagingTestCase
-{
- protected Context ic1;
-
- protected Context ic2;
-
- protected Context ic3;
-
- protected Queue queue1;
-
- protected Topic topic1;
-
- protected Queue queue2;
-
- protected Topic topic2;
-
- protected Queue queue3;
-
- protected Topic topic3;
-
- protected ConnectionFactory cf1;
-
- protected ConnectionFactory cf2;
-
- protected ConnectionFactory cf3;
-
- public ManualClusteringTest(String name)
- {
- super(name);
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- Properties props1 = new Properties();
-
- props1.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
- props1.put(Context.PROVIDER_URL, "jnp://localhost:1199");
- props1.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
-
- ic1 = new InitialContext(props1);
-
- Properties props2 = new Properties();
-
- props2.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
- props2.put(Context.PROVIDER_URL, "jnp://localhost:1299");
- props2.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
-
- ic2 = new InitialContext(props2);
-
- Properties props3 = new Properties();
-
- props3.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
- props3.put(Context.PROVIDER_URL, "jnp://localhost:1399");
- props3.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
-
- ic3 = new InitialContext(props3);
-
- queue1 = (Queue)ic1.lookup("queue/testDistributedQueue");
-
- queue2 = (Queue)ic2.lookup("queue/testDistributedQueue");
-
- queue3 = (Queue)ic3.lookup("queue/testDistributedQueue");
-
- topic1 = (Topic)ic1.lookup("topic/testDistributedTopic");
-
- topic2 = (Topic)ic2.lookup("topic/testDistributedTopic");
-
- topic3 = (Topic)ic3.lookup("topic/testDistributedTopic");
-
- cf1 = (ConnectionFactory)ic1.lookup("/ConnectionFactory");
-
- cf2 = (ConnectionFactory)ic2.lookup("/ConnectionFactory");
-
- cf3 = (ConnectionFactory)ic3.lookup("/ConnectionFactory");
-
- drainStuff();
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
-
- ic1.close();
-
- ic2.close();
- }
-
- protected void drainStuff() throws Exception
- {
- Connection conn1 = null;
-
- Connection conn2 = null;
-
- Connection conn3 = null;
-
- try
- {
- conn1 = cf1.createConnection();
-
- conn2 = cf2.createConnection();
-
- conn3 = cf3.createConnection();
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons1 = sess1.createConsumer(queue1);
-
- MessageConsumer cons2 = sess2.createConsumer(queue2);
-
- MessageConsumer cons3 = sess3.createConsumer(queue2);
-
- conn1.start();
-
- conn2.start();
-
- conn3.start();
-
- Message msg = null;
-
- do
- {
- msg = cons1.receive(1000);
- }
- while (msg != null);
-
- do
- {
- msg = cons2.receive(1000);
- }
- while (msg != null);
-
- do
- {
- msg = cons3.receive(1000);
- }
- while (msg != null);
- }
- finally
- {
- if (conn1 != null) conn1.close();
-
- if (conn2 != null) conn2.close();
-
- if (conn3 != null) conn3.close();
- }
- }
-
- public void testClusteredQueueLocalConsumerNonPersistent() throws Exception
- {
- clusteredQueueLocalConsumer(false);
- }
-
- public void testClusteredQueueLocalConsumerPersistent() throws Exception
- {
- clusteredQueueLocalConsumer(true);
- }
-
- public void testClusteredQueueNoLocalConsumerNonPersistent() throws Exception
- {
- clusteredQueueNoLocalConsumer(false);
- }
-
- public void testClusteredQueueNoLocalConsumerPersistent() throws Exception
- {
- clusteredQueueNoLocalConsumer(true);
- }
-
-
- public void testClusteredTopicNonDurableNonPersistent() throws Exception
- {
- clusteredTopicNonDurable(false);
- }
-
- public void testClusteredTopicNonDurablePersistent() throws Exception
- {
- clusteredTopicNonDurable(true);
- }
-
-
- public void testClusteredTopicNonDurableWithSelectorsNonPersistent() throws Exception
- {
- clusteredTopicNonDurableWithSelectors(false);
- }
-
- public void testClusteredTopicNonDurableWithSelectorsPersistent() throws Exception
- {
- clusteredTopicNonDurableWithSelectors(true);
- }
-
- public void testClusteredTopicDurableNonPersistent() throws Exception
- {
- clusteredTopicDurable(false);
- }
-
- public void testClusteredTopicDurablePersistent() throws Exception
- {
- clusteredTopicDurable(true);
- }
-
- public void testClusteredTopicSharedDurableLocalConsumerNonPersistent() throws Exception
- {
- clusteredTopicSharedDurableLocalConsumer(false);
- }
-
- public void testClusteredTopicSharedDurableLocalConsumerPersistent() throws Exception
- {
- clusteredTopicSharedDurableLocalConsumer(true);
- }
-
- public void testClusteredTopicSharedDurableNoLocalConsumerNonPersistent() throws Exception
- {
- clusteredTopicSharedDurableNoLocalConsumer(false);
- }
-
- public void testClusteredTopicSharedDurableNoLocalConsumerPersistent() throws Exception
- {
- clusteredTopicSharedDurableNoLocalConsumer(true);
- }
-
- public void testClusteredTopicSharedDurableNoLocalSubNonPersistent() throws Exception
- {
- clusteredTopicSharedDurableNoLocalSub(false);
- }
-
- public void testClusteredTopicSharedDurableNoLocalSubPersistent() throws Exception
- {
- clusteredTopicSharedDurableNoLocalSub(true);
- }
-
-
-
-
- /*
- * Create a consumer on each queue on each node.
- * Send messages in turn from all nodes.
- * Ensure that the local consumer gets the message
- */
- protected void clusteredQueueLocalConsumer(boolean persistent) throws Exception
- {
- Connection conn1 = null;
-
- Connection conn2 = null;
-
- Connection conn3 = null;
- try
- {
- conn1 = cf1.createConnection();
-
- conn2 = cf2.createConnection();
-
- conn3 = cf3.createConnection();
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons1 = sess1.createConsumer(queue1);
-
- MessageConsumer cons2 = sess2.createConsumer(queue2);
-
- MessageConsumer cons3 = sess3.createConsumer(queue3);
-
- conn1.start();
-
- conn2.start();
-
- conn3.start();
-
- //Send at node1
-
- MessageProducer prod1 = sess1.createProducer(queue1);
-
- prod1.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-
- final int NUM_MESSAGES = 100;
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sess1.createTextMessage("message" + i);
-
- prod1.send(tm);
- }
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage)cons1.receive(1000);
-
- assertNotNull(tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- Message m = cons2.receive(2000);
-
- assertNull(m);
-
- m = cons3.receive(2000);
-
- assertNull(m);
-
- // Send at node2
-
- MessageProducer prod2 = sess2.createProducer(queue2);
-
- prod2.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sess2.createTextMessage("message" + i);
-
- prod2.send(tm);
- }
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage)cons2.receive(1000);
-
- assertNotNull(tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- m = cons1.receive(2000);
-
- assertNull(m);
-
- m = cons3.receive(2000);
-
- assertNull(m);
-
- // Send at node3
-
- MessageProducer prod3 = sess3.createProducer(queue3);
-
- prod3.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sess3.createTextMessage("message" + i);
-
- prod3.send(tm);
- }
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage)cons3.receive(1000);
-
- assertNotNull(tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- m = cons1.receive(2000);
-
- assertNull(m);
-
- m = cons2.receive(2000);
-
- assertNull(m);
- }
- finally
- {
- if (conn1 != null) conn1.close();
-
- if (conn2 != null) conn2.close();
-
- if (conn3 != null) conn3.close();
- }
- }
-
-
-
-
- /*
- * Create a consumer on two nodes out of three
- * Send messages from the third node
- * Ensure that the messages are received from the other two nodes in
- * round robin order.
- * (Note that this test depends on us using the default router which has
- * this round robin behaviour)
- */
- protected void clusteredQueueNoLocalConsumer(boolean persistent) throws Exception
- {
- Connection conn1 = null;
-
- Connection conn2 = null;
-
- Connection conn3 = null;
- try
- {
- conn1 = cf1.createConnection();
-
- conn2 = cf2.createConnection();
-
- conn3 = cf3.createConnection();
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons2 = sess2.createConsumer(queue2);
-
- MessageConsumer cons3 = sess3.createConsumer(queue3);
-
- conn2.start();
-
- conn3.start();
-
- //Send at node1
-
- MessageProducer prod1 = sess1.createProducer(queue1);
-
- prod1.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-
- final int NUM_MESSAGES = 100;
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sess1.createTextMessage("message" + i);
-
- prod1.send(tm);
- }
-
- for (int i = 0; i < NUM_MESSAGES / 2; i++)
- {
- TextMessage tm = (TextMessage)cons2.receive(1000);
-
- assertNotNull(tm);
-
- assertEquals("message" + i * 2, tm.getText());
- }
-
- for (int i = 0; i < NUM_MESSAGES / 2; i++)
- {
- TextMessage tm = (TextMessage)cons3.receive(1000);
-
- assertNotNull(tm);
-
- assertEquals("message" + (i * 2 + 1), tm.getText());
- }
-
- }
- finally
- {
- if (conn1 != null) conn1.close();
-
- if (conn2 != null) conn2.close();
-
- if (conn3 != null) conn3.close();
- }
- }
-
-
-
- /*
- * Create non durable subscriptions on all nodes of the cluster.
- * Ensure all messages are receive as appropriate
- */
- public void clusteredTopicNonDurable(boolean persistent) throws Exception
- {
- Connection conn1 = null;
-
- Connection conn2 = null;
-
- Connection conn3 = null;
- try
- {
- conn1 = cf1.createConnection();
-
- conn2 = cf2.createConnection();
-
- conn3 = cf3.createConnection();
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons1 = sess1.createConsumer(topic1);
-
- MessageConsumer cons2 = sess2.createConsumer(topic2);
-
- MessageConsumer cons3 = sess3.createConsumer(topic3);
-
- MessageConsumer cons4 = sess1.createConsumer(topic1);
-
- MessageConsumer cons5 = sess2.createConsumer(topic2);
-
- conn1.start();
-
- conn2.start();
-
- conn3.start();
-
- //Send at node1
-
- MessageProducer prod1 = sess1.createProducer(topic1);
-
- prod1.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-
- final int NUM_MESSAGES = 100;
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sess1.createTextMessage("message" + i);
-
- prod1.send(tm);
- }
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage)cons1.receive(1000);
-
- assertNotNull(tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage)cons2.receive(1000);
-
- assertNotNull(tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage)cons3.receive(1000);
-
- assertNotNull(tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage)cons4.receive(1000);
-
- assertNotNull(tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage)cons5.receive(1000);
-
- assertNotNull(tm);
-
- assertEquals("message" + i, tm.getText());
- }
- }
- finally
- {
- if (conn1 != null) conn1.close();
-
- if (conn2 != null) conn2.close();
-
- if (conn3 != null) conn3.close();
- }
- }
-
-
-
-
- /*
- * Create non durable subscriptions on all nodes of the cluster.
- * Include some with selectors
- * Ensure all messages are receive as appropriate
- */
- public void clusteredTopicNonDurableWithSelectors(boolean persistent) throws Exception
- {
- Connection conn1 = null;
-
- Connection conn2 = null;
-
- Connection conn3 = null;
- try
- {
- conn1 = cf1.createConnection();
-
- conn2 = cf2.createConnection();
-
- conn3 = cf3.createConnection();
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons1 = sess1.createConsumer(topic1);
-
- MessageConsumer cons2 = sess2.createConsumer(topic2);
-
- MessageConsumer cons3 = sess3.createConsumer(topic3);
-
- MessageConsumer cons4 = sess1.createConsumer(topic1, "COLOUR='red'");
-
- MessageConsumer cons5 = sess2.createConsumer(topic2, "COLOUR='blue'");
-
- conn1.start();
-
- conn2.start();
-
- conn3.start();
-
- //Send at node1
-
- MessageProducer prod1 = sess1.createProducer(topic1);
-
- prod1.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-
- final int NUM_MESSAGES = 100;
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sess1.createTextMessage("message" + i);
-
- int c = i % 3;
- if (c == 0)
- {
- tm.setStringProperty("COLOUR", "red");
- }
- else if (c == 1)
- {
- tm.setStringProperty("COLOUR", "blue");
- }
-
- prod1.send(tm);
- }
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage)cons1.receive(1000);
-
- assertNotNull(tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage)cons2.receive(1000);
-
- assertNotNull(tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage)cons3.receive(1000);
-
- assertNotNull(tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- int c = i % 3;
-
- if (c == 0)
- {
- TextMessage tm = (TextMessage)cons4.receive(1000);
-
- assertNotNull(tm);
-
- assertEquals("message" + i, tm.getText());
- }
- }
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- int c = i % 3;
-
- if (c == 1)
- {
- TextMessage tm = (TextMessage)cons5.receive(1000);
-
- assertNotNull(tm);
-
- assertEquals("message" + i, tm.getText());
- }
- }
- }
- finally
- {
- if (conn1 != null) conn1.close();
-
- if (conn2 != null) conn2.close();
-
- if (conn3 != null) conn3.close();
- }
- }
-
-
-
- /*
- * Create durable subscriptions on all nodes of the cluster.
- * Include a couple with selectors
- * Ensure all messages are receive as appropriate
- * None of the durable subs are shared
- */
- public void clusteredTopicDurable(boolean persistent) throws Exception
- {
- Connection conn1 = null;
-
- Connection conn2 = null;
-
- Connection conn3 = null;
- try
- {
- conn1 = cf1.createConnection();
-
- conn2 = cf2.createConnection();
-
- conn3 = cf3.createConnection();
-
- conn1.setClientID("wib1");
-
- conn2.setClientID("wib1");
-
- conn3.setClientID("wib1");
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons1 = sess1.createDurableSubscriber(topic1, "sub1");
-
- MessageConsumer cons2 = sess2.createDurableSubscriber(topic2, "sub2");
-
- MessageConsumer cons3 = sess3.createDurableSubscriber(topic3, "sub3");
-
- MessageConsumer cons4 = sess1.createDurableSubscriber(topic1, "sub4");
-
- MessageConsumer cons5 = sess2.createDurableSubscriber(topic2, "sub5");
-
- conn1.start();
-
- conn2.start();
-
- conn3.start();
-
- //Send at node1
-
- MessageProducer prod1 = sess1.createProducer(topic1);
-
- prod1.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-
- final int NUM_MESSAGES = 100;
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sess1.createTextMessage("message" + i);
-
- prod1.send(tm);
- }
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage)cons1.receive(1000);
-
- assertNotNull(tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage)cons2.receive(1000);
-
- assertNotNull(tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage)cons3.receive(1000);
-
- assertNotNull(tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage)cons4.receive(1000);
-
- assertNotNull(tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage)cons5.receive(1000);
-
- assertNotNull(tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- cons1.close();
-
- cons2.close();
-
- cons3.close();
-
- cons4.close();
-
- cons5.close();
-
- sess1.unsubscribe("sub1");
-
- sess2.unsubscribe("sub2");
-
- sess3.unsubscribe("sub3");
-
- sess1.unsubscribe("sub4");
-
- sess2.unsubscribe("sub5");
-
- }
- finally
- {
- if (conn1 != null) conn1.close();
-
- if (conn2 != null) conn2.close();
-
- if (conn3 != null) conn3.close();
- }
- }
-
-
-
-
- /*
- * Create shared durable subs on multiple nodes, the local instance should always get the message
- */
- protected void clusteredTopicSharedDurableLocalConsumer(boolean persistent) throws Exception
- {
- Connection conn1 = null;
-
- Connection conn2 = null;
-
- Connection conn3 = null;
- try
- {
- conn1 = cf1.createConnection();
-
- conn2 = cf2.createConnection();
-
- conn3 = cf3.createConnection();
-
- conn1.setClientID("wib1");
-
- conn2.setClientID("wib1");
-
- conn3.setClientID("wib1");
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons1 = sess1.createDurableSubscriber(topic1, "sub1");
-
- MessageConsumer cons2 = sess2.createDurableSubscriber(topic2, "sub1");
-
- MessageConsumer cons3 = sess3.createDurableSubscriber(topic3, "sub1");
-
- conn1.start();
-
- conn2.start();
-
- conn3.start();
-
- //Send at node1
-
- MessageProducer prod1 = sess1.createProducer(topic1);
-
- prod1.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-
- final int NUM_MESSAGES = 100;
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sess1.createTextMessage("message" + i);
-
- prod1.send(tm);
- }
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage)cons1.receive(1000);
-
- assertNotNull(tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- Message m = cons2.receive(2000);
-
- assertNull(m);
-
- m = cons3.receive(2000);
-
- assertNull(m);
-
- // Send at node2
-
- MessageProducer prod2 = sess2.createProducer(topic2);
-
- prod2.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sess2.createTextMessage("message" + i);
-
- prod2.send(tm);
- }
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage)cons2.receive(1000);
-
- assertNotNull(tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- m = cons1.receive(2000);
-
- assertNull(m);
-
- m = cons3.receive(2000);
-
- assertNull(m);
-
- // Send at node3
-
- MessageProducer prod3 = sess3.createProducer(topic3);
-
- prod3.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sess3.createTextMessage("message" + i);
-
- prod3.send(tm);
- }
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage)cons3.receive(1000);
-
- assertNotNull(tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- m = cons1.receive(2000);
-
- assertNull(m);
-
- m = cons2.receive(2000);
-
- assertNull(m);
-
- cons1.close();
-
- cons2.close();
-
- cons3.close();
-
- //Need to unsubscribe on any node that the durable sub was created on
-
- sess1.unsubscribe("sub1");
-
- sess2.unsubscribe("sub1");
-
- sess3.unsubscribe("sub1");
- }
- finally
- {
- if (conn1 != null) conn1.close();
-
- if (conn2 != null) conn2.close();
-
- if (conn3 != null) conn3.close();
- }
- }
-
-
- /*
- * Create shared durable subs on multiple nodes, but without consumer on local node
- * even thought there is durable sub
- * should round robin
- * note that this test assumes round robin
- */
- protected void clusteredTopicSharedDurableNoLocalConsumer(boolean persistent) throws Exception
- {
- Connection conn1 = null;
-
- Connection conn2 = null;
-
- Connection conn3 = null;
- try
- {
- conn1 = cf1.createConnection();
-
- conn2 = cf2.createConnection();
-
- conn3 = cf3.createConnection();
-
- conn1.setClientID("wib1");
-
- conn2.setClientID("wib1");
-
- conn3.setClientID("wib1");
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons1 = sess1.createDurableSubscriber(topic1, "sub1");
-
- //Now close it on node 1
- conn1.close();
-
- conn1 = cf1.createConnection();
-
- conn1.setClientID("wib1");
-
- sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- //This means the durable sub is inactive on node1
-
- MessageConsumer cons2 = sess2.createDurableSubscriber(topic2, "sub1");
-
- MessageConsumer cons3 = sess3.createDurableSubscriber(topic3, "sub1");
-
- conn2.start();
-
- conn3.start();
-
- //Send at node1
-
- //Should round robin between the other 2 since there is no active consumer on sub1 on node1
-
- MessageProducer prod1 = sess1.createProducer(topic1);
-
- prod1.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-
- final int NUM_MESSAGES = 100;
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sess1.createTextMessage("message" + i);
-
- prod1.send(tm);
- }
-
- for (int i = 0; i < NUM_MESSAGES / 2; i++)
- {
- TextMessage tm = (TextMessage)cons2.receive(1000);
-
- assertNotNull(tm);
-
- assertEquals("message" + i * 2, tm.getText());
- }
-
- for (int i = 0; i < NUM_MESSAGES / 2; i++)
- {
- TextMessage tm = (TextMessage)cons3.receive(1000);
-
- assertNotNull(tm);
-
- assertEquals("message" + (i * 2 + 1), tm.getText());
- }
-
- cons2.close();
-
- cons3.close();
-
- sess1.unsubscribe("sub1");
-
- sess2.unsubscribe("sub1");
-
- sess3.unsubscribe("sub1");
-
- }
- finally
- {
- if (conn1 != null) conn1.close();
-
- if (conn2 != null) conn2.close();
-
- if (conn3 != null) conn3.close();
- }
- }
-
-
-
- /*
- * Create shared durable subs on multiple nodes, but without sub on local node
- * should round robin
- * note that this test assumes round robin
- */
- protected void clusteredTopicSharedDurableNoLocalSub(boolean persistent) throws Exception
- {
- Connection conn1 = null;
-
- Connection conn2 = null;
-
- Connection conn3 = null;
- try
- {
- conn1 = cf1.createConnection();
-
- conn2 = cf2.createConnection();
-
- conn3 = cf3.createConnection();
-
- conn2.setClientID("wib1");
-
- conn3.setClientID("wib1");
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons2 = sess2.createDurableSubscriber(topic2, "sub1");
-
- MessageConsumer cons3 = sess3.createDurableSubscriber(topic3, "sub1");
-
- conn2.start();
-
- conn3.start();
-
- //Send at node1
-
- //Should round robin between the other 2 since there is no active consumer on sub1 on node1
-
- MessageProducer prod1 = sess1.createProducer(topic1);
-
- prod1.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-
- final int NUM_MESSAGES = 100;
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sess1.createTextMessage("message" + i);
-
- prod1.send(tm);
- }
-
- for (int i = 0; i < NUM_MESSAGES / 2; i++)
- {
- TextMessage tm = (TextMessage)cons2.receive(1000);
-
- assertNotNull(tm);
-
- assertEquals("message" + i * 2, tm.getText());
- }
-
- for (int i = 0; i < NUM_MESSAGES / 2; i++)
- {
- TextMessage tm = (TextMessage)cons3.receive(1000);
-
- assertNotNull(tm);
-
- assertEquals("message" + (i * 2 + 1), tm.getText());
- }
-
- cons2.close();
-
- cons3.close();
-
- sess2.unsubscribe("sub1");
-
- sess3.unsubscribe("sub1");
-
- }
- finally
- {
- if (conn1 != null) conn1.close();
-
- if (conn2 != null) conn2.close();
-
- if (conn3 != null) conn3.close();
- }
- }
-
- class MyListener implements MessageListener
- {
- private int i;
-
- MyListener(int i)
- {
- this.i = i;
- }
-
- public void onMessage(Message m)
- {
- try
- {
- int count = m.getIntProperty("count");
-
- log.info("Listener " + i + " received message " + count);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- }
-
-}
Copied: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/manual/ManualClusteringTest.java (from rev 1517, trunk/tests/src/org/jboss/test/messaging/jms/manual/ManualClusteringTest.java)
Deleted: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/manual/ManualPagingSoakTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/manual/ManualPagingSoakTest.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/manual/ManualPagingSoakTest.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -1,139 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.messaging.jms.manual;
-
-import java.util.Properties;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-
-import org.jboss.test.messaging.MessagingTestCase;
-
-
-public class ManualPagingSoakTest extends MessagingTestCase
-{
- protected Context ic1;
-
- protected Queue queue;
-
- protected Topic topic;
-
- protected ConnectionFactory cf;
-
- public ManualPagingSoakTest(String name)
- {
- super(name);
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- Properties props1 = new Properties();
-
- props1.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
- props1.put(Context.PROVIDER_URL, "jnp://localhost:1199");
- props1.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
-
- ic1 = new InitialContext(props1);
-
- queue = (Queue)ic1.lookup("queue/testQueue");
-
- topic = (Topic)ic1.lookup("topic/testTopic");
-
- cf = (ConnectionFactory)ic1.lookup("/ConnectionFactory");
-
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
-
- ic1.close();
- }
-
- public void test1() throws Exception
- {
- Connection conn = null;
-
- try
- {
- conn = cf.createConnection();
-
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = sess.createProducer(queue);
-
- prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
- final int NUM_MESSAGES = 1000000;
-
- byte[] bytes = new byte[2048];
-
- String s = new String(bytes);
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sess.createTextMessage(s);
-
- prod.send(tm);
-
- if (i % 1000 == 0)
- {
- log.info("Sent " + i);
- }
- }
-
- log.info("Receiving");
-
- MessageConsumer cons = sess.createConsumer(queue);
-
- conn.start();
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage)cons.receive(2000);
-
- assertNotNull(tm);
-
- if (i % 1000 == 0)
- {
- log.info("Received " + i);
- }
- }
-
- }
- finally
- {
- if (conn != null) conn.close();
- }
- }
-}
Copied: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/manual/ManualPagingSoakTest.java (from rev 1517, trunk/tests/src/org/jboss/test/messaging/jms/manual/ManualPagingSoakTest.java)
Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/persistence/MessagePersistenceManagerTest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/persistence/MessagePersistenceManagerTest.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/persistence/MessagePersistenceManagerTest.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -72,8 +72,9 @@
protected JDBCPersistenceManager createPM(boolean batch, int maxParams) throws Throwable
{
JDBCPersistenceManager p =
- new JDBCPersistenceManager(sc.getDataSource(), sc.getTransactionManager(), null,
- true, batch, true, maxParams);
+ new JDBCPersistenceManager(sc.getDataSource(), sc.getTransactionManager(),
+ sc.getPersistenceManagerSQLProperties(),
+ true, batch, true, maxParams);
p.start();
return p;
}
Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/server/destination/QueueManagementTest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/server/destination/QueueManagementTest.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/server/destination/QueueManagementTest.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -229,7 +229,6 @@
public void testMessageCountOverFullSize() throws Exception
{
- log.info("** starting testMessageCountOverFullSize");
InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
Connection conn = null;
@@ -271,13 +270,10 @@
int receivedCount = 0;
- log.info("Starting receiver loop...");
-
while((cons.receive(2000)) != null)
{
receivedCount++;
- log.info(receivedCount + " messages received");
Thread.sleep(500);
int mc = ((Integer)ServerManagement.
getAttribute(destObjectName, "MessageCount")).intValue();
@@ -296,7 +292,6 @@
}
finally
{
- log.info("** leaving testMessageCountOverFullSize");
ServerManagement.undeployQueue("QueueMessageCount2");
if (conn != null)
Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -22,6 +22,7 @@
package org.jboss.test.messaging.tools.jmx;
+import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
@@ -32,8 +33,10 @@
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
+import java.util.Properties;
import java.util.Set;
import java.util.StringTokenizer;
+import java.io.ByteArrayInputStream;
import java.io.InputStream;
import javax.management.Attribute;
@@ -72,6 +75,7 @@
import org.jboss.system.ServiceCreator;
import org.jboss.test.messaging.tools.ServerManagement;
import org.jboss.test.messaging.tools.jboss.MBeanConfigurationElement;
+import org.jboss.test.messaging.tools.jboss.ServiceDeploymentDescriptor;
import org.jboss.test.messaging.tools.jndi.InVMInitialContextFactory;
import org.jboss.test.messaging.tools.jndi.InVMInitialContextFactoryBuilder;
import org.jboss.tm.TransactionManagerLocator;
@@ -470,6 +474,122 @@
{
return mbeanServer.invoke(on, "getInstance", new Object[0], new String[0]);
}
+
+ public Properties getPersistenceManagerSQLProperties() throws Exception
+ {
+ String databaseType = getDatabaseType();
+
+ String persistenceConfigFile =
+ "server/default/deploy/" + databaseType + "-persistence-service.xml";
+
+ log.info("********* LOADING CONFIG FILE: " + persistenceConfigFile);
+
+ URL persistenceConfigFileURL = getClass().getClassLoader().getResource(persistenceConfigFile);
+ if (persistenceConfigFileURL == null)
+ {
+ throw new Exception("Cannot find " + persistenceConfigFile + " in the classpath");
+ }
+
+ ServiceDeploymentDescriptor pdd = new ServiceDeploymentDescriptor(persistenceConfigFileURL);
+
+ MBeanConfigurationElement persistenceManagerConfig =
+ (MBeanConfigurationElement)pdd.query("service", "PersistenceManager").iterator().next();
+
+ String props = persistenceManagerConfig.getAttributeValue("SqlProperties");
+
+ log.info("sql properties are: " + props);
+
+ if (props != null)
+ {
+ ByteArrayInputStream is = new ByteArrayInputStream(props.getBytes());
+
+ Properties sqlProperties = new Properties();
+
+ sqlProperties.load(is);
+
+ return sqlProperties;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public Properties getPostOfficeSQLProperties() throws Exception
+ {
+ String databaseType = getDatabaseType();
+
+ String persistenceConfigFile =
+ "server/default/deploy/" + databaseType + "-persistence-service.xml";
+
+ log.info("********* LOADING CONFIG FILE: " + persistenceConfigFile);
+
+ URL persistenceConfigFileURL = getClass().getClassLoader().getResource(persistenceConfigFile);
+ if (persistenceConfigFileURL == null)
+ {
+ throw new Exception("Cannot find " + persistenceConfigFile + " in the classpath");
+ }
+
+ ServiceDeploymentDescriptor pdd = new ServiceDeploymentDescriptor(persistenceConfigFileURL);
+
+ MBeanConfigurationElement postOfficeConfig =
+ (MBeanConfigurationElement)pdd.query("service", "QueuePostOffice").iterator().next();
+
+ String props = postOfficeConfig.getAttributeValue("SqlProperties");
+
+ if (props != null)
+ {
+ ByteArrayInputStream is = new ByteArrayInputStream(props.getBytes());
+
+ Properties sqlProperties = new Properties();
+
+ sqlProperties.load(is);
+
+ return sqlProperties;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public Properties getClusteredPostOfficeSQLProperties() throws Exception
+ {
+ String databaseType = getDatabaseType();
+
+ String persistenceConfigFile =
+ "server/default/deploy/clustered-" + databaseType + "-persistence-service.xml";
+
+ log.info("********* LOADING CONFIG FILE: " + persistenceConfigFile);
+
+ URL persistenceConfigFileURL = getClass().getClassLoader().getResource(persistenceConfigFile);
+ if (persistenceConfigFileURL == null)
+ {
+ throw new Exception("Cannot find " + persistenceConfigFile + " in the classpath");
+ }
+
+ ServiceDeploymentDescriptor pdd = new ServiceDeploymentDescriptor(persistenceConfigFileURL);
+
+ MBeanConfigurationElement postOfficeConfig =
+ (MBeanConfigurationElement)pdd.query("service", "QueuePostOffice").iterator().next();
+
+ String props = postOfficeConfig.getAttributeValue("SqlProperties");
+
+ if (props != null)
+ {
+ ByteArrayInputStream is = new ByteArrayInputStream(props.getBytes());
+
+ Properties sqlProperties = new Properties();
+
+ sqlProperties.load(is);
+
+ return sqlProperties;
+ }
+ else
+ {
+ return null;
+ }
+ }
/**
* @return Set<ObjectName>
@@ -482,20 +602,8 @@
}
return mbeanServer.queryNames(pattern, null);
}
-
+
/**
- * Note that this method makes no assumption on whether the service was created or started, nor
- * does it attempt to create/start the service.
- *
- * @param service - a Standard/DynamicMBean instance.
- */
- public void registerService(Object service, ObjectName on) throws Exception
- {
- mbeanServer.registerMBean(service, on);
- log.debug(service + " registered as " + on);
- }
-
- /**
* Creates and registers a service based on the MBean service descriptor element. Supports
* XMBeans. The implementing class and the ObjectName are inferred from the mbean element. If
* there are configuration attributed specified in the deployment descriptor, they are applied
@@ -647,6 +755,18 @@
// Protected -----------------------------------------------------
// Private -------------------------------------------------------
+
+ /**
+ * Note that this method makes no assumption on whether the service was created or started, nor
+ * does it attempt to create/start the service.
+ *
+ * @param service - a Standard/DynamicMBean instance.
+ */
+ private void registerService(Object service, ObjectName on) throws Exception
+ {
+ mbeanServer.registerMBean(service, on);
+ log.debug(service + " registered as " + on);
+ }
private void readConfigurationFile() throws Exception
{
@@ -1055,6 +1175,8 @@
{
try
{
+ log.info("************************** Deleting all data from database");
+
InitialContext ctx = new InitialContext();
TransactionManager mgr = (TransactionManager)ctx.lookup(TransactionManagerService.JNDI_NAME);
@@ -1065,7 +1187,7 @@
Connection conn = ds.getConnection();
- String sql = "DELETE FROM JMS_CHANNEL_MAPPING";
+ String sql = "DELETE FROM JMS_POSTOFFICE";
PreparedStatement ps = conn.prepareStatement(sql);
int rows = ps.executeUpdate();
Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java 2006-10-25 12:37:33 UTC (rev 1517)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java 2006-10-25 20:30:08 UTC (rev 1518)
@@ -73,7 +73,6 @@
private ObjectName queuePostOfficeObjectName;
private ObjectName topicPostOfficeObjectName;
private ObjectName jmsUserManagerObjectName;
- private ObjectName shutdownLoggerObjectName;
// the server MBean itself
private ObjectName serverPeerObjectName;
@@ -265,12 +264,6 @@
sc.invoke(jmsUserManagerObjectName, "create", new Object[0], new String[0]);
sc.invoke(jmsUserManagerObjectName, "start", new Object[0], new String[0]);
- MBeanConfigurationElement shutdownLoggerConfig =
- (MBeanConfigurationElement)pdd.query("service", "ShutdownLogger").iterator().next();
- shutdownLoggerObjectName = sc.registerAndConfigureService(shutdownLoggerConfig);
- sc.invoke(shutdownLoggerObjectName, "create", new Object[0], new String[0]);
- sc.invoke(shutdownLoggerObjectName, "start", new Object[0], new String[0]);
-
// register server peer as a service, dependencies are injected automatically
MBeanConfigurationElement serverPeerConfig =
(MBeanConfigurationElement)mdd.query("service", "ServerPeer").iterator().next();
@@ -417,26 +410,10 @@
//Hence we must catch and ignore or we won't shut everything down
}
-
-
log.debug("stopping ServerPeer's plug-in dependencies");
-
+
try
{
- sc.invoke(shutdownLoggerObjectName, "stop", new Object[0], new String[0]);
- sc.invoke(shutdownLoggerObjectName, "destroy", new Object[0], new String[0]);
- sc.unregisterService(shutdownLoggerObjectName);
- }
- catch (Exception ignore)
- {
- //If the serverpeer failed when starting up previously, then only some of the
- //services may be started. The ones that didn't start will fail when attempting to shut
- //them down.
- //Hence we must catch and ignore or we won't shut everything down
- }
-
- try
- {
sc.invoke(jmsUserManagerObjectName, "stop", new Object[0], new String[0]);
sc.invoke(jmsUserManagerObjectName, "destroy", new Object[0], new String[0]);
sc.unregisterService(jmsUserManagerObjectName);
More information about the jboss-cvs-commits
mailing list