JBoss hornetq SVN: r7955 - in branches/hornetq_grouping: examples/core and 16 other directories.
by do-not-reply@jboss.org
Author: ataylor
Date: 2009-09-11 10:22:36 -0400 (Fri, 11 Sep 2009)
New Revision: 7955
Added:
branches/hornetq_grouping/src/main/org/hornetq/core/postoffice/BindingsFactory.java
branches/hornetq_grouping/src/main/org/hornetq/core/server/group/
branches/hornetq_grouping/src/main/org/hornetq/core/server/group/Arbitrator.java
branches/hornetq_grouping/src/main/org/hornetq/core/server/group/ProposalHandler.java
branches/hornetq_grouping/src/main/org/hornetq/core/server/group/impl/
branches/hornetq_grouping/src/main/org/hornetq/core/server/group/impl/ArbitratorConfiguration.java
branches/hornetq_grouping/src/main/org/hornetq/core/server/group/impl/LocalArbitrator.java
branches/hornetq_grouping/src/main/org/hornetq/core/server/group/impl/Proposal.java
branches/hornetq_grouping/src/main/org/hornetq/core/server/group/impl/RemoteArbitrator.java
branches/hornetq_grouping/src/main/org/hornetq/core/server/group/impl/Response.java
branches/hornetq_grouping/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusteredGroupingTest.java
Modified:
branches/hornetq_grouping/examples/core/hornetq-core-examples.iml
branches/hornetq_grouping/examples/javaee/hornetq-javaee-examples.iml
branches/hornetq_grouping/examples/jms/hornetq-jms-examples.iml
branches/hornetq_grouping/hornetq.ipr
branches/hornetq_grouping/src/main/org/hornetq/core/client/management/impl/ManagementHelper.java
branches/hornetq_grouping/src/main/org/hornetq/core/management/NotificationType.java
branches/hornetq_grouping/src/main/org/hornetq/core/postoffice/PostOffice.java
branches/hornetq_grouping/src/main/org/hornetq/core/postoffice/impl/BindingsImpl.java
branches/hornetq_grouping/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
branches/hornetq_grouping/src/main/org/hornetq/core/postoffice/impl/SimpleAddressManager.java
branches/hornetq_grouping/src/main/org/hornetq/core/postoffice/impl/WildcardAddressManager.java
branches/hornetq_grouping/src/main/org/hornetq/core/server/cluster/impl/BridgeImpl.java
branches/hornetq_grouping/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java
branches/hornetq_grouping/tests/hornetq-tests.iml
branches/hornetq_grouping/tests/jms-tests/hornetq-jms-tests.iml
branches/hornetq_grouping/tests/joram-tests/hornetq-joram-tests.iml
branches/hornetq_grouping/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java
branches/hornetq_grouping/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingImplTest.java
branches/hornetq_grouping/tests/src/org/hornetq/tests/unit/core/server/impl/fakes/FakePostOffice.java
Log:
merged in JBM branch
Modified: branches/hornetq_grouping/examples/core/hornetq-core-examples.iml
===================================================================
--- branches/hornetq_grouping/examples/core/hornetq-core-examples.iml 2009-09-11 10:56:25 UTC (rev 7954)
+++ branches/hornetq_grouping/examples/core/hornetq-core-examples.iml 2009-09-11 14:22:36 UTC (rev 7955)
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module relativePaths="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
+ <output url="file:///production/hornetq-core-examples" />
+ <output-test url="file:///test/hornetq-core-examples" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/embedded/src" isTestSource="false" />
Modified: branches/hornetq_grouping/examples/javaee/hornetq-javaee-examples.iml
===================================================================
--- branches/hornetq_grouping/examples/javaee/hornetq-javaee-examples.iml 2009-09-11 10:56:25 UTC (rev 7954)
+++ branches/hornetq_grouping/examples/javaee/hornetq-javaee-examples.iml 2009-09-11 14:22:36 UTC (rev 7955)
@@ -1,91 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<module relativePaths="true" type="JAVA_MODULE" version="4">
- <component name="FacetManager">
- <facet type="web" name="Web">
- <configuration>
- <descriptors>
- <deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/servlet-transport/config/WEB-INF/web.xml" optional="false" version="2.5" />
- </descriptors>
- <webroots>
- <root url="file://$MODULE_DIR$/servlet-transport/config/jms-servlet.war" relative="/" />
- </webroots>
- <sourceRoots>
- <root url="file://$MODULE_DIR$/ejb-jms-transaction/src" />
- <root url="file://$MODULE_DIR$/hajndi/src" />
- <root url="file://$MODULE_DIR$/jca-config/src" />
- <root url="file://$MODULE_DIR$/jms-bridge/src" />
- <root url="file://$MODULE_DIR$/mdb/src" />
- <root url="file://$MODULE_DIR$/servlet-transport/src" />
- <root url="file://$MODULE_DIR$/xarecovery/src" />
- </sourceRoots>
- <building>
- <setting name="EXPLODED_URL" value="file://" />
- <setting name="EXPLODED_ENABLED" value="false" />
- <setting name="JAR_URL" value="file://" />
- <setting name="JAR_ENABLED" value="false" />
- <setting name="EXCLUDE_EXPLODED_DIRECTORY" value="true" />
- </building>
- <packaging>
- <containerElement type="module" name="messaging-javaee-examples">
- <attribute name="method" value="1" />
- <attribute name="URI" value="/WEB-INF/classes" />
- </containerElement>
- </packaging>
- </configuration>
- </facet>
- <facet type="javaeeApplication" name="javaEEApplication">
- <configuration>
- <descriptors>
- <deploymentDescriptor name="application.xml" url="file://$MODULE_DIR$/servlet-transport/config/META-INF/application.xml" optional="false" version="5" />
- </descriptors>
- <building>
- <setting name="EXPLODED_URL" value="file://" />
- <setting name="EXPLODED_ENABLED" value="false" />
- <setting name="JAR_URL" value="file://" />
- <setting name="JAR_ENABLED" value="false" />
- <setting name="EXCLUDE_EXPLODED_DIRECTORY" value="true" />
- </building>
- </configuration>
- </facet>
- <facet type="javaeeApplication" name="javaEEApplication2">
- <configuration>
- <descriptors>
- <deploymentDescriptor name="application.xml" url="file://$MODULE_DIR$/servlet-ssl-example/config/META-INF/application.xml" optional="false" version="5" />
- </descriptors>
- <building>
- <setting name="EXPLODED_URL" value="file://" />
- <setting name="EXPLODED_ENABLED" value="false" />
- <setting name="JAR_URL" value="file://" />
- <setting name="JAR_ENABLED" value="false" />
- <setting name="EXCLUDE_EXPLODED_DIRECTORY" value="true" />
- </building>
- </configuration>
- </facet>
- <facet type="web" name="Web2">
- <configuration>
- <descriptors>
- <deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/servlet-ssl-example/config/WEB-INF/web.xml" optional="false" version="2.5" />
- </descriptors>
- <webroots>
- <root url="file://$MODULE_DIR$/servlet-ssl-example/config" relative="/" />
- </webroots>
- <building>
- <setting name="EXPLODED_URL" value="file://" />
- <setting name="EXPLODED_ENABLED" value="false" />
- <setting name="JAR_URL" value="file://" />
- <setting name="JAR_ENABLED" value="false" />
- <setting name="EXCLUDE_EXPLODED_DIRECTORY" value="true" />
- </building>
- <packaging>
- <containerElement type="module" name="messaging-javaee-examples">
- <attribute name="method" value="1" />
- <attribute name="URI" value="/WEB-INF/classes" />
- </containerElement>
- </packaging>
- </configuration>
- </facet>
- </component>
- <component name="NewModuleRootManager" inherit-compiler-output="false">
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
<output url="file://$MODULE_DIR$/output/classes" />
<exclude-output />
<content url="file://$MODULE_DIR$">
Modified: branches/hornetq_grouping/examples/jms/hornetq-jms-examples.iml
===================================================================
--- branches/hornetq_grouping/examples/jms/hornetq-jms-examples.iml 2009-09-11 10:56:25 UTC (rev 7954)
+++ branches/hornetq_grouping/examples/jms/hornetq-jms-examples.iml 2009-09-11 14:22:36 UTC (rev 7955)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<module relativePaths="true" type="JAVA_MODULE" version="4">
- <component name="NewModuleRootManager" inherit-compiler-output="false">
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
<output url="file://$MODULE_DIR$/output/classes" />
<output-test url="file://$MODULE_DIR$/output" />
<exclude-output />
Modified: branches/hornetq_grouping/hornetq.ipr
===================================================================
--- branches/hornetq_grouping/hornetq.ipr 2009-09-11 10:56:25 UTC (rev 7954)
+++ branches/hornetq_grouping/hornetq.ipr 2009-09-11 14:22:36 UTC (rev 7955)
@@ -336,11 +336,21 @@
<facet-type id="javaeeApplication">
<modules>
<module name="messaging" />
+ <module name="hornetq-javaee-examples">
+ <files>
+ <file url="file://$PROJECT_DIR$/examples/javaee/servlet-transport/config/META-INF/application.xml" />
+ </files>
+ </module>
</modules>
</facet-type>
<facet-type id="web">
<modules>
<module name="messaging" />
+ <module name="hornetq-javaee-examples">
+ <files>
+ <file url="file://$PROJECT_DIR$/examples/javaee/servlet-transport/config/WEB-INF/web.xml" />
+ </files>
+ </module>
</modules>
</facet-type>
</autodetection-disabled>
@@ -579,7 +589,7 @@
</component>
<component name="ProjectFileVersion" converted="true" />
<component name="ProjectKey">
- <option name="state" value="https://svn.jboss.org/repos/hornetq/trunk/hornetq.ipr" />
+ <option name="state" value="https://svn.jboss.org/repos/hornetq/branches/hornetq_grouping/hornetq.ipr" />
</component>
<component name="ProjectModuleManager">
<modules>
@@ -592,7 +602,9 @@
<module fileurl="file://$PROJECT_DIR$/tests/hornetq-tests.iml" filepath="$PROJECT_DIR$/tests/hornetq-tests.iml" />
</modules>
</component>
- <component name="ProjectRootManager" version="2" languageLevel="JDK_1_5" assert-keyword="true" jdk-15="true" project-jdk-name="1.5" project-jdk-type="JavaSDK" />
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_1_5" assert-keyword="true" jdk-15="true" project-jdk-name="1.5" project-jdk-type="JavaSDK">
+ <output url="file://$PROJECT_DIR$/build/classes" />
+ </component>
<component name="ResourceManagerContainer">
<option name="myResourceBundles">
<value>
Modified: branches/hornetq_grouping/src/main/org/hornetq/core/client/management/impl/ManagementHelper.java
===================================================================
--- branches/hornetq_grouping/src/main/org/hornetq/core/client/management/impl/ManagementHelper.java 2009-09-11 10:56:25 UTC (rev 7954)
+++ branches/hornetq_grouping/src/main/org/hornetq/core/client/management/impl/ManagementHelper.java 2009-09-11 14:22:36 UTC (rev 7955)
@@ -71,6 +71,12 @@
public static final SimpleString HDR_CHECK_TYPE = new SimpleString("_HQ_CheckType");
+ public static final SimpleString HDR_PROPOSAL_TYPE = new SimpleString("_JBM_ProposalType");
+
+ public static final SimpleString HDR_PROPOSAL_VALUE = new SimpleString("_JBM_ProposalValue");
+
+ public static final SimpleString HDR_PROPOSAL_ALT_VALUE = new SimpleString("_JBM_ProposalAltValue");
+
// Attributes ----------------------------------------------------
// Static --------------------------------------------------------
Modified: branches/hornetq_grouping/src/main/org/hornetq/core/management/NotificationType.java
===================================================================
--- branches/hornetq_grouping/src/main/org/hornetq/core/management/NotificationType.java 2009-09-11 10:56:25 UTC (rev 7954)
+++ branches/hornetq_grouping/src/main/org/hornetq/core/management/NotificationType.java 2009-09-11 14:22:36 UTC (rev 7955)
@@ -30,7 +30,9 @@
BROADCAST_GROUP_STARTED(10),
BROADCAST_GROUP_STOPPED(11),
BRIDGE_STARTED(12),
- BRIDGE_STOPPED(13);
+ BRIDGE_STOPPED(13),
+ PROPOSAL(14),
+ PROPOSAL_RESPONSE(15);
private final int value;
Added: branches/hornetq_grouping/src/main/org/hornetq/core/postoffice/BindingsFactory.java
===================================================================
--- branches/hornetq_grouping/src/main/org/hornetq/core/postoffice/BindingsFactory.java (rev 0)
+++ branches/hornetq_grouping/src/main/org/hornetq/core/postoffice/BindingsFactory.java 2009-09-11 14:22:36 UTC (rev 7955)
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.hornetq.core.postoffice;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
+ */
+public interface BindingsFactory
+{
+ Bindings createBindings();
+}
Modified: branches/hornetq_grouping/src/main/org/hornetq/core/postoffice/PostOffice.java
===================================================================
--- branches/hornetq_grouping/src/main/org/hornetq/core/postoffice/PostOffice.java 2009-09-11 10:56:25 UTC (rev 7954)
+++ branches/hornetq_grouping/src/main/org/hornetq/core/postoffice/PostOffice.java 2009-09-11 14:22:36 UTC (rev 7955)
@@ -19,6 +19,7 @@
import org.hornetq.core.server.HornetQComponent;
import org.hornetq.core.server.Queue;
import org.hornetq.core.server.ServerMessage;
+import org.hornetq.core.server.group.Arbitrator;
import org.hornetq.core.transaction.Transaction;
import org.hornetq.utils.SimpleString;
@@ -66,5 +67,9 @@
void sendQueueInfoToQueue(SimpleString queueName, SimpleString address) throws Exception;
- Object getNotificationLock();
+ Object getNotificationLock();
+
+ void addArbitrator(Arbitrator arbitrator);
+
+ Arbitrator getArbitrator();
}
Modified: branches/hornetq_grouping/src/main/org/hornetq/core/postoffice/impl/BindingsImpl.java
===================================================================
--- branches/hornetq_grouping/src/main/org/hornetq/core/postoffice/impl/BindingsImpl.java 2009-09-11 10:56:25 UTC (rev 7954)
+++ branches/hornetq_grouping/src/main/org/hornetq/core/postoffice/impl/BindingsImpl.java 2009-09-11 14:22:36 UTC (rev 7955)
@@ -28,9 +28,13 @@
import org.hornetq.core.message.impl.MessageImpl;
import org.hornetq.core.postoffice.Binding;
import org.hornetq.core.postoffice.Bindings;
+import org.hornetq.core.postoffice.PostOffice;
import org.hornetq.core.server.Bindable;
import org.hornetq.core.server.Queue;
import org.hornetq.core.server.ServerMessage;
+import org.hornetq.core.server.group.impl.Proposal;
+import org.hornetq.core.server.group.impl.Response;
+import org.hornetq.core.server.group.Arbitrator;
import org.hornetq.core.transaction.Transaction;
import org.hornetq.utils.SimpleString;
@@ -38,10 +42,8 @@
* A BindingsImpl
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- *
- * Created 11 Dec 2008 08:34:33
- *
- *
+ * <p/>
+ * Created 11 Dec 2008 08:34:33
*/
public class BindingsImpl implements Bindings
{
@@ -57,6 +59,13 @@
private volatile boolean routeWhenNoConsumers;
+ private final PostOffice postOffice;
+
+ public BindingsImpl(PostOffice postOffice)
+ {
+ this.postOffice = postOffice;
+ }
+
public void setRouteWhenNoConsumers(final boolean routeWhenNoConsumers)
{
this.routeWhenNoConsumers = routeWhenNoConsumers;
@@ -125,7 +134,7 @@
private void routeFromCluster(final ServerMessage message, final Transaction tx) throws Exception
{
- byte[] ids = (byte[])message.removeProperty(MessageImpl.HDR_ROUTE_TO_IDS);
+ byte[] ids = (byte[]) message.removeProperty(MessageImpl.HDR_ROUTE_TO_IDS);
ByteBuffer buff = ByteBuffer.wrap(ids);
@@ -167,7 +176,7 @@
{
return false;
}
-
+
SimpleString routingName = originatingQueue.getName();
List<Binding> bindings = routingNameBindingMap.get(routingName);
@@ -251,10 +260,14 @@
}
}
- public void route(final ServerMessage message, final Transaction tx) throws Exception
+ public void route(final ServerMessage message, final Transaction tx) throws Exception
{
boolean routed = false;
-
+ Object o = message.getProperty("count_prop");
+ if (o != null)
+ {
+ System.out.println("routing message " + o);
+ }
if (!exclusiveBindings.isEmpty())
{
for (Binding binding : exclusiveBindings)
@@ -262,7 +275,7 @@
if (binding.getFilter() == null || binding.getFilter().match(message))
{
binding.getBindable().route(message, tx);
-
+
routed = true;
}
}
@@ -270,10 +283,96 @@
if (!routed)
{
+ Arbitrator groupingArbitrator = postOffice.getArbitrator();
+
if (message.getProperty(MessageImpl.HDR_FROM_CLUSTER) != null)
{
routeFromCluster(message, tx);
}
+ else if(groupingArbitrator != null && message.getProperty(MessageImpl.HDR_GROUP_ID)!= null)
+ {
+ SimpleString groupId = (SimpleString) message.getProperty(MessageImpl.HDR_GROUP_ID);
+ Response resp = groupingArbitrator.propose(new Proposal(groupId, null));
+ if(resp == null)
+ {
+ for (Map.Entry<SimpleString, List<Binding>> entry : routingNameBindingMap.entrySet())
+ {
+ SimpleString routingName = entry.getKey();
+
+ List<Binding> bindings = entry.getValue();
+ Binding chosen = null;
+ Binding lowestPriorityBinding = null;
+ int lowestPriority = Integer.MAX_VALUE;
+ for (Binding binding : bindings)
+ {
+ boolean bindingIsHighAcceptPriority = binding.isHighAcceptPriority(message);
+ int distance = binding.getDistance();
+ if((distance < lowestPriority))
+ {
+ lowestPriorityBinding = binding;
+ lowestPriority = distance;
+ if(bindingIsHighAcceptPriority)
+ {
+ chosen = binding;
+ }
+ }
+ }
+ if(chosen == null)
+ {
+ chosen = lowestPriorityBinding;
+ }
+ resp = groupingArbitrator.propose(new Proposal(groupId, chosen.getClusterName()));
+ if(!resp.getChosen().equals(chosen.getClusterName()))
+ {
+ for (Binding binding : bindings)
+ {
+ if (binding.getClusterName().equals(resp.getChosen()))
+ {
+ chosen = binding;
+ break;
+ }
+ }
+ }
+
+ if( chosen != null )
+ {
+ System.out.println("sending message" + message.getProperty("count_prop") + " to " + chosen.getClusterName());
+ chosen.willRoute(message);
+ chosen.getBindable().preroute(message, tx);
+ chosen.getBindable().route(message, tx);
+ }
+ }
+ }
+ else
+ {
+ for (Map.Entry<SimpleString, List<Binding>> entry : routingNameBindingMap.entrySet())
+ {
+ SimpleString routingName = entry.getKey();
+
+ List<Binding> bindings = entry.getValue();
+ Binding chosen = null;
+ for (Binding binding : bindings)
+ {
+ if(binding.getClusterName().equals(resp.getChosen()))
+ {
+ chosen = binding;
+ break;
+ }
+ }
+ if( chosen != null && (routeWhenNoConsumers || chosen.isHighAcceptPriority(message)))
+ {
+ System.out.println("found sending message" + message.getProperty("count_prop") + " to " + chosen.getClusterName());
+ chosen.willRoute(message);
+ chosen.getBindable().preroute(message, tx);
+ chosen.getBindable().route(message, tx);
+ }
+ else
+ {
+ System.out.println("BindingsImpl.route");
+ }
+ }
+ }
+ }
else
{
Set<Bindable> chosen = new HashSet<Bindable>();
@@ -327,74 +426,74 @@
}
}
- Filter filter = binding.getFilter();
+ Filter filter = binding.getFilter();
- if (filter == null || filter.match(message))
- {
- // bindings.length == 1 ==> only a local queue so we don't check for matching consumers (it's an
- // unnecessary overhead)
- if (length == 1 || routeWhenNoConsumers || binding.isHighAcceptPriority(message))
- {
- theBinding = binding;
+ if (filter == null || filter.match(message))
+ {
+ // bindings.length == 1 ==> only a local queue so we don't check for matching consumers (it's an
+ // unnecessary overhead)
+ if (length == 1 || routeWhenNoConsumers || binding.isHighAcceptPriority(message))
+ {
+ theBinding = binding;
- pos = incrementPos(pos, length);
+ pos = incrementPos(pos, length);
- break;
- }
- else
- {
- if (lastLowPriorityBinding == -1)
- {
- lastLowPriorityBinding = pos;
- }
- }
+ break;
+ }
+ else
+ {
+ if (lastLowPriorityBinding == -1)
+ {
+ lastLowPriorityBinding = pos;
}
+ }
+ }
- pos = incrementPos(pos, length);
+ pos = incrementPos(pos, length);
- if (pos == startPos)
+ if (pos == startPos)
+ {
+ if (lastLowPriorityBinding != -1)
+ {
+ try
{
- if (lastLowPriorityBinding != -1)
+ theBinding = bindings.get(pos);
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ // This can occur if binding is removed while in route
+ if (!bindings.isEmpty())
{
- try
- {
- theBinding = bindings.get(pos);
- }
- catch (IndexOutOfBoundsException e)
- {
- // This can occur if binding is removed while in route
- if (!bindings.isEmpty())
- {
- pos = 0;
+ pos = 0;
- lastLowPriorityBinding = -1;
+ lastLowPriorityBinding = -1;
- continue;
- }
- else
- {
- break;
- }
- }
-
- pos = lastLowPriorityBinding;
-
- pos = incrementPos(pos, length);
+ continue;
}
- break;
+ else
+ {
+ break;
+ }
}
- }
- if (theBinding != null)
- {
- theBinding.willRoute(message);
+ pos = lastLowPriorityBinding;
- chosen.add(theBinding.getBindable());
+ pos = incrementPos(pos, length);
}
-
- routingNamePositions.put(routingName, pos);
+ break;
}
+ }
+ if (theBinding != null)
+ {
+ theBinding.willRoute(message);
+
+ chosen.add(theBinding.getBindable());
+ }
+
+ routingNamePositions.put(routingName, pos);
+ }
+
// TODO refactor to do this is one iteration
for (Bindable bindable : chosen)
Modified: branches/hornetq_grouping/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
===================================================================
--- branches/hornetq_grouping/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java 2009-09-11 10:56:25 UTC (rev 7954)
+++ branches/hornetq_grouping/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java 2009-09-11 14:22:36 UTC (rev 7955)
@@ -45,10 +45,12 @@
import org.hornetq.core.postoffice.DuplicateIDCache;
import org.hornetq.core.postoffice.PostOffice;
import org.hornetq.core.postoffice.QueueInfo;
+import org.hornetq.core.postoffice.BindingsFactory;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.Queue;
import org.hornetq.core.server.QueueFactory;
import org.hornetq.core.server.ServerMessage;
+import org.hornetq.core.server.group.Arbitrator;
import org.hornetq.core.server.impl.ServerMessageImpl;
import org.hornetq.core.settings.HierarchicalRepository;
import org.hornetq.core.settings.impl.AddressSettings;
@@ -69,7 +71,7 @@
* @author <a href="jmesnil(a)redhat.com">Jeff Mesnil</a>
* @author <a href="csuconic(a)redhat.com">Clebert Suconic</a>
*/
-public class PostOfficeImpl implements PostOffice, NotificationListener
+public class PostOfficeImpl implements PostOffice, NotificationListener, BindingsFactory
{
private static final Logger log = Logger.getLogger(PostOfficeImpl.class);
@@ -123,6 +125,8 @@
private final HierarchicalRepository<AddressSettings> addressSettingsRepository;
+ private Arbitrator groupingArbitrator;
+
public PostOfficeImpl(final HornetQServer server,
final StorageManager storageManager,
final PagingManager pagingManager,
@@ -154,11 +158,11 @@
if (enableWildCardRouting)
{
- addressManager = new WildcardAddressManager();
+ addressManager = new WildcardAddressManager(this);
}
else
{
- addressManager = new SimpleAddressManager();
+ addressManager = new SimpleAddressManager(this);
}
this.backup = backup;
@@ -553,7 +557,7 @@
if (bindings == null)
{
- bindings = new BindingsImpl();
+ bindings = createBindings();
}
return bindings;
@@ -738,6 +742,17 @@
return notificationLock;
}
+
+ public void addArbitrator(Arbitrator arbitrator)
+ {
+ groupingArbitrator = arbitrator;
+ }
+
+ public Arbitrator getArbitrator()
+ {
+ return groupingArbitrator;
+ }
+
public void sendQueueInfoToQueue(final SimpleString queueName, final SimpleString address) throws Exception
{
// We send direct to the queue so we can send it to the same queue that is bound to the notifications adress -
@@ -1099,4 +1114,9 @@
}
}
}
+
+ public Bindings createBindings()
+ {
+ return new BindingsImpl(this);
+ }
}
Modified: branches/hornetq_grouping/src/main/org/hornetq/core/postoffice/impl/SimpleAddressManager.java
===================================================================
--- branches/hornetq_grouping/src/main/org/hornetq/core/postoffice/impl/SimpleAddressManager.java 2009-09-11 10:56:25 UTC (rev 7954)
+++ branches/hornetq_grouping/src/main/org/hornetq/core/postoffice/impl/SimpleAddressManager.java 2009-09-11 14:22:36 UTC (rev 7955)
@@ -21,6 +21,7 @@
import org.hornetq.core.postoffice.AddressManager;
import org.hornetq.core.postoffice.Binding;
import org.hornetq.core.postoffice.Bindings;
+import org.hornetq.core.postoffice.BindingsFactory;
import org.hornetq.utils.SimpleString;
/**
@@ -38,6 +39,13 @@
private final ConcurrentMap<SimpleString, Binding> nameMap = new ConcurrentHashMap<SimpleString, Binding>();
+ private final BindingsFactory bindingsFactory;
+
+ public SimpleAddressManager(BindingsFactory bindingsFactory)
+ {
+ this.bindingsFactory = bindingsFactory;
+ }
+
public boolean addBinding(final Binding binding)
{
if (nameMap.putIfAbsent(binding.getUniqueName(), binding) != null)
@@ -81,7 +89,7 @@
{
Address add = new AddressImpl(address);
- Bindings bindings = new BindingsImpl();
+ Bindings bindings = bindingsFactory.createBindings();
for (Binding binding: nameMap.values())
{
@@ -150,7 +158,7 @@
if (bindings == null)
{
- bindings = new BindingsImpl();
+ bindings = bindingsFactory.createBindings();
prevBindings = mappings.putIfAbsent(address, bindings);
Modified: branches/hornetq_grouping/src/main/org/hornetq/core/postoffice/impl/WildcardAddressManager.java
===================================================================
--- branches/hornetq_grouping/src/main/org/hornetq/core/postoffice/impl/WildcardAddressManager.java 2009-09-11 10:56:25 UTC (rev 7954)
+++ branches/hornetq_grouping/src/main/org/hornetq/core/postoffice/impl/WildcardAddressManager.java 2009-09-11 14:22:36 UTC (rev 7955)
@@ -21,6 +21,7 @@
import org.hornetq.core.postoffice.Address;
import org.hornetq.core.postoffice.Binding;
import org.hornetq.core.postoffice.Bindings;
+import org.hornetq.core.postoffice.BindingsFactory;
import org.hornetq.utils.SimpleString;
/**
@@ -50,6 +51,11 @@
private final Map<SimpleString, Address> wildCardAddresses = new HashMap<SimpleString, Address>();
+ public WildcardAddressManager(BindingsFactory bindingsFactory)
+ {
+ super(bindingsFactory);
+ }
+
public Bindings getBindingsForRoutingAddress(final SimpleString address)
{
Bindings bindings = super.getBindingsForRoutingAddress(address);
Modified: branches/hornetq_grouping/src/main/org/hornetq/core/server/cluster/impl/BridgeImpl.java
===================================================================
--- branches/hornetq_grouping/src/main/org/hornetq/core/server/cluster/impl/BridgeImpl.java 2009-09-11 10:56:25 UTC (rev 7954)
+++ branches/hornetq_grouping/src/main/org/hornetq/core/server/cluster/impl/BridgeImpl.java 2009-09-11 14:22:36 UTC (rev 7955)
@@ -613,6 +613,10 @@
NotificationType.CONSUMER_CREATED +
"','" +
NotificationType.CONSUMER_CLOSED +
+ "','" +
+ NotificationType.PROPOSAL +
+ "','" +
+ NotificationType.PROPOSAL_RESPONSE +
"') AND " +
ManagementHelper.HDR_DISTANCE +
"<" +
Modified: branches/hornetq_grouping/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java
===================================================================
--- branches/hornetq_grouping/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java 2009-09-11 10:56:25 UTC (rev 7954)
+++ branches/hornetq_grouping/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java 2009-09-11 14:22:36 UTC (rev 7955)
@@ -46,6 +46,8 @@
import org.hornetq.core.remoting.impl.wireformat.replication.ReplicateRemoteConsumerRemovedMessage;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.Queue;
+import org.hornetq.core.server.group.impl.Response;
+import org.hornetq.core.server.group.impl.Proposal;
import org.hornetq.core.server.cluster.Bridge;
import org.hornetq.core.server.cluster.ClusterConnection;
import org.hornetq.core.server.cluster.MessageFlowRecord;
@@ -609,6 +611,12 @@
case SECURITY_AUTHENTICATION_VIOLATION:
case SECURITY_PERMISSION_VIOLATION:
break;
+ case PROPOSAL:
+ doProposalReceived(message);
+ break;
+ case PROPOSAL_RESPONSE:
+ doProposalResponseReceived(message);
+ break;
default:
{
throw new IllegalArgumentException("Invalid type " + ntype);
@@ -621,6 +629,37 @@
}
}
+ private synchronized void doProposalReceived(final ClientMessage message) throws Exception
+ {
+ SimpleString type = (SimpleString) message.getProperty(ManagementHelper.HDR_PROPOSAL_TYPE);
+ if (type == null)
+ {
+ throw new IllegalStateException("proposal type is null");
+ }
+ SimpleString val = (SimpleString) message.getProperty(ManagementHelper.HDR_PROPOSAL_VALUE);
+ Integer hops = (Integer) message.getProperty(ManagementHelper.HDR_DISTANCE);
+ Response response = postOffice.getArbitrator().receive(new Proposal(type, val), hops + 1);
+ if(response != null)
+ {
+ postOffice.getArbitrator().send(response, 0);
+ }
+ }
+
+ private synchronized void doProposalResponseReceived(final ClientMessage message) throws Exception
+ {
+ SimpleString type = (SimpleString) message.getProperty(ManagementHelper.HDR_PROPOSAL_TYPE);
+ if (type == null)
+ {
+ throw new IllegalStateException("proposal type is null");
+ }
+ SimpleString val = (SimpleString) message.getProperty(ManagementHelper.HDR_PROPOSAL_VALUE);
+ SimpleString alt = (SimpleString) message.getProperty(ManagementHelper.HDR_PROPOSAL_ALT_VALUE);
+ Integer hops = (Integer) message.getProperty(ManagementHelper.HDR_DISTANCE);
+ Response response = new Response(type, val, alt);
+ postOffice.getArbitrator().proposed(response);
+ postOffice.getArbitrator().send(response, hops + 1);
+ }
+
private synchronized void clearBindings() throws Exception
{
for (RemoteQueueBinding binding : new HashSet<RemoteQueueBinding>(bindings.values()))
Added: branches/hornetq_grouping/src/main/org/hornetq/core/server/group/Arbitrator.java
===================================================================
--- branches/hornetq_grouping/src/main/org/hornetq/core/server/group/Arbitrator.java (rev 0)
+++ branches/hornetq_grouping/src/main/org/hornetq/core/server/group/Arbitrator.java 2009-09-11 14:22:36 UTC (rev 7955)
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.hornetq.core.server.group;
+
+import org.hornetq.utils.SimpleString;
+import org.hornetq.core.server.group.impl.Proposal;
+import org.hornetq.core.server.group.impl.Response;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
+ */
+public interface Arbitrator
+{
+ SimpleString getName();
+
+ Response propose(Proposal proposal) throws Exception;
+
+ void proposed(Response response) throws Exception;
+
+ void send(Response response, int distance) throws Exception;
+
+ Response receive(Proposal proposal, int distance) throws Exception;
+
+ Response rePropose(Proposal proposal) throws Exception;
+}
Added: branches/hornetq_grouping/src/main/org/hornetq/core/server/group/ProposalHandler.java
===================================================================
--- branches/hornetq_grouping/src/main/org/hornetq/core/server/group/ProposalHandler.java (rev 0)
+++ branches/hornetq_grouping/src/main/org/hornetq/core/server/group/ProposalHandler.java 2009-09-11 14:22:36 UTC (rev 7955)
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.hornetq.core.server.group;
+
+import org.hornetq.utils.TypedProperties;
+import org.hornetq.core.server.group.impl.Proposal;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
+ */
+public interface ProposalHandler
+{
+ public void handleSend(Proposal proposal, TypedProperties clientMessage);
+
+ void handleReceive(Proposal proposal);
+}
Added: branches/hornetq_grouping/src/main/org/hornetq/core/server/group/impl/ArbitratorConfiguration.java
===================================================================
--- branches/hornetq_grouping/src/main/org/hornetq/core/server/group/impl/ArbitratorConfiguration.java (rev 0)
+++ branches/hornetq_grouping/src/main/org/hornetq/core/server/group/impl/ArbitratorConfiguration.java 2009-09-11 14:22:36 UTC (rev 7955)
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.hornetq.core.server.group.impl;
+
+import org.hornetq.utils.SimpleString;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
+ */
+public class ArbitratorConfiguration
+{
+ private final SimpleString name;
+
+ private final TYPE type;
+
+ private final SimpleString address;
+
+ public ArbitratorConfiguration(final SimpleString name, final TYPE type, SimpleString address)
+ {
+ this.type = type;
+ this.name = name;
+ this.address = address;
+ }
+
+ public SimpleString getName()
+ {
+ return name;
+ }
+
+ public TYPE getType()
+ {
+ return type;
+ }
+
+ public SimpleString getAddress()
+ {
+ return address;
+ }
+
+ public enum TYPE
+ {
+ LOCAL("LOCAL"),
+ REMOTE("REMOTE");
+
+ private String type;
+
+ TYPE(String type)
+ {
+ this.type = type;
+ }
+
+ public String getType()
+ {
+ return type;
+ }
+ }
+}
Added: branches/hornetq_grouping/src/main/org/hornetq/core/server/group/impl/LocalArbitrator.java
===================================================================
--- branches/hornetq_grouping/src/main/org/hornetq/core/server/group/impl/LocalArbitrator.java (rev 0)
+++ branches/hornetq_grouping/src/main/org/hornetq/core/server/group/impl/LocalArbitrator.java 2009-09-11 14:22:36 UTC (rev 7955)
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.hornetq.core.server.group.impl;
+
+import org.hornetq.core.management.NotificationType;
+import org.hornetq.core.management.Notification;
+import org.hornetq.core.management.ManagementService;
+import org.hornetq.core.client.management.impl.ManagementHelper;
+import org.hornetq.core.postoffice.BindingType;
+import org.hornetq.core.logging.Logger;
+import org.hornetq.core.server.group.Arbitrator;
+import org.hornetq.utils.SimpleString;
+import org.hornetq.utils.TypedProperties;
+import org.hornetq.utils.ConcurrentHashSet;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
+ */
+public class LocalArbitrator implements Arbitrator
+{
+ private static Logger log = Logger.getLogger(LocalArbitrator.class);
+
+ private ConcurrentHashMap<SimpleString, Object> map = new ConcurrentHashMap<SimpleString, Object>();
+
+ private final SimpleString name;
+
+ private final ManagementService managementService;
+
+ private SimpleString address;
+
+ private ScheduledExecutorService scheduledExecutor;
+
+ private ConcurrentHashSet<SimpleString> reProposals = new ConcurrentHashSet<SimpleString>();
+
+ public LocalArbitrator(final ManagementService managementService, final SimpleString name, final SimpleString address, ScheduledExecutorService scheduledExecutor)
+ {
+ this.managementService = managementService;
+ this.name = name;
+ this.address = address;
+ this.scheduledExecutor = scheduledExecutor;
+ }
+
+ public SimpleString getName()
+ {
+ return name;
+ }
+
+
+ public Response propose(Proposal proposal) throws Exception
+ {
+ if(proposal.getProposal() == null)
+ {
+ Object original = map.get(proposal.getProposalType());
+ return original == null?null:new Response(proposal.getProposalType(), original);
+ }
+ Response response = new Response(proposal.getProposalType(), proposal.getProposal());
+ if (map.putIfAbsent(response.getResponseType(), response.getChosen()) == null)
+ {
+ log.info("accepted proposal for " + proposal.getProposalType() + " with value " + proposal.getProposal());
+ return response;
+ }
+ else
+ {
+ log.info("denied proposal for " + proposal.getProposalType() + " with value " + proposal.getProposal());
+ return new Response(proposal.getProposalType(), proposal.getProposal(), map.get(proposal.getProposalType()));
+ }
+ }
+
+ public void proposed(Response response) throws Exception
+ {
+ }
+
+ public void send(Response response, int distance) throws Exception
+ {
+ Object value = response.getAlternative() != null ? response.getAlternative() : response.getOriginal();
+ log.info("sending proposal response for " + response.getResponseType() + " with value " + value);
+ TypedProperties props = new TypedProperties();
+ props.putStringProperty(ManagementHelper.HDR_PROPOSAL_TYPE, response.getResponseType());
+ props.putStringProperty(ManagementHelper.HDR_PROPOSAL_VALUE, (SimpleString)response.getOriginal());
+ props.putStringProperty(ManagementHelper.HDR_PROPOSAL_ALT_VALUE, (SimpleString)response.getAlternative());
+ props.putIntProperty(ManagementHelper.HDR_BINDING_TYPE, BindingType.LOCAL_QUEUE_INDEX);
+ props.putStringProperty(ManagementHelper.HDR_ADDRESS, address);
+ props.putIntProperty(ManagementHelper.HDR_DISTANCE, distance);
+ Notification notification = new Notification(null, NotificationType.PROPOSAL_RESPONSE, props);
+ managementService.sendNotification(notification);
+ }
+
+ public Response receive(Proposal proposal, int distance) throws Exception
+ {
+ return propose(proposal);
+ }
+
+ public Response rePropose(final Proposal proposal) throws Exception
+ {
+ if(reProposals.addIfAbsent(proposal.getProposalType()))
+ {
+ Response response = new Response(proposal.getProposalType(), proposal.getProposal());
+ map.replace(proposal.getProposalType(), response);
+ send(response, 0);
+ scheduledExecutor.schedule(new Runnable()
+ {
+ public void run()
+ {
+ reProposals.remove(proposal.getProposalType());
+ }
+ }, 2000, TimeUnit.MILLISECONDS);
+ return response;
+ }
+ else
+ {
+ return new Response(proposal.getProposalType(), map.get(proposal.getProposalType()));
+ }
+ }
+}
+
Added: branches/hornetq_grouping/src/main/org/hornetq/core/server/group/impl/Proposal.java
===================================================================
--- branches/hornetq_grouping/src/main/org/hornetq/core/server/group/impl/Proposal.java (rev 0)
+++ branches/hornetq_grouping/src/main/org/hornetq/core/server/group/impl/Proposal.java 2009-09-11 14:22:36 UTC (rev 7955)
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.hornetq.core.server.group.impl;
+
+import org.hornetq.utils.SimpleString;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
+ */
+public class Proposal
+{
+ private final SimpleString proposalType;
+ private final Object proposal;
+
+ public static final String PROPOSAL_TYPE_HEADER = "_JBM_PROPOSAL_TYPE";
+ public static final String PROPOSAL_HEADER = "_JBM_PROPOSAL";
+
+ public Proposal(SimpleString proposalType, Object proposal)
+ {
+ this.proposal = proposal;
+ this.proposalType = proposalType;
+ }
+
+ public SimpleString getProposalType()
+ {
+ return proposalType;
+ }
+
+ public Object getProposal()
+ {
+ return proposal;
+ }
+}
+
Added: branches/hornetq_grouping/src/main/org/hornetq/core/server/group/impl/RemoteArbitrator.java
===================================================================
--- branches/hornetq_grouping/src/main/org/hornetq/core/server/group/impl/RemoteArbitrator.java (rev 0)
+++ branches/hornetq_grouping/src/main/org/hornetq/core/server/group/impl/RemoteArbitrator.java 2009-09-11 14:22:36 UTC (rev 7955)
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.hornetq.core.server.group.impl;
+
+import org.hornetq.core.management.NotificationType;
+import org.hornetq.core.management.Notification;
+import org.hornetq.core.management.ManagementService;
+import org.hornetq.core.client.management.impl.ManagementHelper;
+import org.hornetq.core.postoffice.BindingType;
+import org.hornetq.core.server.group.Arbitrator;
+import org.hornetq.utils.SimpleString;
+import org.hornetq.utils.TypedProperties;
+
+import java.util.logging.Logger;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
+ */
+public class RemoteArbitrator implements Arbitrator
+{
+ private static Logger log = Logger.getLogger(RemoteArbitrator.class.getName());
+
+ private final SimpleString name;
+
+ private final ManagementService managementService;
+
+ private final SimpleString address;
+
+ private Map<SimpleString, Response> responses = new HashMap<SimpleString, Response>();
+
+ private final Lock lock = new ReentrantLock();
+
+ private final Condition sendCondition = lock.newCondition();
+
+ private int waitTime = 1000;
+
+ public RemoteArbitrator(final ManagementService managementService, final SimpleString name, final SimpleString address)
+ {
+ this.name = name;
+ this.address = address;
+ this.managementService = managementService;
+ }
+
+ public SimpleString getName()
+ {
+ return name;
+ }
+
+ public Response propose(final Proposal proposal) throws Exception
+ {
+ Response response = responses.get(proposal.getProposalType());
+ if( response != null)
+ {
+ return response;
+ }
+ if (proposal.getProposal() == null)
+ {
+ return null;
+ }
+ try
+ {
+ lock.lock();
+ TypedProperties props = new TypedProperties();
+ log.info("sending proposal for " + proposal.getProposalType() + " with value " + proposal.getProposal());
+ props.putStringProperty(ManagementHelper.HDR_PROPOSAL_TYPE, proposal.getProposalType());
+ props.putStringProperty(ManagementHelper.HDR_PROPOSAL_VALUE, (SimpleString)proposal.getProposal());
+ props.putIntProperty(ManagementHelper.HDR_BINDING_TYPE, BindingType.LOCAL_QUEUE_INDEX);
+ props.putStringProperty(ManagementHelper.HDR_ADDRESS, address);
+ props.putIntProperty(ManagementHelper.HDR_DISTANCE, 0);
+ Notification notification = new Notification(null, NotificationType.PROPOSAL, props);
+ managementService.sendNotification(notification);
+ sendCondition.await(waitTime, TimeUnit.MILLISECONDS);
+ }
+ finally
+ {
+ lock.unlock();
+ }
+ return responses.get(proposal.getProposalType());
+ }
+
+ public void proposed(Response response) throws Exception
+ {
+ Object value = response.getAlternative() != null ? response.getAlternative() : response.getOriginal();
+ log.info("received proposal response for " + response.getResponseType() + " with value " + value);
+ try
+ {
+ lock.lock();
+ responses.put(response.getResponseType(), response);
+ sendCondition.signal();
+ }
+ finally
+ {
+ lock.unlock();
+ }
+ }
+
+ public Response receive(Proposal proposal, int distance) throws Exception
+ {
+ TypedProperties props = new TypedProperties();
+ props.putStringProperty(ManagementHelper.HDR_PROPOSAL_TYPE, proposal.getProposalType());
+ props.putStringProperty(ManagementHelper.HDR_PROPOSAL_VALUE, (SimpleString)proposal.getProposal());
+ props.putIntProperty(ManagementHelper.HDR_BINDING_TYPE, BindingType.LOCAL_QUEUE_INDEX);
+ props.putStringProperty(ManagementHelper.HDR_ADDRESS, address);
+ props.putIntProperty(ManagementHelper.HDR_DISTANCE, distance);
+ Notification notification = new Notification(null, NotificationType.PROPOSAL, props);
+ managementService.sendNotification(notification);
+ return null;
+ }
+
+ public void send(Response response, int distance) throws Exception
+ {
+ }
+
+ public Response rePropose(Proposal proposal)
+ {
+ return null;
+ }
+
+}
+
Added: branches/hornetq_grouping/src/main/org/hornetq/core/server/group/impl/Response.java
===================================================================
--- branches/hornetq_grouping/src/main/org/hornetq/core/server/group/impl/Response.java (rev 0)
+++ branches/hornetq_grouping/src/main/org/hornetq/core/server/group/impl/Response.java 2009-09-11 14:22:36 UTC (rev 7955)
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.hornetq.core.server.group.impl;
+
+import org.hornetq.utils.SimpleString;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
+ */
+public class Response
+{
+ private final boolean accepted;
+
+ private final Object original;
+
+ private final Object alternative;
+
+ private SimpleString responseType;
+
+ public Response(SimpleString responseType, Object original)
+ {
+ this(responseType, original, null);
+ }
+
+ public Response(SimpleString responseType, Object original, Object alternative)
+ {
+ this.responseType = responseType;
+ this.accepted = alternative == null;
+ this.original = original;
+ this.alternative = alternative;
+ }
+
+ public boolean isAccepted()
+ {
+ return accepted;
+ }
+
+ public Object getOriginal()
+ {
+ return original;
+ }
+
+ public Object getAlternative()
+ {
+ return alternative;
+ }
+
+ public Object getChosen()
+ {
+ return alternative != null?alternative:original;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "accepted = " + accepted + " original = " + original + " alternative = " + alternative;
+ }
+
+ public SimpleString getResponseType()
+ {
+ return responseType;
+ }
+}
Modified: branches/hornetq_grouping/tests/hornetq-tests.iml
===================================================================
--- branches/hornetq_grouping/tests/hornetq-tests.iml 2009-09-11 10:56:25 UTC (rev 7954)
+++ branches/hornetq_grouping/tests/hornetq-tests.iml 2009-09-11 14:22:36 UTC (rev 7955)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<module relativePaths="true" type="JAVA_MODULE" version="4">
- <component name="NewModuleRootManager" inherit-compiler-output="false">
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
<output url="file://$MODULE_DIR$/output/classes" />
<output-test url="file://$MODULE_DIR$/output" />
<exclude-output />
Modified: branches/hornetq_grouping/tests/jms-tests/hornetq-jms-tests.iml
===================================================================
--- branches/hornetq_grouping/tests/jms-tests/hornetq-jms-tests.iml 2009-09-11 10:56:25 UTC (rev 7954)
+++ branches/hornetq_grouping/tests/jms-tests/hornetq-jms-tests.iml 2009-09-11 14:22:36 UTC (rev 7955)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<module relativePaths="true" type="JAVA_MODULE" version="4">
- <component name="NewModuleRootManager" inherit-compiler-output="false">
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
<output url="file://$MODULE_DIR$/output/classes" />
<output-test url="file://$MODULE_DIR$/output" />
<exclude-output />
Modified: branches/hornetq_grouping/tests/joram-tests/hornetq-joram-tests.iml
===================================================================
--- branches/hornetq_grouping/tests/joram-tests/hornetq-joram-tests.iml 2009-09-11 10:56:25 UTC (rev 7954)
+++ branches/hornetq_grouping/tests/joram-tests/hornetq-joram-tests.iml 2009-09-11 14:22:36 UTC (rev 7955)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<module relativePaths="true" type="JAVA_MODULE" version="4">
- <component name="NewModuleRootManager" inherit-compiler-output="false">
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
<output url="file://$MODULE_DIR$/output/classes" />
<output-test url="file://$MODULE_DIR$/output" />
<exclude-output />
@@ -14,6 +14,7 @@
<orderEntry type="module" module-name="hornetq-tests" />
<orderEntry type="library" name="messaging_jars" level="project" />
<orderEntry type="library" name="messaging-joram-tests" level="project" />
+ <orderEntry type="module" module-name="hornetq-jms-tests" />
</component>
</module>
Modified: branches/hornetq_grouping/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java
===================================================================
--- branches/hornetq_grouping/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java 2009-09-11 10:56:25 UTC (rev 7954)
+++ branches/hornetq_grouping/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java 2009-09-11 14:22:36 UTC (rev 7955)
@@ -45,6 +45,10 @@
import org.hornetq.core.server.HornetQ;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.JournalType;
+import org.hornetq.core.server.group.impl.ArbitratorConfiguration;
+import org.hornetq.core.server.group.impl.LocalArbitrator;
+import org.hornetq.core.server.group.impl.RemoteArbitrator;
+import org.hornetq.core.server.group.Arbitrator;
import org.hornetq.core.server.cluster.ClusterConnection;
import org.hornetq.core.server.cluster.RemoteQueueBinding;
import org.hornetq.integration.transports.netty.TransportConstants;
@@ -421,6 +425,52 @@
session.close();
}
+ protected void sendWithProperty(int node, String address, int numMessages, boolean durable, SimpleString key, SimpleString val) throws Exception
+ {
+ sendInRange(node, address, 0, numMessages, durable, key, val);
+ }
+
+ protected void sendInRange(int node, String address, int msgStart, int msgEnd, boolean durable, SimpleString key, SimpleString val) throws Exception
+ {
+ ClientSessionFactory sf = this.sfs[node];
+
+ if (sf == null)
+ {
+ throw new IllegalArgumentException("No sf at " + node);
+ }
+
+ ClientSession session = sf.createSession(false, true, true);
+
+ ClientProducer producer = session.createProducer(address);
+
+ for (int i = msgStart; i < msgEnd; i++)
+ {
+ ClientMessage message = session.createClientMessage(durable);
+
+ message.putStringProperty(key, val);
+ message.putIntProperty(COUNT_PROP, i);
+ System.out.println("i = " + i);
+ producer.send(message);
+ }
+
+ session.close();
+ }
+
+
+ protected void setUpGroupArbitrator(ArbitratorConfiguration.TYPE type, int node)
+ {
+ Arbitrator arbitrator;
+ if(type == ArbitratorConfiguration.TYPE.LOCAL)
+ {
+ arbitrator = new LocalArbitrator(servers[node].getManagementService(), new SimpleString("grouparbitrator"), new SimpleString("queues"), null);
+ }
+ else
+ {
+ arbitrator = new RemoteArbitrator(servers[node].getManagementService(), new SimpleString("grouparbitrator"), new SimpleString("queues"));
+ }
+ this.servers[node].getPostOffice().addArbitrator(arbitrator);
+ }
+
protected void send(int node, String address, int numMessages, boolean durable, String filterVal) throws Exception
{
sendInRange(node, address, 0, numMessages, durable, filterVal);
Added: branches/hornetq_grouping/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusteredGroupingTest.java
===================================================================
--- branches/hornetq_grouping/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusteredGroupingTest.java (rev 0)
+++ branches/hornetq_grouping/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusteredGroupingTest.java 2009-09-11 14:22:36 UTC (rev 7955)
@@ -0,0 +1,529 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.hornetq.tests.integration.cluster.distribution;
+
+import org.hornetq.core.message.impl.MessageImpl;
+import org.hornetq.core.server.group.impl.ArbitratorConfiguration;
+import org.hornetq.utils.SimpleString;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
+ */
+public class ClusteredGroupingTest extends ClusterTestBase
+{
+
+ public void testGroupingSimple() throws Exception
+ {
+ setupServer(0, isFileStorage(), isNetty());
+ setupServer(1, isFileStorage(), isNetty());
+ setupServer(2, isFileStorage(), isNetty());
+
+ setupClusterConnection("cluster0", "queues", false, 1, isNetty(), 0, 1, 2);
+
+ setupClusterConnection("cluster1", "queues", false, 1, isNetty(), 1, 0, 2);
+
+ setupClusterConnection("cluster2", "queues", false, 1, isNetty(), 2, 0, 1);
+
+ startServers(0, 1, 2);
+
+ try
+ {
+ setUpGroupArbitrator(ArbitratorConfiguration.TYPE.LOCAL, 0);
+ setUpGroupArbitrator(ArbitratorConfiguration.TYPE.REMOTE, 1);
+ setUpGroupArbitrator(ArbitratorConfiguration.TYPE.REMOTE, 2);
+
+ setupSessionFactory(0, isNetty());
+ setupSessionFactory(1, isNetty());
+ setupSessionFactory(2, isNetty());
+
+ createQueue(0, "queues.testaddress", "queue0", null, false);
+ createQueue(1, "queues.testaddress", "queue0", null, false);
+ createQueue(2, "queues.testaddress", "queue0", null, false);
+
+ addConsumer(0, 0, "queue0", null);
+ addConsumer(1, 1, "queue0", null);
+ addConsumer(2, 2, "queue0", null);
+
+ waitForBindings(0, "queues.testaddress", 1, 1, true);
+ waitForBindings(1, "queues.testaddress", 1, 1, true);
+ waitForBindings(2, "queues.testaddress", 1, 1, true);
+
+ /*waitForBindings(0, "queues.testaddress", 2, 2, false);
+ waitForBindings(1, "queues.testaddress", 2, 2, false);
+ waitForBindings(2, "queues.testaddress", 2, 2, false);*/
+
+ sendWithProperty(0, "queues.testaddress", 10, false, MessageImpl.HDR_GROUP_ID, new SimpleString("id1"));
+
+ verifyReceiveAll(10, 0);
+
+ System.out.println("*****************************************************************************");
+ }
+ finally
+ {
+ closeAllConsumers();
+
+ closeAllSessionFactories();
+
+ stopServers(0, 1, 2);
+ }
+ }
+
+ public void testGroupingSendTo2queues() throws Exception
+ {
+ setupServer(0, isFileStorage(), isNetty());
+ setupServer(1, isFileStorage(), isNetty());
+ setupServer(2, isFileStorage(), isNetty());
+
+ setupClusterConnection("cluster0", "queues", false, 1, isNetty(), 0, 1, 2);
+
+ setupClusterConnection("cluster1", "queues", false, 1, isNetty(), 1, 0, 2);
+
+ setupClusterConnection("cluster2", "queues", false, 1, isNetty(), 2, 0, 1);
+
+ startServers(0, 1, 2);
+
+ try
+ {
+ setUpGroupArbitrator(ArbitratorConfiguration.TYPE.LOCAL, 0);
+ setUpGroupArbitrator(ArbitratorConfiguration.TYPE.REMOTE, 1);
+ setUpGroupArbitrator(ArbitratorConfiguration.TYPE.REMOTE, 2);
+
+ setupSessionFactory(0, isNetty());
+ setupSessionFactory(1, isNetty());
+ setupSessionFactory(2, isNetty());
+
+ createQueue(0, "queues.testaddress", "queue0", null, false);
+ createQueue(1, "queues.testaddress", "queue0", null, false);
+ createQueue(2, "queues.testaddress", "queue0", null, false);
+
+ addConsumer(0, 0, "queue0", null);
+ addConsumer(1, 1, "queue0", null);
+ addConsumer(2, 2, "queue0", null);
+
+ waitForBindings(0, "queues.testaddress", 1, 1, true);
+ waitForBindings(1, "queues.testaddress", 1, 1, true);
+ waitForBindings(2, "queues.testaddress", 1, 1, true);
+
+ /*waitForBindings(0, "queues.testaddress", 2, 2, false);
+ waitForBindings(1, "queues.testaddress", 2, 2, false);
+ waitForBindings(2, "queues.testaddress", 2, 2, false);*/
+
+ sendInRange(0, "queues.testaddress", 0, 10, false, MessageImpl.HDR_GROUP_ID, new SimpleString("id1"));
+
+ verifyReceiveAllInRange(0, 10, 0);
+ sendInRange(1, "queues.testaddress", 10, 20, false, MessageImpl.HDR_GROUP_ID, new SimpleString("id1"));
+
+ verifyReceiveAllInRange(10, 20, 0);
+
+ System.out.println("*****************************************************************************");
+ }
+ finally
+ {
+ closeAllConsumers();
+
+ closeAllSessionFactories();
+
+ stopServers(0, 1, 2);
+ }
+ }
+
+ public void testGroupingSendTo3queues() throws Exception
+ {
+ setupServer(0, isFileStorage(), isNetty());
+ setupServer(1, isFileStorage(), isNetty());
+ setupServer(2, isFileStorage(), isNetty());
+
+ setupClusterConnection("cluster0", "queues", false, 1, isNetty(), 0, 1, 2);
+
+ setupClusterConnection("cluster1", "queues", false, 1, isNetty(), 1, 0, 2);
+
+ setupClusterConnection("cluster2", "queues", false, 1, isNetty(), 2, 0, 1);
+
+ startServers(0, 1, 2);
+
+ try
+ {
+ setUpGroupArbitrator(ArbitratorConfiguration.TYPE.LOCAL, 0);
+ setUpGroupArbitrator(ArbitratorConfiguration.TYPE.REMOTE, 1);
+ setUpGroupArbitrator(ArbitratorConfiguration.TYPE.REMOTE, 2);
+
+ setupSessionFactory(0, isNetty());
+ setupSessionFactory(1, isNetty());
+ setupSessionFactory(2, isNetty());
+
+ createQueue(0, "queues.testaddress", "queue0", null, false);
+ createQueue(1, "queues.testaddress", "queue0", null, false);
+ createQueue(2, "queues.testaddress", "queue0", null, false);
+
+ addConsumer(0, 0, "queue0", null);
+ addConsumer(1, 1, "queue0", null);
+ addConsumer(2, 2, "queue0", null);
+
+ waitForBindings(0, "queues.testaddress", 1, 1, true);
+ waitForBindings(1, "queues.testaddress", 1, 1, true);
+ waitForBindings(2, "queues.testaddress", 1, 1, true);
+
+ waitForBindings(0, "queues.testaddress", 2, 2, false);
+ waitForBindings(1, "queues.testaddress", 2, 2, false);
+ waitForBindings(2, "queues.testaddress", 2, 2, false);
+
+ sendInRange(0, "queues.testaddress", 0, 10, false, MessageImpl.HDR_GROUP_ID, new SimpleString("id1"));
+
+ verifyReceiveAllInRange(0, 10, 0);
+ sendInRange(1, "queues.testaddress", 10, 20, false, MessageImpl.HDR_GROUP_ID, new SimpleString("id1"));
+
+ verifyReceiveAllInRange(10, 20, 0);
+ sendInRange(2, "queues.testaddress", 10, 20, false, MessageImpl.HDR_GROUP_ID, new SimpleString("id1"));
+
+ verifyReceiveAllInRange(10, 20, 0);
+
+ System.out.println("*****************************************************************************");
+ }
+ finally
+ {
+ closeAllConsumers();
+
+ closeAllSessionFactories();
+
+ stopServers(0, 1, 2);
+ }
+ }
+
+ public void testGroupingSendTo3queuesRemoteArbitrator() throws Exception
+ {
+ setupServer(0, isFileStorage(), isNetty());
+ setupServer(1, isFileStorage(), isNetty());
+ setupServer(2, isFileStorage(), isNetty());
+
+ setupClusterConnection("cluster0", "queues", false, 1, isNetty(), 0, 1, 2);
+
+ setupClusterConnection("cluster1", "queues", false, 1, isNetty(), 1, 0, 2);
+
+ setupClusterConnection("cluster2", "queues", false, 1, isNetty(), 2, 0, 1);
+
+ startServers(0, 1, 2);
+
+ try
+ {
+ setUpGroupArbitrator(ArbitratorConfiguration.TYPE.LOCAL, 0);
+ setUpGroupArbitrator(ArbitratorConfiguration.TYPE.REMOTE, 1);
+ setUpGroupArbitrator(ArbitratorConfiguration.TYPE.REMOTE, 2);
+
+ setupSessionFactory(0, isNetty());
+ setupSessionFactory(1, isNetty());
+ setupSessionFactory(2, isNetty());
+
+ createQueue(0, "queues.testaddress", "queue0", null, false);
+ createQueue(1, "queues.testaddress", "queue0", null, false);
+ createQueue(2, "queues.testaddress", "queue0", null, false);
+
+ addConsumer(0, 0, "queue0", null);
+ addConsumer(1, 1, "queue0", null);
+ addConsumer(2, 2, "queue0", null);
+
+ waitForBindings(0, "queues.testaddress", 1, 1, true);
+ waitForBindings(1, "queues.testaddress", 1, 1, true);
+ waitForBindings(2, "queues.testaddress", 1, 1, true);
+
+ waitForBindings(0, "queues.testaddress", 2, 2, false);
+ waitForBindings(1, "queues.testaddress", 2, 2, false);
+ waitForBindings(2, "queues.testaddress", 2, 2, false);
+
+ sendInRange(1, "queues.testaddress", 0, 10, false, MessageImpl.HDR_GROUP_ID, new SimpleString("id1"));
+
+ verifyReceiveAllInRange(0, 10, 1);
+ sendInRange(2, "queues.testaddress", 10, 20, false, MessageImpl.HDR_GROUP_ID, new SimpleString("id1"));
+
+ verifyReceiveAllInRange(10, 20, 1);
+ sendInRange(0, "queues.testaddress", 20, 30, false, MessageImpl.HDR_GROUP_ID, new SimpleString("id1"));
+
+ verifyReceiveAllInRange(20, 30, 1);
+
+ System.out.println("*****************************************************************************");
+ }
+ finally
+ {
+ closeAllConsumers();
+
+ closeAllSessionFactories();
+
+ stopServers(0, 1, 2);
+ }
+ }
+
+ public void testGroupingSendTo3queuesNoConsumerOnLocalQueue() throws Exception
+ {
+ setupServer(0, isFileStorage(), isNetty());
+ setupServer(1, isFileStorage(), isNetty());
+ setupServer(2, isFileStorage(), isNetty());
+
+ setupClusterConnection("cluster0", "queues", false, 1, isNetty(), 0, 1, 2);
+
+ setupClusterConnection("cluster1", "queues", false, 1, isNetty(), 1, 0, 2);
+
+ setupClusterConnection("cluster2", "queues", false, 1, isNetty(), 2, 0, 1);
+
+ startServers(0, 1, 2);
+
+ try
+ {
+ setUpGroupArbitrator(ArbitratorConfiguration.TYPE.LOCAL, 0);
+ setUpGroupArbitrator(ArbitratorConfiguration.TYPE.REMOTE, 1);
+ setUpGroupArbitrator(ArbitratorConfiguration.TYPE.REMOTE, 2);
+
+ setupSessionFactory(0, isNetty());
+ setupSessionFactory(1, isNetty());
+ setupSessionFactory(2, isNetty());
+
+ createQueue(0, "queues.testaddress", "queue0", null, false);
+ createQueue(1, "queues.testaddress", "queue0", null, false);
+ createQueue(2, "queues.testaddress", "queue0", null, false);
+
+ addConsumer(0, 0, "queue0", null);
+ //addConsumer(1, 1, "queue0", null);
+ addConsumer(2, 2, "queue0", null);
+
+ waitForBindings(0, "queues.testaddress", 1, 1, true);
+ waitForBindings(1, "queues.testaddress", 1, 0, true);
+ waitForBindings(2, "queues.testaddress", 1, 1, true);
+
+ waitForBindings(0, "queues.testaddress", 2, 1, false);
+ waitForBindings(1, "queues.testaddress", 2, 2, false);
+ waitForBindings(2, "queues.testaddress", 2, 1, false);
+
+ sendInRange(1, "queues.testaddress", 0, 10, false, MessageImpl.HDR_GROUP_ID, new SimpleString("id1"));
+
+ verifyReceiveAllInRange(0, 10, 0);
+ sendInRange(2, "queues.testaddress", 10, 20, false, MessageImpl.HDR_GROUP_ID, new SimpleString("id1"));
+
+ verifyReceiveAllInRange(10, 20, 0);
+ sendInRange(0, "queues.testaddress", 20, 30, false, MessageImpl.HDR_GROUP_ID, new SimpleString("id1"));
+
+ verifyReceiveAllInRange(20, 30, 0);
+
+ System.out.println("*****************************************************************************");
+ }
+ finally
+ {
+ closeAllConsumers();
+
+ closeAllSessionFactories();
+
+ stopServers(0, 1, 2);
+ }
+ }
+
+ public void testGroupingSendTo3queuesNoConsumersDeliveredToLocalQueue() throws Exception
+ {
+ setupServer(0, isFileStorage(), isNetty());
+ setupServer(1, isFileStorage(), isNetty());
+ setupServer(2, isFileStorage(), isNetty());
+
+ setupClusterConnection("cluster0", "queues", false, 1, isNetty(), 0, 1, 2);
+
+ setupClusterConnection("cluster1", "queues", false, 1, isNetty(), 1, 0, 2);
+
+ setupClusterConnection("cluster2", "queues", false, 1, isNetty(), 2, 0, 1);
+
+ startServers(0, 1, 2);
+
+ try
+ {
+ setUpGroupArbitrator(ArbitratorConfiguration.TYPE.LOCAL, 0);
+ setUpGroupArbitrator(ArbitratorConfiguration.TYPE.REMOTE, 1);
+ setUpGroupArbitrator(ArbitratorConfiguration.TYPE.REMOTE, 2);
+
+ setupSessionFactory(0, isNetty());
+ setupSessionFactory(1, isNetty());
+ setupSessionFactory(2, isNetty());
+
+ createQueue(0, "queues.testaddress", "queue0", null, false);
+ createQueue(1, "queues.testaddress", "queue0", null, false);
+ createQueue(2, "queues.testaddress", "queue0", null, false);
+
+ waitForBindings(0, "queues.testaddress", 1, 0, true);
+ waitForBindings(1, "queues.testaddress", 1, 0, true);
+ waitForBindings(2, "queues.testaddress", 1, 0, true);
+
+ waitForBindings(0, "queues.testaddress", 2, 0, false);
+ waitForBindings(1, "queues.testaddress", 2, 0, false);
+ waitForBindings(2, "queues.testaddress", 2, 0, false);
+
+ sendInRange(1, "queues.testaddress", 0, 10, false, MessageImpl.HDR_GROUP_ID, new SimpleString("id1"));
+
+ sendInRange(2, "queues.testaddress", 10, 20, false, MessageImpl.HDR_GROUP_ID, new SimpleString("id1"));
+
+ sendInRange(0, "queues.testaddress", 20, 30, false, MessageImpl.HDR_GROUP_ID, new SimpleString("id1"));
+
+ addConsumer(0, 0, "queue0", null);
+ addConsumer(1, 1, "queue0", null);
+ addConsumer(2, 2, "queue0", null);
+
+ verifyReceiveAllInRange(0, 30, 1);
+
+ System.out.println("*****************************************************************************");
+ }
+ finally
+ {
+ closeAllConsumers();
+
+ closeAllSessionFactories();
+
+ stopServers(0, 1, 2);
+ }
+ }
+
+ public void testGroupingSendTo3queuesQueueRemoved() throws Exception
+ {
+ setupServer(0, isFileStorage(), isNetty());
+ setupServer(1, isFileStorage(), isNetty());
+ setupServer(2, isFileStorage(), isNetty());
+
+ setupClusterConnection("cluster0", "queues", false, 1, isNetty(), 0, 1, 2);
+
+ setupClusterConnection("cluster1", "queues", false, 1, isNetty(), 1, 0, 2);
+
+ setupClusterConnection("cluster2", "queues", false, 1, isNetty(), 2, 0, 1);
+
+ startServers(0, 1, 2);
+
+ try
+ {
+ setUpGroupArbitrator(ArbitratorConfiguration.TYPE.LOCAL, 0);
+ setUpGroupArbitrator(ArbitratorConfiguration.TYPE.REMOTE, 1);
+ setUpGroupArbitrator(ArbitratorConfiguration.TYPE.REMOTE, 2);
+
+ setupSessionFactory(0, isNetty());
+ setupSessionFactory(1, isNetty());
+ setupSessionFactory(2, isNetty());
+
+ createQueue(0, "queues.testaddress", "queue0", null, false);
+ createQueue(1, "queues.testaddress", "queue0", null, false);
+ createQueue(2, "queues.testaddress", "queue0", null, false);
+
+ addConsumer(0, 0, "queue0", null);
+ addConsumer(1, 1, "queue0", null);
+ addConsumer(2, 2, "queue0", null);
+
+ waitForBindings(0, "queues.testaddress", 1, 1, true);
+ waitForBindings(1, "queues.testaddress", 1, 1, true);
+ waitForBindings(2, "queues.testaddress", 1, 1, true);
+
+ waitForBindings(0, "queues.testaddress", 2, 2, false);
+ waitForBindings(1, "queues.testaddress", 2, 2, false);
+ waitForBindings(2, "queues.testaddress", 2, 2, false);
+
+ sendInRange(0, "queues.testaddress", 0, 10, false, MessageImpl.HDR_GROUP_ID, new SimpleString("id1"));
+
+ verifyReceiveAllInRange(0, 10, 0);
+ removeConsumer(0);
+ deleteQueue(0, "queue0");
+ sendInRange(1, "queues.testaddress", 10, 20, false, MessageImpl.HDR_GROUP_ID, new SimpleString("id1"));
+
+ verifyReceiveAllInRange(10, 20, 0);
+ sendInRange(2, "queues.testaddress", 10, 20, false, MessageImpl.HDR_GROUP_ID, new SimpleString("id1"));
+
+ verifyReceiveAllInRange(10, 20, 0);
+
+ System.out.println("*****************************************************************************");
+ }
+ finally
+ {
+ closeAllConsumers();
+
+ closeAllSessionFactories();
+
+ stopServers(0, 1, 2);
+ }
+ }
+
+ /*public void testGroupingSendTo3queuesPinnedNodeGoesDown() throws Exception
+ {
+ setupServer(0, isFileStorage(), isNetty());
+ setupServer(1, isFileStorage(), isNetty());
+ setupServer(2, isFileStorage(), isNetty());
+
+ setupClusterConnection("cluster0", "queues", false, 1, isNetty(), 0, 1, 2);
+
+ setupClusterConnection("cluster1", "queues", false, 1, isNetty(), 1, 0, 2);
+
+ setupClusterConnection("cluster2", "queues", false, 1, isNetty(), 2, 0, 1);
+
+ startServers(0, 1, 2);
+
+ try
+ {
+ setUpGroupArbitrator(ArbitratorConfiguration.TYPE.LOCAL, 0);
+ setUpGroupArbitrator(ArbitratorConfiguration.TYPE.REMOTE, 1);
+ setUpGroupArbitrator(ArbitratorConfiguration.TYPE.REMOTE, 2);
+
+ setupSessionFactory(0, isNetty());
+ setupSessionFactory(1, isNetty());
+ setupSessionFactory(2, isNetty());
+
+ createQueue(0, "queues.testaddress", "queue0", null, false);
+ createQueue(1, "queues.testaddress", "queue0", null, false);
+ createQueue(2, "queues.testaddress", "queue0", null, false);
+
+ addConsumer(0, 0, "queue0", null);
+ addConsumer(1, 1, "queue0", null);
+ addConsumer(2, 2, "queue0", null);
+
+ waitForBindings(0, "queues.testaddress", 1, 1, true);
+ waitForBindings(1, "queues.testaddress", 1, 1, true);
+ waitForBindings(2, "queues.testaddress", 1, 1, true);
+
+ waitForBindings(0, "queues.testaddress", 2, 2, false);
+ waitForBindings(1, "queues.testaddress", 2, 2, false);
+ waitForBindings(2, "queues.testaddress", 2, 2, false);
+
+ sendInRange(1, "queues.testaddress", 0, 10, false, MessageImpl.HDR_GROUP_ID, new SimpleString("id1"));
+
+ verifyReceiveAllInRange(0, 10, 1);
+
+ stopClusterConnections(1);
+
+ stopServers(1);
+
+ Thread.sleep(5000);
+
+ sendInRange(2, "queues.testaddress", 10, 20, false, MessageImpl.HDR_GROUP_ID, new SimpleString("id1"));
+
+ verifyReceiveAllInRange(10, 20, 1);
+ sendInRange(0, "queues.testaddress", 20, 30, false, MessageImpl.HDR_GROUP_ID, new SimpleString("id1"));
+
+ verifyReceiveAllInRange(20, 30, 1);
+
+ System.out.println("*****************************************************************************");
+ }
+ finally
+ {
+ //closeAllConsumers();
+
+ closeAllSessionFactories();
+
+ stopServers(0, 1, 2);
+ }
+ }*/
+
+ public boolean isNetty()
+ {
+ return true;
+ }
+
+ public boolean isFileStorage()
+ {
+ return false;
+ }
+}
+
Modified: branches/hornetq_grouping/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingImplTest.java
===================================================================
--- branches/hornetq_grouping/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingImplTest.java 2009-09-11 10:56:25 UTC (rev 7954)
+++ branches/hornetq_grouping/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingImplTest.java 2009-09-11 14:22:36 UTC (rev 7955)
@@ -39,6 +39,7 @@
import org.hornetq.core.transaction.Transaction;
import org.hornetq.core.transaction.TransactionOperation;
import org.hornetq.tests.util.UnitTestCase;
+import org.hornetq.tests.unit.core.server.impl.fakes.FakePostOffice;
import org.hornetq.utils.SimpleString;
import org.hornetq.utils.TypedProperties;
@@ -86,7 +87,7 @@
{
final FakeBinding fake = new FakeBinding(new SimpleString("a"));
- final BindingsImpl bind = new BindingsImpl();
+ final BindingsImpl bind = new BindingsImpl(new FakePostOffice());
bind.addBinding(fake);
bind.addBinding(new FakeBinding(new SimpleString("a")));
bind.addBinding(new FakeBinding(new SimpleString("a")));
Modified: branches/hornetq_grouping/tests/src/org/hornetq/tests/unit/core/server/impl/fakes/FakePostOffice.java
===================================================================
--- branches/hornetq_grouping/tests/src/org/hornetq/tests/unit/core/server/impl/fakes/FakePostOffice.java 2009-09-11 10:56:25 UTC (rev 7954)
+++ branches/hornetq_grouping/tests/src/org/hornetq/tests/unit/core/server/impl/fakes/FakePostOffice.java 2009-09-11 14:22:36 UTC (rev 7955)
@@ -23,6 +23,7 @@
import org.hornetq.core.postoffice.PostOffice;
import org.hornetq.core.server.Queue;
import org.hornetq.core.server.ServerMessage;
+import org.hornetq.core.server.group.Arbitrator;
import org.hornetq.core.transaction.Transaction;
import org.hornetq.utils.SimpleString;
@@ -150,4 +151,12 @@
}
+ public void addArbitrator(Arbitrator arbitrator)
+ {
+ }
+
+ public Arbitrator getArbitrator()
+ {
+ return null;
+ }
}
\ No newline at end of file
15 years, 3 months
JBoss hornetq SVN: r7954 - in branches/Branch_Replication_Changes: src/main/org/hornetq/core/client/impl and 25 other directories.
by do-not-reply@jboss.org
Author: timfox
Date: 2009-09-11 06:56:25 -0400 (Fri, 11 Sep 2009)
New Revision: 7954
Removed:
branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/impl/ReplicationOperationInvokerImpl.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/jmx/
branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicateCreateSessionMessage.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/wireformat/SessionFailoverCompleteMessage.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/wireformat/replication/
branches/Branch_Replication_Changes/src/main/org/hornetq/jms/server/management/jmx/
branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/integration/cluster/failover/ActivationTimeoutTest.java
branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/integration/cluster/management/
branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/integration/jms/cluster/management/
Modified:
branches/Branch_Replication_Changes/src/config/common/schema/hornetq-configuration.xsd
branches/Branch_Replication_Changes/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/config/Configuration.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/config/impl/ConfigurationImpl.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/config/impl/FileConfiguration.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/HornetQServerControl.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/ManagementService.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/QueueControl.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/impl/HornetQServerControlImpl.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/impl/QueueControlImpl.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/paging/PagingManager.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/paging/impl/PagingManagerImpl.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/postoffice/PostOffice.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/Channel.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/Packet.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/RemotingConnection.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/ChannelImpl.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/PacketDecoder.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/RemotingConnectionImpl.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/wireformat/CreateSessionResponseMessage.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/wireformat/PacketImpl.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/wireformat/Ping.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/wireformat/ReattachSessionResponseMessage.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/HornetQServer.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/Queue.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/ScheduledDeliveryHandler.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/ServerConsumer.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/ServerSession.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/cluster/impl/BridgeImpl.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/cluster/impl/ClusterManagerImpl.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/cluster/impl/Redistributor.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/HornetQPacketHandler.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/QueueImpl.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/ScheduledDeliveryHandlerImpl.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/ServerConsumerImpl.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/ServerSessionPacketHandler.java
branches/Branch_Replication_Changes/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
branches/Branch_Replication_Changes/src/main/org/hornetq/jms/server/management/impl/JMSManagementServiceImpl.java
branches/Branch_Replication_Changes/tests/config/ConfigurationTest-full-config.xml
branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/integration/management/HornetQServerControlTest.java
branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/integration/management/QueueControlTest.java
branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/unit/core/config/impl/ConfigurationImplTest.java
branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/unit/core/config/impl/DefaultsFileConfigurationTest.java
branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/unit/core/config/impl/FileConfigurationTest.java
branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingImplTest.java
Log:
initial commit
Modified: branches/Branch_Replication_Changes/src/config/common/schema/hornetq-configuration.xsd
===================================================================
--- branches/Branch_Replication_Changes/src/config/common/schema/hornetq-configuration.xsd 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/config/common/schema/hornetq-configuration.xsd 2009-09-11 10:56:25 UTC (rev 7954)
@@ -63,10 +63,10 @@
</xsd:element>
<xsd:element maxOccurs="1" minOccurs="0" ref="remoting-interceptors">
</xsd:element>
- <xsd:element maxOccurs="1" minOccurs="0" name="queue-activation-timeout" type="xsd:long">
- </xsd:element>
<xsd:element maxOccurs="1" minOccurs="0" name="backup" type="xsd:boolean">
- </xsd:element>
+ </xsd:element>
+ <xsd:element maxOccurs="1" minOccurs="0" name="shared-store" type="xsd:boolean">
+ </xsd:element>
<xsd:element maxOccurs="1" minOccurs="0" name="persist-delivery-count-before-delivery" type="xsd:boolean">
</xsd:element>
<xsd:element maxOccurs="1" minOccurs="0" name="backup-connector-ref" type="backup-connectorType">
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -50,7 +50,6 @@
import org.hornetq.core.remoting.impl.wireformat.SessionCreateConsumerMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionDeleteQueueMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionExpiredMessage;
-import org.hornetq.core.remoting.impl.wireformat.SessionFailoverCompleteMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionQueueQueryMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionQueueQueryResponseMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionReceiveContinuationMessage;
@@ -743,7 +742,7 @@
try
{
- channel.transferConnection(backupConnection, channel.getID(), null);
+ channel.transferConnection(backupConnection);
backupConnection.syncIDGeneratorSequence(remotingConnection.getIDGeneratorSequence());
@@ -793,8 +792,6 @@
channel.unlock();
}
- channel.send(new SessionFailoverCompleteMessage(name));
-
return ok;
}
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/config/Configuration.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/config/Configuration.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/config/Configuration.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -57,6 +57,10 @@
void setBackup(boolean backup);
+ boolean isSharedStore();
+
+ void setSharedStore(boolean sharedStore);
+
boolean isFileDeploymentEnabled();
void setFileDeploymentEnabled(boolean enable);
@@ -69,10 +73,6 @@
void setFileDeployerScanPeriod(long period);
- long getQueueActivationTimeout();
-
- void setQueueActivationTimeout(long timeout);
-
int getThreadPoolMaxSize();
void setThreadPoolMaxSize(int maxSize);
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/config/impl/ConfigurationImpl.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/config/impl/ConfigurationImpl.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/config/impl/ConfigurationImpl.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -47,6 +47,8 @@
public static final boolean DEFAULT_PERSIST_DELIVERY_COUNT_BEFORE_DELIVERY = false;
public static final boolean DEFAULT_BACKUP = false;
+
+ public static final boolean DEFAULT_SHARED_STORE = false;
public static final boolean DEFAULT_FILE_DEPLOYMENT_ENABLED = false;
@@ -54,8 +56,6 @@
public static final long DEFAULT_FILE_DEPLOYER_SCAN_PERIOD = 5000;
- public static final long DEFAULT_QUEUE_ACTIVATION_TIMEOUT = 30000;
-
public static final int DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE = 5;
public static final int DEFAULT_THREAD_POOL_MAX_SIZE = -1;
@@ -163,7 +163,9 @@
protected boolean clustered = DEFAULT_CLUSTERED;
protected boolean backup = DEFAULT_BACKUP;
-
+
+ protected boolean sharedStore = DEFAULT_SHARED_STORE;
+
protected boolean fileDeploymentEnabled = DEFAULT_FILE_DEPLOYMENT_ENABLED;
protected boolean persistenceEnabled = DEFAULT_PERSISTENCE_ENABLED;
@@ -172,8 +174,6 @@
protected boolean persistDeliveryCountBeforeDelivery = DEFAULT_PERSIST_DELIVERY_COUNT_BEFORE_DELIVERY;
- protected long queueActivationTimeout = DEFAULT_QUEUE_ACTIVATION_TIMEOUT;
-
protected int scheduledThreadPoolMaxSize = DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE;
protected int threadPoolMaxSize = DEFAULT_THREAD_POOL_MAX_SIZE;
@@ -364,15 +364,15 @@
{
this.backup = backup;
}
-
- public long getQueueActivationTimeout()
+
+ public boolean isSharedStore()
{
- return queueActivationTimeout;
+ return sharedStore;
}
- public void setQueueActivationTimeout(final long timeout)
+ public void setSharedStore(final boolean sharedStore)
{
- queueActivationTimeout = timeout;
+ this.sharedStore = sharedStore;
}
public int getScheduledThreadPoolMaxSize()
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/config/impl/FileConfiguration.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/config/impl/FileConfiguration.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/config/impl/FileConfiguration.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -104,6 +104,8 @@
backup = getBoolean(e, "backup", backup);
+ sharedStore = getBoolean(e, "shared-store", sharedStore);
+
//Defaults to true when using FileConfiguration
fileDeploymentEnabled = getBoolean(e, "file-deployment-enabled", true);
@@ -111,8 +113,6 @@
persistDeliveryCountBeforeDelivery = getBoolean(e, "persist-delivery-count-before-delivery", persistDeliveryCountBeforeDelivery);
- queueActivationTimeout = getLong(e, "queue-activation-timeout", queueActivationTimeout, GE_ZERO);
-
// NOTE! All the defaults come from the super class
scheduledThreadPoolMaxSize = getInteger(e, "scheduled-thread-pool-max-size", scheduledThreadPoolMaxSize, GT_ZERO);
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/HornetQServerControl.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/HornetQServerControl.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/HornetQServerControl.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -25,7 +25,7 @@
{
// Attributes ----------------------------------------------------
- public String getBackupConnectorName();
+ String getBackupConnectorName();
String getVersion();
@@ -77,18 +77,18 @@
void setMessageCounterSamplePeriod(long newPeriod) throws Exception;
- public boolean isBackup();
+ boolean isBackup();
+
+ boolean isSharedStore();
int getAIOBufferSize();
int getAIOBufferTimeout();
- public String getPagingDirectory();
+ String getPagingDirectory();
boolean isPersistDeliveryCountBeforeDelivery();
- long getQueueActivationTimeout();
-
long getConnectionTTLOverride();
String getManagementAddress();
@@ -156,7 +156,7 @@
void resetAllMessageCounterHistories() throws Exception;
@Operation(desc = "List all the prepared transaction, sorted by date, oldest first")
- public String[] listPreparedTransactions() throws Exception;
+ String[] listPreparedTransactions() throws Exception;
@Operation(desc = "Commit a prepared transaction")
boolean commitPreparedTransaction(@Parameter(desc = "the Base64 representation of a transaction", name = "transactionAsBase64") String transactionAsBase64) throws Exception;
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/ManagementService.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/ManagementService.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/ManagementService.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -67,8 +67,6 @@
SimpleString getManagementNotificationAddress();
- ReplicationOperationInvoker getReplicationOperationInvoker();
-
// Resource Registration
HornetQServerControlImpl registerServer(PostOffice postOffice,
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/QueueControl.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/QueueControl.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/QueueControl.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -58,8 +58,6 @@
void setDeadLetterAddress(@Parameter(name = "deadLetterAddress", desc = "Dead-letter address of the queue") String deadLetterAddress) throws Exception;
- boolean isBackup();
-
// Operations ----------------------------------------------------
@Operation(desc = "List the messages scheduled for delivery", impact = INFO)
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/impl/HornetQServerControlImpl.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/impl/HornetQServerControlImpl.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/impl/HornetQServerControlImpl.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -127,6 +127,11 @@
{
return configuration.isBackup();
}
+
+ public boolean isSharedStore()
+ {
+ return configuration.isSharedStore();
+ }
public String getBackupConnectorName()
{
@@ -602,11 +607,6 @@
return configuration.getMessageExpiryThreadPriority();
}
- public long getQueueActivationTimeout()
- {
- return configuration.getQueueActivationTimeout();
- }
-
public long getTransactionTimeout()
{
return configuration.getTransactionTimeout();
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -50,11 +50,7 @@
import org.hornetq.core.management.Notification;
import org.hornetq.core.management.NotificationListener;
import org.hornetq.core.management.ObjectNames;
-import org.hornetq.core.management.ReplicationOperationInvoker;
import org.hornetq.core.management.ResourceNames;
-import org.hornetq.core.management.jmx.impl.ReplicationAwareAddressControlWrapper;
-import org.hornetq.core.management.jmx.impl.ReplicationAwareHornetQServerControlWrapper;
-import org.hornetq.core.management.jmx.impl.ReplicationAwareQueueControlWrapper;
import org.hornetq.core.messagecounter.MessageCounter;
import org.hornetq.core.messagecounter.MessageCounterManager;
import org.hornetq.core.messagecounter.impl.MessageCounterManagerImpl;
@@ -130,8 +126,6 @@
private final Set<NotificationListener> listeners = new org.hornetq.utils.ConcurrentHashSet<NotificationListener>();
- private ReplicationOperationInvoker replicationInvoker;
-
// Static --------------------------------------------------------
private static void checkDefaultManagementClusterCredentials(String user, String password)
@@ -163,12 +157,6 @@
registry = new HashMap<String, Object>();
broadcaster = new NotificationBroadcasterSupport();
notificationsEnabled = true;
-
- replicationInvoker = new ReplicationOperationInvokerImpl(managementClusterUser,
- managementClusterPassword,
- managementAddress,
- managementRequestTimeout,
- managementConnectorID);
}
// Public --------------------------------------------------------
@@ -210,8 +198,7 @@
messageCounterManager,
broadcaster);
ObjectName objectName = ObjectNames.getHornetQServerObjectName();
- registerInJMX(objectName, new ReplicationAwareHornetQServerControlWrapper(messagingServerControl,
- replicationInvoker));
+ registerInJMX(objectName, messagingServerControl);
registerInRegistry(ResourceNames.CORE_SERVER, messagingServerControl);
return messagingServerControl;
@@ -229,7 +216,7 @@
ObjectName objectName = ObjectNames.getAddressObjectName(address);
AddressControlImpl addressControl = new AddressControlImpl(address, postOffice, securityRepository);
- registerInJMX(objectName, new ReplicationAwareAddressControlWrapper(addressControl, replicationInvoker));
+ registerInJMX(objectName, addressControl);
registerInRegistry(ResourceNames.CORE_ADDRESS + address, addressControl);
@@ -264,7 +251,7 @@
queueControl.setMessageCounter(counter);
messageCounterManager.registerMessageCounter(queue.getName().toString(), counter);
ObjectName objectName = ObjectNames.getQueueObjectName(address, queue.getName());
- registerInJMX(objectName, new ReplicationAwareQueueControlWrapper(queueControl, replicationInvoker));
+ registerInJMX(objectName, queueControl);
registerInRegistry(ResourceNames.CORE_QUEUE + queue.getName(), queueControl);
if (log.isDebugEnabled())
@@ -572,11 +559,6 @@
return managementClusterPassword;
}
- public ReplicationOperationInvoker getReplicationOperationInvoker()
- {
- return replicationInvoker;
- }
-
// HornetQComponent implementation -----------------------------
public void start() throws Exception
@@ -639,8 +621,6 @@
registeredNames.clear();
- replicationInvoker.stop();
-
started = false;
}
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/impl/QueueControlImpl.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/impl/QueueControlImpl.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/impl/QueueControlImpl.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -133,11 +133,6 @@
return queue.isTemporary();
}
- public boolean isBackup()
- {
- return queue.isBackup();
- }
-
public int getMessageCount()
{
return queue.getMessageCount();
Deleted: branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/impl/ReplicationOperationInvokerImpl.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/impl/ReplicationOperationInvokerImpl.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/management/impl/ReplicationOperationInvokerImpl.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -1,134 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.core.management.impl;
-
-import java.util.HashMap;
-
-import org.hornetq.core.client.ClientMessage;
-import org.hornetq.core.client.ClientRequestor;
-import org.hornetq.core.client.ClientSession;
-import org.hornetq.core.client.ClientSessionFactory;
-import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
-import org.hornetq.core.client.management.impl.ManagementHelper;
-import org.hornetq.core.config.TransportConfiguration;
-import org.hornetq.core.logging.Logger;
-import org.hornetq.core.management.ReplicationOperationInvoker;
-import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
-import org.hornetq.core.remoting.impl.invm.TransportConstants;
-import org.hornetq.utils.SimpleString;
-
-/**
- * A ReplicationOperationInvoker
- *
- * @author <a href="jmesnil(a)redhat.com">Jeff Mesnil</a>
- *
- */
-public class ReplicationOperationInvokerImpl implements ReplicationOperationInvoker
-{
-
- // Constants -----------------------------------------------------
-
- private static final Logger log = Logger.getLogger(ReplicationOperationInvokerImpl.class);
-
- // Attributes ----------------------------------------------------
-
- private final long timeout;
-
- private final String clusterUser;
-
- private final String clusterPassword;
-
- private final SimpleString managementAddress;
-
- private ClientSession clientSession;
-
- private ClientRequestor requestor;
-
- private final int managementConnectorID;
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- public ReplicationOperationInvokerImpl(final String clusterUser,
- final String clusterPassword,
- final SimpleString managementAddress,
- final long managementRequestTimeout,
- final int managementConnectorID)
- {
- this.timeout = managementRequestTimeout;
- this.clusterUser = clusterUser;
- this.clusterPassword = clusterPassword;
- this.managementAddress = managementAddress;
- this.managementConnectorID = managementConnectorID;
- }
-
- // Public --------------------------------------------------------
-
- public synchronized Object invoke(final String resourceName, final String operationName, final Object... parameters) throws Exception
- {
- if (clientSession == null)
- {
- ClientSessionFactory sf = new ClientSessionFactoryImpl(new TransportConfiguration(InVMConnectorFactory.class.getName(),
- new HashMap<String, Object>()
- {
- {
- put(TransportConstants.SERVER_ID_PROP_NAME,
- managementConnectorID);
- }
- }));
-
- clientSession = sf.createSession(clusterUser, clusterPassword, false, true, true, false, 1);
- requestor = new ClientRequestor(clientSession, managementAddress);
- clientSession.start();
- }
- ClientMessage mngmntMessage = clientSession.createClientMessage(false);
- ManagementHelper.putOperationInvocation(mngmntMessage, resourceName, operationName, parameters);
- ClientMessage reply = requestor.request(mngmntMessage, timeout);
-
- if (reply == null)
- {
- throw new Exception("did not receive reply for message " + mngmntMessage);
- }
- reply.acknowledge();
- if (ManagementHelper.hasOperationSucceeded(reply))
- {
- return ManagementHelper.getResult(reply);
- }
- else
- {
- throw new Exception((String)ManagementHelper.getResult(reply));
- }
- }
-
- public void stop() throws Exception
- {
- if (clientSession != null)
- {
- clientSession.close();
- }
- }
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/paging/PagingManager.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/paging/PagingManager.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/paging/PagingManager.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -47,10 +47,6 @@
*/
public interface PagingManager extends HornetQComponent
{
- void activate();
-
- boolean isBackup();
-
/** To return the PageStore associated with the address */
PagingStore getPageStore(SimpleString address) throws Exception;
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/paging/impl/PagingManagerImpl.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/paging/impl/PagingManagerImpl.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/paging/impl/PagingManagerImpl.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -47,7 +47,7 @@
private volatile boolean started = false;
- private volatile boolean backup;
+ // private volatile boolean backup;
private final AtomicLong totalMemoryBytes = new AtomicLong(0);
@@ -74,14 +74,12 @@
public PagingManagerImpl(final PagingStoreFactory pagingSPI,
final StorageManager storageManager,
final HierarchicalRepository<AddressSettings> addressSettingsRepository,
- final boolean syncNonTransactional,
- final boolean backup)
+ final boolean syncNonTransactional)
{
pagingStoreFactory = pagingSPI;
this.addressSettingsRepository = addressSettingsRepository;
this.storageManager = storageManager;
this.syncNonTransactional = syncNonTransactional;
- this.backup = backup;
}
// Public
@@ -95,25 +93,7 @@
Set<SimpleString> names = stores.keySet();
return (SimpleString[])names.toArray(new SimpleString[names.size()]);
}
-
- public void activate()
- {
- backup = false;
- for (PagingStore store : stores.values())
- {
- if (store.isPaging())
- {
- store.startDepaging();
- }
- }
- }
-
- public boolean isBackup()
- {
- return backup;
- }
-
/* (non-Javadoc)
* @see org.hornetq.core.paging.PagingManager#reloadStores()
*/
@@ -270,14 +250,11 @@
}
synchronized (this)
{
- if (!isBackup())
+ for (PagingStore store : stores.values())
{
- for (PagingStore store : stores.values())
+ if (store.isPaging())
{
- if (store.isPaging())
- {
- store.startDepaging();
- }
+ store.startDepaging();
}
}
}
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -401,11 +401,6 @@
return false;
}
- if (pagingManager.isBackup())
- {
- return false;
- }
-
currentPageLock.readLock().lock();
try
{
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/postoffice/PostOffice.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/postoffice/PostOffice.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/postoffice/PostOffice.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -13,8 +13,6 @@
package org.hornetq.core.postoffice;
-import java.util.List;
-
import org.hornetq.core.paging.PagingManager;
import org.hornetq.core.server.HornetQComponent;
import org.hornetq.core.server.Queue;
@@ -58,8 +56,6 @@
boolean redistribute(ServerMessage message, final Queue originatingQueue, Transaction tx) throws Exception;
- List<Queue> activate();
-
PagingManager getPagingManager();
DuplicateIDCache getDuplicateIDCache(SimpleString address);
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -75,8 +75,6 @@
public static final SimpleString HDR_RESET_QUEUE_DATA = new SimpleString("_HQ_RESET_QUEUE_DATA");
- private HornetQServer server;
-
private final AddressManager addressManager;
private final QueueFactory queueFactory;
@@ -87,7 +85,7 @@
private volatile boolean started;
- private volatile boolean backup;
+ // private volatile boolean backup;
private final ManagementService managementService;
@@ -123,23 +121,19 @@
private final HierarchicalRepository<AddressSettings> addressSettingsRepository;
- public PostOfficeImpl(final HornetQServer server,
- final StorageManager storageManager,
+ public PostOfficeImpl(final StorageManager storageManager,
final PagingManager pagingManager,
final QueueFactory bindableFactory,
final ManagementService managementService,
final long reaperPeriod,
final int reaperPriority,
- final boolean enableWildCardRouting,
- final boolean backup,
+ final boolean enableWildCardRouting,
final int idCacheSize,
final boolean persistIDCache,
final ExecutorFactory orderedExecutorFactory,
HierarchicalRepository<AddressSettings> addressSettingsRepository)
{
- this.server = server;
-
this.storageManager = storageManager;
this.queueFactory = bindableFactory;
@@ -161,8 +155,6 @@
addressManager = new SimpleAddressManager();
}
- this.backup = backup;
-
this.idCacheSize = idCacheSize;
this.persistIDCache = persistIDCache;
@@ -190,10 +182,7 @@
// This is to avoid thread leakages where the Reaper would run beyong the life cycle of the PostOffice
started = true;
- if (!backup)
- {
- startExpiryScanner();
- }
+ startExpiryScanner();
}
public synchronized void stop() throws Exception
@@ -356,8 +345,7 @@
if (redistributionDelay != -1)
{
queue.addRedistributor(redistributionDelay,
- redistributorExecutorFactory.getExecutor(),
- server.getReplicatingChannel());
+ redistributorExecutorFactory.getExecutor());
}
}
}
@@ -428,8 +416,7 @@
if (redistributionDelay != -1)
{
queue.addRedistributor(redistributionDelay,
- redistributorExecutorFactory.getExecutor(),
- server.getReplicatingChannel());
+ redistributorExecutorFactory.getExecutor());
}
}
}
@@ -463,11 +450,6 @@
{
Queue queue = (Queue)binding.getBindable();
- if (backup)
- {
- queue.setBackup();
- }
-
managementService.registerQueue(queue, binding.getAddress(), storageManager);
if (!existed)
@@ -683,37 +665,6 @@
return pagingManager;
}
- public List<Queue> activate()
- {
-
- backup = false;
-
- pagingManager.activate();
-
- Map<SimpleString, Binding> nameMap = addressManager.getBindings();
-
- List<Queue> queues = new ArrayList<Queue>();
-
- for (Binding binding : nameMap.values())
- {
- if (binding.getType() == BindingType.LOCAL_QUEUE)
- {
- Queue queue = (Queue)binding.getBindable();
-
- boolean activated = queue.activate();
-
- if (!activated)
- {
- queues.add(queue);
- }
- }
- }
-
- startExpiryScanner();
-
- return queues;
- }
-
public DuplicateIDCache getDuplicateIDCache(final SimpleString address)
{
DuplicateIDCache cache = duplicateIDCaches.get(address);
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/Channel.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/Channel.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/Channel.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -31,15 +31,13 @@
Packet sendBlocking(Packet packet) throws HornetQException;
- void replicatePacket(Packet packet, long replicatedChannelID, Runnable action);
-
void setHandler(ChannelHandler handler);
ChannelHandler getHandler();
void close();
- void transferConnection(RemotingConnection newConnection, final long newID, final Channel replicatingChannel);
+ void transferConnection(RemotingConnection newConnection);
void replayCommands(int lastReceivedCommandID, final long newID);
@@ -55,8 +53,6 @@
RemotingConnection getConnection();
- void executeOutstandingDelayedResults();
-
void confirm(Packet packet);
void setCommandConfirmationHandler(CommandConfirmationHandler handler);
@@ -64,6 +60,4 @@
void flushConfirmations();
void handlePacket(Packet packet);
-
- void waitForAllReplicationResponse();
}
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/Packet.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/Packet.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/Packet.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -41,8 +41,6 @@
int getRequiredBufferSize();
boolean isRequiresConfirmations();
-
- boolean isWriteAlways();
}
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/RemotingConnection.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/RemotingConnection.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/RemotingConnection.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -62,14 +62,8 @@
long getIDGeneratorSequence();
- void activate();
-
- void freeze();
-
Connection getTransportConnection();
- boolean isActive();
-
boolean isClient();
boolean isDestroyed();
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/ChannelImpl.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/ChannelImpl.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/ChannelImpl.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -14,11 +14,7 @@
package org.hornetq.core.remoting.impl;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.PACKETS_CONFIRMED;
-import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.REPLICATION_RESPONSE;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
@@ -73,12 +69,8 @@
private final Object sendBlockingLock = new Object();
- private final Object replicationLock = new Object();
-
private boolean failingOver;
- private final Queue<Runnable> responseActions = new ConcurrentLinkedQueue<Runnable>();
-
private final int windowSize;
private final int confWindowSize;
@@ -89,10 +81,6 @@
private CommandConfirmationHandler commandConfirmationHandler;
- private int responseActionCount;
-
- private boolean playedResponsesOnFailure;
-
public ChannelImpl(final RemotingConnection connection, final long id, final int windowSize, final boolean block)
{
this.connection = connection;
@@ -200,10 +188,7 @@
resendCache.add(packet);
}
- if (connection.isActive() || packet.isWriteAlways())
- {
- connection.getTransportConnection().write(buffer, flush);
- }
+ connection.getTransportConnection().write(buffer, flush);
}
finally
{
@@ -333,99 +318,11 @@
}
}
- // Must be synchronized since can be called by incoming session commands but also by deliveries
- // Also needs to be synchronized with respect to replicatingChannelDead
- public void replicatePacket(final Packet packet, final long replicatedChannelID, final Runnable action)
- {
- packet.setChannelID(replicatedChannelID);
-
- boolean runItNow = false;
-
- synchronized (replicationLock)
- {
- if (playedResponsesOnFailure && action != null)
- {
- // Already replicating channel failed, so just play the action now
-
- runItNow = true;
- }
- else
- {
- if (action != null)
- {
- responseActions.add(action);
-
- responseActionCount++;
- }
-
- final HornetQBuffer buffer = connection.getTransportConnection()
- .createBuffer(packet.getRequiredBufferSize());
-
- packet.encode(buffer);
-
- connection.getTransportConnection().write(buffer);
- }
- }
-
- // Execute outside lock
-
- if (runItNow)
- {
- action.run();
- }
- }
-
public void setCommandConfirmationHandler(final CommandConfirmationHandler handler)
{
this.commandConfirmationHandler = handler;
}
- public void executeOutstandingDelayedResults()
- {
- // Execute on different thread to avoid deadlock
-
- new Thread()
- {
- public void run()
- {
- doExecuteOutstandingDelayedResults();
- }
- }.start();
- }
-
- private void doExecuteOutstandingDelayedResults()
- {
- List<Runnable> toRun = new ArrayList<Runnable>();
-
- synchronized (replicationLock)
- {
- playedResponsesOnFailure = true;
-
- responseActionCount = 0;
- }
-
- while (true)
- {
- // Execute all the response actions now
-
- Runnable action = responseActions.poll();
-
- if (action != null)
- {
- toRun.add(action);
- }
- else
- {
- break;
- }
- }
-
- for (Runnable action : toRun)
- {
- action.run();
- }
- }
-
public void setHandler(final ChannelHandler handler)
{
this.handler = handler;
@@ -451,9 +348,7 @@
closed = true;
}
- public void transferConnection(final RemotingConnection newConnection,
- final long newChannelID,
- final Channel replicatingChannel)
+ public void transferConnection(final RemotingConnection newConnection)
{
// Needs to synchronize on the connection to make sure no packets from
// the old connection get processed after transfer has occurred
@@ -461,25 +356,13 @@
{
connection.removeChannel(id);
- if (replicatingChannel != null)
- {
- // If we're reconnecting to a live node which is replicated then there will be a replicating channel
- // too. We need to then make sure that all replication responses come back since packets aren't
- // considered confirmed until response comes back and is processed. Otherwise responses to previous
- // message sends could come back after reconnection resulting in clients resending same message
- // since it wasn't confirmed yet.
- replicatingChannel.waitForAllReplicationResponse();
- }
-
// And switch it
final RemotingConnectionImpl rnewConnection = (RemotingConnectionImpl)newConnection;
- rnewConnection.putChannel(newChannelID, this);
+ rnewConnection.putChannel(id, this);
connection = rnewConnection;
-
- this.id = newChannelID;
}
}
@@ -522,7 +405,7 @@
public void flushConfirmations()
{
- if (receivedBytes != 0 && connection.isActive())
+ if (receivedBytes != 0)
{
receivedBytes = 0;
@@ -546,14 +429,11 @@
{
receivedBytes = 0;
- if (connection.isActive())
- {
- final Packet confirmed = new PacketsConfirmedMessage(lastReceivedCommandID);
+ final Packet confirmed = new PacketsConfirmedMessage(lastReceivedCommandID);
- confirmed.setChannelID(id);
+ confirmed.setChannelID(id);
- doWrite(confirmed);
- }
+ doWrite(confirmed);
}
}
}
@@ -576,12 +456,6 @@
return;
}
- else if (packet.getType() == REPLICATION_RESPONSE)
- {
- replicateResponseReceived();
-
- return;
- }
else
{
if (packet.isResponse())
@@ -606,98 +480,8 @@
handler.handlePacket(packet);
}
}
-
- replicateComplete();
}
- public void waitForAllReplicationResponse()
- {
- synchronized (replicationLock)
- {
- long toWait = 10000; // TODO don't hardcode timeout
-
- long start = System.currentTimeMillis();
-
- while (responseActionCount > 0 && toWait > 0)
- {
- try
- {
- replicationLock.wait();
- }
- catch (InterruptedException e)
- {
- }
-
- long now = System.currentTimeMillis();
-
- toWait -= now - start;
-
- start = now;
- }
-
- if (toWait <= 0)
- {
- log.warn("Timed out waiting for replication responses to return");
- }
- }
- }
-
- private void replicateComplete()
- {
- if (!connection.isActive() && id != 0)
- {
- // We're on backup and not ping channel so send back a replication response
-
- Packet packet = new PacketImpl(REPLICATION_RESPONSE);
-
- packet.setChannelID(2);
-
- doWrite(packet);
- }
- }
-
- // This will never get called concurrently by more than one thread
-
- // TODO it's not ideal synchronizing this since it forms a contention point with replication
- // but we need to do this to protect it w.r.t. the check on replicatingChannel
-
- private void replicateResponseReceived()
- {
- Runnable result = null;
-
- synchronized (replicationLock)
- {
- if (playedResponsesOnFailure)
- {
- return;
- }
-
- result = responseActions.poll();
-
- if (result == null)
- {
- throw new IllegalStateException("Cannot find response action");
- }
- }
-
- // Must execute outside of lock
- if (result != null)
- {
- result.run();
-
- // TODO - we can optimise this not to lock every time - only if waiting for all replications to return
- synchronized (replicationLock)
- {
- responseActionCount--;
-
- if (responseActionCount == 0)
- {
- replicationLock.notify();
- }
- }
- }
- }
-
private void doWrite(final Packet packet)
{
final HornetQBuffer buffer = connection.getTransportConnection().createBuffer(packet.getRequiredBufferSize());
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/PacketDecoder.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/PacketDecoder.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/PacketDecoder.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -24,15 +24,6 @@
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.PING;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.REATTACH_SESSION;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.REATTACH_SESSION_RESP;
-import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.REPLICATE_ACKNOWLEDGE;
-import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.REPLICATE_ADD_REMOTE_CONSUMER;
-import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.REPLICATE_ADD_REMOTE_QUEUE_BINDING;
-import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.REPLICATE_CREATESESSION;
-import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.REPLICATE_REDISTRIBUTION;
-import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.REPLICATE_REMOVE_REMOTE_CONSUMER;
-import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.REPLICATE_REMOVE_REMOTE_QUEUE_BINDING;
-import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.REPLICATE_STARTUP_INFO;
-import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.REPLICATION_RESPONSE;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_ACKNOWLEDGE;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_BINDINGQUERY;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_BINDINGQUERY_RESP;
@@ -41,13 +32,11 @@
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_CONSUMER_CLOSE;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_CREATECONSUMER;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_EXPIRED;
-import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_FAILOVER_COMPLETE;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_FLOWTOKEN;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_QUEUEQUERY;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_QUEUEQUERY_RESP;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_RECEIVE_CONTINUATION;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_RECEIVE_MSG;
-import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_REPLICATE_DELIVERY;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_ROLLBACK;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_SEND;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_SEND_CONTINUATION;
@@ -82,7 +71,6 @@
import org.hornetq.core.remoting.impl.wireformat.Ping;
import org.hornetq.core.remoting.impl.wireformat.ReattachSessionMessage;
import org.hornetq.core.remoting.impl.wireformat.ReattachSessionResponseMessage;
-import org.hornetq.core.remoting.impl.wireformat.ReplicateCreateSessionMessage;
import org.hornetq.core.remoting.impl.wireformat.RollbackMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionAcknowledgeMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionBindingQueryMessage;
@@ -93,7 +81,6 @@
import org.hornetq.core.remoting.impl.wireformat.SessionCreateConsumerMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionDeleteQueueMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionExpiredMessage;
-import org.hornetq.core.remoting.impl.wireformat.SessionFailoverCompleteMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionQueueQueryMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionQueueQueryResponseMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionReceiveContinuationMessage;
@@ -114,14 +101,6 @@
import org.hornetq.core.remoting.impl.wireformat.SessionXASetTimeoutMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionXASetTimeoutResponseMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionXAStartMessage;
-import org.hornetq.core.remoting.impl.wireformat.replication.ReplicateAcknowledgeMessage;
-import org.hornetq.core.remoting.impl.wireformat.replication.ReplicateRedistributionMessage;
-import org.hornetq.core.remoting.impl.wireformat.replication.ReplicateRemoteBindingAddedMessage;
-import org.hornetq.core.remoting.impl.wireformat.replication.ReplicateRemoteBindingRemovedMessage;
-import org.hornetq.core.remoting.impl.wireformat.replication.ReplicateRemoteConsumerAddedMessage;
-import org.hornetq.core.remoting.impl.wireformat.replication.ReplicateRemoteConsumerRemovedMessage;
-import org.hornetq.core.remoting.impl.wireformat.replication.ReplicateStartupInfoMessage;
-import org.hornetq.core.remoting.impl.wireformat.replication.SessionReplicateDeliveryMessage;
import org.hornetq.core.remoting.spi.HornetQBuffer;
/**
@@ -161,21 +140,11 @@
packet = new PacketsConfirmedMessage();
break;
}
- case REPLICATION_RESPONSE:
- {
- packet = new PacketImpl(REPLICATION_RESPONSE);
- break;
- }
case CREATESESSION:
{
packet = new CreateSessionMessage();
break;
}
- case REPLICATE_CREATESESSION:
- {
- packet = new ReplicateCreateSessionMessage();
- break;
- }
case CREATESESSION_RESP:
{
packet = new CreateSessionResponseMessage();
@@ -191,11 +160,6 @@
packet = new ReattachSessionResponseMessage();
break;
}
- case SESS_FAILOVER_COMPLETE:
- {
- packet = new SessionFailoverCompleteMessage();
- break;
- }
case SESS_CLOSE:
{
packet = new SessionCloseMessage();
@@ -385,47 +349,7 @@
{
packet = new SessionSendContinuationMessage();
break;
- }
- case REPLICATE_ADD_REMOTE_QUEUE_BINDING:
- {
- packet = new ReplicateRemoteBindingAddedMessage();
- break;
- }
- case REPLICATE_REMOVE_REMOTE_QUEUE_BINDING:
- {
- packet = new ReplicateRemoteBindingRemovedMessage();
- break;
- }
- case REPLICATE_ADD_REMOTE_CONSUMER:
- {
- packet = new ReplicateRemoteConsumerAddedMessage();
- break;
- }
- case REPLICATE_REMOVE_REMOTE_CONSUMER:
- {
- packet = new ReplicateRemoteConsumerRemovedMessage();
- break;
- }
- case SESS_REPLICATE_DELIVERY:
- {
- packet = new SessionReplicateDeliveryMessage();
- break;
- }
- case REPLICATE_STARTUP_INFO:
- {
- packet = new ReplicateStartupInfoMessage();
- break;
- }
- case REPLICATE_ACKNOWLEDGE:
- {
- packet = new ReplicateAcknowledgeMessage();
- break;
- }
- case REPLICATE_REDISTRIBUTION:
- {
- packet = new ReplicateRedistributionMessage();
- break;
- }
+ }
default:
{
throw new IllegalArgumentException("Invalid type: " + packetType);
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/RemotingConnectionImpl.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/RemotingConnectionImpl.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/RemotingConnectionImpl.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -65,7 +65,7 @@
private volatile boolean destroyed;
- private volatile boolean active;
+ // private volatile boolean active;
private final boolean client;
@@ -79,7 +79,7 @@
private final Object transferLock = new Object();
- private boolean frozen;
+ // private boolean frozen;
private final Object failLock = new Object();
@@ -99,7 +99,7 @@
final long blockingCallTimeout,
final List<Interceptor> interceptors)
{
- this(transportConnection, blockingCallTimeout, interceptors, true, true, null);
+ this(transportConnection, blockingCallTimeout, interceptors, true, null);
}
/*
@@ -107,17 +107,15 @@
*/
public RemotingConnectionImpl(final Connection transportConnection,
final List<Interceptor> interceptors,
- final boolean active,
final Executor executor)
{
- this(transportConnection, -1, interceptors, active, false, executor);
+ this(transportConnection, -1, interceptors, false, executor);
}
private RemotingConnectionImpl(final Connection transportConnection,
final long blockingCallTimeout,
final List<Interceptor> interceptors,
- final boolean active,
final boolean client,
final Executor executor)
@@ -128,8 +126,6 @@
this.interceptors = interceptors;
- this.active = active;
-
this.client = client;
this.executor = executor;
@@ -306,11 +302,6 @@
return transferLock;
}
- public boolean isActive()
- {
- return active;
- }
-
public boolean isClient()
{
return client;
@@ -366,55 +357,37 @@
{
synchronized (transferLock)
{
- if (!frozen)
+ if (interceptors != null)
{
- if (interceptors != null)
+ for (final Interceptor interceptor : interceptors)
{
- for (final Interceptor interceptor : interceptors)
+ try
{
- try
+ boolean callNext = interceptor.intercept(packet, this);
+
+ if (!callNext)
{
- boolean callNext = interceptor.intercept(packet, this);
+ // abort
- if (!callNext)
- {
- // abort
-
- return;
- }
+ return;
}
- catch (final Throwable e)
- {
- log.warn("Failure in calling interceptor: " + interceptor, e);
- }
}
+ catch (final Throwable e)
+ {
+ log.warn("Failure in calling interceptor: " + interceptor, e);
+ }
}
+ }
- final Channel channel = channels.get(packet.getChannelID());
+ final Channel channel = channels.get(packet.getChannelID());
- if (channel != null)
- {
- channel.handlePacket(packet);
- }
+ if (channel != null)
+ {
+ channel.handlePacket(packet);
}
}
}
- public void activate()
- {
- active = true;
- }
-
- public void freeze()
- {
- // Prevent any more packets being handled on this connection
-
- synchronized (transferLock)
- {
- frozen = true;
- }
- }
-
// Package protected
// ----------------------------------------------------------------------------
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/wireformat/CreateSessionResponseMessage.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/wireformat/CreateSessionResponseMessage.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/wireformat/CreateSessionResponseMessage.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -29,14 +29,18 @@
// Attributes ----------------------------------------------------
private int serverVersion;
+
+ private boolean created;
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
- public CreateSessionResponseMessage(final int serverVersion)
+ public CreateSessionResponseMessage(final boolean created, final int serverVersion)
{
super(CREATESESSION_RESP);
+
+ this.created = created;
this.serverVersion = serverVersion;
}
@@ -48,6 +52,11 @@
// Public --------------------------------------------------------
+ public boolean isCreated()
+ {
+ return created;
+ }
+
@Override
public boolean isResponse()
{
@@ -62,18 +71,20 @@
@Override
public void encodeBody(final HornetQBuffer buffer)
{
+ buffer.writeBoolean(created);
buffer.writeInt(serverVersion);
}
@Override
public void decodeBody(final HornetQBuffer buffer)
{
+ created = buffer.readBoolean();
serverVersion = buffer.readInt();
}
public int getRequiredBufferSize()
{
- return BASIC_PACKET_SIZE + DataConstants.SIZE_INT;
+ return BASIC_PACKET_SIZE + DataConstants.SIZE_BOOLEAN + DataConstants.SIZE_INT;
}
@Override
@@ -86,7 +97,7 @@
CreateSessionResponseMessage r = (CreateSessionResponseMessage)other;
- boolean matches = super.equals(other) && serverVersion == r.serverVersion;
+ boolean matches = super.equals(other) && serverVersion == r.serverVersion && created == r.created;
return matches;
}
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/wireformat/PacketImpl.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/wireformat/PacketImpl.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/wireformat/PacketImpl.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -52,8 +52,6 @@
public static final byte PACKETS_CONFIRMED = 22;
- public static final byte REPLICATION_RESPONSE = 23;
-
// Server
public static final byte CREATESESSION = 30;
@@ -63,11 +61,9 @@
public static final byte REATTACH_SESSION_RESP = 33;
- public static final byte REPLICATE_CREATESESSION = 34;
-
- public static final byte CREATE_QUEUE = 35;
+ public static final byte CREATE_QUEUE = 34;
- public static final byte DELETE_QUEUE = 36;
+ public static final byte DELETE_QUEUE = 35;
// Session
@@ -141,26 +137,6 @@
public static final byte SESS_RECEIVE_CONTINUATION = 76;
- public static final byte SESS_FAILOVER_COMPLETE = 77;
-
- //Replication
-
- public static final byte SESS_REPLICATE_DELIVERY = 90;
-
- public static final byte REPLICATE_ADD_REMOTE_QUEUE_BINDING = 91;
-
- public static final byte REPLICATE_REMOVE_REMOTE_QUEUE_BINDING = 92;
-
- public static final byte REPLICATE_ADD_REMOTE_CONSUMER = 93;
-
- public static final byte REPLICATE_REMOVE_REMOTE_CONSUMER = 94;
-
- public static final byte REPLICATE_ACKNOWLEDGE = 95;
-
- public static final byte REPLICATE_STARTUP_INFO = 96;
-
- public static final byte REPLICATE_REDISTRIBUTION = 97;
-
// Static --------------------------------------------------------
public PacketImpl(final byte type)
@@ -242,11 +218,6 @@
return true;
}
- public boolean isWriteAlways()
- {
- return false;
- }
-
@Override
public String toString()
{
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/wireformat/Ping.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/wireformat/Ping.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/wireformat/Ping.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -49,11 +49,6 @@
// Public --------------------------------------------------------
- public boolean isWriteAlways()
- {
- return true;
- }
-
public long getConnectionTTL()
{
return connectionTTL;
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/wireformat/ReattachSessionResponseMessage.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/wireformat/ReattachSessionResponseMessage.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/wireformat/ReattachSessionResponseMessage.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -30,21 +30,20 @@
// Attributes ----------------------------------------------------
private int lastReceivedCommandID;
+
+ private boolean sessionFound;
- //Is this flag really necessary - try removing it
- private boolean removed;
-
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
- public ReattachSessionResponseMessage(final int lastReceivedCommandID, final boolean removed)
+ public ReattachSessionResponseMessage(final int lastReceivedCommandID, final boolean sessionFound)
{
super(REATTACH_SESSION_RESP);
this.lastReceivedCommandID = lastReceivedCommandID;
- this.removed = removed;
+ this.sessionFound = sessionFound;
}
public ReattachSessionResponseMessage()
@@ -59,9 +58,9 @@
return lastReceivedCommandID;
}
- public boolean isRemoved()
+ public boolean isSessionFound()
{
- return removed;
+ return sessionFound;
}
public int getRequiredBufferSize()
@@ -73,13 +72,13 @@
public void encodeBody(final HornetQBuffer buffer)
{
buffer.writeInt(lastReceivedCommandID);
- buffer.writeBoolean(removed);
+ buffer.writeBoolean(sessionFound);
}
public void decodeBody(final HornetQBuffer buffer)
{
lastReceivedCommandID = buffer.readInt();
- removed = buffer.readBoolean();
+ sessionFound = buffer.readBoolean();
}
public boolean isResponse()
Deleted: branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicateCreateSessionMessage.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicateCreateSessionMessage.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicateCreateSessionMessage.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -1,255 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.core.remoting.impl.wireformat;
-
-import org.hornetq.core.remoting.spi.HornetQBuffer;
-import org.hornetq.utils.DataConstants;
-
-/**
- * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- * @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>.
- *
- * @version <tt>$Revision$</tt>
- */
-public class ReplicateCreateSessionMessage extends PacketImpl
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private String name;
-
- private long replicatedSessionChannelID;
-
- private long originalSessionChannelID;
-
- private int version;
-
- private String username;
-
- private String password;
-
- private int minLargeMessageSize;
-
- private boolean xa;
-
- private boolean autoCommitSends;
-
- private boolean autoCommitAcks;
-
- private boolean preAcknowledge;
-
- private int windowSize;
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- public ReplicateCreateSessionMessage(final String name,
- final long replicatedSessionChannelID,
- final long originalSessionChannelID,
- final int version,
- final String username,
- final String password,
- final int minLargeMessageSize,
- final boolean xa,
- final boolean autoCommitSends,
- final boolean autoCommitAcks,
- final boolean preAcknowledge,
- final int windowSize)
- {
- super(REPLICATE_CREATESESSION);
-
- this.name = name;
-
- this.replicatedSessionChannelID = replicatedSessionChannelID;
-
- this.originalSessionChannelID = originalSessionChannelID;
-
- this.version = version;
-
- this.username = username;
-
- this.password = password;
-
- this.minLargeMessageSize = minLargeMessageSize;
-
- this.xa = xa;
-
- this.autoCommitSends = autoCommitSends;
-
- this.autoCommitAcks = autoCommitAcks;
-
- this.preAcknowledge = preAcknowledge;
-
- this.windowSize = windowSize;
- }
-
- public ReplicateCreateSessionMessage()
- {
- super(REPLICATE_CREATESESSION);
- }
-
- // Public --------------------------------------------------------
-
- public String getName()
- {
- return name;
- }
-
- public long getReplicatedSessionChannelID()
- {
- return replicatedSessionChannelID;
- }
-
- public long getOriginalSessionChannelID()
- {
- return originalSessionChannelID;
- }
-
- public int getVersion()
- {
- return version;
- }
-
- public String getUsername()
- {
- return username;
- }
-
- public String getPassword()
- {
- return password;
- }
-
- public int getMinLargeMessageSize()
- {
- return minLargeMessageSize;
- }
-
- public boolean isXA()
- {
- return xa;
- }
-
- public boolean isAutoCommitSends()
- {
- return autoCommitSends;
- }
-
- public boolean isAutoCommitAcks()
- {
- return autoCommitAcks;
- }
-
- public boolean isPreAcknowledge()
- {
- return preAcknowledge;
- }
-
- public int getWindowSize()
- {
- return windowSize;
- }
-
- public int getRequiredBufferSize()
- {
- return BASIC_PACKET_SIZE +
- stringEncodeSize(name) + // buffer.writeString(name);
- DataConstants.SIZE_LONG + // buffer.writeLong(originalSessionChannelID);
- DataConstants.SIZE_LONG + // buffer.writeLong(replicatedSessionChannelID);
- DataConstants.SIZE_INT + // buffer.writeInt(version);
- nullableStringEncodeSize(username) + // buffer.writeNullableString(username);
- nullableStringEncodeSize(password) + // buffer.writeNullableString(password);
- DataConstants.SIZE_INT + // buffer.writeInt(minLargeMessageSize);
- DataConstants.SIZE_BOOLEAN + // buffer.writeBoolean(xa);
- DataConstants.SIZE_BOOLEAN + // buffer.writeBoolean(autoCommitSends);
- DataConstants.SIZE_BOOLEAN + // buffer.writeBoolean(autoCommitAcks);
- DataConstants.SIZE_INT + // buffer.writeInt(windowSize);
- DataConstants.SIZE_BOOLEAN; // buffer.writeBoolean(preAcknowledge);
- }
-
- @Override
- public void encodeBody(final HornetQBuffer buffer)
- {
- buffer.writeString(name);
- buffer.writeLong(originalSessionChannelID);
- buffer.writeLong(replicatedSessionChannelID);
- buffer.writeInt(version);
- buffer.writeNullableString(username);
- buffer.writeNullableString(password);
- buffer.writeInt(minLargeMessageSize);
- buffer.writeBoolean(xa);
- buffer.writeBoolean(autoCommitSends);
- buffer.writeBoolean(autoCommitAcks);
- buffer.writeInt(windowSize);
- buffer.writeBoolean(preAcknowledge);
- }
-
- @Override
- public void decodeBody(final HornetQBuffer buffer)
- {
- name = buffer.readString();
- originalSessionChannelID = buffer.readLong();
- replicatedSessionChannelID = buffer.readLong();
- version = buffer.readInt();
- username = buffer.readNullableString();
- password = buffer.readNullableString();
- minLargeMessageSize = buffer.readInt();
- xa = buffer.readBoolean();
- autoCommitSends = buffer.readBoolean();
- autoCommitAcks = buffer.readBoolean();
- windowSize = buffer.readInt();
- preAcknowledge = buffer.readBoolean();
- }
-
- @Override
- public boolean equals(final Object other)
- {
- if (other instanceof ReplicateCreateSessionMessage == false)
- {
- return false;
- }
-
- ReplicateCreateSessionMessage r = (ReplicateCreateSessionMessage)other;
-
- boolean matches = super.equals(other) && name.equals(r.name) &&
- originalSessionChannelID == r.originalSessionChannelID &&
- replicatedSessionChannelID == r.replicatedSessionChannelID &&
- version == r.version &&
- xa == r.xa &&
- autoCommitSends == r.autoCommitSends &&
- autoCommitAcks == r.autoCommitAcks &&
- (username == null ? r.username == null : username.equals(r.username)) &&
- (password == null ? r.password == null : password.equals(r.password)) &&
- minLargeMessageSize == r.minLargeMessageSize &&
- windowSize == r.windowSize;
-
- return matches;
- }
-
- @Override
- public final boolean isRequiresConfirmations()
- {
- return false;
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/wireformat/SessionFailoverCompleteMessage.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/wireformat/SessionFailoverCompleteMessage.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/impl/wireformat/SessionFailoverCompleteMessage.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -1,99 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.core.remoting.impl.wireformat;
-
-import org.hornetq.core.remoting.spi.HornetQBuffer;
-
-/**
- *
- * A SessionFailoverCompleteMessage
- *
- * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- *
- */
-public class SessionFailoverCompleteMessage extends PacketImpl
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private String name;
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- public SessionFailoverCompleteMessage(final String name)
- {
- super(SESS_FAILOVER_COMPLETE);
-
- this.name = name;
- }
-
- public SessionFailoverCompleteMessage()
- {
- super(SESS_FAILOVER_COMPLETE);
- }
-
- // Public --------------------------------------------------------
-
- public String getName()
- {
- return name;
- }
-
- public int getRequiredBufferSize()
- {
- return BASIC_PACKET_SIZE + stringEncodeSize(name);
- }
-
- @Override
- public void encodeBody(final HornetQBuffer buffer)
- {
- buffer.writeString(name);
- }
-
- @Override
- public void decodeBody(final HornetQBuffer buffer)
- {
- name = buffer.readString();
- }
-
- @Override
- public boolean isRequiresConfirmations()
- {
- return false;
- }
-
- @Override
- public boolean equals(final Object other)
- {
- if (other instanceof SessionFailoverCompleteMessage == false)
- {
- return false;
- }
-
- SessionFailoverCompleteMessage r = (SessionFailoverCompleteMessage)other;
-
- return super.equals(other) && name.equals(r.name);
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -303,8 +303,7 @@
}
RemotingConnection rc = new RemotingConnectionImpl(connection,
- interceptors,
- !config.isBackup(),
+ interceptors,
server.getConfiguration().isAsyncConnectionExecutionEnabled() ? server.getExecutorFactory()
.getExecutor()
: null);
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/HornetQServer.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/HornetQServer.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/HornetQServer.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -23,7 +23,6 @@
import org.hornetq.core.management.impl.HornetQServerControlImpl;
import org.hornetq.core.persistence.StorageManager;
import org.hornetq.core.postoffice.PostOffice;
-import org.hornetq.core.remoting.Channel;
import org.hornetq.core.remoting.RemotingConnection;
import org.hornetq.core.remoting.impl.wireformat.CreateSessionResponseMessage;
import org.hornetq.core.remoting.impl.wireformat.ReattachSessionResponseMessage;
@@ -65,15 +64,10 @@
HornetQServerControlImpl getHornetQServerControl();
- void registerActivateCallback(ActivateCallback callback);
-
- void unregisterActivateCallback(ActivateCallback callback);
-
ReattachSessionResponseMessage reattachSession(RemotingConnection connection, String name, int lastReceivedCommandID) throws Exception;
CreateSessionResponseMessage createSession(String name,
- long channelID,
- long replicatedSessionID,
+ long channelID,
String username,
String password,
int minLargeMessageSize,
@@ -85,20 +79,6 @@
boolean xa,
int producerWindowSize) throws Exception;
- void replicateCreateSession(String name,
- long channelID,
- long originalSessionID,
- String username,
- String password,
- int minLargeMessageSize,
- int incrementingVersion,
- RemotingConnection remotingConnection,
- boolean autoCommitSends,
- boolean autoCommitAcks,
- boolean preAcknowledge,
- boolean xa,
- int sendWindowSize) throws Exception;
-
void removeSession(String name) throws Exception;
ServerSession getSession(String name);
@@ -125,10 +105,8 @@
SimpleString getNodeID();
- Channel getReplicatingChannel();
+ // void initialiseBackup(UUID nodeID, long currentMessageID) throws Exception;
- void initialiseBackup(UUID nodeID, long currentMessageID) throws Exception;
-
boolean isInitialised();
Queue createQueue(SimpleString address,
@@ -145,7 +123,5 @@
void destroyQueue(SimpleString queueName, ServerSession session) throws Exception;
- void handleReplicateRedistribution(final SimpleString queueName, final long messageID) throws Exception;
-
ExecutorFactory getExecutorFactory();
}
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/Queue.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/Queue.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/Queue.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -121,18 +121,8 @@
int moveReferences(Filter filter, SimpleString toAddress) throws Exception;
- void setBackup();
+ void addRedistributor(long delay, Executor executor);
- boolean activate();
-
- void activateNow(Executor executor);
-
- boolean isBackup();
-
- boolean consumerFailedOver();
-
- void addRedistributor(long delay, Executor executor, final Channel replicatingChannel);
-
void cancelRedistributor() throws Exception;
// Only used in testing
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/ScheduledDeliveryHandler.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/ScheduledDeliveryHandler.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/ScheduledDeliveryHandler.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -19,7 +19,7 @@
*/
public interface ScheduledDeliveryHandler
{
- boolean checkAndSchedule(MessageReference ref, boolean backup);
+ boolean checkAndSchedule(MessageReference ref);
void reSchedule();
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/ServerConsumer.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/ServerConsumer.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/ServerConsumer.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -43,12 +43,4 @@
MessageReference getExpired(long messageID) throws Exception;
void acknowledge(boolean autoCommitAcks, Transaction tx, long messageID) throws Exception;
-
- void failedOver();
-
- void deliverReplicated(long messageID) throws Exception;
-
- void lock();
-
- void unlock();
}
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/ServerSession.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/ServerSession.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/ServerSession.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -17,7 +17,6 @@
import org.hornetq.core.remoting.Packet;
import org.hornetq.core.remoting.RemotingConnection;
import org.hornetq.core.remoting.impl.wireformat.CreateQueueMessage;
-import org.hornetq.core.remoting.impl.wireformat.PacketsConfirmedMessage;
import org.hornetq.core.remoting.impl.wireformat.RollbackMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionAcknowledgeMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionBindingQueryMessage;
@@ -39,7 +38,6 @@
import org.hornetq.core.remoting.impl.wireformat.SessionXARollbackMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionXASetTimeoutMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionXAStartMessage;
-import org.hornetq.core.remoting.impl.wireformat.replication.SessionReplicateDeliveryMessage;
import org.hornetq.core.server.impl.ServerSessionPacketHandler;
/**
@@ -126,14 +124,8 @@
void handleSendLargeMessage(SessionSendLargeMessage packet);
- void handleFailedOver(Packet packet);
-
void handleClose(Packet packet);
- void handleReplicatedDelivery(SessionReplicateDeliveryMessage packet);
-
- void handlePacketsConfirmed(PacketsConfirmedMessage packet);
-
int transferConnection(RemotingConnection newConnection, int lastReceivedCommandID);
Channel getChannel();
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/cluster/impl/BridgeImpl.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/cluster/impl/BridgeImpl.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/cluster/impl/BridgeImpl.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -41,11 +41,8 @@
import org.hornetq.core.message.impl.MessageImpl;
import org.hornetq.core.persistence.StorageManager;
import org.hornetq.core.postoffice.BindingType;
-import org.hornetq.core.remoting.Channel;
import org.hornetq.core.remoting.FailureListener;
-import org.hornetq.core.remoting.Packet;
import org.hornetq.core.remoting.RemotingConnection;
-import org.hornetq.core.remoting.impl.wireformat.replication.ReplicateAcknowledgeMessage;
import org.hornetq.core.server.HandleStatus;
import org.hornetq.core.server.MessageReference;
import org.hornetq.core.server.Queue;
@@ -131,8 +128,6 @@
private final String clusterPassword;
- private Channel replicatingChannel;
-
private boolean activated;
private NotificationService notificationService;
@@ -169,7 +164,6 @@
final String clusterUser,
final String clusterPassword,
final MessageFlowRecord flowRecord,
- final Channel replicatingChannel,
final boolean activated,
final StorageManager storageManager) throws Exception
{
@@ -215,8 +209,6 @@
this.flowRecord = flowRecord;
- this.replicatingChannel = replicatingChannel;
-
this.activated = activated;
}
@@ -309,8 +301,6 @@
public synchronized void activate()
{
- replicatingChannel = null;
-
activated = true;
executor.execute(new CreateObjectsRunnable());
@@ -374,30 +364,7 @@
if (ref != null)
{
- if (replicatingChannel == null)
- {
- // Acknowledge when we know send has been processed on the server
- ref.getQueue().acknowledge(ref);
- }
- else
- {
- Packet packet = new ReplicateAcknowledgeMessage(name, ref.getMessage().getMessageID());
-
- replicatingChannel.replicatePacket(packet, 1, new Runnable()
- {
- public void run()
- {
- try
- {
- ref.getQueue().acknowledge(ref);
- }
- catch (Exception e)
- {
- log.error("Failed to ack", e);
- }
- }
- });
- }
+ ref.getQueue().acknowledge(ref);
}
}
catch (Exception e)
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -37,13 +37,6 @@
import org.hornetq.core.postoffice.Binding;
import org.hornetq.core.postoffice.Bindings;
import org.hornetq.core.postoffice.PostOffice;
-import org.hornetq.core.remoting.Channel;
-import org.hornetq.core.remoting.Packet;
-import org.hornetq.core.remoting.impl.wireformat.CreateQueueMessage;
-import org.hornetq.core.remoting.impl.wireformat.replication.ReplicateRemoteBindingAddedMessage;
-import org.hornetq.core.remoting.impl.wireformat.replication.ReplicateRemoteBindingRemovedMessage;
-import org.hornetq.core.remoting.impl.wireformat.replication.ReplicateRemoteConsumerAddedMessage;
-import org.hornetq.core.remoting.impl.wireformat.replication.ReplicateRemoteConsumerRemovedMessage;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.Queue;
import org.hornetq.core.server.cluster.Bridge;
@@ -97,16 +90,12 @@
private final UUID nodeUUID;
- private final Channel replicatingChannel;
-
private final List<Pair<TransportConfiguration, TransportConfiguration>> staticConnectors;
private boolean backup;
private volatile boolean started;
-
- private int replicationCount;
-
+
/*
* Constructor using static list of connectors
*/
@@ -123,7 +112,6 @@
final List<Pair<TransportConfiguration, TransportConfiguration>> connectors,
final int maxHops,
final UUID nodeUUID,
- final Channel replicatingChannel,
final boolean backup) throws Exception
{
this.name = name;
@@ -157,8 +145,6 @@
this.nodeUUID = nodeUUID;
- this.replicatingChannel = replicatingChannel;
-
this.backup = backup;
this.staticConnectors = connectors;
@@ -185,7 +171,6 @@
final DiscoveryGroup discoveryGroup,
final int maxHops,
final UUID nodeUUID,
- final Channel replicatingChannel,
final boolean backup) throws Exception
{
this.name = name;
@@ -214,8 +199,6 @@
this.nodeUUID = nodeUUID;
- this.replicatingChannel = replicatingChannel;
-
this.backup = backup;
this.staticConnectors = null;
@@ -237,7 +220,8 @@
}
public synchronized void stop() throws Exception
- { if (!started)
+ {
+ if (!started)
{
return;
}
@@ -374,47 +358,9 @@
// Add binding in storage so the queue will get reloaded on startup and we can find it - it's never
// actually routed to at that address though
- if (replicatingChannel == null)
- {
- queue = server.createQueue(queueName, queueName, null, true, false);
+ queue = server.createQueue(queueName, queueName, null, true, false);
- createNewRecord(entry.getKey(), connectorPair, queueName, queue, true);
- }
- else
- {
- // We need to create the record before we replicate, since otherwise, two updates can come in for
- // the same entry before the first replication comes back, and it won't find the record, so it
- // will try and create the queue twice
- createNewRecord(entry.getKey(), connectorPair, queueName, null, false);
-
- // Replicate the createQueue first
- Packet packet = new CreateQueueMessage(queueName, queueName, null, true, false);
-
- replicatingChannel.replicatePacket(packet, 1, new Runnable()
- {
- public void run()
- {
- try
- {
- Queue queue = server.createQueue(queueName, queueName, null, true, false);
-
- synchronized (ClusterConnectionImpl.this)
- {
- MessageFlowRecord record = records.get(entry.getKey());
-
- if (record != null)
- {
- record.activate(queue);
- }
- }
- }
- catch (Exception e)
- {
- log.error("Failed create record", e);
- }
- }
- });
- }
+ createNewRecord(entry.getKey(), connectorPair, queueName, queue, true);
}
}
}
@@ -449,7 +395,6 @@
managementService.getClusterUser(),
managementService.getClusterPassword(),
record,
- replicatingChannel,
!backup,
server.getStorageManager());
@@ -495,52 +440,8 @@
bridge.stop();
clearBindings();
-
- waitForReplicationsToComplete(3000);
}
-
- private synchronized void waitForReplicationsToComplete(long timeout)
- {
- long toWait = timeout;
- long start = System.currentTimeMillis();
-
- while (replicationCount > 0 && toWait > 0)
- {
- try
- {
- wait(toWait);
- }
- catch (InterruptedException e)
- {
- }
-
- long now = System.currentTimeMillis();
-
- toWait -= now - start;
-
- start = now;
- }
-
- if (toWait <= 0)
- {
- log.warn("Timed out waiting for replication responses to return");
- }
-
- }
-
- private synchronized void replicationComplete()
- {
- replicationCount--;
-
- notify();
- }
-
- private synchronized void beforeReplicate()
- {
- replicationCount++;
- }
-
public void activate(final Queue queue) throws Exception
{
this.queue = queue;
@@ -584,7 +485,7 @@
{
case BINDING_ADDED:
{
- doBindingAdded(message, replicatingChannel);
+ doBindingAdded(message);
break;
}
@@ -596,13 +497,13 @@
}
case CONSUMER_CREATED:
{
- doConsumerCreated(message, replicatingChannel);
+ doConsumerCreated(message);
break;
}
case CONSUMER_CLOSED:
{
- doConsumerClosed(message, replicatingChannel);
+ doConsumerClosed(message);
break;
}
@@ -622,14 +523,14 @@
}
private synchronized void clearBindings() throws Exception
- {
+ {
for (RemoteQueueBinding binding : new HashSet<RemoteQueueBinding>(bindings.values()))
{
- removeBinding(binding.getClusterName(), replicatingChannel);
- }
+ removeBinding(binding.getClusterName());
+ }
}
- private synchronized void doBindingAdded(final ClientMessage message, final Channel replChannel) throws Exception
+ private synchronized void doBindingAdded(final ClientMessage message) throws Exception
{
Integer distance = (Integer)message.getProperty(ManagementHelper.HDR_DISTANCE);
@@ -668,73 +569,42 @@
throw new IllegalStateException("queueID is null");
}
- if (replChannel != null)
- {
- Packet packet = new ReplicateRemoteBindingAddedMessage(name,
- queueAddress,
- clusterName,
- routingName,
- queueID,
- filterString,
- queue.getName(),
- distance + 1);
+ RemoteQueueBinding binding = new RemoteQueueBindingImpl(queueAddress,
+ clusterName,
+ routingName,
+ queueID,
+ filterString,
+ queue,
+ bridge.getName(),
+ distance + 1);
- beforeReplicate();
- replChannel.replicatePacket(packet, 1, new Runnable()
- {
- public void run()
- {
- try
- {
- doBindingAdded(message, null);
- }
- catch (Exception e)
- {
- log.error("Failed to add remote queue binding", e);
- }
-
- replicationComplete();
- }
- });
- }
- else
+ bindings.put(clusterName, binding);
+
+ if (postOffice.getBinding(clusterName) != null)
{
- RemoteQueueBinding binding = new RemoteQueueBindingImpl(queueAddress,
- clusterName,
- routingName,
- queueID,
- filterString,
- queue,
- bridge.getName(),
- distance + 1);
+ // Sanity check - this means the binding has already been added via another bridge, probably max
+ // hops is too high
+ // or there are multiple cluster connections for the same address
- bindings.put(clusterName, binding);
+ log.warn("Remote queue binding " + clusterName +
+ " has already been bound in the post office. Most likely cause for this is you have a loop " +
+ "in your cluster due to cluster max-hops being too large or you have multiple cluster connections to the same nodes using overlapping addresses");
- if (postOffice.getBinding(clusterName) != null)
- {
- // Sanity check - this means the binding has already been added via another bridge, probably max
- // hops is too high
- // or there are multiple cluster connections for the same address
+ return;
+ }
- log.warn("Remote queue binding " + clusterName +
- " has already been bound in the post office. Most likely cause for this is you have a loop " +
- "in your cluster due to cluster max-hops being too large or you have multiple cluster connections to the same nodes using overlapping addresses");
+ try
+ {
+ postOffice.addBinding(binding);
+ }
+ catch (Exception ignore)
+ {
+ }
- return;
- }
+ Bindings theBindings = postOffice.getBindingsForAddress(queueAddress);
- try
- {
- postOffice.addBinding(binding);
- }
- catch (Exception ignore)
- {
- }
+ theBindings.setRouteWhenNoConsumers(routeWhenNoConsumers);
- Bindings theBindings = postOffice.getBindingsForAddress(queueAddress);
-
- theBindings.setRouteWhenNoConsumers(routeWhenNoConsumers);
- }
}
private void doBindingRemoved(final ClientMessage message) throws Exception
@@ -746,47 +616,22 @@
throw new IllegalStateException("clusterName is null");
}
- removeBinding(clusterName, replicatingChannel);
+ removeBinding(clusterName);
}
-
- private synchronized void removeBinding(final SimpleString clusterName, final Channel replChannel) throws Exception
+
+ private synchronized void removeBinding(final SimpleString clusterName) throws Exception
{
- if (replChannel != null)
- {
- Packet packet = new ReplicateRemoteBindingRemovedMessage(clusterName);
+ RemoteQueueBinding binding = bindings.remove(clusterName);
- beforeReplicate();
- replChannel.replicatePacket(packet, 1, new Runnable()
- {
- public void run()
- {
- try
- {
- removeBinding(clusterName, null);
- }
- catch (Exception e)
- {
- log.error("Failed to remove remote queue binding", e);
- }
-
- replicationComplete();
- }
- });
- }
- else
+ if (binding == null)
{
- RemoteQueueBinding binding = bindings.remove(clusterName);
-
- if (binding == null)
- {
- throw new IllegalStateException("Cannot find binding for queue " + clusterName);
- }
-
- postOffice.removeBinding(binding.getUniqueName());
+ throw new IllegalStateException("Cannot find binding for queue " + clusterName);
}
+
+ postOffice.removeBinding(binding.getUniqueName());
}
- private synchronized void doConsumerCreated(final ClientMessage message, final Channel replChannel) throws Exception
+ private synchronized void doConsumerCreated(final ClientMessage message) throws Exception
{
Integer distance = (Integer)message.getProperty(ManagementHelper.HDR_DISTANCE);
@@ -806,47 +651,22 @@
SimpleString filterString = (SimpleString)message.getProperty(ManagementHelper.HDR_FILTERSTRING);
- if (replChannel != null)
- {
- Packet packet = new ReplicateRemoteConsumerAddedMessage(clusterName, filterString, message.getProperties());
+ RemoteQueueBinding binding = bindings.get(clusterName);
- beforeReplicate();
- replChannel.replicatePacket(packet, 1, new Runnable()
- {
- public void run()
- {
- try
- {
- doConsumerCreated(message, null);
- }
- catch (Exception e)
- {
- log.error("Failed to add remote consumer", e);
- }
-
- replicationComplete();
- }
- });
- }
- else
+ if (binding == null)
{
- RemoteQueueBinding binding = bindings.get(clusterName);
+ throw new IllegalStateException("Cannot find binding for " + clusterName);
+ }
- if (binding == null)
- {
- throw new IllegalStateException("Cannot find binding for " + clusterName);
- }
+ binding.addConsumer(filterString);
- binding.addConsumer(filterString);
+ // Need to propagate the consumer add
+ Notification notification = new Notification(null, CONSUMER_CREATED, message.getProperties());
- // Need to propagate the consumer add
- Notification notification = new Notification(null, CONSUMER_CREATED, message.getProperties());
-
- managementService.sendNotification(notification);
- }
+ managementService.sendNotification(notification);
}
- private synchronized void doConsumerClosed(final ClientMessage message, final Channel replChannel) throws Exception
+ private synchronized void doConsumerClosed(final ClientMessage message) throws Exception
{
Integer distance = (Integer)message.getProperty(ManagementHelper.HDR_DISTANCE);
@@ -866,46 +686,19 @@
SimpleString filterString = (SimpleString)message.getProperty(ManagementHelper.HDR_FILTERSTRING);
- if (replChannel != null)
- {
- Packet packet = new ReplicateRemoteConsumerRemovedMessage(clusterName,
- filterString,
- message.getProperties());
+ RemoteQueueBinding binding = bindings.get(clusterName);
- beforeReplicate();
- replChannel.replicatePacket(packet, 1, new Runnable()
- {
- public void run()
- {
- try
- {
- doConsumerClosed(message, null);
- }
- catch (Exception e)
- {
- log.error("Failed to remove remote consumer", e);
- }
-
- replicationComplete();
- }
- });
- }
- else
+ if (binding == null)
{
- RemoteQueueBinding binding = bindings.get(clusterName);
+ throw new IllegalStateException("Cannot find binding for " + clusterName);
+ }
- if (binding == null)
- {
- throw new IllegalStateException("Cannot find binding for " + clusterName);
- }
+ binding.removeConsumer(filterString);
- binding.removeConsumer(filterString);
+ // Need to propagate the consumer close
+ Notification notification = new Notification(null, CONSUMER_CLOSED, message.getProperties());
- // Need to propagate the consumer close
- Notification notification = new Notification(null, CONSUMER_CLOSED, message.getProperties());
-
- managementService.sendNotification(notification);
- }
+ managementService.sendNotification(notification);
}
}
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/cluster/impl/ClusterManagerImpl.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/cluster/impl/ClusterManagerImpl.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/cluster/impl/ClusterManagerImpl.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -84,8 +84,6 @@
private final UUID nodeUUID;
- private Channel replicatingChannel;
-
private volatile boolean started;
private boolean backup;
@@ -96,8 +94,7 @@
final ScheduledExecutorService scheduledExecutor,
final ManagementService managementService,
final Configuration configuration,
- final UUID nodeUUID,
- final Channel replicatingChannel,
+ final UUID nodeUUID,
final boolean backup)
{
if (nodeUUID == null)
@@ -119,8 +116,6 @@
this.nodeUUID = nodeUUID;
- this.replicatingChannel = replicatingChannel;
-
this.backup = backup;
}
@@ -236,8 +231,6 @@
cc.activate();
}
- replicatingChannel = null;
-
backup = false;
}
@@ -420,8 +413,7 @@
managementService.getManagementNotificationAddress(),
managementService.getClusterUser(),
managementService.getClusterPassword(),
- null,
- replicatingChannel,
+ null,
!backup,
server.getStorageManager());
}
@@ -473,8 +465,7 @@
managementService.getManagementNotificationAddress(),
managementService.getClusterUser(),
managementService.getClusterPassword(),
- null,
- replicatingChannel,
+ null,
!backup,
server.getStorageManager());
}
@@ -553,8 +544,7 @@
scheduledExecutor,
connectors,
config.getMaxHops(),
- nodeUUID,
- replicatingChannel,
+ nodeUUID,
backup);
}
else
@@ -579,8 +569,7 @@
scheduledExecutor,
dg,
config.getMaxHops(),
- nodeUUID,
- replicatingChannel,
+ nodeUUID,
backup);
}
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/cluster/impl/Redistributor.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/cluster/impl/Redistributor.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/cluster/impl/Redistributor.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -19,9 +19,6 @@
import org.hornetq.core.logging.Logger;
import org.hornetq.core.persistence.StorageManager;
import org.hornetq.core.postoffice.PostOffice;
-import org.hornetq.core.remoting.Channel;
-import org.hornetq.core.remoting.Packet;
-import org.hornetq.core.remoting.impl.wireformat.replication.ReplicateRedistributionMessage;
import org.hornetq.core.server.Consumer;
import org.hornetq.core.server.HandleStatus;
import org.hornetq.core.server.MessageReference;
@@ -57,14 +54,11 @@
private int count;
- private final Channel replicatingChannel;
-
public Redistributor(final Queue queue,
final StorageManager storageManager,
final PostOffice postOffice,
final Executor executor,
- final int batchSize,
- final Channel replicatingChannel)
+ final int batchSize)
{
this.queue = queue;
@@ -75,8 +69,6 @@
this.executor = executor;
this.batchSize = batchSize;
-
- this.replicatingChannel = replicatingChannel;
}
public Filter getFilter()
@@ -134,30 +126,8 @@
if (routed)
{
- if (replicatingChannel == null)
- {
- doRedistribute(reference, tx);
- }
- else
- {
- Packet packet = new ReplicateRedistributionMessage(queue.getName(), reference.getMessage().getMessageID());
-
- replicatingChannel.replicatePacket(packet, 1, new Runnable()
- {
- public void run()
- {
- try
- {
- doRedistribute(reference, tx);
- }
- catch (Exception e)
- {
- log.error("Failed to handle redistribution", e);
- }
- }
- });
- }
-
+ doRedistribute(reference, tx);
+
return HandleStatus.HANDLED;
}
else
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/HornetQPacketHandler.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/HornetQPacketHandler.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/HornetQPacketHandler.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -13,18 +13,12 @@
package org.hornetq.core.server.impl;
-import static org.hornetq.core.management.NotificationType.CONSUMER_CLOSED;
-import static org.hornetq.core.management.NotificationType.CONSUMER_CREATED;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.CREATESESSION;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.CREATE_QUEUE;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.REATTACH_SESSION;
-import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.REPLICATE_CREATESESSION;
-import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.REPLICATE_STARTUP_INFO;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.logging.Logger;
-import org.hornetq.core.management.Notification;
-import org.hornetq.core.postoffice.Binding;
import org.hornetq.core.remoting.Channel;
import org.hornetq.core.remoting.ChannelHandler;
import org.hornetq.core.remoting.Packet;
@@ -32,21 +26,8 @@
import org.hornetq.core.remoting.impl.wireformat.CreateQueueMessage;
import org.hornetq.core.remoting.impl.wireformat.CreateSessionMessage;
import org.hornetq.core.remoting.impl.wireformat.HornetQExceptionMessage;
-import org.hornetq.core.remoting.impl.wireformat.PacketImpl;
import org.hornetq.core.remoting.impl.wireformat.ReattachSessionMessage;
-import org.hornetq.core.remoting.impl.wireformat.ReplicateCreateSessionMessage;
-import org.hornetq.core.remoting.impl.wireformat.replication.ReplicateAcknowledgeMessage;
-import org.hornetq.core.remoting.impl.wireformat.replication.ReplicateRedistributionMessage;
-import org.hornetq.core.remoting.impl.wireformat.replication.ReplicateRemoteBindingAddedMessage;
-import org.hornetq.core.remoting.impl.wireformat.replication.ReplicateRemoteBindingRemovedMessage;
-import org.hornetq.core.remoting.impl.wireformat.replication.ReplicateRemoteConsumerAddedMessage;
-import org.hornetq.core.remoting.impl.wireformat.replication.ReplicateRemoteConsumerRemovedMessage;
-import org.hornetq.core.remoting.impl.wireformat.replication.ReplicateStartupInfoMessage;
import org.hornetq.core.server.HornetQServer;
-import org.hornetq.core.server.MessageReference;
-import org.hornetq.core.server.Queue;
-import org.hornetq.core.server.cluster.ClusterConnection;
-import org.hornetq.core.server.cluster.RemoteQueueBinding;
/**
* A packet handler for all packets that need to be handled at the server level
@@ -80,30 +61,10 @@
{
byte type = packet.getType();
- if (!server.isInitialised() && type != PacketImpl.REPLICATE_STARTUP_INFO)
- {
- throw new IllegalStateException("First packet must be startup info for backup " + type);
- }
-
// All these operations need to be idempotent since they are outside of the session
// reliability replay functionality
switch (type)
- {
- case REPLICATE_STARTUP_INFO:
- {
- ReplicateStartupInfoMessage msg = (ReplicateStartupInfoMessage)packet;
-
- try
- {
- server.initialiseBackup(msg.getNodeID(), msg.getCurrentMessageID());
- }
- catch (Exception e)
- {
- log.error("Failed to initialise", e);
- }
-
- break;
- }
+ {
case CREATESESSION:
{
CreateSessionMessage request = (CreateSessionMessage)packet;
@@ -111,15 +72,7 @@
handleCreateSession(request);
break;
- }
- case REPLICATE_CREATESESSION:
- {
- ReplicateCreateSessionMessage request = (ReplicateCreateSessionMessage)packet;
-
- handleReplicateCreateSession(request);
-
- break;
- }
+ }
case REATTACH_SESSION:
{
ReattachSessionMessage request = (ReattachSessionMessage)packet;
@@ -137,55 +90,7 @@
handleCreateQueue(request);
break;
- }
- case PacketImpl.REPLICATE_ADD_REMOTE_QUEUE_BINDING:
- {
- ReplicateRemoteBindingAddedMessage request = (ReplicateRemoteBindingAddedMessage)packet;
-
- handleAddRemoteQueueBinding(request);
-
- break;
- }
- case PacketImpl.REPLICATE_REMOVE_REMOTE_QUEUE_BINDING:
- {
- ReplicateRemoteBindingRemovedMessage request = (ReplicateRemoteBindingRemovedMessage)packet;
-
- handleRemoveRemoteQueueBinding(request);
-
- break;
- }
- case PacketImpl.REPLICATE_ADD_REMOTE_CONSUMER:
- {
- ReplicateRemoteConsumerAddedMessage request = (ReplicateRemoteConsumerAddedMessage)packet;
-
- handleAddRemoteConsumer(request);
-
- break;
- }
- case PacketImpl.REPLICATE_REMOVE_REMOTE_CONSUMER:
- {
- ReplicateRemoteConsumerRemovedMessage request = (ReplicateRemoteConsumerRemovedMessage)packet;
-
- handleRemoveRemoteConsumer(request);
-
- break;
- }
- case PacketImpl.REPLICATE_ACKNOWLEDGE:
- {
- ReplicateAcknowledgeMessage request = (ReplicateAcknowledgeMessage)packet;
-
- handleReplicateAcknowledge(request);
-
- break;
- }
- case PacketImpl.REPLICATE_REDISTRIBUTION:
- {
- ReplicateRedistributionMessage message = (ReplicateRedistributionMessage)packet;
-
- handleReplicateRedistribution(message);
-
- break;
- }
+ }
default:
{
log.error("Invalid packet " + packet);
@@ -193,14 +98,13 @@
}
}
- private void doHandleCreateSession(final CreateSessionMessage request, final long oppositeChannelID)
+ private void handleCreateSession(final CreateSessionMessage request)
{
Packet response;
try
{
response = server.createSession(request.getName(),
- request.getSessionChannelID(),
- oppositeChannelID,
+ request.getSessionChannelID(),
request.getUsername(),
request.getPassword(),
request.getMinLargeMessageSize(),
@@ -231,68 +135,9 @@
}
}
- channel1.send(response);
+ channel1.send(response);
}
-
- private void handleCreateSession(final CreateSessionMessage request)
- {
- Channel replicatingChannel = server.getReplicatingChannel();
-
- if (replicatingChannel == null)
- {
- doHandleCreateSession(request, -1);
- }
- else
- {
- final long replicatedChannelID = replicatingChannel.getConnection().generateChannelID();
-
- Packet replPacket = new ReplicateCreateSessionMessage(request.getName(),
- replicatedChannelID,
- request.getSessionChannelID(),
- request.getVersion(),
- request.getUsername(),
- request.getPassword(),
- request.getMinLargeMessageSize(),
- request.isXA(),
- request.isAutoCommitSends(),
- request.isAutoCommitAcks(),
- request.isPreAcknowledge(),
- request.getWindowSize());
-
- replicatingChannel.replicatePacket(replPacket, 1, new Runnable()
- {
- public void run()
- {
- doHandleCreateSession(request, replicatedChannelID);
- }
- });
- }
- }
-
- private void handleReplicateCreateSession(final ReplicateCreateSessionMessage request)
- {
- try
- {
- server.replicateCreateSession(request.getName(),
- request.getReplicatedSessionChannelID(),
- request.getOriginalSessionChannelID(),
- request.getUsername(),
- request.getPassword(),
- request.getMinLargeMessageSize(),
- request.getVersion(),
- connection,
- request.isAutoCommitSends(),
- request.isAutoCommitAcks(),
- request.isPreAcknowledge(),
- request.isXA(),
- request.getWindowSize());
- }
- catch (Exception e)
- {
- log.error("Failed to handle replicate create session", e);
- }
- }
-
+
private void handleReattachSession(final ReattachSessionMessage request)
{
Packet response;
@@ -330,151 +175,5 @@
}
}
- private void handleAddRemoteQueueBinding(final ReplicateRemoteBindingAddedMessage request)
- {
- ClusterConnection cc = server.getClusterManager().getClusterConnection(request.getClusterConnectionName());
-
- if (cc == null)
- {
- throw new IllegalStateException("No cluster connection found with name " + request.getClusterConnectionName());
- }
-
- try
- {
- cc.handleReplicatedAddBinding(request.getAddress(),
- request.getUniqueName(),
- request.getRoutingName(),
- request.getRemoteQueueID(),
- request.getFilterString(),
- request.getSfQueueName(),
- request.getDistance());
- }
- catch (Exception e)
- {
- log.error("Failed to handle add remote queue binding", e);
- }
- }
-
- private void handleRemoveRemoteQueueBinding(final ReplicateRemoteBindingRemovedMessage request)
- {
- try
- {
- Binding binding = server.getPostOffice().removeBinding(request.getUniqueName());
-
- if (binding == null)
- {
- throw new IllegalStateException("Cannot find binding to remove " + request.getUniqueName());
- }
- }
- catch (Exception e)
- {
- log.error("Failed to handle remove remote queue binding", e);
- }
- }
-
- private void handleAddRemoteConsumer(final ReplicateRemoteConsumerAddedMessage request)
- {
- RemoteQueueBinding binding = (RemoteQueueBinding)server.getPostOffice()
- .getBinding(request.getUniqueBindingName());
-
- if (binding == null)
- {
- throw new IllegalStateException("Cannot find binding to remove " + request.getUniqueBindingName());
- }
-
- try
- {
- binding.addConsumer(request.getFilterString());
- }
- catch (Exception e)
- {
- log.error("Failed to handle add remote consumer", e);
- }
-
- // Need to propagate the consumer add
- Notification notification = new Notification(null, CONSUMER_CREATED, request.getProperties());
-
- try
- {
- server.getManagementService().sendNotification(notification);
- }
- catch (Exception e)
- {
- log.error("Failed to handle add remote consumer", e);
- }
- }
-
- private void handleRemoveRemoteConsumer(final ReplicateRemoteConsumerRemovedMessage request)
- {
- RemoteQueueBinding binding = (RemoteQueueBinding)server.getPostOffice()
- .getBinding(request.getUniqueBindingName());
-
- if (binding == null)
- {
- throw new IllegalStateException("Cannot find binding to remove " + request.getUniqueBindingName());
- }
-
- try
- {
- binding.removeConsumer(request.getFilterString());
- }
- catch (Exception e)
- {
- log.error("Failed to handle remove remote consumer", e);
- }
-
- // Need to propagate the consumer close
- Notification notification = new Notification(null, CONSUMER_CLOSED, request.getProperties());
-
- try
- {
- server.getManagementService().sendNotification(notification);
- }
- catch (Exception e)
- {
- log.error("Failed to handle remove remote consumer", e);
- }
- }
-
- private void handleReplicateAcknowledge(final ReplicateAcknowledgeMessage request)
- {
- Binding binding = server.getPostOffice().getBinding(request.getUniqueName());
-
- if (binding == null)
- {
- throw new IllegalStateException("Cannot find binding " + request.getUniqueName());
- }
-
- try
- {
- Queue queue = (Queue)binding.getBindable();
-
- MessageReference ref = queue.removeFirstReference(request.getMessageID());
-
- queue.acknowledge(ref);
- }
- catch (Exception e)
- {
- log.error("Failed to handle remove remote consumer", e);
- }
- }
- private void handleReplicateRedistribution(final ReplicateRedistributionMessage request)
- {
- Binding binding = server.getPostOffice().getBinding(request.getQueueName());
-
- if (binding == null)
- {
- throw new IllegalStateException("Cannot find binding " + request.getQueueName());
- }
-
- try
- {
- server.handleReplicateRedistribution(request.getQueueName(), request.getMessageID());
- }
- catch (Exception e)
- {
- log.error("Failed to handle remove remote consumer", e);
- }
- }
}
\ No newline at end of file
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -32,11 +32,7 @@
import javax.management.MBeanServer;
-import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
-import org.hornetq.core.client.impl.ConnectionManager;
-import org.hornetq.core.client.impl.ConnectionManagerImpl;
import org.hornetq.core.config.Configuration;
-import org.hornetq.core.config.TransportConfiguration;
import org.hornetq.core.config.cluster.DivertConfiguration;
import org.hornetq.core.config.cluster.QueueConfiguration;
import org.hornetq.core.config.impl.ConfigurationImpl;
@@ -68,12 +64,9 @@
import org.hornetq.core.postoffice.impl.LocalQueueBinding;
import org.hornetq.core.postoffice.impl.PostOfficeImpl;
import org.hornetq.core.remoting.Channel;
-import org.hornetq.core.remoting.FailureListener;
-import org.hornetq.core.remoting.Packet;
import org.hornetq.core.remoting.RemotingConnection;
import org.hornetq.core.remoting.impl.wireformat.CreateSessionResponseMessage;
import org.hornetq.core.remoting.impl.wireformat.ReattachSessionResponseMessage;
-import org.hornetq.core.remoting.impl.wireformat.replication.ReplicateStartupInfoMessage;
import org.hornetq.core.remoting.server.RemotingService;
import org.hornetq.core.remoting.server.impl.RemotingServiceImpl;
import org.hornetq.core.security.CheckType;
@@ -81,7 +74,6 @@
import org.hornetq.core.security.Role;
import org.hornetq.core.security.SecurityStore;
import org.hornetq.core.security.impl.SecurityStoreImpl;
-import org.hornetq.core.server.ActivateCallback;
import org.hornetq.core.server.Divert;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.MemoryManager;
@@ -101,7 +93,6 @@
import org.hornetq.core.transaction.impl.TransactionImpl;
import org.hornetq.core.version.Version;
import org.hornetq.utils.ExecutorFactory;
-import org.hornetq.utils.Future;
import org.hornetq.utils.HornetQThreadFactory;
import org.hornetq.utils.OrderedExecutorFactory;
import org.hornetq.utils.Pair;
@@ -142,8 +133,6 @@
private final MBeanServer mbeanServer;
- private final Set<ActivateCallback> activateCallbacks = new HashSet<ActivateCallback>();
-
private volatile boolean started;
private SecurityStore securityStore;
@@ -189,17 +178,11 @@
private Deployer securityDeployer;
private final Map<String, ServerSession> sessions = new ConcurrentHashMap<String, ServerSession>();
-
- private RemotingConnection replicatingConnection;
-
- private Channel replicatingChannel;
-
+
private final Object initialiseLock = new Object();
private boolean initialised;
-
- private ConnectionManager replicatingConnectionManager;
-
+
private int managementConnectorID;
private static AtomicInteger managementConnectorSequence = new AtomicInteger(0);
@@ -276,7 +259,7 @@
if (configuration.isBackup())
{
// We defer actually initialisation until the live node has contacted the backup
- log.info("Backup server will await live server before becoming operational");
+ log.info("Backup server initialised");
}
else
{
@@ -354,22 +337,7 @@
{
securityManager.stop();
}
-
- if (replicatingConnection != null)
- {
- try
- {
- replicatingConnection.destroy();
- }
- catch (Exception ignore)
- {
- }
-
- replicatingConnection = null;
- replicatingChannel = null;
- replicatingConnectionManager = null;
- }
-
+
resourceManager.stop();
postOffice.stop();
@@ -496,57 +464,28 @@
{
ServerSession session = sessions.get(name);
- // Need to activate the connection even if session can't be found - since otherwise response
- // will never get back
+ if (!checkActivate())
+ {
+ return new ReattachSessionResponseMessage(-1, false, false);
+ }
- checkActivate(connection);
-
if (session == null)
{
- return new ReattachSessionResponseMessage(-1, true);
+ create the session
+
+ return new ReattachSessionResponseMessage(-1, false, true);
}
else
{
// Reconnect the channel to the new connection
int serverLastReceivedCommandID = session.transferConnection(connection, lastReceivedCommandID);
- return new ReattachSessionResponseMessage(serverLastReceivedCommandID, false);
+ return new ReattachSessionResponseMessage(serverLastReceivedCommandID, true, true);
}
}
- public void replicateCreateSession(final String name,
- final long replicatedChannelID,
- final long originalChannelID,
- final String username,
- final String password,
- final int minLargeMessageSize,
- final int incrementingVersion,
- final RemotingConnection connection,
- final boolean autoCommitSends,
- final boolean autoCommitAcks,
- final boolean preAcknowledge,
- final boolean xa,
- final int producerWindowSize) throws Exception
- {
- doCreateSession(name,
- replicatedChannelID,
- originalChannelID,
- username,
- password,
- minLargeMessageSize,
- incrementingVersion,
- connection,
- autoCommitSends,
- autoCommitAcks,
- preAcknowledge,
- xa,
- producerWindowSize,
- true);
- }
-
public CreateSessionResponseMessage createSession(final String name,
- final long channelID,
- final long replicatedChannelID,
+ final long channelID,
final String username,
final String password,
final int minLargeMessageSize,
@@ -557,23 +496,70 @@
final boolean preAcknowledge,
final boolean xa,
final int sendWindowSize) throws Exception
- {
- checkActivate(connection);
+ {
+ if (version.getIncrementingVersion() != incrementingVersion)
+ {
+ log.warn("Client with version " + incrementingVersion +
+ " and address " +
+ connection.getRemoteAddress() +
+ " is not compatible with server version " +
+ version.getFullVersion() +
+ ". " +
+ "Please ensure all clients and servers are upgraded to the same version for them to " +
+ "interoperate properly");
+ return null;
+ }
+
+ if (!checkActivate())
+ {
+ //Backup server is not ready to accept connections
+
+ return new CreateSessionResponseMessage(false, version.getIncrementingVersion());
+ }
- return doCreateSession(name,
- channelID,
- replicatedChannelID,
- username,
- password,
- minLargeMessageSize,
- incrementingVersion,
- connection,
- autoCommitSends,
- autoCommitAcks,
- preAcknowledge,
- xa,
- sendWindowSize,
- false);
+ securityStore.authenticate(username, password);
+
+ ServerSession currentSession = sessions.remove(name);
+
+ if (currentSession != null)
+ {
+ // This session may well be on a different connection and different channel id, so we must get rid
+ // of it and create another
+ currentSession.getChannel().close();
+ }
+
+ Channel channel = connection.getChannel(channelID, sendWindowSize, false);
+
+ final ServerSessionImpl session = new ServerSessionImpl(name,
+ username,
+ password,
+ minLargeMessageSize,
+ autoCommitSends,
+ autoCommitAcks,
+ preAcknowledge,
+ configuration.isPersistDeliveryCountBeforeDelivery(),
+ xa,
+ connection,
+ storageManager,
+ postOffice,
+ resourceManager,
+ securityStore,
+ executorFactory.getExecutor(),
+ channel,
+ managementService,
+ queueFactory,
+ this,
+ configuration.getManagementAddress());
+
+ sessions.put(name, session);
+
+ ServerSessionPacketHandler handler = new ServerSessionPacketHandler(session);
+
+ session.setHandler(handler);
+
+ channel.setHandler(handler);
+
+ return new CreateSessionResponseMessage(true, version.getIncrementingVersion());
}
public void removeSession(final String name) throws Exception
@@ -614,42 +600,42 @@
}
}
- public void initialiseBackup(final UUID theUUID, final long liveUniqueID) throws Exception
- {
- if (theUUID == null)
- {
- throw new IllegalArgumentException("node id is null");
- }
+// public void initialiseBackup(final UUID theUUID, final long liveUniqueID) throws Exception
+// {
+// if (theUUID == null)
+// {
+// throw new IllegalArgumentException("node id is null");
+// }
+//
+// synchronized (initialiseLock)
+// {
+// if (initialised)
+// {
+// throw new IllegalStateException("Server is already initialised");
+// }
+//
+// this.uuid = theUUID;
+//
+// this.nodeID = new SimpleString(uuid.toString());
+//
+// initialisePart2();
+//
+// long backupID = storageManager.getCurrentUniqueID();
+//
+// if (liveUniqueID != backupID)
+// {
+// initialised = false;
+//
+// throw new IllegalStateException("Live and backup unique ids different (" + liveUniqueID +
+// ":" +
+// backupID +
+// "). You're probably trying to restart a live backup pair after a crash");
+// }
+//
+// log.info("Backup server is now operational");
+// }
+// }
- synchronized (initialiseLock)
- {
- if (initialised)
- {
- throw new IllegalStateException("Server is already initialised");
- }
-
- this.uuid = theUUID;
-
- this.nodeID = new SimpleString(uuid.toString());
-
- initialisePart2();
-
- long backupID = storageManager.getCurrentUniqueID();
-
- if (liveUniqueID != backupID)
- {
- initialised = false;
-
- throw new IllegalStateException("Live and backup unique ids different (" + liveUniqueID +
- ":" +
- backupID +
- "). You're probably trying to restart a live backup pair after a crash");
- }
-
- log.info("Backup server is now operational");
- }
- }
-
public HornetQServerControlImpl getHornetQServerControl()
{
return messagingServerControl;
@@ -761,16 +747,6 @@
postOffice.removeBinding(queueName);
}
- public synchronized void registerActivateCallback(final ActivateCallback callback)
- {
- activateCallbacks.add(callback);
- }
-
- public synchronized void unregisterActivateCallback(final ActivateCallback callback)
- {
- activateCallbacks.remove(callback);
- }
-
public ExecutorFactory getExecutorFactory()
{
return executorFactory;
@@ -790,92 +766,31 @@
return new PagingManagerImpl(new PagingStoreFactoryNIO(configuration.getPagingDirectory(), executorFactory),
storageManager,
addressSettingsRepository,
- configuration.isJournalSyncNonTransactional(),
- configuration.isBackup());
+ configuration.isJournalSyncNonTransactional());
}
// Private
// --------------------------------------------------------------------------------------
- private synchronized void callActivateCallbacks()
+ private boolean checkActivate() throws Exception
{
- for (ActivateCallback callback : activateCallbacks)
- {
- callback.activated();
- }
- }
-
- private void checkActivate(final RemotingConnection connection) throws Exception
- {
if (configuration.isBackup())
{
- log.info("A connection has been made to the backup server so it will be activated! This will result in the live server being considered failed.");
-
- synchronized (this)
+ //Handle backup server activation
+
+ if (configuration.isSharedStore())
{
- freezeBackupConnection();
-
- List<Queue> toActivate = postOffice.activate();
-
- for (Queue queue : toActivate)
- {
- scheduledPool.schedule(new ActivateRunner(queue),
- configuration.getQueueActivationTimeout(),
- TimeUnit.MILLISECONDS);
- }
-
+ //load shared store
+
configuration.setBackup(false);
-
- if (clusterManager != null)
- {
- clusterManager.activate();
- }
-
- if (configuration.isFileDeploymentEnabled())
- {
- queueDeployer = new QueueDeployer(deploymentManager, messagingServerControl);
-
- queueDeployer.start();
- }
}
- }
-
- connection.activate();
- }
-
- // We need to prevent any more packets being handled on replicating connection as soon as first live connection
- // is created or re-attaches, to prevent a situation like the following:
- // connection 1 create queue A
- // connection 2 fails over
- // A gets activated since no consumers
- // connection 1 create consumer on A
- // connection 1 delivery
- // connection 1 delivery gets replicated
- // can't find message in queue since active was delivered immediately
- private void freezeBackupConnection()
- {
- // Sanity check
- // All replicated sessions should be on the same connection
- RemotingConnection replConnection = null;
-
- for (ServerSession session : sessions.values())
- {
- RemotingConnection rc = session.getChannel().getConnection();
-
- if (replConnection == null)
+ else
{
- replConnection = rc;
+ //just load journal
}
- else if (replConnection != rc)
- {
- throw new IllegalStateException("More than one replicating connection!");
- }
}
-
- if (replConnection != null)
- {
- replConnection.freeze();
- }
+
+ return true;
}
private void initialisePart1() throws Exception
@@ -948,15 +863,13 @@
resourceManager = new ResourceManagerImpl((int)(configuration.getTransactionTimeout() / 1000),
configuration.getTransactionTimeoutScanPeriod(),
scheduledPool);
- postOffice = new PostOfficeImpl(this,
- storageManager,
+ postOffice = new PostOfficeImpl(storageManager,
pagingManager,
queueFactory,
managementService,
configuration.getMessageExpiryScanPeriod(),
configuration.getMessageExpiryThreadPriority(),
- configuration.isWildcardRoutingEnabled(),
- configuration.isBackup(),
+ configuration.isWildcardRoutingEnabled(),
configuration.getIDCacheSize(),
configuration.isPersistIDCache(),
executorFactory,
@@ -1022,28 +935,16 @@
// Deploy any predefined queues
- // We don't activate queue deployer on the backup - all queues deployed on live are deployed on backup by
- // replicating them
- if (configuration.isFileDeploymentEnabled() && !configuration.isBackup())
+ if (configuration.isFileDeploymentEnabled())
{
queueDeployer = new QueueDeployer(deploymentManager, messagingServerControl);
queueDeployer.start();
}
- // We need to call this here, this gives any dependent server a chance to deploy its own destinations
- // this needs to be done before clustering is initialised, and in the same order on live and backup
- callActivateCallbacks();
-
// Deply any pre-defined diverts
deployDiverts();
- // Set-up the replicating connection
- if (!setupReplicatingConnection())
- {
- return;
- }
-
if (configuration.isClustered())
{
// This can't be created until node id is set
@@ -1053,8 +954,7 @@
scheduledPool,
managementService,
configuration,
- uuid,
- replicatingChannel,
+ uuid,
configuration.isBackup());
clusterManager.start();
@@ -1068,7 +968,9 @@
pagingManager.resumeDepages();
final ServerInfo dumper = new ServerInfo(this, pagingManager);
+
long dumpInfoInterval = configuration.getServerDumpInterval();
+
if (dumpInfoInterval > 0)
{
scheduledPool.scheduleWithFixedDelay(new Runnable()
@@ -1079,6 +981,7 @@
}
}, 0, dumpInfoInterval, TimeUnit.MILLISECONDS);
}
+
initialised = true;
started = true;
@@ -1094,89 +997,7 @@
config.isDurable());
}
}
-
- public Channel getReplicatingChannel()
- {
- return replicatingChannel;
- }
-
- private boolean setupReplicatingConnection() throws Exception
- {
- String backupConnectorName = configuration.getBackupConnectorName();
-
- if (backupConnectorName != null)
- {
- TransportConfiguration backupConnector = configuration.getConnectorConfigurations().get(backupConnectorName);
-
- if (backupConnector == null)
- {
- log.warn("connector with name '" + backupConnectorName + "' is not defined in the configuration.");
- }
- else
- {
- replicatingConnectionManager = new ConnectionManagerImpl(null,
- backupConnector,
- null,
- false,
- 1,
- ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT,
- ClientSessionFactoryImpl.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD,
- ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL,
- 0,
- 1.0d,
- 0,
- threadPool,
- scheduledPool);
-
- replicatingConnection = replicatingConnectionManager.getConnection(1);
-
- if (replicatingConnection != null)
- {
- replicatingChannel = replicatingConnection.getChannel(2, -1, false);
-
- replicatingConnection.addFailureListener(new FailureListener()
- {
- public void connectionFailed(HornetQException me)
- {
- replicatingChannel.executeOutstandingDelayedResults();
- }
- });
-
- // First time we get channel we send a message down it informing the backup of our node id -
- // backup and live must have the same node id
-
- Packet packet = new ReplicateStartupInfoMessage(uuid, storageManager.getCurrentUniqueID());
-
- final Future future = new Future();
-
- replicatingChannel.replicatePacket(packet, 1, new Runnable()
- {
- public void run()
- {
- future.run();
- }
- });
-
- // This may take a while especially if the journal is large
- boolean ok = future.await(60000);
-
- if (!ok)
- {
- throw new IllegalStateException("Timed out waiting for response from backup for initialisation");
- }
- }
- else
- {
- log.warn("Backup server MUST be started before live server. Initialisation will not proceed.");
-
- return false;
- }
- }
- }
-
- return true;
- }
-
+
private void loadJournal() throws Exception
{
List<QueueBindingInfo> queueBindingInfos = new ArrayList<QueueBindingInfo>();
@@ -1369,95 +1190,6 @@
}
}
- private CreateSessionResponseMessage doCreateSession(final String name,
- final long channelID,
- final long oppositeChannelID,
- final String username,
- final String password,
- final int minLargeMessageSize,
- final int incrementingVersion,
- final RemotingConnection connection,
- final boolean autoCommitSends,
- final boolean autoCommitAcks,
- final boolean preAcknowledge,
- final boolean xa,
- final int sendWindowSize,
- final boolean backup) throws Exception
- {
- if (version.getIncrementingVersion() != incrementingVersion)
- {
- log.warn("Client with version " + incrementingVersion +
- " and address " +
- connection.getRemoteAddress() +
- " is not compatible with server version " +
- version.getFullVersion() +
- ". " +
- "Please ensure all clients and servers are upgraded to the same version for them to " +
- "interoperate properly");
- return null;
- }
-
- // Is this comment relevant any more ?
-
- // Authenticate. Successful autentication will place a new SubjectContext
- // on thread local,
- // which will be used in the authorization process. However, we need to
- // make sure we clean
- // up thread local immediately after we used the information, otherwise
- // some other people
- // security my be screwed up, on account of thread local security stack
- // being corrupted.
-
- securityStore.authenticate(username, password);
-
- ServerSession currentSession = sessions.remove(name);
-
- if (currentSession != null)
- {
- // This session may well be on a different connection and different channel id, so we must get rid
- // of it and create another
- currentSession.getChannel().close();
- }
-
- Channel channel = connection.getChannel(channelID, sendWindowSize, false);
-
- Channel replicatingChannel = getReplicatingChannel();
-
- final ServerSessionImpl session = new ServerSessionImpl(name,
- oppositeChannelID,
- username,
- password,
- minLargeMessageSize,
- autoCommitSends,
- autoCommitAcks,
- preAcknowledge,
- configuration.isPersistDeliveryCountBeforeDelivery(),
- xa,
- connection,
- storageManager,
- postOffice,
- resourceManager,
- securityStore,
- executorFactory.getExecutor(),
- channel,
- managementService,
- queueFactory,
- this,
- configuration.getManagementAddress(),
- replicatingChannel,
- backup);
-
- sessions.put(name, session);
-
- ServerSessionPacketHandler handler = new ServerSessionPacketHandler(session);
-
- session.setHandler(handler);
-
- channel.setHandler(handler);
-
- return new CreateSessionResponseMessage(version.getIncrementingVersion());
- }
-
private Transformer instantiateTransformer(final String transformerClassName)
{
Transformer transformer = null;
@@ -1480,21 +1212,5 @@
}
// Inner classes
- // --------------------------------------------------------------------------------
-
- private class ActivateRunner implements Runnable
- {
- private Queue queue;
-
- ActivateRunner(final Queue queue)
- {
- this.queue = queue;
- }
-
- public void run()
- {
- queue.activateNow(threadPool);
- }
- }
-
+ // --------------------------------------------------------------------------------
}
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/QueueImpl.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/QueueImpl.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/QueueImpl.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -46,7 +46,6 @@
import org.hornetq.core.persistence.StorageManager;
import org.hornetq.core.postoffice.Bindings;
import org.hornetq.core.postoffice.PostOffice;
-import org.hornetq.core.remoting.Channel;
import org.hornetq.core.server.Consumer;
import org.hornetq.core.server.Distributor;
import org.hornetq.core.server.HandleStatus;
@@ -127,10 +126,6 @@
private final ScheduledExecutorService scheduledExecutor;
- private volatile boolean backup;
-
- private int consumersToFailover = -1;
-
private SimpleString address;
private Redistributor redistributor;
@@ -146,7 +141,7 @@
private final Map<Consumer, Iterator<MessageReference>> iterators = new HashMap<Consumer, Iterator<MessageReference>>();
private ConcurrentMap<SimpleString, Consumer> groups = new ConcurrentHashMap<SimpleString, Consumer>();
-
+
private volatile SimpleString expiryAddress;
public QueueImpl(final long persistenceID,
@@ -192,7 +187,7 @@
direct = true;
scheduledDeliveryHandler = new ScheduledDeliveryHandlerImpl(scheduledExecutor);
-
+
if (addressSettingsRepository != null)
{
expiryAddress = addressSettingsRepository.getMatch(address.toString()).getExpiryAddress();
@@ -202,7 +197,7 @@
expiryAddress = null;
}
}
-
+
// Bindable implementation -------------------------------------------------------------------------------------
public SimpleString getRoutingName()
@@ -352,11 +347,6 @@
public void lockDelivery()
{
- if (backup)
- {
- return;
- }
-
try
{
lock.acquire();
@@ -369,11 +359,6 @@
public void unlockDelivery()
{
- if (backup)
- {
- return;
- }
-
lock.release();
}
@@ -471,7 +456,7 @@
return removed;
}
- public synchronized void addRedistributor(final long delay, final Executor executor, final Channel replicatingChannel)
+ public synchronized void addRedistributor(final long delay, final Executor executor)
{
if (future != null)
{
@@ -490,7 +475,7 @@
{
if (consumers.size() == 0)
{
- DelayedAddRedistributor dar = new DelayedAddRedistributor(executor, replicatingChannel);
+ DelayedAddRedistributor dar = new DelayedAddRedistributor(executor);
future = scheduledExecutor.schedule(dar, delay, TimeUnit.MILLISECONDS);
@@ -499,7 +484,7 @@
}
else
{
- internalAddRedistributor(executor, replicatingChannel);
+ internalAddRedistributor(executor);
}
}
@@ -743,26 +728,26 @@
{
if (checkDLQ(reference))
{
- if (!scheduledDeliveryHandler.checkAndSchedule(reference, backup))
+ if (!scheduledDeliveryHandler.checkAndSchedule(reference))
{
messageReferences.addFirst(reference, reference.getMessage().getPriority());
}
}
- }
+ }
public void expire(final MessageReference ref) throws Exception
- {
+ {
log.info("expiring ref " + this.expiryAddress);
if (expiryAddress != null)
{
- move(expiryAddress, ref, true);
+ move(expiryAddress, ref, true);
}
else
- {
+ {
acknowledge(ref);
}
}
-
+
public void setExpiryAddress(final SimpleString expiryAddress)
{
this.expiryAddress = expiryAddress;
@@ -1003,69 +988,6 @@
return false;
}
- public boolean isBackup()
- {
- return backup;
- }
-
- public synchronized void setBackup()
- {
- backup = true;
-
- direct = false;
- }
-
- public synchronized boolean activate()
- {
- consumersToFailover = consumers.size();
-
- if (consumersToFailover == 0)
- {
- backup = false;
-
- return true;
- }
- else
- {
- return false;
- }
- }
-
- public synchronized void activateNow(final Executor executor)
- {
- if (backup)
- {
- log.info("Timed out waiting for all consumers to reconnect to queue " + name +
- " so queue will be activated now");
-
- backup = false;
-
- scheduledDeliveryHandler.reSchedule();
-
- deliverAsync(executor);
- }
- }
-
- public synchronized boolean consumerFailedOver()
- {
- consumersToFailover--;
-
- if (consumersToFailover == 0)
- {
- // All consumers for the queue have failed over, can re-activate it now
-
- backup = false;
-
- scheduledDeliveryHandler.reSchedule();
-
- return true;
- }
- else
- {
- return false;
- }
- }
-
// Public
// -----------------------------------------------------------------------------
@@ -1097,17 +1019,12 @@
// Private
// ------------------------------------------------------------------------------
- private void internalAddRedistributor(final Executor executor, final Channel replicatingChannel)
+ private void internalAddRedistributor(final Executor executor)
{
// create the redistributor only once if there are no local consumers
if (consumers.size() == 0 && redistributor == null)
{
- redistributor = new Redistributor(this,
- storageManager,
- postOffice,
- executor,
- REDISTRIBUTOR_BATCH_SIZE,
- replicatingChannel);
+ redistributor = new Redistributor(this, storageManager, postOffice, executor, REDISTRIBUTOR_BATCH_SIZE);
distributionPolicy.addConsumer(redistributor);
@@ -1287,16 +1204,6 @@
*/
private synchronized void deliver()
{
- // We don't do actual delivery if the queue is on a backup node - this is
- // because it's async and could get out of step
- // with the live node. Instead, when we replicate the delivery we remove
- // the ref from the queue
-
- if (backup)
- {
- return;
- }
-
direct = false;
if (distributionPolicy.getConsumerCount() == 0)
@@ -1310,11 +1217,11 @@
Iterator<MessageReference> iterator = null;
- //TODO - this needs to be optimised!! Creating too much stuff on an inner loop
+ // TODO - this needs to be optimised!! Creating too much stuff on an inner loop
int totalConsumers = distributionPolicy.getConsumerCount();
Set<Consumer> busyConsumers = new HashSet<Consumer>();
Set<Consumer> nullReferences = new HashSet<Consumer>();
-
+
while (true)
{
consumer = distributionPolicy.getNextConsumer();
@@ -1334,7 +1241,7 @@
else
{
reference = null;
-
+
if (consumer.getFilter() != null)
{
// we have iterated on the whole queue for
@@ -1347,7 +1254,7 @@
if (reference == null)
{
- nullReferences.add(consumer);
+ nullReferences.add(consumer);
if (nullReferences.size() + busyConsumers.size() == totalConsumers)
{
startDepaging();
@@ -1361,10 +1268,10 @@
else
{
nullReferences.remove(consumer);
-
+
if (reference.getMessage().isExpired())
{
- //We expire messages on the server too
+ // We expire messages on the server too
if (iterator == null)
{
messageReferences.removeFirst();
@@ -1373,9 +1280,9 @@
{
iterator.remove();
}
-
+
referenceHandled();
-
+
try
{
expire(reference);
@@ -1384,7 +1291,7 @@
{
log.error("Failed to expire ref", e);
}
-
+
continue;
}
}
@@ -1443,14 +1350,14 @@
messagesAdded.incrementAndGet();
}
- if (scheduledDeliveryHandler.checkAndSchedule(ref, backup))
+ if (scheduledDeliveryHandler.checkAndSchedule(ref))
{
return;
}
boolean add = false;
- if (direct && !backup)
+ if (direct)
{
// Deliver directly
@@ -1670,7 +1577,7 @@
if (message.decrementRefCount() == 0 && store != null)
{
- store.addSize(-ref.getMessage().getMemoryEstimate());
+ store.addSize(-ref.getMessage().getMemoryEstimate());
}
}
@@ -1682,7 +1589,7 @@
{
ServerMessage msg = ref.getMessage();
- if (!scheduledDeliveryHandler.checkAndSchedule(ref, backup))
+ if (!scheduledDeliveryHandler.checkAndSchedule(ref))
{
messageReferences.addFirst(ref, msg.getPriority());
}
@@ -1871,20 +1778,16 @@
{
private final Executor executor;
- private final Channel replicatingChannel;
-
- DelayedAddRedistributor(final Executor executor, final Channel replicatingChannel)
+ DelayedAddRedistributor(final Executor executor)
{
this.executor = executor;
-
- this.replicatingChannel = replicatingChannel;
}
public void run()
{
synchronized (QueueImpl.this)
{
- internalAddRedistributor(executor, replicatingChannel);
+ internalAddRedistributor(executor);
futures.remove(this);
}
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/ScheduledDeliveryHandlerImpl.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/ScheduledDeliveryHandlerImpl.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/ScheduledDeliveryHandlerImpl.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -49,7 +49,7 @@
this.scheduledExecutor = scheduledExecutor;
}
- public boolean checkAndSchedule(final MessageReference ref, final boolean backup)
+ public boolean checkAndSchedule(final MessageReference ref)
{
long deliveryTime = ref.getScheduledDeliveryTime();
@@ -67,10 +67,7 @@
scheduledRunnables.put(ref.getMessage().getMessageID(), runnable);
}
- if (!backup)
- {
- scheduleDelivery(runnable, deliveryTime);
- }
+ scheduleDelivery(runnable, deliveryTime);
return true;
}
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/ServerConsumerImpl.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/ServerConsumerImpl.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/ServerConsumerImpl.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -34,10 +34,8 @@
import org.hornetq.core.postoffice.Binding;
import org.hornetq.core.postoffice.QueueBinding;
import org.hornetq.core.remoting.Channel;
-import org.hornetq.core.remoting.Packet;
import org.hornetq.core.remoting.impl.wireformat.SessionReceiveContinuationMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionReceiveMessage;
-import org.hornetq.core.remoting.impl.wireformat.replication.SessionReplicateDeliveryMessage;
import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.server.HandleStatus;
import org.hornetq.core.server.LargeServerMessage;
@@ -78,8 +76,6 @@
private final long id;
- private final long replicatedSessionID;
-
private final Queue messageQueue;
private final Filter filter;
@@ -119,8 +115,6 @@
private final Channel channel;
- private final Channel replicatingChannel;
-
private volatile boolean closed;
private final boolean preAcknowledge;
@@ -132,7 +126,6 @@
// Constructors ---------------------------------------------------------------------------------
public ServerConsumerImpl(final long id,
- final long replicatedSessionID,
final ServerSession session,
final QueueBinding binding,
final Filter filter,
@@ -141,7 +134,6 @@
final StorageManager storageManager,
final PagingManager pagingManager,
final Channel channel,
- final Channel replicatingChannel,
final boolean preAcknowledge,
final boolean updateDeliveries,
final Executor executor,
@@ -149,8 +141,6 @@
{
this.id = id;
- this.replicatedSessionID = replicatedSessionID;
-
this.filter = filter;
this.session = session;
@@ -169,8 +159,6 @@
this.channel = channel;
- this.replicatingChannel = replicatingChannel;
-
this.preAcknowledge = preAcknowledge;
this.pagingManager = pagingManager;
@@ -180,7 +168,7 @@
this.minLargeMessageSize = session.getMinLargeMessageSize();
this.updateDeliveries = updateDeliveries;
-
+
if (browseOnly)
{
browserDeliverer = new BrowserDeliverer(messageQueue.iterator());
@@ -222,7 +210,7 @@
{
messageQueue.removeConsumer(this);
}
-
+
session.removeConsumer(this);
LinkedList<MessageReference> refs = cancelRefs(false, null);
@@ -371,8 +359,6 @@
id +
", messageId = " +
messageID +
- " backup = " +
- messageQueue.isBackup() +
" queue = " +
messageQueue.getName() +
" closed = " +
@@ -397,7 +383,7 @@
{
return null;
}
-
+
// Expiries can come in out of sequence with respect to delivery order
Iterator<MessageReference> iter = deliveringRefs.iterator();
@@ -421,70 +407,6 @@
return ref;
}
- public void deliverReplicated(final long messageID) throws Exception
- {
- MessageReference ref = messageQueue.removeFirstReference(messageID);
-
- if (ref == null)
- {
- // The order is correct, but it hasn't been depaged yet, so we need to force a depage
- PagingStore store = pagingManager.getPageStore(binding.getAddress());
-
- // force a depage
- if (!store.readPage()) // This returns false if there are no pages
- {
- throw new IllegalStateException("Cannot find Reference[" + messageID +
- "] in queue " +
- messageQueue.getName());
- }
- else
- {
- ref = messageQueue.removeFirstReference(messageID);
-
- if (ref == null)
- {
- throw new IllegalStateException("Cannot find Reference[" + messageID +
- "] after depaging on Queue " +
- messageQueue.getName());
- }
- }
- }
-
- // We call doHandle rather than handle, since we don't want to check available credits
- // This is because delivery and receive credits can be processed in different order on live
- // and backup, and otherwise we could have a situation where the delivery is replicated
- // but the credits haven't arrived yet, so the delivery gets rejected on backup
- HandleStatus handled = doHandle(ref);
-
- if (handled != HandleStatus.HANDLED)
- {
- throw new IllegalStateException("Reference " + ref +
- " was not handled on backup node, handleStatus = " +
- handled);
- }
- }
-
- public void failedOver()
- {
- if (messageQueue.consumerFailedOver())
- {
- if (started)
- {
- promptDelivery();
- }
- }
- }
-
- public void lock()
- {
- lock.lock();
- }
-
- public void unlock()
- {
- lock.unlock();
- }
-
// Public ---------------------------------------------------------------------------------------
/** To be used on tests only */
@@ -533,23 +455,14 @@
*/
private void resumeLargeMessage()
{
- if (messageQueue.isBackup())
- {
- // We need to deliver the largeMessage on backup also, exactly as done on the live node.
- // In case of failure the same packets will be available for resume sending.
- largeMessageDeliverer.deliver();
- }
- else
- {
- executor.execute(resumeLargeMessageRunnable);
- }
+ executor.execute(resumeLargeMessageRunnable);
}
private HandleStatus doHandle(final MessageReference ref) throws Exception
{
if (availableCredits != null && availableCredits.get() <= 0)
{
- // log.info("busy - available credits is " + availableCredits.get());
+ // log.info("busy - available credits is " + availableCredits.get());
return HandleStatus.BUSY;
}
@@ -571,13 +484,6 @@
// This has to be checked inside the lock as the set to null is done inside the lock
if (pendingLargeMessagesCounter.get() > 0)
{
- if (messageQueue.isBackup())
- {
- log.warn("doHandle: rejecting message while send is pending, ignoring reference = " + ref +
- " backup = " +
- messageQueue.isBackup());
- }
-
return HandleStatus.BUSY;
}
@@ -646,40 +552,9 @@
final LargeMessageDeliverer localDeliverer = new LargeMessageDeliverer((LargeServerMessage)message, ref);
- if (replicatingChannel == null)
- {
- // it doesn't need lock because deliverLargeMesasge is already inside the lock()
- largeMessageDeliverer = localDeliverer;
- largeMessageDeliverer.deliver();
- }
- else
- {
- Packet replPacket = new SessionReplicateDeliveryMessage(id, message.getMessageID());
- replPacket.setChannelID(channel.getID());
-
- replicatingChannel.replicatePacket(replPacket, replicatedSessionID, new Runnable()
- {
- public void run()
- {
- // setting & unsetting largeMessageDeliver is done inside the lock,
- // so this needs to be locked
- lock.lock();
- try
- {
- largeMessageDeliverer = localDeliverer;
- if (largeMessageDeliverer.deliver())
- {
- promptDelivery();
- }
- }
- finally
- {
- lock.unlock();
- }
- }
- });
- }
-
+ // it doesn't need lock because deliverLargeMesasge is already inside the lock()
+ largeMessageDeliverer = localDeliverer;
+ largeMessageDeliverer.deliver();
}
/**
@@ -699,33 +574,7 @@
}
}
- if (replicatingChannel == null)
- {
- // Not replicated - just send now
-
- if (trace)
- {
- log.trace("delivering Message " + ref + " on backup");
- }
- channel.send(packet);
- }
- else
- {
- Packet replPacket = new SessionReplicateDeliveryMessage(id, message.getMessageID());
- replPacket.setChannelID(channel.getID());
-
- replicatingChannel.replicatePacket(replPacket, replicatedSessionID, new Runnable()
- {
- public void run()
- {
- if (trace)
- {
- log.trace("delivering Message " + ref + " on live");
- }
- channel.send(packet);
- }
- });
- }
+ channel.send(packet);
}
// Inner classes
@@ -849,7 +698,7 @@
{
if (trace)
{
- trace("deliverLargeMessage: Leaving loop of send LargeMessage because of credits, backup = " + messageQueue.isBackup());
+ trace("deliverLargeMessage: Leaving loop of send LargeMessage because of credits");
}
return false;
}
@@ -870,9 +719,7 @@
{
trace("deliverLargeMessage: Sending " + chunk.getRequiredBufferSize() +
" availableCredits now is " +
- availableCredits +
- " isBackup = " +
- messageQueue.isBackup());
+ availableCredits);
}
channel.send(chunk);
@@ -887,7 +734,7 @@
if (trace)
{
- trace("Finished deliverLargeMessage isBackup = " + messageQueue.isBackup());
+ trace("Finished deliverLargeMessage");
}
close();
@@ -997,18 +844,18 @@
return chunk;
}
}
-
+
private class BrowserDeliverer implements Runnable
{
private MessageReference current = null;
-
+
public BrowserDeliverer(final Iterator<MessageReference> iterator)
{
this.iterator = iterator;
}
private final Iterator<MessageReference> iterator;
-
+
public void run()
{
// if the reference was busy during the previous iteration, handle it now
@@ -1020,7 +867,7 @@
if (status == HandleStatus.BUSY)
{
return;
- }
+ }
}
catch (Exception e)
{
@@ -1050,6 +897,6 @@
}
}
}
-
+
}
}
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -52,7 +52,6 @@
import org.hornetq.core.remoting.impl.wireformat.HornetQExceptionMessage;
import org.hornetq.core.remoting.impl.wireformat.NullResponseMessage;
import org.hornetq.core.remoting.impl.wireformat.PacketImpl;
-import org.hornetq.core.remoting.impl.wireformat.PacketsConfirmedMessage;
import org.hornetq.core.remoting.impl.wireformat.RollbackMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionAcknowledgeMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionBindingQueryMessage;
@@ -80,7 +79,6 @@
import org.hornetq.core.remoting.impl.wireformat.SessionXASetTimeoutMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionXASetTimeoutResponseMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionXAStartMessage;
-import org.hornetq.core.remoting.impl.wireformat.replication.SessionReplicateDeliveryMessage;
import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.security.CheckType;
import org.hornetq.core.security.SecurityStore;
@@ -114,23 +112,12 @@
private static final Logger log = Logger.getLogger(ServerSessionImpl.class);
- private static final boolean trace = log.isTraceEnabled();
-
- private static void trace(String message)
- {
- log.trace(message);
- }
-
// Static -------------------------------------------------------------------------------
// Attributes ----------------------------------------------------------------------------
- private volatile long id;
+ private final long id;
- // The id of the opposite channel - i.e. if this is the live then its the id on the backup, if this is the backup
- // then it's the id on the live, or -1 if non clustered
- private volatile long oppositeChannelID;
-
private final String username;
private final String password;
@@ -147,8 +134,6 @@
private RemotingConnection remotingConnection;
- private Channel replicatingChannel;
-
private final Map<Long, ServerConsumer> consumers = new ConcurrentHashMap<Long, ServerConsumer>();
private final Executor executor;
@@ -183,8 +168,6 @@
private final SimpleString nodeID;
- private boolean backup;
-
// The current currentLargeMessage being processed
// In case of replication, currentLargeMessage should only be accessed within the replication callbacks
private volatile LargeServerMessage currentLargeMessage;
@@ -193,8 +176,7 @@
// Constructors ---------------------------------------------------------------------------------
- public ServerSessionImpl(final String name,
- final long oppositeChannelID,
+ public ServerSessionImpl(final String name,
final String username,
final String password,
final int minLargeMessageSize,
@@ -213,14 +195,10 @@
final ManagementService managementService,
final QueueFactory queueFactory,
final HornetQServer server,
- final SimpleString managementAddress,
- final Channel replicatingChannel,
- final boolean backup) throws Exception
+ final SimpleString managementAddress) throws Exception
{
this.id = channel.getID();
- this.oppositeChannelID = oppositeChannelID;
-
this.username = username;
this.password = password;
@@ -266,10 +244,6 @@
this.nodeID = server.getNodeID();
- this.replicatingChannel = replicatingChannel;
-
- this.backup = backup;
-
remotingConnection.addFailureListener(this);
remotingConnection.addCloseListener(this);
@@ -367,890 +341,6 @@
public void handleCreateConsumer(final SessionCreateConsumerMessage packet)
{
- if (replicatingChannel == null)
- {
- doHandleCreateConsumer(packet);
- }
- else
- {
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- doHandleCreateConsumer(packet);
- }
- });
- }
- }
-
- public void handleCreateQueue(final CreateQueueMessage packet)
- {
- if (replicatingChannel == null)
- {
- doHandleCreateQueue(packet);
- }
- else
- {
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- doHandleCreateQueue(packet);
- }
- });
- }
- }
-
- public void handleDeleteQueue(final SessionDeleteQueueMessage packet)
- {
- if (replicatingChannel == null)
- {
- doHandleDeleteQueue(packet);
- }
- else
- {
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- doHandleDeleteQueue(packet);
- }
- });
- }
- }
-
- public void handleExecuteQueueQuery(final SessionQueueQueryMessage packet)
- {
- if (replicatingChannel == null)
- {
- doHandleExecuteQueueQuery(packet);
- }
- else
- {
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- doHandleExecuteQueueQuery(packet);
- }
- });
- }
- }
-
- public void handleExecuteBindingQuery(final SessionBindingQueryMessage packet)
- {
- if (replicatingChannel == null)
- {
- doHandleExecuteBindingQuery(packet);
- }
- else
- {
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- doHandleExecuteBindingQuery(packet);
- }
- });
- }
- }
-
- public void handleAcknowledge(final SessionAcknowledgeMessage packet)
- {
- if (replicatingChannel == null)
- {
- doHandleAcknowledge(packet);
- }
- else
- {
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- doHandleAcknowledge(packet);
- }
- });
- }
- }
-
- public void handleExpired(final SessionExpiredMessage packet)
- {
- if (replicatingChannel == null)
- {
- doHandleExpired(packet);
- }
- else
- {
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- doHandleExpired(packet);
- }
- });
- }
- }
-
- public void handleCommit(final Packet packet)
- {
- if (replicatingChannel == null)
- {
- doHandleCommit(packet);
- }
- else
- {
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- doHandleCommit(packet);
- }
- });
- }
- }
-
- public void handleRollback(final RollbackMessage packet)
- {
-
- if (replicatingChannel == null)
- {
- doHandleRollback(packet);
- }
- else
- {
- final HashSet<Queue> queues = lockUsedQueues(null);
-
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- try
- {
- doHandleRollback(packet);
- }
- finally
- {
- for (Queue queue : queues)
- {
- queue.unlockDelivery();
- }
- }
- }
- });
- }
- }
-
- public void handleXACommit(final SessionXACommitMessage packet)
- {
- if (replicatingChannel == null)
- {
- doHandleXACommit(packet);
- }
- else
- {
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- doHandleXACommit(packet);
- }
- });
- }
- }
-
- public void handleXAEnd(final SessionXAEndMessage packet)
- {
- if (replicatingChannel == null)
- {
- doHandleXAEnd(packet);
- }
- else
- {
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- doHandleXAEnd(packet);
- }
- });
- }
- }
-
- public void handleXAForget(final SessionXAForgetMessage packet)
- {
- if (replicatingChannel == null)
- {
- doHandleXAForget(packet);
- }
- else
- {
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- doHandleXAForget(packet);
- }
- });
- }
- }
-
- public void handleXAJoin(final SessionXAJoinMessage packet)
- {
- if (replicatingChannel == null)
- {
- doHandleXAJoin(packet);
- }
- else
- {
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- doHandleXAJoin(packet);
- }
- });
- }
- }
-
- public void handleXAResume(final SessionXAResumeMessage packet)
- {
- if (replicatingChannel == null)
- {
- doHandleXAResume(packet);
- }
- else
- {
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- doHandleXAResume(packet);
- }
- });
- }
- }
-
- public void handleXARollback(final SessionXARollbackMessage packet)
- {
-
- if (replicatingChannel == null)
- {
- doHandleXARollback(packet);
- }
- else
- {
- final Set<Queue> queues = lockUsedQueues(packet.getXid());
-
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- try
- {
- doHandleXARollback(packet);
- }
- finally
- {
- for (Queue queue : queues)
- {
- queue.unlockDelivery();
- }
- }
- }
- });
- }
- }
-
- public void handleXAStart(final SessionXAStartMessage packet)
- {
- if (replicatingChannel == null)
- {
- doHandleXAStart(packet);
- }
- else
- {
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- doHandleXAStart(packet);
- }
- });
- }
- }
-
- public void handleXASuspend(final Packet packet)
- {
- if (replicatingChannel == null)
- {
- doHandleXASuspend(packet);
- }
- else
- {
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- doHandleXASuspend(packet);
- }
- });
- }
- }
-
- public void handleXAPrepare(final SessionXAPrepareMessage packet)
- {
- if (replicatingChannel == null)
- {
- doHandleXAPrepare(packet);
- }
- else
- {
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- doHandleXAPrepare(packet);
- }
- });
- }
- }
-
- public void handleGetInDoubtXids(final Packet packet)
- {
- if (replicatingChannel == null)
- {
- doHandleGetInDoubtXids(packet);
- }
- else
- {
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- doHandleGetInDoubtXids(packet);
- }
- });
- }
- }
-
- public void handleGetXATimeout(final Packet packet)
- {
- if (replicatingChannel == null)
- {
- doHandleGetXATimeout(packet);
- }
- else
- {
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- doHandleGetXATimeout(packet);
- }
- });
- }
- }
-
- public void handleSetXATimeout(final SessionXASetTimeoutMessage packet)
- {
- if (replicatingChannel == null)
- {
- doHandleSetXATimeout(packet);
- }
- else
- {
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- doHandleSetXATimeout(packet);
- }
- });
- }
- }
-
- private void lockConsumers()
- {
- for (ServerConsumer consumer : consumers.values())
- {
- consumer.lock();
- }
- }
-
- private void unlockConsumers()
- {
- for (ServerConsumer consumer : consumers.values())
- {
- consumer.unlock();
- }
- }
-
- public void handleStart(final Packet packet)
- {
- if (replicatingChannel == null)
- {
- setStarted(true);
-
- channel.confirm(packet);
- }
- else
- {
- lockConsumers();
-
- try
- {
- setStarted(true);
-
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- // setStarted(true);
-
- channel.confirm(packet);
- }
- });
- }
- finally
- {
- unlockConsumers();
- }
- }
- }
-
- public void handleStop(final Packet packet)
- {
- final Packet response = new NullResponseMessage();
-
- // We need to stop the session *before* replicating, to avoid this situation:
- // session stop,
- // stop is replicated
- // delivery occurs, local is not stopped yet
- // stop is processed on backup
- // backup is stopped
- // delivery is processed on backup
- // it's stopped so barfs and cannot process delivery
-
- if (replicatingChannel == null)
- {
- setStarted(false);
-
- channel.confirm(packet);
-
- channel.send(response);
- }
- else
- {
- lockConsumers();
-
- try
- {
-
- setStarted(false);
-
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- channel.confirm(packet);
-
- channel.send(response);
-
- }
- });
- }
- finally
- {
- unlockConsumers();
- }
- }
- }
-
- public void handleFailedOver(final Packet packet)
- {
- Set<ServerConsumer> consumersClone = new HashSet<ServerConsumer>(consumers.values());
-
- for (ServerConsumer consumer : consumersClone)
- {
- consumer.failedOver();
- }
- }
-
- public void handleClose(final Packet packet)
- {
-
- if (replicatingChannel == null)
- {
- doHandleClose(packet);
- }
- else
- {
- final HashSet<Queue> queues = lockUsedQueues(null);
-
- // We need to stop the consumers first before replicating, to ensure no deliveries occur after this,
- // but we need to process the actual close() when the replication response returns, otherwise things
- // can happen like acks can come in after close
-
- for (ServerConsumer consumer : consumers.values())
- {
- consumer.setStarted(false);
- }
-
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- try
- {
- doHandleClose(packet);
- }
- finally
- {
- for (Queue queue : queues)
- {
- queue.unlockDelivery();
- }
- }
- }
- });
- }
- }
-
- public void handleCloseConsumer(final SessionConsumerCloseMessage packet)
- {
- final ServerConsumer consumer = consumers.get(packet.getConsumerID());
-
- consumer.setStarted(false);
-
- if (replicatingChannel == null)
- {
- doHandleCloseConsumer(packet, consumer);
- }
- else
- {
- final Queue queue;
-
- if (consumer.getCountOfPendingDeliveries() > 0)
- {
- queue = consumer.getQueue();
- queue.lockDelivery();
- }
- else
- {
- queue = null;
- }
-
- // We need to stop the consumer first before replicating, to ensure no deliveries occur after this,
- // but we need to process the actual close() when the replication response returns, otherwise things
- // can happen like acks can come in after close
-
- consumer.setStarted(false);
-
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- try
- {
- doHandleCloseConsumer(packet, consumer);
- }
- finally
- {
- if (queue != null)
- {
- queue.unlockDelivery();
- }
- }
- }
- });
- }
- }
-
- public void handleReceiveConsumerCredits(final SessionConsumerFlowCreditMessage packet)
- {
- if (replicatingChannel == null)
- {
- doReceiveCredits(packet);
- }
- else
- {
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- doReceiveCredits(packet);
- }
- });
- }
- }
-
- public void handleSendLargeMessage(final SessionSendLargeMessage packet)
- {
- // need to create the LargeMessage before continue
- final LargeServerMessage msg = doCreateLargeMessage(packet);
-
- if (msg == null)
- {
- // packet logged an error, and played with channel.returns... and nothing needs to be done now
- return;
- }
-
- // With a send we must make sure it is replicated to backup before being processed on live
- // or can end up with delivery being processed on backup before original send
-
- if (replicatingChannel == null)
- {
- if (currentLargeMessage != null)
- {
- log.warn("Replacing incomplete LargeMessage with ID=" + currentLargeMessage.getMessageID());
- }
-
- currentLargeMessage = msg;
-
- doSendLargeMessage(packet);
- }
- else
- {
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- if (trace)
- {
- trace("(Replication) SendLargeMessage, id=" + msg.getMessageID());
- }
-
- if (currentLargeMessage != null)
- {
- log.warn("Replacing incomplete LargeMessage with ID=" + currentLargeMessage.getMessageID());
- }
-
- currentLargeMessage = msg;
-
- doSendLargeMessage(packet);
- }
- });
- }
- }
-
- public void handleSend(final SessionSendMessage packet)
- {
- if (replicatingChannel == null)
- {
- doSend(packet);
- }
- else
- {
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- doSend(packet);
- }
- });
- }
- }
-
- public void handleSendContinuations(final SessionSendContinuationMessage packet)
- {
- if (replicatingChannel == null)
- {
- doSendContinuations(packet);
- }
- else
- {
- replicatingChannel.replicatePacket(packet, oppositeChannelID, new Runnable()
- {
- public void run()
- {
- doSendContinuations(packet);
- }
- });
- }
- }
-
- public void handleReplicatedDelivery(final SessionReplicateDeliveryMessage packet)
- {
- ServerConsumer consumer = consumers.get(packet.getConsumerID());
-
- if (consumer == null)
- {
- throw new IllegalStateException("Cannot handle replicated delivery, consumer is closed " + packet.getConsumerID() +
- " session " +
- id +
- " " +
- System.identityHashCode(this));
- }
-
- try
- {
- consumer.deliverReplicated(packet.getMessageID());
- }
- catch (Exception e)
- {
- log.error("Failed to handle replicated delivery", e);
- }
- }
-
- public void handlePacketsConfirmed(final PacketsConfirmedMessage packet)
- {
- if (replicatingChannel != null)
- {
- replicatingChannel.replicatePacket(packet, oppositeChannelID, null);
- }
- }
-
- public int transferConnection(final RemotingConnection newConnection, final int lastReceivedCommandID)
- {
- boolean wasStarted = this.started;
-
- if (wasStarted)
- {
- this.setStarted(false);
- }
-
- if (backup)
- {
- // Put the id back to the original client session id
- this.id = this.oppositeChannelID;
-
- this.oppositeChannelID = -1;
-
- backup = false;
- }
-
- remotingConnection.removeFailureListener(this);
- remotingConnection.removeCloseListener(this);
-
- // Note. We do not destroy the replicating connection here. In the case the live server has really crashed
- // then the connection will get cleaned up anyway when the server ping timeout kicks in.
- // In the case the live server is really still up, i.e. a split brain situation (or in tests), then closing
- // the replicating connection will cause the outstanding responses to be be replayed on the live server,
- // if these reach the client who then subsequently fails over, on reconnection to backup, it will have
- // received responses that the backup did not know about.
-
- channel.transferConnection(newConnection, this.id, replicatingChannel);
-
- newConnection.syncIDGeneratorSequence(remotingConnection.getIDGeneratorSequence());
-
- remotingConnection = newConnection;
-
- remotingConnection.addFailureListener(this);
- remotingConnection.addCloseListener(this);
-
- int serverLastReceivedCommandID = channel.getLastReceivedCommandID();
-
- channel.replayCommands(lastReceivedCommandID, this.id);
-
- if (wasStarted)
- {
- this.setStarted(true);
- }
-
- return serverLastReceivedCommandID;
- }
-
- public Channel getChannel()
- {
- return channel;
- }
-
- // FailureListener implementation
- // --------------------------------------------------------------------
-
- public void connectionFailed(final HornetQException me)
- {
- try
- {
- log.warn("Client connection failed, clearing up resources for session " + name);
-
- for (Runnable runner : failureRunners)
- {
- try
- {
- runner.run();
- }
- catch (Throwable t)
- {
- log.error("Failed to execute failure runner", t);
- }
- }
-
- handleClose(new PacketImpl(PacketImpl.SESS_CLOSE));
-
- log.warn("Cleared up resources for session " + name);
- }
- catch (Throwable t)
- {
- log.error("Failed to close connection " + this);
- }
- }
-
- public void connectionClosed()
- {
- try
- {
- for (Runnable runner : failureRunners)
- {
- try
- {
- runner.run();
- }
- catch (Throwable t)
- {
- log.error("Failed to execute failure runner", t);
- }
- }
- }
- catch (Throwable t)
- {
- log.error("Failed fire listeners " + this);
- }
-
- }
-
- // Public
- // ----------------------------------------------------------------------------
-
- public Transaction getTransaction()
- {
- return tx;
- }
-
- // Private
- // ----------------------------------------------------------------------------
-
- private void doHandleCloseConsumer(final SessionConsumerCloseMessage packet, final ServerConsumer consumer)
- {
- Packet response;
-
- try
- {
- consumer.close();
-
- response = new NullResponseMessage();
- }
- catch (Exception e)
- {
- log.error("Failed to close consumer", e);
-
- if (e instanceof HornetQException)
- {
- response = new HornetQExceptionMessage((HornetQException)e);
- }
- else
- {
- response = new HornetQExceptionMessage(new HornetQException(HornetQException.INTERNAL_ERROR));
- }
- }
-
- channel.confirm(packet);
-
- channel.send(response);
- }
-
- private void doHandleCreateConsumer(final SessionCreateConsumerMessage packet)
- {
SimpleString name = packet.getQueueName();
SimpleString filterString = packet.getFilterString();
@@ -1301,8 +391,7 @@
theQueue = (Queue)binding.getBindable();
}
- ServerConsumer consumer = new ServerConsumerImpl(idGenerator.generateID(),
- oppositeChannelID,
+ ServerConsumer consumer = new ServerConsumerImpl(idGenerator.generateID(),
this,
(QueueBinding)binding,
filter,
@@ -1310,8 +399,7 @@
browseOnly,
storageManager,
postOffice.getPagingManager(),
- channel,
- replicatingChannel,
+ channel,
preAcknowledge,
updateDeliveries,
executor,
@@ -1362,10 +450,9 @@
channel.confirm(packet);
channel.send(response);
-
}
- private void doHandleCreateQueue(final CreateQueueMessage packet)
+ public void handleCreateQueue(final CreateQueueMessage packet)
{
SimpleString address = packet.getAddress();
@@ -1406,7 +493,7 @@
public void run()
{
try
- {
+ {
if (postOffice.getBinding(name) != null)
{
postOffice.removeBinding(name);
@@ -1439,7 +526,7 @@
channel.send(response);
}
- private void doHandleDeleteQueue(final SessionDeleteQueueMessage packet)
+ public void handleDeleteQueue(final SessionDeleteQueueMessage packet)
{
SimpleString name = packet.getQueueName();
@@ -1477,7 +564,7 @@
channel.send(response);
}
- private void doHandleExecuteQueueQuery(final SessionQueueQueryMessage packet)
+ public void handleExecuteQueueQuery(final SessionQueueQueryMessage packet)
{
SimpleString name = packet.getQueueName();
@@ -1530,7 +617,7 @@
channel.send(response);
}
- private void doHandleExecuteBindingQuery(final SessionBindingQueryMessage packet)
+ public void handleExecuteBindingQuery(final SessionBindingQueryMessage packet)
{
SimpleString address = packet.getAddress();
@@ -1576,7 +663,7 @@
channel.send(response);
}
- private void doHandleAcknowledge(final SessionAcknowledgeMessage packet)
+ public void handleAcknowledge(final SessionAcknowledgeMessage packet)
{
Packet response = null;
@@ -1616,7 +703,7 @@
}
}
- private void doHandleExpired(final SessionExpiredMessage packet)
+ public void handleExpired(final SessionExpiredMessage packet)
{
try
{
@@ -1635,7 +722,7 @@
channel.confirm(packet);
}
- private void doHandleCommit(final Packet packet)
+ public void handleCommit(final Packet packet)
{
Packet response = null;
@@ -1668,7 +755,7 @@
channel.send(response);
}
- private void doHandleRollback(final RollbackMessage packet)
+ public void handleRollback(final RollbackMessage packet)
{
Packet response = null;
@@ -1697,7 +784,7 @@
channel.send(response);
}
- private void doHandleXACommit(final SessionXACommitMessage packet)
+ public void handleXACommit(final SessionXACommitMessage packet)
{
Packet response = null;
@@ -1760,7 +847,7 @@
channel.send(response);
}
- private void doHandleXAEnd(final SessionXAEndMessage packet)
+ public void handleXAEnd(final SessionXAEndMessage packet)
{
Packet response = null;
@@ -1834,7 +921,7 @@
channel.send(response);
}
- private void doHandleXAForget(final SessionXAForgetMessage packet)
+ public void handleXAForget(final SessionXAForgetMessage packet)
{
// Do nothing since we don't support heuristic commits / rollback from the
// resource manager
@@ -1846,7 +933,7 @@
channel.send(response);
}
- private void doHandleXAJoin(final SessionXAJoinMessage packet)
+ public void handleXAJoin(final SessionXAJoinMessage packet)
{
Packet response = null;
@@ -1897,7 +984,7 @@
channel.send(response);
}
- private void doHandleXAResume(final SessionXAResumeMessage packet)
+ public void handleXAResume(final SessionXAResumeMessage packet)
{
Packet response = null;
@@ -1959,7 +1046,7 @@
channel.send(response);
}
- private void doHandleXARollback(final SessionXARollbackMessage packet)
+ public void handleXARollback(final SessionXARollbackMessage packet)
{
Packet response = null;
@@ -2022,7 +1109,7 @@
channel.send(response);
}
- private void doHandleXAStart(final SessionXAStartMessage packet)
+ public void handleXAStart(final SessionXAStartMessage packet)
{
Packet response = null;
@@ -2073,7 +1160,7 @@
channel.send(response);
}
- private void doHandleXASuspend(final Packet packet)
+ public void handleXASuspend(final Packet packet)
{
Packet response = null;
@@ -2122,7 +1209,7 @@
channel.send(response);
}
- private void doHandleXAPrepare(final SessionXAPrepareMessage packet)
+ public void handleXAPrepare(final SessionXAPrepareMessage packet)
{
Packet response = null;
@@ -2182,7 +1269,7 @@
channel.send(response);
}
- private void doHandleGetInDoubtXids(final Packet packet)
+ public void handleGetInDoubtXids(final Packet packet)
{
Packet response = new SessionXAGetInDoubtXidsResponseMessage(resourceManager.getPreparedTransactions());
@@ -2191,7 +1278,7 @@
channel.send(response);
}
- private void doHandleGetXATimeout(final Packet packet)
+ public void handleGetXATimeout(final Packet packet)
{
Packet response = new SessionXAGetTimeoutResponseMessage(resourceManager.getTimeoutSeconds());
@@ -2200,7 +1287,7 @@
channel.send(response);
}
- private void doHandleSetXATimeout(final SessionXASetTimeoutMessage packet)
+ public void handleSetXATimeout(final SessionXASetTimeoutMessage packet)
{
Packet response = new SessionXASetTimeoutResponseMessage(resourceManager.setTimeoutSeconds(packet.getTimeoutSeconds()));
@@ -2209,8 +1296,26 @@
channel.send(response);
}
- private void doHandleClose(final Packet packet)
+ public void handleStart(final Packet packet)
{
+ setStarted(true);
+
+ channel.confirm(packet);
+ }
+
+ public void handleStop(final Packet packet)
+ {
+ final Packet response = new NullResponseMessage();
+
+ setStarted(false);
+
+ channel.confirm(packet);
+
+ channel.send(response);
+ }
+
+ public void handleClose(final Packet packet)
+ {
Packet response = null;
try
@@ -2243,45 +1348,38 @@
channel.close();
}
- private void setStarted(final boolean s)
+ public void handleCloseConsumer(final SessionConsumerCloseMessage packet)
{
- Set<ServerConsumer> consumersClone = new HashSet<ServerConsumer>(consumers.values());
+ final ServerConsumer consumer = consumers.get(packet.getConsumerID());
- for (ServerConsumer consumer : consumersClone)
- {
- consumer.setStarted(s);
- }
+ Packet response;
- started = s;
- }
-
- /**
- * We need to create the LargeMessage before replicating the packet, or else we won't know how to extract the destination,
- * which is stored on the header
- * @param packet
- * @throws Exception
- */
- private LargeServerMessage doCreateLargeMessage(final SessionSendLargeMessage packet)
- {
try
{
- return createLargeMessageStorage(packet.getLargeMessageHeader());
+ consumer.close();
+
+ response = new NullResponseMessage();
}
catch (Exception e)
{
- log.error("Failed to create large message", e);
- Packet response = null;
+ log.error("Failed to close consumer", e);
- channel.confirm(packet);
- if (response != null)
+ if (e instanceof HornetQException)
{
- channel.send(response);
+ response = new HornetQExceptionMessage((HornetQException)e);
}
- return null;
+ else
+ {
+ response = new HornetQExceptionMessage(new HornetQException(HornetQException.INTERNAL_ERROR));
+ }
}
+
+ channel.confirm(packet);
+
+ channel.send(response);
}
- private void doReceiveCredits(final SessionConsumerFlowCreditMessage packet)
+ public void handleReceiveConsumerCredits(final SessionConsumerFlowCreditMessage packet)
{
try
{
@@ -2294,8 +1392,27 @@
channel.confirm(packet);
}
- private void doSendLargeMessage(final SessionSendLargeMessage packet)
+ public void handleSendLargeMessage(final SessionSendLargeMessage packet)
{
+ // need to create the LargeMessage before continue
+ final LargeServerMessage msg = doCreateLargeMessage(packet);
+
+ if (msg == null)
+ {
+ // packet logged an error, and played with channel.returns... and nothing needs to be done now
+ return;
+ }
+
+ // With a send we must make sure it is replicated to backup before being processed on live
+ // or can end up with delivery being processed on backup before original send
+
+ if (currentLargeMessage != null)
+ {
+ log.warn("Replacing incomplete LargeMessage with ID=" + currentLargeMessage.getMessageID());
+ }
+
+ currentLargeMessage = msg;
+
try
{
long id = storageManager.generateUniqueID();
@@ -2310,7 +1427,7 @@
channel.confirm(packet);
}
- private void doSend(final SessionSendMessage packet)
+ public void handleSend(final SessionSendMessage packet)
{
Packet response = null;
@@ -2360,13 +1477,10 @@
if (response != null)
{
channel.send(response);
- }
+ }
}
- /**
- * @param packet
- */
- private void doSendContinuations(final SessionSendContinuationMessage packet)
+ public void handleSendContinuations(final SessionSendContinuationMessage packet)
{
Packet response = null;
@@ -2417,9 +1531,157 @@
if (response != null)
{
channel.send(response);
+ }
+ }
+
+ public int transferConnection(final RemotingConnection newConnection, final int lastReceivedCommandID)
+ {
+ boolean wasStarted = this.started;
+
+ if (wasStarted)
+ {
+ this.setStarted(false);
}
+
+ remotingConnection.removeFailureListener(this);
+ remotingConnection.removeCloseListener(this);
+
+ // Note. We do not destroy the replicating connection here. In the case the live server has really crashed
+ // then the connection will get cleaned up anyway when the server ping timeout kicks in.
+ // In the case the live server is really still up, i.e. a split brain situation (or in tests), then closing
+ // the replicating connection will cause the outstanding responses to be be replayed on the live server,
+ // if these reach the client who then subsequently fails over, on reconnection to backup, it will have
+ // received responses that the backup did not know about.
+
+ channel.transferConnection(newConnection);
+
+ newConnection.syncIDGeneratorSequence(remotingConnection.getIDGeneratorSequence());
+
+ remotingConnection = newConnection;
+
+ remotingConnection.addFailureListener(this);
+ remotingConnection.addCloseListener(this);
+
+ int serverLastReceivedCommandID = channel.getLastReceivedCommandID();
+
+ channel.replayCommands(lastReceivedCommandID, this.id);
+
+ if (wasStarted)
+ {
+ this.setStarted(true);
+ }
+
+ return serverLastReceivedCommandID;
}
+ public Channel getChannel()
+ {
+ return channel;
+ }
+
+ // FailureListener implementation
+ // --------------------------------------------------------------------
+
+ public void connectionFailed(final HornetQException me)
+ {
+ try
+ {
+ log.warn("Client connection failed, clearing up resources for session " + name);
+
+ for (Runnable runner : failureRunners)
+ {
+ try
+ {
+ runner.run();
+ }
+ catch (Throwable t)
+ {
+ log.error("Failed to execute failure runner", t);
+ }
+ }
+
+ handleClose(new PacketImpl(PacketImpl.SESS_CLOSE));
+
+ log.warn("Cleared up resources for session " + name);
+ }
+ catch (Throwable t)
+ {
+ log.error("Failed to close connection " + this);
+ }
+ }
+
+ public void connectionClosed()
+ {
+ try
+ {
+ for (Runnable runner : failureRunners)
+ {
+ try
+ {
+ runner.run();
+ }
+ catch (Throwable t)
+ {
+ log.error("Failed to execute failure runner", t);
+ }
+ }
+ }
+ catch (Throwable t)
+ {
+ log.error("Failed fire listeners " + this);
+ }
+
+ }
+
+ // Public
+ // ----------------------------------------------------------------------------
+
+ public Transaction getTransaction()
+ {
+ return tx;
+ }
+
+ // Private
+ // ----------------------------------------------------------------------------
+
+ private void setStarted(final boolean s)
+ {
+ Set<ServerConsumer> consumersClone = new HashSet<ServerConsumer>(consumers.values());
+
+ for (ServerConsumer consumer : consumersClone)
+ {
+ consumer.setStarted(s);
+ }
+
+ started = s;
+ }
+
+ /**
+ * We need to create the LargeMessage before replicating the packet, or else we won't know how to extract the destination,
+ * which is stored on the header
+ * @param packet
+ * @throws Exception
+ */
+ private LargeServerMessage doCreateLargeMessage(final SessionSendLargeMessage packet)
+ {
+ try
+ {
+ return createLargeMessageStorage(packet.getLargeMessageHeader());
+ }
+ catch (Exception e)
+ {
+ log.error("Failed to create large message", e);
+ Packet response = null;
+
+ channel.confirm(packet);
+ if (response != null)
+ {
+ channel.send(response);
+ }
+ return null;
+ }
+ }
+
private void handleManagementMessage(final ServerMessage message) throws Exception
{
try
@@ -2528,40 +1790,5 @@
{
postOffice.route(msg, tx);
}
- }
-
- /**
- * We need to avoid delivery when rolling back while doing replication, or the backup node could be on a different order
- * @return
- */
- private HashSet<Queue> lockUsedQueues(Xid xid)
- {
- final HashSet<Queue> queues = new HashSet<Queue>();
-
- for (ServerConsumer consumer : consumers.values())
- {
- queues.add(consumer.getQueue());
- }
-
- Transaction localTX;
- if (xid == null)
- {
- localTX = tx;
- }
- else
- {
- localTX = resourceManager.getTransaction(xid);
- }
-
- if (localTX != null)
- {
- queues.addAll(localTX.getDistinctQueues());
- }
-
- for (Queue queue : queues)
- {
- queue.lockDelivery();
- }
- return queues;
- }
+ }
}
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/ServerSessionPacketHandler.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/ServerSessionPacketHandler.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/core/server/impl/ServerSessionPacketHandler.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -22,10 +22,8 @@
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_CONSUMER_CLOSE;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_CREATECONSUMER;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_EXPIRED;
-import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_FAILOVER_COMPLETE;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_FLOWTOKEN;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_QUEUEQUERY;
-import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_REPLICATE_DELIVERY;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_ROLLBACK;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_SEND;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_SEND_CONTINUATION;
@@ -49,8 +47,6 @@
import org.hornetq.core.remoting.ChannelHandler;
import org.hornetq.core.remoting.Packet;
import org.hornetq.core.remoting.impl.wireformat.CreateQueueMessage;
-import org.hornetq.core.remoting.impl.wireformat.PacketImpl;
-import org.hornetq.core.remoting.impl.wireformat.PacketsConfirmedMessage;
import org.hornetq.core.remoting.impl.wireformat.RollbackMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionAcknowledgeMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionBindingQueryMessage;
@@ -72,7 +68,6 @@
import org.hornetq.core.remoting.impl.wireformat.SessionXARollbackMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionXASetTimeoutMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionXAStartMessage;
-import org.hornetq.core.remoting.impl.wireformat.replication.SessionReplicateDeliveryMessage;
import org.hornetq.core.server.ServerSession;
/**
@@ -106,11 +101,6 @@
{
switch (type)
{
- case PacketImpl.PACKETS_CONFIRMED:
- {
- session.handlePacketsConfirmed((PacketsConfirmedMessage)packet);
- break;
- }
case SESS_CREATECONSUMER:
{
SessionCreateConsumerMessage request = (SessionCreateConsumerMessage)packet;
@@ -118,15 +108,15 @@
break;
}
case CREATE_QUEUE:
- {
- CreateQueueMessage request = (CreateQueueMessage)packet;
- session.handleCreateQueue(request);
+ {
+ CreateQueueMessage request = (CreateQueueMessage)packet;
+ session.handleCreateQueue(request);
break;
}
case DELETE_QUEUE:
{
SessionDeleteQueueMessage request = (SessionDeleteQueueMessage)packet;
- session.handleDeleteQueue(request);
+ session.handleDeleteQueue(request);
break;
}
case SESS_QUEUEQUERY:
@@ -237,11 +227,6 @@
session.handleStart(packet);
break;
}
- case SESS_FAILOVER_COMPLETE:
- {
- session.handleFailedOver(packet);
- break;
- }
case SESS_STOP:
{
session.handleStop(packet);
@@ -267,27 +252,21 @@
case SESS_SEND:
{
SessionSendMessage message = (SessionSendMessage)packet;
- session.handleSend(message);
- break;
+ session.handleSend(message);
+ break;
}
case SESS_SEND_LARGE:
{
SessionSendLargeMessage message = (SessionSendLargeMessage)packet;
- session.handleSendLargeMessage(message);
- break;
+ session.handleSendLargeMessage(message);
+ break;
}
case SESS_SEND_CONTINUATION:
{
SessionSendContinuationMessage message = (SessionSendContinuationMessage)packet;
session.handleSendContinuations(message);
- break;
+ break;
}
- case SESS_REPLICATE_DELIVERY:
- {
- SessionReplicateDeliveryMessage message = (SessionReplicateDeliveryMessage)packet;
- session.handleReplicatedDelivery(message);
- break;
- }
}
}
catch (Throwable t)
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -141,8 +141,6 @@
deploymentManager = new FileDeploymentManager(server.getConfiguration().getFileDeployerScanPeriod());
- server.registerActivateCallback(this);
-
server.start();
started = true;
Modified: branches/Branch_Replication_Changes/src/main/org/hornetq/jms/server/management/impl/JMSManagementServiceImpl.java
===================================================================
--- branches/Branch_Replication_Changes/src/main/org/hornetq/jms/server/management/impl/JMSManagementServiceImpl.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/src/main/org/hornetq/jms/server/management/impl/JMSManagementServiceImpl.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -13,7 +13,6 @@
package org.hornetq.jms.server.management.impl;
-
import java.util.List;
import javax.management.ObjectName;
@@ -31,10 +30,6 @@
import org.hornetq.jms.server.JMSServerManager;
import org.hornetq.jms.server.management.JMSManagementService;
import org.hornetq.jms.server.management.JMSServerControl;
-import org.hornetq.jms.server.management.jmx.impl.ReplicationAwareConnectionFactoryControlWrapper;
-import org.hornetq.jms.server.management.jmx.impl.ReplicationAwareJMSQueueControlWrapper;
-import org.hornetq.jms.server.management.jmx.impl.ReplicationAwareJMSServerControlWrapper;
-import org.hornetq.jms.server.management.jmx.impl.ReplicationAwareTopicControlWrapper;
/*
* @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
@@ -65,12 +60,10 @@
{
ObjectName objectName = ObjectNames.getJMSServerObjectName();
JMSServerControlImpl control = new JMSServerControlImpl(server);
- JMSServerControl replicatingProxy = new ReplicationAwareJMSServerControlWrapper(control,
- managementService.getReplicationOperationInvoker());
managementService.registerInJMX(objectName,
- replicatingProxy);
+ control);
managementService.registerInRegistry(ResourceNames.JMS_SERVER, control);
- return replicatingProxy;
+ return control;
}
public synchronized void unregisterJMSServer() throws Exception
@@ -97,9 +90,7 @@
coreQueueControl,
jndiBinding,
counter);
- managementService.registerInJMX(objectName,
- new ReplicationAwareJMSQueueControlWrapper(control,
- managementService.getReplicationOperationInvoker()));
+ managementService.registerInJMX(objectName, control);
managementService.registerInRegistry(ResourceNames.JMS_QUEUE + queue.getQueueName(), control);
}
@@ -116,8 +107,7 @@
ObjectName objectName = ObjectNames.getJMSTopicObjectName(topic.getTopicName());
AddressControl addressControl = (AddressControl)managementService.getResource(ResourceNames.CORE_ADDRESS + topic.getAddress());
TopicControlImpl control = new TopicControlImpl(topic, addressControl, jndiBinding, managementService);
- managementService.registerInJMX(objectName, new ReplicationAwareTopicControlWrapper(control,
- managementService.getReplicationOperationInvoker()));
+ managementService.registerInJMX(objectName, control);
managementService.registerInRegistry(ResourceNames.JMS_TOPIC + topic.getTopicName(), control);
}
@@ -134,9 +124,7 @@
{
ObjectName objectName = ObjectNames.getConnectionFactoryObjectName(name);
ConnectionFactoryControlImpl control = new ConnectionFactoryControlImpl(connectionFactory, name, bindings);
- managementService.registerInJMX(objectName,
- new ReplicationAwareConnectionFactoryControlWrapper(control,
- managementService.getReplicationOperationInvoker()));
+ managementService.registerInJMX(objectName, control);
managementService.registerInRegistry(ResourceNames.JMS_CONNECTION_FACTORY + name, control);
}
Modified: branches/Branch_Replication_Changes/tests/config/ConfigurationTest-full-config.xml
===================================================================
--- branches/Branch_Replication_Changes/tests/config/ConfigurationTest-full-config.xml 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/tests/config/ConfigurationTest-full-config.xml 2009-09-11 10:56:25 UTC (rev 7954)
@@ -28,6 +28,7 @@
<persist-id-cache>true</persist-id-cache>
<queue-activation-timeout>12456</queue-activation-timeout>
<backup>true</backup>
+ <shared-store>true</shared-store>
<persist-delivery-count-before-delivery>true</persist-delivery-count-before-delivery>
<paging-directory>pagingdir</paging-directory>
<bindings-directory>somedir</bindings-directory>
Deleted: branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/integration/cluster/failover/ActivationTimeoutTest.java
===================================================================
--- branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/integration/cluster/failover/ActivationTimeoutTest.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/integration/cluster/failover/ActivationTimeoutTest.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -1,324 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.tests.integration.cluster.failover;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.hornetq.core.client.ClientConsumer;
-import org.hornetq.core.client.ClientMessage;
-import org.hornetq.core.client.ClientProducer;
-import org.hornetq.core.client.ClientSession;
-import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
-import org.hornetq.core.client.impl.ClientSessionFactoryInternal;
-import org.hornetq.core.client.impl.ClientSessionInternal;
-import org.hornetq.core.config.Configuration;
-import org.hornetq.core.config.TransportConfiguration;
-import org.hornetq.core.config.impl.ConfigurationImpl;
-import org.hornetq.core.exception.HornetQException;
-import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.RemotingConnection;
-import org.hornetq.core.remoting.impl.invm.InVMRegistry;
-import org.hornetq.core.remoting.impl.invm.TransportConstants;
-import org.hornetq.core.server.HornetQ;
-import org.hornetq.core.server.HornetQServer;
-import org.hornetq.jms.client.HornetQTextMessage;
-import org.hornetq.tests.util.UnitTestCase;
-import org.hornetq.utils.SimpleString;
-
-/**
- *
- * A ActivationTimeoutTest
- *
- * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- *
- * Created 4 Nov 2008 16:54:50
- *
- *
- */
-public class ActivationTimeoutTest extends UnitTestCase
-{
- private static final Logger log = Logger.getLogger(SimpleAutomaticFailoverTest.class);
-
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private static final long ACTIVATION_TIMEOUT = 5000;
-
- private static final SimpleString ADDRESS = new SimpleString("FailoverTestAddress");
-
- private HornetQServer liveService;
-
- private HornetQServer backupService;
-
- private Map<String, Object> backupParams = new HashMap<String, Object>();
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public void testTimeoutAfterConsumerFailsToReattach() throws Exception
- {
- ClientSessionFactoryInternal sf1 = new ClientSessionFactoryImpl(new TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory"),
- new TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
- backupParams));
-
- ClientSessionFactoryInternal sf2 = new ClientSessionFactoryImpl(new TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory"),
- new TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
- backupParams));
-
- sf1.setProducerWindowSize(32 * 1024);
- sf2.setProducerWindowSize(32 * 1024);
-
- ClientSession session1 = sf1.createSession(false, true, true);
-
- session1.createQueue(ADDRESS, ADDRESS, null, false);
-
- ClientProducer producer = session1.createProducer(ADDRESS);
-
- final int numMessages = 1000;
-
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage message = session1.createClientMessage(HornetQTextMessage.TYPE,
- false,
- 0,
- System.currentTimeMillis(),
- (byte)1);
- message.putIntProperty(new SimpleString("count"), i);
- message.getBody().writeString("aardvarks");
- producer.send(message);
- }
-
- ClientConsumer consumer1 = session1.createConsumer(ADDRESS);
-
- ClientSession session2 = sf2.createSession(false, true, true);
-
- // Create another consumer so we have two consumers on the queue
- ClientConsumer consumer2 = session2.createConsumer(ADDRESS);
-
- long start = System.currentTimeMillis();
-
- RemotingConnection conn1 = ((ClientSessionInternal)session1).getConnection();
-
- // Now we fail ONLY the connections on sf1, not on sf2
- conn1.fail(new HornetQException(HornetQException.NOT_CONNECTED));
-
- session1.start();
-
- // The messages should not be delivered until after activationTimeout ms, since
- // session 2 didn't reattach
-
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage message = consumer1.receive(2 * ACTIVATION_TIMEOUT);
-
- assertNotNull(message);
-
- if (i == 0)
- {
- long now = System.currentTimeMillis();
-
- assertTrue(now - start >= ACTIVATION_TIMEOUT);
- }
-
- assertEquals("aardvarks", message.getBody().readString());
-
- assertEquals(i, message.getProperty(new SimpleString("count")));
-
- message.acknowledge();
- }
-
- ClientMessage message = consumer1.receive(1000);
-
- assertNull(message);
-
- session1.close();
-
- RemotingConnection conn2 = ((ClientSessionInternal)session2).getConnection();
-
- conn2.fail(new HornetQException(HornetQException.NOT_CONNECTED));
-
- session2.close();
- }
-
- public void testTimeoutAfterAllConsumerFailsToReattach() throws Exception
- {
- for (int j = 0; j < 5; j++)
- {
- log.info("*************** ITERATION " + j);
-
- ClientSessionFactoryInternal sf1 = new ClientSessionFactoryImpl(new TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory"),
- new TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
- backupParams));
-
- ClientSessionFactoryInternal sf2 = new ClientSessionFactoryImpl(new TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory"),
- new TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
- backupParams));
-
- sf1.setProducerWindowSize(32 * 1024);
- sf2.setProducerWindowSize(32 * 1024);
-
- ClientSession session1 = sf1.createSession(false, true, true);
-
- session1.createQueue(ADDRESS, ADDRESS, null, false);
-
- ClientProducer producer = session1.createProducer(ADDRESS);
-
- final int numMessages = 1000;
-
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage message = session1.createClientMessage(HornetQTextMessage.TYPE,
- false,
- 0,
- System.currentTimeMillis(),
- (byte)1);
- message.putIntProperty(new SimpleString("count"), i);
- message.getBody().writeString("aardvarks");
- producer.send(message);
- }
-
- ClientSession session2 = sf2.createSession(false, true, true);
-
- ClientConsumer consumer1 = session2.createConsumer(ADDRESS);
-
- ClientConsumer consumer2 = session2.createConsumer(ADDRESS);
-
- long start = System.currentTimeMillis();
-
- RemotingConnection conn1 = ((ClientSessionInternal)session1).getConnection();
-
- // Now we fail ONLY the connections on sf1, not on sf2
- conn1.fail(new HornetQException(HornetQException.NOT_CONNECTED));
-
- session1.start();
-
- // The messages should not be delivered until after activationTimeout ms, since
- // session 2 didn't reattach
-
- // We now create a new consumer but it shouldn't receive the messages until after the timeout
-
- ClientConsumer consumer3 = session1.createConsumer(ADDRESS);
-
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage message = consumer3.receive(2 * ACTIVATION_TIMEOUT);
-
- assertNotNull(message);
-
- if (i == 0)
- {
- long now = System.currentTimeMillis();
-
- assertTrue(now - start >= ACTIVATION_TIMEOUT);
- }
-
- assertEquals("aardvarks", message.getBody().readString());
-
- assertEquals(i, message.getProperty(new SimpleString("count")));
-
- message.acknowledge();
- }
-
- ClientMessage message = consumer3.receive(1000);
-
- assertNull(message);
-
- session1.close();
-
- RemotingConnection conn2 = ((ClientSessionInternal)session2).getConnection();
-
- conn2.fail(new HornetQException(HornetQException.NOT_CONNECTED));
-
- session2.close();
-
- stop();
-
- start();
-
- }
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- private void start() throws Exception
- {
- Configuration backupConf = new ConfigurationImpl();
- backupConf.setSecurityEnabled(false);
- backupConf.setQueueActivationTimeout(ACTIVATION_TIMEOUT);
- backupParams.put(TransportConstants.SERVER_ID_PROP_NAME, 1);
- backupConf.getAcceptorConfigurations()
- .add(new TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory",
- backupParams));
- backupConf.setBackup(true);
- backupService = HornetQ.newHornetQServer(backupConf, false);
- backupService.start();
-
- Configuration liveConf = new ConfigurationImpl();
- liveConf.setSecurityEnabled(false);
- liveConf.getAcceptorConfigurations()
- .add(new TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory"));
- Map<String, TransportConfiguration> connectors = new HashMap<String, TransportConfiguration>();
- TransportConfiguration backupTC = new TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory",
- backupParams,
- "backup-connector");
- connectors.put(backupTC.getName(), backupTC);
- liveConf.setConnectorConfigurations(connectors);
- liveConf.setBackupConnectorName(backupTC.getName());
- liveService = HornetQ.newHornetQServer(liveConf, false);
- liveService.start();
- }
-
- private void stop() throws Exception
- {
- backupService.stop();
-
- liveService.stop();
-
- assertEquals(0, InVMRegistry.instance.size());
-
- }
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
-
- start();
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- stop();
-
- backupService = null;
-
- liveService = null;
-
- backupParams = null;
-
- super.tearDown();
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Modified: branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/integration/management/HornetQServerControlTest.java
===================================================================
--- branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/integration/management/HornetQServerControlTest.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/integration/management/HornetQServerControlTest.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -72,7 +72,7 @@
assertEquals(conf.isClustered(), serverControl.isClustered());
assertEquals(conf.isPersistDeliveryCountBeforeDelivery(), serverControl.isPersistDeliveryCountBeforeDelivery());
assertEquals(conf.isBackup(), serverControl.isBackup());
- assertEquals(conf.getQueueActivationTimeout(), serverControl.getQueueActivationTimeout());
+ assertEquals(conf.isSharedStore(), serverControl.isSharedStore());
assertEquals(conf.getScheduledThreadPoolMaxSize(), serverControl.getScheduledThreadPoolMaxSize());
assertEquals(conf.getThreadPoolMaxSize(), serverControl.getThreadPoolMaxSize());
assertEquals(conf.getSecurityInvalidationInterval(), serverControl.getSecurityInvalidationInterval());
Modified: branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/integration/management/QueueControlTest.java
===================================================================
--- branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/integration/management/QueueControlTest.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/integration/management/QueueControlTest.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -84,7 +84,6 @@
assertEquals(filter.toString(), queueControl.getFilter());
assertEquals(durable, queueControl.isDurable());
assertEquals(false, queueControl.isTemporary());
- assertEquals(false, queueControl.isBackup());
session.deleteQueue(queue);
}
Modified: branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/unit/core/config/impl/ConfigurationImplTest.java
===================================================================
--- branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/unit/core/config/impl/ConfigurationImplTest.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/unit/core/config/impl/ConfigurationImplTest.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -44,7 +44,7 @@
{
assertEquals(ConfigurationImpl.DEFAULT_CLUSTERED, conf.isClustered());
assertEquals(ConfigurationImpl.DEFAULT_BACKUP, conf.isBackup());
- assertEquals(ConfigurationImpl.DEFAULT_QUEUE_ACTIVATION_TIMEOUT, conf.getQueueActivationTimeout());
+ assertEquals(ConfigurationImpl.DEFAULT_SHARED_STORE, conf.isSharedStore());
assertEquals(ConfigurationImpl.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE, conf.getScheduledThreadPoolMaxSize());
assertEquals(ConfigurationImpl.DEFAULT_SECURITY_INVALIDATION_INTERVAL, conf.getSecurityInvalidationInterval());
assertEquals(ConfigurationImpl.DEFAULT_SECURITY_ENABLED, conf.isSecurityEnabled());
@@ -83,15 +83,15 @@
conf.setBackup(b);
assertEquals(b, conf.isBackup());
- long l = randomLong();
- conf.setQueueActivationTimeout(l);
- assertEquals(l, conf.getQueueActivationTimeout());
+ b = randomBoolean();
+ conf.setSharedStore(b);
+ assertEquals(b, conf.isSharedStore());
int i = randomInt();
conf.setScheduledThreadPoolMaxSize(i);
assertEquals(i, conf.getScheduledThreadPoolMaxSize());
- l = randomLong();
+ long l = randomLong();
conf.setSecurityInvalidationInterval(l);
assertEquals(l, conf.getSecurityInvalidationInterval());
@@ -176,14 +176,13 @@
b = randomBoolean();
conf.setBackup(b);
- long l = randomLong();
- conf.setQueueActivationTimeout(l);
-
-
+ b = randomBoolean();
+ conf.setSharedStore(b);
+
int i = randomInt();
conf.setScheduledThreadPoolMaxSize(i);
- l = randomLong();
+ long l = randomLong();
conf.setSecurityInvalidationInterval(l);
b = randomBoolean();
Modified: branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/unit/core/config/impl/DefaultsFileConfigurationTest.java
===================================================================
--- branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/unit/core/config/impl/DefaultsFileConfigurationTest.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/unit/core/config/impl/DefaultsFileConfigurationTest.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -37,7 +37,7 @@
assertEquals(ConfigurationImpl.DEFAULT_BACKUP, conf.isBackup());
- assertEquals(ConfigurationImpl.DEFAULT_QUEUE_ACTIVATION_TIMEOUT, conf.getQueueActivationTimeout());
+ assertEquals(ConfigurationImpl.DEFAULT_SHARED_STORE, conf.isSharedStore());
assertEquals(ConfigurationImpl.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE, conf.getScheduledThreadPoolMaxSize());
Modified: branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/unit/core/config/impl/FileConfigurationTest.java
===================================================================
--- branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/unit/core/config/impl/FileConfigurationTest.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/unit/core/config/impl/FileConfigurationTest.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -59,8 +59,8 @@
assertEquals(8, conf.getMessageExpiryThreadPriority());
assertEquals(127, conf.getIDCacheSize());
assertEquals(true, conf.isPersistIDCache());
- assertEquals(12456, conf.getQueueActivationTimeout());
assertEquals(true, conf.isBackup());
+ assertEquals(true, conf.isSharedStore());
assertEquals(true, conf.isPersistDeliveryCountBeforeDelivery());
assertEquals("pagingdir", conf.getPagingDirectory());
assertEquals("somedir", conf.getBindingsDirectory());
Modified: branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingImplTest.java
===================================================================
--- branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingImplTest.java 2009-09-11 02:25:29 UTC (rev 7953)
+++ branches/Branch_Replication_Changes/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingImplTest.java 2009-09-11 10:56:25 UTC (rev 7954)
@@ -1089,7 +1089,7 @@
/* (non-Javadoc)
* @see org.hornetq.core.server.Queue#addRedistributor(long, java.util.concurrent.Executor, org.hornetq.core.remoting.Channel)
*/
- public void addRedistributor(long delay, Executor executor, Channel replicatingChannel)
+ public void addRedistributor(long delay, Executor executor)
{
}
15 years, 3 months
JBoss hornetq SVN: r7953 - trunk/src/main/org/hornetq/core/config/impl.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2009-09-10 22:25:29 -0400 (Thu, 10 Sep 2009)
New Revision: 7953
Modified:
trunk/src/main/org/hornetq/core/config/impl/ConfigurationImpl.java
Log:
removing collections from equals (fixing FileConfigurationTest)
Modified: trunk/src/main/org/hornetq/core/config/impl/ConfigurationImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/config/impl/ConfigurationImpl.java 2009-09-10 22:39:33 UTC (rev 7952)
+++ trunk/src/main/org/hornetq/core/config/impl/ConfigurationImpl.java 2009-09-11 02:25:29 UTC (rev 7953)
@@ -868,13 +868,6 @@
if (getClass() != obj.getClass())
return false;
ConfigurationImpl other = (ConfigurationImpl)obj;
- if (acceptorConfigs == null)
- {
- if (other.acceptorConfigs != null)
- return false;
- }
- else if (!acceptorConfigs.equals(other.acceptorConfigs))
- return false;
if (asyncConnectionExecutionEnabled != other.asyncConnectionExecutionEnabled)
return false;
if (backup != other.backup)
@@ -893,69 +886,21 @@
}
else if (!bindingsDirectory.equals(other.bindingsDirectory))
return false;
- if (bridgeConfigurations == null)
- {
- if (other.bridgeConfigurations != null)
- return false;
- }
- else if (!bridgeConfigurations.equals(other.bridgeConfigurations))
+ if (clustered != other.clustered)
return false;
- if (broadcastGroupConfigurations == null)
- {
- if (other.broadcastGroupConfigurations != null)
- return false;
- }
- else if (!broadcastGroupConfigurations.equals(other.broadcastGroupConfigurations))
- return false;
- if (clusterConfigurations == null)
- {
- if (other.clusterConfigurations != null)
- return false;
- }
- else if (!clusterConfigurations.equals(other.clusterConfigurations))
- return false;
- if (clustered != other.clustered)
- return false;
if (connectionTTLOverride != other.connectionTTLOverride)
return false;
- if (connectorConfigs == null)
- {
- if (other.connectorConfigs != null)
- return false;
- }
- else if (!connectorConfigs.equals(other.connectorConfigs))
- return false;
if (createBindingsDir != other.createBindingsDir)
return false;
if (createJournalDir != other.createJournalDir)
return false;
- if (discoveryGroupConfigurations == null)
- {
- if (other.discoveryGroupConfigurations != null)
- return false;
- }
- else if (!discoveryGroupConfigurations.equals(other.discoveryGroupConfigurations))
- return false;
- if (divertConfigurations == null)
- {
- if (other.divertConfigurations != null)
- return false;
- }
- else if (!divertConfigurations.equals(other.divertConfigurations))
- return false;
+
if (fileDeploymentEnabled != other.fileDeploymentEnabled)
return false;
if (fileDeploymentScanPeriod != other.fileDeploymentScanPeriod)
return false;
if (idCacheSize != other.idCacheSize)
return false;
- if (interceptorClassNames == null)
- {
- if (other.interceptorClassNames != null)
- return false;
- }
- else if (!interceptorClassNames.equals(other.interceptorClassNames))
- return false;
if (jmxManagementEnabled != other.jmxManagementEnabled)
return false;
if (journalAIOBufferSize != other.journalAIOBufferSize)
@@ -1058,13 +1003,6 @@
return false;
if (queueActivationTimeout != other.queueActivationTimeout)
return false;
- if (queueConfigurations == null)
- {
- if (other.queueConfigurations != null)
- return false;
- }
- else if (!queueConfigurations.equals(other.queueConfigurations))
- return false;
if (scheduledThreadPoolMaxSize != other.scheduledThreadPoolMaxSize)
return false;
if (securityEnabled != other.securityEnabled)
15 years, 3 months
JBoss hornetq SVN: r7952 - in trunk: src/main/org/hornetq/core/config/impl and 1 other directories.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2009-09-10 18:39:33 -0400 (Thu, 10 Sep 2009)
New Revision: 7952
Modified:
trunk/src/main/org/hornetq/core/config/Configuration.java
trunk/src/main/org/hornetq/core/config/impl/ConfigurationImpl.java
trunk/tests/src/org/hornetq/tests/unit/core/config/impl/ConfigurationImplTest.java
Log:
Adding Configuration tests, and adding a few missing properties
Modified: trunk/src/main/org/hornetq/core/config/Configuration.java
===================================================================
--- trunk/src/main/org/hornetq/core/config/Configuration.java 2009-09-10 11:19:52 UTC (rev 7951)
+++ trunk/src/main/org/hornetq/core/config/Configuration.java 2009-09-10 22:39:33 UTC (rev 7952)
@@ -146,12 +146,20 @@
void setManagementAddress(SimpleString address);
SimpleString getManagementNotificationAddress();
+
+ void setManagementNotificationAddress(SimpleString address);
String getManagementClusterUser();
-
+
+ void setManagementClusterUser(String user);
+
String getManagementClusterPassword();
+
+ void setManagementClusterPassword(String password);
long getManagementRequestTimeout();
+
+ void setManagementRequestTimeout(long timeout);
int getIDCacheSize();
@@ -233,7 +241,7 @@
long getServerDumpInterval();
- void getServerDumpInterval(long interval);
+ void setServerDumpInterval(long interval);
// Paging Properties --------------------------------------------------------------------
@@ -258,10 +266,14 @@
void setTransactionTimeout(long timeout);
boolean isMessageCounterEnabled();
+
+ void setMessageCounterEnabled(boolean enabled);
long getMessageCounterSamplePeriod();
int getMessageCounterMaxDayHistory();
+
+ void setMessageCounterMaxDayHistory(int maxDayHistory);
long getTransactionTimeoutScanPeriod();
Modified: trunk/src/main/org/hornetq/core/config/impl/ConfigurationImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/config/impl/ConfigurationImpl.java 2009-09-10 11:19:52 UTC (rev 7951)
+++ trunk/src/main/org/hornetq/core/config/impl/ConfigurationImpl.java 2009-09-10 22:39:33 UTC (rev 7952)
@@ -67,7 +67,7 @@
public static final boolean DEFAULT_JMX_MANAGEMENT_ENABLED = true;
public static final long DEFAULT_CONNECTION_TTL_OVERRIDE = -1;
-
+
public static final boolean DEFAULT_ASYNC_CONNECTION_EXECUTION_ENABLED = true;
public static final String DEFAULT_BINDINGS_DIRECTORY = "data/bindings";
@@ -89,23 +89,23 @@
public static final boolean DEFAULT_JOURNAL_SYNC_NON_TRANSACTIONAL = false;
public static final int DEFAULT_JOURNAL_FILE_SIZE = 10485760;
-
+
public static final int DEFAULT_JOURNAL_COMPACT_MIN_FILES = 10;
-
+
public static final int DEFAULT_JOURNAL_COMPACT_PERCENTAGE = 30;
public static final int DEFAULT_JOURNAL_MIN_FILES = 2;
public static final int DEFAULT_JOURNAL_MAX_AIO = 500;
-
+
public static final boolean DEFAULT_JOURNAL_AIO_FLUSH_SYNC = false;
-
+
public static final int DEFAULT_JOURNAL_AIO_BUFFER_TIMEOUT = 20000;
-
+
public static final int DEFAULT_JOURNAL_AIO_BUFFER_SIZE = 128 * 1024;
-
+
public static final boolean DEFAULT_JOURNAL_LOG_WRITE_RATE = false;
-
+
public static final int DEFAULT_JOURNAL_PERF_BLAST_PAGES = -1;
public static final boolean DEFAULT_WILDCARD_ROUTING_ENABLED = true;
@@ -185,9 +185,9 @@
protected boolean jmxManagementEnabled = DEFAULT_JMX_MANAGEMENT_ENABLED;
protected long connectionTTLOverride = DEFAULT_CONNECTION_TTL_OVERRIDE;
-
+
protected boolean asyncConnectionExecutionEnabled = DEFAULT_ASYNC_CONNECTION_EXECUTION_ENABLED;
-
+
protected long messageExpiryScanPeriod = DEFAULT_MESSAGE_EXPIRY_SCAN_PERIOD;
protected int messageExpiryThreadPriority = DEFAULT_MESSAGE_EXPIRY_THREAD_PRIORITY;
@@ -238,25 +238,24 @@
protected boolean journalSyncNonTransactional = DEFAULT_JOURNAL_SYNC_NON_TRANSACTIONAL;
-
protected int journalCompactMinFiles = DEFAULT_JOURNAL_COMPACT_MIN_FILES;
-
+
protected int journalCompactPercentage = DEFAULT_JOURNAL_COMPACT_PERCENTAGE;
-
+
protected int journalFileSize = DEFAULT_JOURNAL_FILE_SIZE;
protected int journalMinFiles = DEFAULT_JOURNAL_MIN_FILES;
protected int journalMaxAIO = DEFAULT_JOURNAL_MAX_AIO;
-
+
protected boolean journalAIOFlushSync = DEFAULT_JOURNAL_AIO_FLUSH_SYNC;
-
+
protected int journalAIOBufferTimeout = DEFAULT_JOURNAL_AIO_BUFFER_TIMEOUT;
-
+
protected int journalAIOBufferSize = DEFAULT_JOURNAL_AIO_BUFFER_SIZE;
-
+
protected boolean logJournalWriteRate = DEFAULT_JOURNAL_LOG_WRITE_RATE;
-
+
protected int journalPerfBlastPages = DEFAULT_JOURNAL_PERF_BLAST_PAGES;
protected boolean wildcardRoutingEnabled = DEFAULT_WILDCARD_ROUTING_ENABLED;
@@ -283,7 +282,6 @@
protected long serverDumpInterval = DEFAULT_SERVER_DUMP_INTERVAL;
-
// Public -------------------------------------------------------------------------
public void start() throws Exception
@@ -414,12 +412,12 @@
{
connectionTTLOverride = ttl;
}
-
+
public boolean isAsyncConnectionExecutionEnabled()
{
return asyncConnectionExecutionEnabled;
}
-
+
public void setEnabledAsyncConnectionExecution(final boolean enabled)
{
asyncConnectionExecutionEnabled = enabled;
@@ -634,7 +632,7 @@
{
journalMinFiles = files;
}
-
+
public boolean isLogJournalWriteRate()
{
return logJournalWriteRate;
@@ -644,7 +642,7 @@
{
this.logJournalWriteRate = logJournalWriteRate;
}
-
+
public int getJournalPerfBlastPages()
{
return journalPerfBlastPages;
@@ -745,12 +743,11 @@
jmxManagementEnabled = enabled;
}
-
public void setAIOBufferTimeout(int timeout)
{
this.journalAIOBufferTimeout = timeout;
}
-
+
public int getAIOBufferTimeout()
{
return journalAIOBufferTimeout;
@@ -775,7 +772,7 @@
{
this.journalAIOBufferSize = size;
}
-
+
public String getLargeMessagesDirectory()
{
return largeMessagesDirectory;
@@ -791,6 +788,11 @@
return messageCounterEnabled;
}
+ public void setMessageCounterEnabled(boolean enabled)
+ {
+ this.messageCounterEnabled = enabled;
+ }
+
public long getMessageCounterSamplePeriod()
{
return messageCounterSamplePeriod;
@@ -801,6 +803,11 @@
return messageCounterMaxDayHistory;
}
+ public void setMessageCounterMaxDayHistory(int maxDayHistory)
+ {
+ this.messageCounterMaxDayHistory = maxDayHistory;
+ }
+
public SimpleString getManagementAddress()
{
return managementAddress;
@@ -826,6 +833,11 @@
return managementClusterUser;
}
+ public void setManagementClusterUser(String user)
+ {
+ this.managementClusterUser = user;
+ }
+
public String getManagementClusterPassword()
{
return managementClusterPassword;
@@ -847,36 +859,229 @@
}
@Override
- public boolean equals(final Object other)
+ public boolean equals(Object obj)
{
- if (this == other)
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ConfigurationImpl other = (ConfigurationImpl)obj;
+ if (acceptorConfigs == null)
{
- return true;
+ if (other.acceptorConfigs != null)
+ return false;
}
-
- if (other instanceof Configuration == false)
+ else if (!acceptorConfigs.equals(other.acceptorConfigs))
+ return false;
+ if (asyncConnectionExecutionEnabled != other.asyncConnectionExecutionEnabled)
+ return false;
+ if (backup != other.backup)
+ return false;
+ if (backupConnectorName == null)
{
+ if (other.backupConnectorName != null)
+ return false;
+ }
+ else if (!backupConnectorName.equals(other.backupConnectorName))
return false;
+ if (bindingsDirectory == null)
+ {
+ if (other.bindingsDirectory != null)
+ return false;
}
-
- Configuration cother = (Configuration)other;
-
- return cother.isClustered() == isClustered() && cother.isCreateBindingsDir() == isCreateBindingsDir() &&
- cother.isCreateJournalDir() == isCreateJournalDir() &&
- cother.isJournalSyncNonTransactional() == isJournalSyncNonTransactional() &&
- cother.isJournalSyncTransactional() == isJournalSyncTransactional() &&
- cother.isSecurityEnabled() == isSecurityEnabled() &&
- cother.isWildcardRoutingEnabled() == isWildcardRoutingEnabled() &&
- cother.getLargeMessagesDirectory().equals(getLargeMessagesDirectory()) &&
- cother.getBindingsDirectory().equals(getBindingsDirectory()) &&
- cother.getJournalDirectory().equals(getJournalDirectory()) &&
- cother.getJournalFileSize() == getJournalFileSize() &&
- cother.getJournalMaxAIO() == getJournalMaxAIO() &&
- cother.getJournalMinFiles() == getJournalMinFiles() &&
- cother.getJournalType() == getJournalType() &&
- cother.getScheduledThreadPoolMaxSize() == getScheduledThreadPoolMaxSize() &&
- cother.getSecurityInvalidationInterval() == getSecurityInvalidationInterval() &&
- cother.getManagementAddress().equals(getManagementAddress());
+ else if (!bindingsDirectory.equals(other.bindingsDirectory))
+ return false;
+ if (bridgeConfigurations == null)
+ {
+ if (other.bridgeConfigurations != null)
+ return false;
+ }
+ else if (!bridgeConfigurations.equals(other.bridgeConfigurations))
+ return false;
+ if (broadcastGroupConfigurations == null)
+ {
+ if (other.broadcastGroupConfigurations != null)
+ return false;
+ }
+ else if (!broadcastGroupConfigurations.equals(other.broadcastGroupConfigurations))
+ return false;
+ if (clusterConfigurations == null)
+ {
+ if (other.clusterConfigurations != null)
+ return false;
+ }
+ else if (!clusterConfigurations.equals(other.clusterConfigurations))
+ return false;
+ if (clustered != other.clustered)
+ return false;
+ if (connectionTTLOverride != other.connectionTTLOverride)
+ return false;
+ if (connectorConfigs == null)
+ {
+ if (other.connectorConfigs != null)
+ return false;
+ }
+ else if (!connectorConfigs.equals(other.connectorConfigs))
+ return false;
+ if (createBindingsDir != other.createBindingsDir)
+ return false;
+ if (createJournalDir != other.createJournalDir)
+ return false;
+ if (discoveryGroupConfigurations == null)
+ {
+ if (other.discoveryGroupConfigurations != null)
+ return false;
+ }
+ else if (!discoveryGroupConfigurations.equals(other.discoveryGroupConfigurations))
+ return false;
+ if (divertConfigurations == null)
+ {
+ if (other.divertConfigurations != null)
+ return false;
+ }
+ else if (!divertConfigurations.equals(other.divertConfigurations))
+ return false;
+ if (fileDeploymentEnabled != other.fileDeploymentEnabled)
+ return false;
+ if (fileDeploymentScanPeriod != other.fileDeploymentScanPeriod)
+ return false;
+ if (idCacheSize != other.idCacheSize)
+ return false;
+ if (interceptorClassNames == null)
+ {
+ if (other.interceptorClassNames != null)
+ return false;
+ }
+ else if (!interceptorClassNames.equals(other.interceptorClassNames))
+ return false;
+ if (jmxManagementEnabled != other.jmxManagementEnabled)
+ return false;
+ if (journalAIOBufferSize != other.journalAIOBufferSize)
+ return false;
+ if (journalAIOBufferTimeout != other.journalAIOBufferTimeout)
+ return false;
+ if (journalAIOFlushSync != other.journalAIOFlushSync)
+ return false;
+ if (journalCompactMinFiles != other.journalCompactMinFiles)
+ return false;
+ if (journalCompactPercentage != other.journalCompactPercentage)
+ return false;
+ if (journalDirectory == null)
+ {
+ if (other.journalDirectory != null)
+ return false;
+ }
+ else if (!journalDirectory.equals(other.journalDirectory))
+ return false;
+ if (journalFileSize != other.journalFileSize)
+ return false;
+ if (journalMaxAIO != other.journalMaxAIO)
+ return false;
+ if (journalMinFiles != other.journalMinFiles)
+ return false;
+ if (journalPerfBlastPages != other.journalPerfBlastPages)
+ return false;
+ if (journalSyncNonTransactional != other.journalSyncNonTransactional)
+ return false;
+ if (journalSyncTransactional != other.journalSyncTransactional)
+ return false;
+ if (journalType == null)
+ {
+ if (other.journalType != null)
+ return false;
+ }
+ else if (!journalType.equals(other.journalType))
+ return false;
+ if (largeMessagesDirectory == null)
+ {
+ if (other.largeMessagesDirectory != null)
+ return false;
+ }
+ else if (!largeMessagesDirectory.equals(other.largeMessagesDirectory))
+ return false;
+ if (logJournalWriteRate != other.logJournalWriteRate)
+ return false;
+ if (managementAddress == null)
+ {
+ if (other.managementAddress != null)
+ return false;
+ }
+ else if (!managementAddress.equals(other.managementAddress))
+ return false;
+ if (managementClusterPassword == null)
+ {
+ if (other.managementClusterPassword != null)
+ return false;
+ }
+ else if (!managementClusterPassword.equals(other.managementClusterPassword))
+ return false;
+ if (managementClusterUser == null)
+ {
+ if (other.managementClusterUser != null)
+ return false;
+ }
+ else if (!managementClusterUser.equals(other.managementClusterUser))
+ return false;
+ if (managementNotificationAddress == null)
+ {
+ if (other.managementNotificationAddress != null)
+ return false;
+ }
+ else if (!managementNotificationAddress.equals(other.managementNotificationAddress))
+ return false;
+ if (managementRequestTimeout != other.managementRequestTimeout)
+ return false;
+ if (messageCounterEnabled != other.messageCounterEnabled)
+ return false;
+ if (messageCounterMaxDayHistory != other.messageCounterMaxDayHistory)
+ return false;
+ if (messageCounterSamplePeriod != other.messageCounterSamplePeriod)
+ return false;
+ if (messageExpiryScanPeriod != other.messageExpiryScanPeriod)
+ return false;
+ if (messageExpiryThreadPriority != other.messageExpiryThreadPriority)
+ return false;
+ if (pagingDirectory == null)
+ {
+ if (other.pagingDirectory != null)
+ return false;
+ }
+ else if (!pagingDirectory.equals(other.pagingDirectory))
+ return false;
+ if (persistDeliveryCountBeforeDelivery != other.persistDeliveryCountBeforeDelivery)
+ return false;
+ if (persistIDCache != other.persistIDCache)
+ return false;
+ if (persistenceEnabled != other.persistenceEnabled)
+ return false;
+ if (queueActivationTimeout != other.queueActivationTimeout)
+ return false;
+ if (queueConfigurations == null)
+ {
+ if (other.queueConfigurations != null)
+ return false;
+ }
+ else if (!queueConfigurations.equals(other.queueConfigurations))
+ return false;
+ if (scheduledThreadPoolMaxSize != other.scheduledThreadPoolMaxSize)
+ return false;
+ if (securityEnabled != other.securityEnabled)
+ return false;
+ if (securityInvalidationInterval != other.securityInvalidationInterval)
+ return false;
+ if (serverDumpInterval != other.serverDumpInterval)
+ return false;
+ if (threadPoolMaxSize != other.threadPoolMaxSize)
+ return false;
+ if (transactionTimeout != other.transactionTimeout)
+ return false;
+ if (transactionTimeoutScanPeriod != other.transactionTimeoutScanPeriod)
+ return false;
+ if (wildcardRoutingEnabled != other.wildcardRoutingEnabled)
+ return false;
+ return true;
}
public int getJournalCompactMinFiles()
@@ -888,7 +1093,7 @@
{
return journalCompactPercentage;
}
-
+
public void setJournalCompactMinFiles(int minFiles)
{
this.journalCompactMinFiles = minFiles;
@@ -898,14 +1103,15 @@
{
this.journalCompactPercentage = percentage;
}
-
+
public long getServerDumpInterval()
{
return serverDumpInterval;
}
-
- public void getServerDumpInterval(long intervalInMilliseconds)
+
+ public void setServerDumpInterval(long intervalInMilliseconds)
{
this.serverDumpInterval = intervalInMilliseconds;
}
+
}
Modified: trunk/tests/src/org/hornetq/tests/unit/core/config/impl/ConfigurationImplTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/core/config/impl/ConfigurationImplTest.java 2009-09-10 11:19:52 UTC (rev 7951)
+++ trunk/tests/src/org/hornetq/tests/unit/core/config/impl/ConfigurationImplTest.java 2009-09-10 22:39:33 UTC (rev 7952)
@@ -9,13 +9,14 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
- */
+ */
package org.hornetq.tests.unit.core.config.impl;
import static org.hornetq.tests.util.RandomUtil.randomBoolean;
import static org.hornetq.tests.util.RandomUtil.randomInt;
import static org.hornetq.tests.util.RandomUtil.randomLong;
+import static org.hornetq.tests.util.RandomUtil.randomSimpleString;
import static org.hornetq.tests.util.RandomUtil.randomString;
import java.io.ByteArrayInputStream;
@@ -39,15 +40,15 @@
public class ConfigurationImplTest extends UnitTestCase
{
protected Configuration conf;
-
+
public void testDefaults()
- {
+ {
assertEquals(ConfigurationImpl.DEFAULT_CLUSTERED, conf.isClustered());
assertEquals(ConfigurationImpl.DEFAULT_BACKUP, conf.isBackup());
assertEquals(ConfigurationImpl.DEFAULT_QUEUE_ACTIVATION_TIMEOUT, conf.getQueueActivationTimeout());
assertEquals(ConfigurationImpl.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE, conf.getScheduledThreadPoolMaxSize());
assertEquals(ConfigurationImpl.DEFAULT_SECURITY_INVALIDATION_INTERVAL, conf.getSecurityInvalidationInterval());
- assertEquals(ConfigurationImpl.DEFAULT_SECURITY_ENABLED, conf.isSecurityEnabled());
+ assertEquals(ConfigurationImpl.DEFAULT_SECURITY_ENABLED, conf.isSecurityEnabled());
assertEquals(ConfigurationImpl.DEFAULT_BINDINGS_DIRECTORY, conf.getBindingsDirectory());
assertEquals(ConfigurationImpl.DEFAULT_CREATE_BINDINGS_DIR, conf.isCreateBindingsDir());
assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_DIR, conf.getJournalDirectory());
@@ -56,199 +57,484 @@
assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_SYNC_TRANSACTIONAL, conf.isJournalSyncTransactional());
assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_SYNC_NON_TRANSACTIONAL, conf.isJournalSyncNonTransactional());
assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_FILE_SIZE, conf.getJournalFileSize());
- assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_MIN_FILES, conf.getJournalMinFiles());
+ assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_MIN_FILES, conf.getJournalMinFiles());
assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_MAX_AIO, conf.getJournalMaxAIO());
assertEquals(ConfigurationImpl.DEFAULT_WILDCARD_ROUTING_ENABLED, conf.isWildcardRoutingEnabled());
assertEquals(ConfigurationImpl.DEFAULT_TRANSACTION_TIMEOUT, conf.getTransactionTimeout());
- assertEquals(ConfigurationImpl.DEFAULT_MESSAGE_EXPIRY_SCAN_PERIOD, conf.getMessageExpiryScanPeriod());
- assertEquals(ConfigurationImpl.DEFAULT_MESSAGE_EXPIRY_THREAD_PRIORITY, conf.getMessageExpiryThreadPriority());
- assertEquals(ConfigurationImpl.DEFAULT_TRANSACTION_TIMEOUT_SCAN_PERIOD, conf.getTransactionTimeoutScanPeriod());
- assertEquals(ConfigurationImpl.DEFAULT_MANAGEMENT_ADDRESS, conf.getManagementAddress());
- assertEquals(ConfigurationImpl.DEFAULT_MANAGEMENT_NOTIFICATION_ADDRESS, conf.getManagementNotificationAddress());
- assertEquals(ConfigurationImpl.DEFAULT_MANAGEMENT_CLUSTER_USER, conf.getManagementClusterUser());
- assertEquals(ConfigurationImpl.DEFAULT_MANAGEMENT_CLUSTER_PASSWORD, conf.getManagementClusterPassword());
+ assertEquals(ConfigurationImpl.DEFAULT_MESSAGE_EXPIRY_SCAN_PERIOD, conf.getMessageExpiryScanPeriod()); // OK
+ assertEquals(ConfigurationImpl.DEFAULT_MESSAGE_EXPIRY_THREAD_PRIORITY, conf.getMessageExpiryThreadPriority()); // OK
+ assertEquals(ConfigurationImpl.DEFAULT_TRANSACTION_TIMEOUT_SCAN_PERIOD, conf.getTransactionTimeoutScanPeriod()); // OK
+ assertEquals(ConfigurationImpl.DEFAULT_MANAGEMENT_ADDRESS, conf.getManagementAddress()); // OK
+ assertEquals(ConfigurationImpl.DEFAULT_MANAGEMENT_NOTIFICATION_ADDRESS, conf.getManagementNotificationAddress()); // OK
+ assertEquals(ConfigurationImpl.DEFAULT_MANAGEMENT_CLUSTER_USER, conf.getManagementClusterUser()); // OK
+ assertEquals(ConfigurationImpl.DEFAULT_MANAGEMENT_CLUSTER_PASSWORD, conf.getManagementClusterPassword()); // OK
assertEquals(ConfigurationImpl.DEFAULT_PERSISTENCE_ENABLED, conf.isPersistenceEnabled());
assertEquals(ConfigurationImpl.DEFAULT_FILE_DEPLOYMENT_ENABLED, conf.isFileDeploymentEnabled());
+ assertEquals(ConfigurationImpl.DEFAULT_PERSIST_DELIVERY_COUNT_BEFORE_DELIVERY,
+ conf.isPersistDeliveryCountBeforeDelivery());
+ assertEquals(ConfigurationImpl.DEFAULT_FILE_DEPLOYER_SCAN_PERIOD, conf.getFileDeployerScanPeriod());
+ assertEquals(ConfigurationImpl.DEFAULT_THREAD_POOL_MAX_SIZE, conf.getThreadPoolMaxSize());
+ assertEquals(ConfigurationImpl.DEFAULT_JMX_MANAGEMENT_ENABLED, conf.isJMXManagementEnabled());
+ assertEquals(ConfigurationImpl.DEFAULT_CONNECTION_TTL_OVERRIDE, conf.getConnectionTTLOverride());
+ assertEquals(ConfigurationImpl.DEFAULT_ASYNC_CONNECTION_EXECUTION_ENABLED,
+ conf.isAsyncConnectionExecutionEnabled());
+ assertEquals(ConfigurationImpl.DEFAULT_PAGING_DIR, conf.getPagingDirectory());
+ assertEquals(ConfigurationImpl.DEFAULT_LARGE_MESSAGES_DIR, conf.getLargeMessagesDirectory());
+ assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_COMPACT_PERCENTAGE, conf.getJournalCompactPercentage());
+ assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_AIO_FLUSH_SYNC, conf.isAIOFlushOnSync());
+ assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_AIO_BUFFER_TIMEOUT, conf.getAIOBufferTimeout());
+ assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_LOG_WRITE_RATE, conf.isLogJournalWriteRate());
+ assertEquals(ConfigurationImpl.DEFAULT_JOURNAL_PERF_BLAST_PAGES, conf.getJournalPerfBlastPages());
+ assertEquals(ConfigurationImpl.DEFAULT_MESSAGE_COUNTER_ENABLED, conf.isMessageCounterEnabled());
+ assertEquals(ConfigurationImpl.DEFAULT_MESSAGE_COUNTER_MAX_DAY_HISTORY, conf.getMessageCounterMaxDayHistory());
+ assertEquals(ConfigurationImpl.DEFAULT_MESSAGE_COUNTER_SAMPLE_PERIOD, conf.getMessageCounterSamplePeriod());
+ assertEquals(ConfigurationImpl.DEFAULT_MANAGEMENT_REQUEST_TIMEOUT, conf.getManagementRequestTimeout());
+ assertEquals(ConfigurationImpl.DEFAULT_ID_CACHE_SIZE, conf.getIDCacheSize());
+ assertEquals(ConfigurationImpl.DEFAULT_PERSIST_ID_CACHE, conf.isPersistIDCache());
+
}
-
+
public void testSetGetAttributes()
{
for (int j = 0; j < 100; j++)
- {
+ {
boolean b = randomBoolean();
conf.setClustered(b);
assertEquals(b, conf.isClustered());
-
+
b = randomBoolean();
conf.setBackup(b);
assertEquals(b, conf.isBackup());
-
+
long l = randomLong();
conf.setQueueActivationTimeout(l);
assertEquals(l, conf.getQueueActivationTimeout());
-
+
int i = randomInt();
conf.setScheduledThreadPoolMaxSize(i);
assertEquals(i, conf.getScheduledThreadPoolMaxSize());
-
+
l = randomLong();
conf.setSecurityInvalidationInterval(l);
assertEquals(l, conf.getSecurityInvalidationInterval());
-
+
b = randomBoolean();
conf.setSecurityEnabled(b);
assertEquals(b, conf.isSecurityEnabled());
-
+
String s = randomString();
conf.setBindingsDirectory(s);
assertEquals(s, conf.getBindingsDirectory());
-
+
b = randomBoolean();
conf.setCreateBindingsDir(b);
assertEquals(b, conf.isCreateBindingsDir());
-
+
s = randomString();
conf.setJournalDirectory(s);
assertEquals(s, conf.getJournalDirectory());
-
+
b = randomBoolean();
conf.setCreateJournalDir(b);
assertEquals(b, conf.isCreateJournalDir());
-
+
i = randomInt() % 2;
JournalType journal = i == 0 ? JournalType.ASYNCIO : JournalType.NIO;
conf.setJournalType(journal);
assertEquals(journal, conf.getJournalType());
-
+
b = randomBoolean();
conf.setJournalSyncTransactional(b);
assertEquals(b, conf.isJournalSyncTransactional());
-
+
b = randomBoolean();
conf.setJournalSyncNonTransactional(b);
assertEquals(b, conf.isJournalSyncNonTransactional());
-
+
i = randomInt();
conf.setJournalFileSize(i);
assertEquals(i, conf.getJournalFileSize());
-
+
i = randomInt();
conf.setJournalMinFiles(i);
assertEquals(i, conf.getJournalMinFiles());
-
+
i = randomInt();
conf.setJournalMaxAIO(i);
- assertEquals(i, conf.getJournalMaxAIO());
-
+ assertEquals(i, conf.getJournalMaxAIO());
+
s = randomString();
conf.setManagementAddress(new SimpleString(s));
assertEquals(s, conf.getManagementAddress().toString());
i = randomInt();
-
conf.setMessageExpiryThreadPriority(i);
assertEquals(i, conf.getMessageExpiryThreadPriority());
l = randomLong();
conf.setMessageExpiryScanPeriod(l);
assertEquals(l, conf.getMessageExpiryScanPeriod());
+
+ b = randomBoolean();
+ conf.setPersistDeliveryCountBeforeDelivery(b);
+ assertEquals(b, conf.isPersistDeliveryCountBeforeDelivery());
+
+ b = randomBoolean();
+ conf.setEnabledAsyncConnectionExecution(b);
+ assertEquals(b, conf.isAsyncConnectionExecutionEnabled());
+
+ b = randomBoolean();
+ conf.setFileDeploymentEnabled(b);
+ assertEquals(b, conf.isFileDeploymentEnabled());
+
+ b = randomBoolean();
+ conf.setPersistenceEnabled(b);
+ assertEquals(b, conf.isPersistenceEnabled());
+
+ b = randomBoolean();
+ conf.setJMXManagementEnabled(b);
+ assertEquals(b, conf.isJMXManagementEnabled());
+
+ l = randomLong();
+ conf.setFileDeployerScanPeriod(l);
+ assertEquals(l, conf.getFileDeployerScanPeriod());
+
+ l = randomLong();
+ conf.setConnectionTTLOverride(l);
+ assertEquals(l, conf.getConnectionTTLOverride());
+
+ i = randomInt();
+ conf.setThreadPoolMaxSize(i);
+ assertEquals(i, conf.getThreadPoolMaxSize());
+
+ s = randomString();
+ conf.setBackupConnectorName(s);
+ assertEquals(s, conf.getBackupConnectorName());
+
+ SimpleString ss = randomSimpleString();
+ conf.setManagementNotificationAddress(ss);
+ assertEquals(ss, conf.getManagementNotificationAddress());
+
+ s = randomString();
+ conf.setManagementClusterUser(s);
+ assertEquals(s, conf.getManagementClusterUser());
+
+ l = randomLong();
+ conf.setManagementRequestTimeout(l);
+ assertEquals(l, conf.getManagementRequestTimeout());
+
+ i = randomInt();
+ conf.setIDCacheSize(i);
+ assertEquals(i, conf.getIDCacheSize());
+
+ b = randomBoolean();
+ conf.setPersistIDCache(b);
+ assertEquals(b, conf.isPersistIDCache());
+
+ i = randomInt();
+ conf.setJournalCompactMinFiles(i);
+ assertEquals(i, conf.getJournalCompactMinFiles());
+
+ i = randomInt();
+ conf.setJournalCompactPercentage(i);
+ assertEquals(i, conf.getJournalCompactPercentage());
+
+ i = randomInt();
+ conf.setAIOBufferSize(i);
+ assertEquals(i, conf.getAIOBufferSize());
+
+ i = randomInt();
+ conf.setAIOBufferTimeout(i);
+ assertEquals(i, conf.getAIOBufferTimeout());
+
+ b = randomBoolean();
+ conf.setAIOFlushOnSync(b);
+ assertEquals(b, conf.isAIOFlushOnSync());
+
+ b = randomBoolean();
+ conf.setLogJournalWriteRate(b);
+ assertEquals(b, conf.isLogJournalWriteRate());
+
+ i = randomInt();
+ conf.setJournalPerfBlastPages(i);
+ assertEquals(i, conf.getJournalPerfBlastPages());
+
+ l = randomLong();
+ conf.setServerDumpInterval(l);
+ assertEquals(l, conf.getServerDumpInterval());
+
+ s = randomString();
+ conf.setPagingDirectory(s);
+ assertEquals(s, conf.getPagingDirectory());
+
+ s = randomString();
+ conf.setLargeMessagesDirectory(s);
+ assertEquals(s, conf.getLargeMessagesDirectory());
+
+ b = randomBoolean();
+ conf.setWildcardRoutingEnabled(b);
+ assertEquals(b, conf.isWildcardRoutingEnabled());
+
+ l = randomLong();
+ conf.setTransactionTimeout(l);
+ assertEquals(l, conf.getTransactionTimeout());
+
+ b = randomBoolean();
+ conf.setMessageCounterEnabled(b);
+ assertEquals(b, conf.isMessageCounterEnabled());
+
+ i = randomInt();
+ conf.setMessageCounterMaxDayHistory(i);
+ assertEquals(i, conf.getMessageCounterMaxDayHistory());
+
+ l = randomLong();
+ conf.setTransactionTimeoutScanPeriod(l);
+ assertEquals(l, conf.getTransactionTimeoutScanPeriod());
+
+ s = randomString();
+ conf.setManagementClusterPassword(s);
+ assertEquals(s, conf.getManagementClusterPassword());
}
}
-
+
public void testGetSetInterceptors()
{
final String name1 = "uqwyuqywuy";
final String name2 = "yugyugyguyg";
-
+
conf.getInterceptorClassNames().add(name1);
conf.getInterceptorClassNames().add(name2);
-
+
assertTrue(conf.getInterceptorClassNames().contains(name1));
assertTrue(conf.getInterceptorClassNames().contains(name2));
assertFalse(conf.getInterceptorClassNames().contains("iijij"));
}
-
+
public void testSerialize() throws Exception
{
boolean b = randomBoolean();
conf.setClustered(b);
-
+ assertEquals(b, conf.isClustered());
+
b = randomBoolean();
conf.setBackup(b);
-
+ assertEquals(b, conf.isBackup());
+
long l = randomLong();
conf.setQueueActivationTimeout(l);
-
-
+ assertEquals(l, conf.getQueueActivationTimeout());
+
int i = randomInt();
conf.setScheduledThreadPoolMaxSize(i);
-
+ assertEquals(i, conf.getScheduledThreadPoolMaxSize());
+
l = randomLong();
conf.setSecurityInvalidationInterval(l);
+ assertEquals(l, conf.getSecurityInvalidationInterval());
b = randomBoolean();
conf.setSecurityEnabled(b);
-
+ assertEquals(b, conf.isSecurityEnabled());
+
String s = randomString();
conf.setBindingsDirectory(s);
+ assertEquals(s, conf.getBindingsDirectory());
b = randomBoolean();
conf.setCreateBindingsDir(b);
+ assertEquals(b, conf.isCreateBindingsDir());
s = randomString();
conf.setJournalDirectory(s);
-
+ assertEquals(s, conf.getJournalDirectory());
+
b = randomBoolean();
conf.setCreateJournalDir(b);
-
+ assertEquals(b, conf.isCreateJournalDir());
+
i = randomInt() % 2;
JournalType journal = i == 0 ? JournalType.ASYNCIO : JournalType.NIO;
conf.setJournalType(journal);
-
+ assertEquals(journal, conf.getJournalType());
+
b = randomBoolean();
conf.setJournalSyncTransactional(b);
-
+ assertEquals(b, conf.isJournalSyncTransactional());
+
b = randomBoolean();
conf.setJournalSyncNonTransactional(b);
+ assertEquals(b, conf.isJournalSyncNonTransactional());
i = randomInt();
conf.setJournalFileSize(i);
-
+ assertEquals(i, conf.getJournalFileSize());
+
i = randomInt();
conf.setJournalMinFiles(i);
-
+ assertEquals(i, conf.getJournalMinFiles());
+
i = randomInt();
conf.setJournalMaxAIO(i);
+ assertEquals(i, conf.getJournalMaxAIO());
+
+ s = randomString();
+ conf.setManagementAddress(new SimpleString(s));
+ assertEquals(s, conf.getManagementAddress().toString());
+
+ i = randomInt();
+ conf.setMessageExpiryThreadPriority(i);
+ assertEquals(i, conf.getMessageExpiryThreadPriority());
+
+ l = randomLong();
+ conf.setMessageExpiryScanPeriod(l);
+ assertEquals(l, conf.getMessageExpiryScanPeriod());
+
+ b = randomBoolean();
+ conf.setPersistDeliveryCountBeforeDelivery(b);
+ assertEquals(b, conf.isPersistDeliveryCountBeforeDelivery());
+
+ b = randomBoolean();
+ conf.setEnabledAsyncConnectionExecution(b);
+ assertEquals(b, conf.isAsyncConnectionExecutionEnabled());
+
+ b = randomBoolean();
+ conf.setFileDeploymentEnabled(b);
+ assertEquals(b, conf.isFileDeploymentEnabled());
+
+ b = randomBoolean();
+ conf.setPersistenceEnabled(b);
+ assertEquals(b, conf.isPersistenceEnabled());
+
+ b = randomBoolean();
+ conf.setJMXManagementEnabled(b);
+ assertEquals(b, conf.isJMXManagementEnabled());
+
+ l = randomLong();
+ conf.setFileDeployerScanPeriod(l);
+ assertEquals(l, conf.getFileDeployerScanPeriod());
+
+ l = randomLong();
+ conf.setConnectionTTLOverride(l);
+ assertEquals(l, conf.getConnectionTTLOverride());
+
+ i = randomInt();
+ conf.setThreadPoolMaxSize(i);
+ assertEquals(i, conf.getThreadPoolMaxSize());
+
+ s = randomString();
+ conf.setBackupConnectorName(s);
+ assertEquals(s, conf.getBackupConnectorName());
+
+ SimpleString ss = randomSimpleString();
+ conf.setManagementNotificationAddress(ss);
+ assertEquals(ss, conf.getManagementNotificationAddress());
+
+ s = randomString();
+ conf.setManagementClusterUser(s);
+ assertEquals(s, conf.getManagementClusterUser());
+
+ l = randomLong();
+ conf.setManagementRequestTimeout(l);
+ assertEquals(l, conf.getManagementRequestTimeout());
+
+ i = randomInt();
+ conf.setIDCacheSize(i);
+ assertEquals(i, conf.getIDCacheSize());
+
+ b = randomBoolean();
+ conf.setPersistIDCache(b);
+ assertEquals(b, conf.isPersistIDCache());
+
+ i = randomInt();
+ conf.setJournalCompactMinFiles(i);
+ assertEquals(i, conf.getJournalCompactMinFiles());
+
+ i = randomInt();
+ conf.setJournalCompactPercentage(i);
+ assertEquals(i, conf.getJournalCompactPercentage());
+
+ i = randomInt();
+ conf.setAIOBufferSize(i);
+ assertEquals(i, conf.getAIOBufferSize());
+
+ i = randomInt();
+ conf.setAIOBufferTimeout(i);
+ assertEquals(i, conf.getAIOBufferTimeout());
+
+ b = randomBoolean();
+ conf.setAIOFlushOnSync(b);
+ assertEquals(b, conf.isAIOFlushOnSync());
+
+ b = randomBoolean();
+ conf.setLogJournalWriteRate(b);
+ assertEquals(b, conf.isLogJournalWriteRate());
+
+ i = randomInt();
+ conf.setJournalPerfBlastPages(i);
+ assertEquals(i, conf.getJournalPerfBlastPages());
+
+ l = randomLong();
+ conf.setServerDumpInterval(l);
+ assertEquals(l, conf.getServerDumpInterval());
+
+ s = randomString();
+ conf.setPagingDirectory(s);
+ assertEquals(s, conf.getPagingDirectory());
+
+ s = randomString();
+ conf.setLargeMessagesDirectory(s);
+ assertEquals(s, conf.getLargeMessagesDirectory());
+
+ b = randomBoolean();
+ conf.setWildcardRoutingEnabled(b);
+ assertEquals(b, conf.isWildcardRoutingEnabled());
+
+ l = randomLong();
+ conf.setTransactionTimeout(l);
+ assertEquals(l, conf.getTransactionTimeout());
+
+ b = randomBoolean();
+ conf.setMessageCounterEnabled(b);
+ assertEquals(b, conf.isMessageCounterEnabled());
+
+ i = randomInt();
+ conf.setMessageCounterMaxDayHistory(i);
+ assertEquals(i, conf.getMessageCounterMaxDayHistory());
+
+ l = randomLong();
+ conf.setTransactionTimeoutScanPeriod(l);
+ assertEquals(l, conf.getTransactionTimeoutScanPeriod());
s = randomString();
- conf.setManagementAddress(new SimpleString(s));
-
+ conf.setManagementClusterPassword(s);
+ assertEquals(s, conf.getManagementClusterPassword());
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(conf);
oos.flush();
-
+
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
Configuration conf2 = (Configuration)ois.readObject();
-
- assertTrue(conf.equals(conf2));
+
+ assertTrue(conf.equals(conf2));
}
-
+
// Protected ----------------------------------------------------------------------------------------
-
+
protected void setUp() throws Exception
{
super.setUp();
-
+
conf = createConfiguration();
}
-
+
protected Configuration createConfiguration() throws Exception
{
return new ConfigurationImpl();
}
-
+
// Private --------------------------------------------------------------------------------------------
-
+
}
15 years, 3 months
JBoss hornetq SVN: r7951 - in trunk: docs/user-manual/en and 13 other directories.
by do-not-reply@jboss.org
Author: ataylor
Date: 2009-09-10 07:19:52 -0400 (Thu, 10 Sep 2009)
New Revision: 7951
Added:
trunk/src/main/org/hornetq/integration/jboss/
trunk/src/main/org/hornetq/integration/jboss/security/
trunk/src/main/org/hornetq/integration/jboss/tm/
trunk/src/main/org/hornetq/integration/jboss/tm/JBoss4TransactionManagerLocator.java
trunk/src/main/org/hornetq/integration/jboss/tm/JBoss5TransactionManagerLocator.java
Removed:
trunk/src/main/org/hornetq/integration/security/
trunk/src/main/org/hornetq/ra/inflow/JBoss4TransactionManagerLocator.java
trunk/src/main/org/hornetq/ra/inflow/JBoss5TransactionManagerLocator.java
Modified:
trunk/build-hornetq.xml
trunk/build-maven.xml
trunk/docs/user-manual/en/security.xml
trunk/examples/javaee/jms-bridge/server/jms-bridge-jboss-beans.xml
trunk/examples/jms/jaas/readme.html
trunk/src/config/jboss-as/clustered/hornetq-jboss-beans.xml
trunk/src/config/jboss-as/non-clustered/hornetq-jboss-beans.xml
trunk/src/main/org/hornetq/integration/jboss/security/JBossASSecurityManager.java
trunk/src/main/org/hornetq/integration/jboss/security/SecurityActions.java
trunk/src/main/org/hornetq/jms/bridge/BridgeService.java
trunk/src/main/org/hornetq/jms/bridge/JMSBridge.java
trunk/src/main/org/hornetq/jms/bridge/impl/JMSBridgeImpl.java
trunk/src/main/org/hornetq/ra/HornetQRAProperties.java
trunk/tests/src/org/hornetq/tests/integration/jms/bridge/JMSBridgeTest.java
Log:
https://jira.jboss.org/jira/browse/HORNETQ-119 - also fixed same issue with the JMS bridge and some maven tweaks
Modified: trunk/build-hornetq.xml
===================================================================
--- trunk/build-hornetq.xml 2009-09-10 09:34:46 UTC (rev 7950)
+++ trunk/build-hornetq.xml 2009-09-10 11:19:52 UTC (rev 7951)
@@ -49,7 +49,7 @@
<property name="jms.client.jar.name" value="hornetq-jms-client.jar"/>
<property name="jnp.client.jar.name" value="jnp-client.jar"/>
<property name="transports.jar.name" value="hornetq-transports.jar"/>
- <property name="security.jar.name" value="hornetq-jboss-as-security.jar"/>
+ <property name="jboss.integration.jar.name" value="hornetq-jboss-as-integration.jar"/>
<property name="bootstrap.jar.name" value="hornetq-bootstrap.jar"/>
<property name="logging.jar.name" value="hornetq-logging.jar"/>
<property name="core.client.jar.name" value="hornetq-core-client.jar"/>
@@ -65,7 +65,7 @@
<property name="build.core.classes.dir" value="${build.dir}/classes/core"/>
<property name="build.jms.classes.dir" value="${build.dir}/classes/jms"/>
<property name="build.transports.classes.dir" value="${build.dir}/classes/transports"/>
- <property name="build.security.classes.dir" value="${build.dir}/classes/security"/>
+ <property name="build.jboss.integration.classes.dir" value="${build.dir}/classes/jboss-integration"/>
<property name="build.bootstrap.classes.dir" value="${build.dir}/classes/bootstrap"/>
<property name="build.logging.classes.dir" value="${build.dir}/classes/logging"/>
<property name="build.ra.classes.dir" value="${build.dir}/classes/ra"/>
@@ -171,9 +171,11 @@
<path refid="org.jboss.netty.classpath"/>
</path>
- <path id="security.compilation.classpath">
+ <path id="jboss.integration.compilation.classpath">
<path location="${build.core.classes.dir}"/>
<path refid="org.jboss.security.classpath"/>
+ <path refid="org.jboss.integration.classpath"/>
+ <path refid="org.jboss.javaee.classpath"/>
</path>
<path id="bootstrap.compilation.classpath">
@@ -195,20 +197,20 @@
<path id="test.compilation.classpath">
<path refid="jms.compilation.classpath"/>
<path refid="transports.compilation.classpath"/>
- <path refid="security.compilation.classpath"/>
+ <path refid="jboss.integration.compilation.classpath"/>
<path refid="bootstrap.compilation.classpath"/>
<path refid="junit.junit.classpath"/>
<path location="${build.jars.dir}/${ra.jar.name}"/>
<path location="${build.jars.dir}/${jms.jar.name}"/>
<path location="${build.jars.dir}/${transports.jar.name}"/>
- <path location="${build.jars.dir}/${security.jar.name}"/>
+ <path location="${build.jars.dir}/${jboss.integration.jar.name}"/>
<path location="${build.jars.dir}/${bootstrap.jar.name}"/>
<path location="${build.jars.dir}/${logging.jar.name}"/>
</path>
<path id="jms.test.compilation.classpath">
<path refid="transports.compilation.classpath"/>
- <path refid="security.compilation.classpath"/>
+ <path refid="jboss.integration.compilation.classpath"/>
<path refid="bootstrap.compilation.classpath"/>
<path refid="jms.compilation.classpath"/>
<path refid="junit.junit.classpath"/>
@@ -216,7 +218,7 @@
<path location="${build.jars.dir}/${core.jar.name}"/>
<path location="${build.jars.dir}/${jms.jar.name}"/>
<path location="${build.jars.dir}/${transports.jar.name}"/>
- <path location="${build.jars.dir}/${security.jar.name}"/>
+ <path location="${build.jars.dir}/${jboss.integration.jar.name}"/>
<path location="${build.jars.dir}/${bootstrap.jar.name}"/>
<path location="${build.jars.dir}/${logging.jar.name}"/>
</path>
@@ -321,7 +323,7 @@
<mkdir dir="${build.core.classes.dir}"/>
<mkdir dir="${build.jms.classes.dir}"/>
<mkdir dir="${build.transports.classes.dir}"/>
- <mkdir dir="${build.security.classes.dir}"/>
+ <mkdir dir="${build.jboss.integration.classes.dir}"/>
<mkdir dir="${build.bootstrap.classes.dir}"/>
<mkdir dir="${build.logging.classes.dir}"/>
<mkdir dir="${build.ra.classes.dir}"/>
@@ -430,8 +432,8 @@
</javac>
</target>
- <target name="compile-security" depends="compile-core">
- <javac destdir="${build.security.classes.dir}"
+ <target name="compile-jboss-integration" depends="compile-core">
+ <javac destdir="${build.jboss.integration.classes.dir}"
target="${javac.target}"
source="${javac.source}"
optimize="${javac.optimize}"
@@ -445,8 +447,8 @@
<src>
<pathelement path="${src.main.dir}"/>
</src>
- <include name="org/hornetq/integration/security/**/*.java"/>
- <classpath refid="security.compilation.classpath"/>
+ <include name="org/hornetq/integration/jboss/**/*.java"/>
+ <classpath refid="jboss.integration.compilation.classpath"/>
</javac>
</target>
@@ -562,7 +564,7 @@
<!-- ======================================================================================== -->
<target name="jar"
- depends="jar-core, jar-core-client, jar-jms, jar-jms-client, jar-transports, jar-security, jar-bootstrap, jar-logging, jar-ra, jar-mc, jar-jnp-client">
+ depends="jar-core, jar-core-client, jar-jms, jar-jms-client, jar-transports, jar-jboss-integration, jar-bootstrap, jar-logging, jar-ra, jar-mc, jar-jnp-client">
</target>
<target name="jar-jnp-client" depends="init">
<jar jarfile="${build.jars.dir}/${jnp.client.jar.name}">
@@ -637,10 +639,10 @@
</target>
- <target name="jar-security" depends="compile-security">
+ <target name="jar-jboss-integration" depends="compile-jboss-integration">
- <jar jarfile="${build.jars.dir}/${security.jar.name}">
- <fileset dir="${build.security.classes.dir}" includes="**"/>
+ <jar jarfile="${build.jars.dir}/${jboss.integration.jar.name}">
+ <fileset dir="${build.jboss.integration.classes.dir}" includes="**"/>
</jar>
</target>
@@ -742,7 +744,7 @@
<include name="${core.jar.name}"/>
<include name="${jms.jar.name}"/>
<include name="${transports.jar.name}"/>
- <include name="${security.jar.name}"/>
+ <include name="${jboss.integration.jar.name}"/>
<include name="${bootstrap.jar.name}"/>
<include name="${logging.jar.name}"/>
<include name="${mc.jar.name}"/>
@@ -942,7 +944,7 @@
</antcall>
<antcall target="artifact">
- <param name="artifact.name" value="hornetq-jboss-as-security"/>
+ <param name="artifact.name" value="hornetq-jboss-as-integration"/>
</antcall>
<antcall target="artifact">
Modified: trunk/build-maven.xml
===================================================================
--- trunk/build-maven.xml 2009-09-10 09:34:46 UTC (rev 7950)
+++ trunk/build-maven.xml 2009-09-10 11:19:52 UTC (rev 7951)
@@ -68,7 +68,7 @@
<target name="uploadHornetQSecurity">
<antcall target="upload">
- <param name="artifact.id" value="hornetq-jboss-as-security"/>
+ <param name="artifact.id" value="hornetq-jboss-as-integration"/>
<param name="artifact.type" value="jar"/>
</antcall>
</target>
Modified: trunk/docs/user-manual/en/security.xml
===================================================================
--- trunk/docs/user-manual/en/security.xml 2009-09-10 09:34:46 UTC (rev 7950)
+++ trunk/docs/user-manual/en/security.xml 2009-09-10 11:19:52 UTC (rev 7951)
@@ -215,12 +215,12 @@
<para>To configure the JAAS security manager to work with your pre-built JAAS infrastructure
you need to specify the security manager as a <literal>JAASSecurityManager</literal> in
the beans file. Here's an example:</para>
- <programlisting>
-<bean name="HornetQSecurityManager"
- class="org.hornetq.integration.security.JAASSecurityManager">
+ <programlisting><![CDATA[
+<bean name="HornetQSecurityManager"
+ class="org.hornetq.integration.jboss.security.JAASSecurityManager">
<start ignored="true"/>
<stop ignored="true"/>
-
+
<property name="ConfigurationName">org.hornetq.jms.example.ExampleLoginModule</property>
<property name="Configuration">
<inject bean="ExampleConfiguration"/>
@@ -228,8 +228,8 @@
<property name="CallbackHandler">
<inject bean="ExampleCallbackHandler"/>
</property>
-</bean>
- </programlisting>
+</bean>
+ ]]></programlisting>
<para>Note that you need to feed the JAAS security manager with three properties:</para>
<itemizedlist>
<listitem>
@@ -257,7 +257,7 @@
Application server. This allows tight integration with the JBoss Application Server's
security model.</para>
<para>The class name of this security manager is <literal
- >org.hornetq.integration.security.JBossASSecurityManager</literal></para>
+ >org.hornetq.integration.jboss.security.JBossASSecurityManager</literal></para>
<para>Take a look at one of the default <literal>hornetq-jboss-beans.xml</literal> files for
JBoss Application Server that are bundled in the distribution for an example of how this
is configured.</para>
Modified: trunk/examples/javaee/jms-bridge/server/jms-bridge-jboss-beans.xml
===================================================================
--- trunk/examples/javaee/jms-bridge/server/jms-bridge-jboss-beans.xml 2009-09-10 09:34:46 UTC (rev 7950)
+++ trunk/examples/javaee/jms-bridge/server/jms-bridge-jboss-beans.xml 2009-09-10 11:19:52 UTC (rev 7951)
@@ -52,6 +52,8 @@
<property name="transactionManager">
<inject bean="RealTransactionManager"/>
</property>
+ <!--<property name="transactionManagerLocatorClass">org.hornetq.integration.jboss.tm.JBoss5TransactionManagerLocator</property>
+ <property name="transactionManagerLocatorMethod">getTm</property>-->
</bean>
<!-- SourceCFF describes the ConnectionFactory used to connect to the source destination -->
Modified: trunk/examples/jms/jaas/readme.html
===================================================================
--- trunk/examples/jms/jaas/readme.html 2009-09-10 09:34:46 UTC (rev 7950)
+++ trunk/examples/jms/jaas/readme.html 2009-09-10 11:19:52 UTC (rev 7951)
@@ -22,44 +22,45 @@
<p>HornetQ can use a JAAS security manager by specifying it in <a href="server0/hornetq-beans.xml">hornetq-beans.xml</a>:</p>
<pre>
<code>
- <!-- The security manager using JAAS -->
- <bean name="HornetQSecurityManager" class="org.hornetq.integration.security.JAASSecurityManager">
- <property name="configurationName">org.hornetq.jms.example.ExampleLoginModule</property>
- <property name="configuration">
- <inject bean="ExampleConfiguration"/>
- </property>
- <property name="callbackHandler">
- <inject bean="ExampleCallbackHandler" />
- </property>
- </bean>
+ &lt;!-- The security manager using JAAS --&gt;
+ &lt;bean name="HornetQSecurityManager" class="org.hornetq.integration.jboss.security.JAASSecurityManager"&gt;
+ &lt;property name="configurationName"&gt;org.hornetq.jms.example.ExampleLoginModule&lt;/property&gt;
+ &lt;property name="configuration"&gt;
+ &lt;inject bean="ExampleConfiguration"/&gt;
+ &lt;/property&gt;
+ &lt;property name="callbackHandler"&gt;
+ &lt;inject bean="ExampleCallbackHandler" /&gt;
+ &lt;/property&gt;
+ &lt;/bean&gt;
- <!-- JAAS uses a simple LoginModule where the user credentials and roles are
- specified as options in the constructor -->
- <bean name="ExampleConfiguration" class="org.hornetq.jms.example.ExampleConfiguration">
- <constructor>
- <parameter>org.hornetq.jms.example.ExampleLoginModule</parameter>
- <parameter>
- <map class="java.util.HashMap" keyClass="java.lang.String"
- valueClass="java.lang.String">
- <entry>
- <key>user</key>
- <value>jboss</value>
- </entry>
- <entry>
- <key>pass</key>
- <value>redhat</value>
- </entry>
- <entry>
- <key>role</key>
- <value>guest</value>
- </entry>
- </map>
- </parameter>
- </constructor>
- </bean>
+ &lt;!-- JAAS uses a simple LoginModule where the user credentials and roles are
+ specified as options in the constructor --&gt;
+ &lt;bean name="ExampleConfiguration" class="org.hornetq.jms.example.ExampleConfiguration"&gt;
+ &lt;constructor&gt;
+ &lt;parameter&gt;org.hornetq.jms.example.ExampleLoginModule&lt;/parameter&gt;
+ &lt;parameter&gt;
+ &lt;map class="java.util.HashMap" keyClass="java.lang.String"
+ valueClass="java.lang.String"&gt;
+ &lt;entry&gt;
+ &lt;key&gt;user&lt;/key&gt;
+ &lt;value&gt;jboss&lt;/value&gt;
+ &lt;/entry&gt;
+ &lt;entry&gt;
+ &lt;key&gt;pass&lt;/key&gt;
+ &lt;value&gt;redhat&lt;/value&gt;
+ &lt;/entry&gt;
+ &lt;entry&gt;
+ &lt;key&gt;role&lt;/key&gt;
+ &lt;value&gt;guest&lt;/value&gt;
+ &lt;/entry&gt;
+ &lt;/map&gt;
+ &lt;/parameter&gt;
+ &lt;/constructor&gt;
+ &lt;/bean&gt;
- <!-- the CallbackHandler does nothing as we don't have any user interaction -->
- <bean name="ExampleCallbackHandler" class="org.hornetq.jms.example.ExampleCallbackHandler" />
+ &lt;!-- the CallbackHandler does nothing as we don't have any user interaction --&gt;
+ &lt;bean name="ExampleCallbackHandler" class="org.hornetq.jms.example.ExampleCallbackHandler"
+ /&gt;
</code>
</pre>
Modified: trunk/src/config/jboss-as/clustered/hornetq-jboss-beans.xml
===================================================================
--- trunk/src/config/jboss-as/clustered/hornetq-jboss-beans.xml 2009-09-10 09:34:46 UTC (rev 7950)
+++ trunk/src/config/jboss-as/clustered/hornetq-jboss-beans.xml 2009-09-10 11:19:52 UTC (rev 7951)
@@ -12,7 +12,7 @@
<bean name="Configuration" class="org.hornetq.core.config.impl.FileConfiguration"/>
<!-- The security manager -->
- <bean name="HornetQSecurityManager" class="org.hornetq.integration.security.JBossASSecurityManager">
+ <bean name="HornetQSecurityManager" class="org.hornetq.integration.jboss.security.JBossASSecurityManager">
<depends>JBossSecurityJNDIContextEstablishment</depends>
<start ignored="true"/>
<stop ignored="true"/>
Modified: trunk/src/config/jboss-as/non-clustered/hornetq-jboss-beans.xml
===================================================================
--- trunk/src/config/jboss-as/non-clustered/hornetq-jboss-beans.xml 2009-09-10 09:34:46 UTC (rev 7950)
+++ trunk/src/config/jboss-as/non-clustered/hornetq-jboss-beans.xml 2009-09-10 11:19:52 UTC (rev 7951)
@@ -12,7 +12,7 @@
<bean name="Configuration" class="org.hornetq.core.config.impl.FileConfiguration"/>
<!-- The security manager -->
- <bean name="HornetQSecurityManager" class="org.hornetq.integration.security.JBossASSecurityManager">
+ <bean name="HornetQSecurityManager" class="org.hornetq.integration.jboss.security.JBossASSecurityManager">
<depends>JBossSecurityJNDIContextEstablishment</depends>
<start ignored="true"/>
<stop ignored="true"/>
Copied: trunk/src/main/org/hornetq/integration/jboss/security (from rev 7939, trunk/src/main/org/hornetq/integration/security)
Modified: trunk/src/main/org/hornetq/integration/jboss/security/JBossASSecurityManager.java
===================================================================
--- trunk/src/main/org/hornetq/integration/security/JBossASSecurityManager.java 2009-09-04 17:41:16 UTC (rev 7939)
+++ trunk/src/main/org/hornetq/integration/jboss/security/JBossASSecurityManager.java 2009-09-10 11:19:52 UTC (rev 7951)
@@ -11,7 +11,7 @@
* permissions and limitations under the License.
*/
-package org.hornetq.integration.security;
+package org.hornetq.integration.jboss.security;
import java.security.Principal;
import java.util.HashSet;
Modified: trunk/src/main/org/hornetq/integration/jboss/security/SecurityActions.java
===================================================================
--- trunk/src/main/org/hornetq/integration/security/SecurityActions.java 2009-09-04 17:41:16 UTC (rev 7939)
+++ trunk/src/main/org/hornetq/integration/jboss/security/SecurityActions.java 2009-09-10 11:19:52 UTC (rev 7951)
@@ -11,7 +11,7 @@
* permissions and limitations under the License.
*/
-package org.hornetq.integration.security;
+package org.hornetq.integration.jboss.security;
import java.security.AccessController;
import java.security.Principal;
Copied: trunk/src/main/org/hornetq/integration/jboss/tm/JBoss4TransactionManagerLocator.java (from rev 7939, trunk/src/main/org/hornetq/ra/inflow/JBoss4TransactionManagerLocator.java)
===================================================================
--- trunk/src/main/org/hornetq/integration/jboss/tm/JBoss4TransactionManagerLocator.java (rev 0)
+++ trunk/src/main/org/hornetq/integration/jboss/tm/JBoss4TransactionManagerLocator.java 2009-09-10 11:19:52 UTC (rev 7951)
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.hornetq.integration.jboss.tm;
+
+import org.jboss.tm.TransactionManagerLocator;
+
+import javax.transaction.TransactionManager;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
+ */
+public class JBoss4TransactionManagerLocator
+{
+ public TransactionManager getTm()
+ {
+ return TransactionManagerLocator.getInstance().locate();
+ }
+}
Copied: trunk/src/main/org/hornetq/integration/jboss/tm/JBoss5TransactionManagerLocator.java (from rev 7939, trunk/src/main/org/hornetq/ra/inflow/JBoss5TransactionManagerLocator.java)
===================================================================
--- trunk/src/main/org/hornetq/integration/jboss/tm/JBoss5TransactionManagerLocator.java (rev 0)
+++ trunk/src/main/org/hornetq/integration/jboss/tm/JBoss5TransactionManagerLocator.java 2009-09-10 11:19:52 UTC (rev 7951)
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.hornetq.integration.jboss.tm;
+
+import org.jboss.tm.TransactionManagerLocator;
+
+import javax.transaction.TransactionManager;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
+ */
+public class JBoss5TransactionManagerLocator
+{
+ public TransactionManager getTm()
+ {
+ return TransactionManagerLocator.locateTransactionManager();
+ }
+}
Modified: trunk/src/main/org/hornetq/jms/bridge/BridgeService.java
===================================================================
--- trunk/src/main/org/hornetq/jms/bridge/BridgeService.java 2009-09-10 09:34:46 UTC (rev 7950)
+++ trunk/src/main/org/hornetq/jms/bridge/BridgeService.java 2009-09-10 11:19:52 UTC (rev 7951)
@@ -239,7 +239,28 @@
{
bridge.setAddMessageIDInHeader(value);
}
-
+
+
+ public String getTransactionManagerLocatorClass()
+ {
+ return bridge.getTransactionManagerLocatorClass();
+ }
+
+ public void setTransactionManagerLocatorClass(String transactionManagerLocatorClass)
+ {
+ bridge.setTransactionManagerLocatorClass(transactionManagerLocatorClass);
+ }
+
+ public String getTransactionManagerLocatorMethod()
+ {
+ return bridge.getTransactionManagerLocatorMethod();
+ }
+
+ public void setTransactionManagerLocatorMethod(String transactionManagerLocatorMethod)
+ {
+ bridge.setTransactionManagerLocatorMethod(transactionManagerLocatorMethod);
+ }
+
public boolean isFailed()
{
return bridge.isFailed();
Modified: trunk/src/main/org/hornetq/jms/bridge/JMSBridge.java
===================================================================
--- trunk/src/main/org/hornetq/jms/bridge/JMSBridge.java 2009-09-10 09:34:46 UTC (rev 7950)
+++ trunk/src/main/org/hornetq/jms/bridge/JMSBridge.java 2009-09-10 11:19:52 UTC (rev 7951)
@@ -87,6 +87,14 @@
void setClientID(String clientID);
+ String getTransactionManagerLocatorClass();
+
+ void setTransactionManagerLocatorClass(String transactionManagerLocatorClass);
+
+ String getTransactionManagerLocatorMethod();
+
+ void setTransactionManagerLocatorMethod(String transactionManagerLocatorMethod);
+
boolean isAddMessageIDInHeader();
void setAddMessageIDInHeader(boolean value);
Modified: trunk/src/main/org/hornetq/jms/bridge/impl/JMSBridgeImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/bridge/impl/JMSBridgeImpl.java 2009-09-10 09:34:46 UTC (rev 7950)
+++ trunk/src/main/org/hornetq/jms/bridge/impl/JMSBridgeImpl.java 2009-09-10 11:19:52 UTC (rev 7951)
@@ -18,6 +18,8 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
@@ -144,6 +146,10 @@
private boolean failed;
private int forwardMode;
+
+ private String transactionManagerLocatorClass = "org.hornetq.integration.jboss.tm.JBoss5TransactionManagerLocator";
+
+ private String transactionManagerLocatorMethod = "getTm";
private static final int FORWARD_MODE_XA = 0;
@@ -561,7 +567,28 @@
this.clientID = clientID;
}
-
+
+ public String getTransactionManagerLocatorClass()
+ {
+ return transactionManagerLocatorClass;
+ }
+
+ public void setTransactionManagerLocatorClass(String transactionManagerLocatorClass)
+ {
+ checkBridgeNotStarted();
+ this.transactionManagerLocatorClass = transactionManagerLocatorClass;
+ }
+
+ public String getTransactionManagerLocatorMethod()
+ {
+ return transactionManagerLocatorMethod;
+ }
+
+ public void setTransactionManagerLocatorMethod(String transactionManagerLocatorMethod)
+ {
+ this.transactionManagerLocatorMethod = transactionManagerLocatorMethod;
+ }
+
public boolean isAddMessageIDInHeader()
{
return this.addMessageIDInHeader;
@@ -744,8 +771,20 @@
{
if (tm == null)
{
- tm = TransactionManagerLocator.getInstance().locate();
-
+ try
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ Class aClass = loader.loadClass(transactionManagerLocatorClass);
+ Object o = aClass.newInstance();
+ Method m = aClass.getMethod(transactionManagerLocatorMethod);
+ tm = (TransactionManager) m.invoke(o);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalStateException("unable to create TransactionManager from " + transactionManagerLocatorClass
+ + "." + transactionManagerLocatorMethod, e);
+ }
+
if (tm == null)
{
throw new IllegalStateException("Cannot locate a transaction manager");
Modified: trunk/src/main/org/hornetq/ra/HornetQRAProperties.java
===================================================================
--- trunk/src/main/org/hornetq/ra/HornetQRAProperties.java 2009-09-10 09:34:46 UTC (rev 7950)
+++ trunk/src/main/org/hornetq/ra/HornetQRAProperties.java 2009-09-10 11:19:52 UTC (rev 7951)
@@ -47,7 +47,7 @@
/** Use Local TX instead of XA */
private Boolean localTx = false;
- private String transactionManagerLocatorClass = "org.hornetq.ra.inflow.JBoss5TransactionManagerLocator";
+ private String transactionManagerLocatorClass = "org.hornetq.integration.jboss.tm.JBoss5TransactionManagerLocator";
private String transactionManagerLocatorMethod = "getTm";
Deleted: trunk/src/main/org/hornetq/ra/inflow/JBoss4TransactionManagerLocator.java
===================================================================
--- trunk/src/main/org/hornetq/ra/inflow/JBoss4TransactionManagerLocator.java 2009-09-10 09:34:46 UTC (rev 7950)
+++ trunk/src/main/org/hornetq/ra/inflow/JBoss4TransactionManagerLocator.java 2009-09-10 11:19:52 UTC (rev 7951)
@@ -1,28 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.hornetq.ra.inflow;
-
-import org.jboss.tm.TransactionManagerLocator;
-
-import javax.transaction.TransactionManager;
-
-/**
- * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
- */
-public class JBoss4TransactionManagerLocator
-{
- public TransactionManager getTm()
- {
- return TransactionManagerLocator.getInstance().locate();
- }
-}
Deleted: trunk/src/main/org/hornetq/ra/inflow/JBoss5TransactionManagerLocator.java
===================================================================
--- trunk/src/main/org/hornetq/ra/inflow/JBoss5TransactionManagerLocator.java 2009-09-10 09:34:46 UTC (rev 7950)
+++ trunk/src/main/org/hornetq/ra/inflow/JBoss5TransactionManagerLocator.java 2009-09-10 11:19:52 UTC (rev 7951)
@@ -1,28 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.hornetq.ra.inflow;
-
-import org.jboss.tm.TransactionManagerLocator;
-
-import javax.transaction.TransactionManager;
-
-/**
- * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
- */
-public class JBoss5TransactionManagerLocator
-{
- public TransactionManager getTm()
- {
- return TransactionManagerLocator.locateTransactionManager();
- }
-}
Modified: trunk/tests/src/org/hornetq/tests/integration/jms/bridge/JMSBridgeTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/bridge/JMSBridgeTest.java 2009-09-10 09:34:46 UTC (rev 7950)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/bridge/JMSBridgeTest.java 2009-09-10 11:19:52 UTC (rev 7951)
@@ -1575,8 +1575,35 @@
}
}
}
-
-
+
+ public void testSetTMClass() throws Exception
+ {
+ JMSBridgeImpl bridge = null;
+
+ try
+ {
+ bridge = new JMSBridgeImpl(cff0, cff0, sourceQueueFactory, localTargetQueueFactory,
+ null, null, null, null,
+ null, 3000, 10, QualityOfServiceMode.AT_MOST_ONCE,
+ 10000, 3000,
+ null, null, false);
+ bridge.setTransactionManagerLocatorClass(this.getClass().getName());
+ bridge.setTransactionManagerLocatorMethod("getNewTm");
+ bridge.start();
+ }
+ finally
+ {
+ if (bridge != null)
+ {
+ bridge.stop();
+ }
+ }
+ }
+
+ public TransactionManager getNewTm()
+ {
+ return newTransactionManager();
+ }
// Inner classes -------------------------------------------------------------------
private static class StressSender implements Runnable
15 years, 3 months
JBoss hornetq SVN: r7950 - trunk/tests/src/org/hornetq/tests/unit/core/version/impl.
by do-not-reply@jboss.org
Author: ataylor
Date: 2009-09-10 05:34:46 -0400 (Thu, 10 Sep 2009)
New Revision: 7950
Modified:
trunk/tests/src/org/hornetq/tests/unit/core/version/impl/VersionImplTest.java
Log:
version fix
Modified: trunk/tests/src/org/hornetq/tests/unit/core/version/impl/VersionImplTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/core/version/impl/VersionImplTest.java 2009-09-10 09:11:37 UTC (rev 7949)
+++ trunk/tests/src/org/hornetq/tests/unit/core/version/impl/VersionImplTest.java 2009-09-10 09:34:46 UTC (rev 7950)
@@ -48,6 +48,7 @@
int microVersion = 1;
int incrementingVersion = 10;
String versionSuffix = "suffix";
+ String nettyVersion = "netty";
VersionImpl version = new VersionImpl(versionName, majorVersion, minorVersion, microVersion, incrementingVersion, versionSuffix, nettyVersion);
assertEquals(versionName, version.getVersionName());
@@ -60,6 +61,7 @@
public void testEquals() throws Exception
{
+ String nettyVersion = "netty";
VersionImpl version = new VersionImpl("HORNETQ", 2, 0, 1, 10, "suffix", nettyVersion);
VersionImpl sameVersion = new VersionImpl("HORNETQ", 2, 0, 1, 10, "suffix", nettyVersion);
VersionImpl differentVersion = new VersionImpl("HORNETQ", 2, 0, 1, 11, "suffix", nettyVersion);
@@ -73,6 +75,7 @@
public void testSerialize() throws Exception
{
+ String nettyVersion = "netty";
VersionImpl version = new VersionImpl("uyiuy", 3, 7, 6, 12, "uhuhuh", nettyVersion);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
15 years, 3 months
JBoss hornetq SVN: r7949 - in trunk: examples/javaee and 6 other directories.
by do-not-reply@jboss.org
Author: ataylor
Date: 2009-09-10 05:11:37 -0400 (Thu, 10 Sep 2009)
New Revision: 7949
Modified:
trunk/build-hornetq.xml
trunk/build-thirdparty.xml
trunk/examples/javaee/hornetq-javaee-examples.iml
trunk/hornetq.iml
trunk/hornetq.ipr
trunk/pom.xml
trunk/src/config/common/hornetq-version.properties
trunk/src/main/org/hornetq/core/version/Version.java
trunk/src/main/org/hornetq/core/version/impl/VersionImpl.java
trunk/src/main/org/hornetq/integration/transports/netty/NettyAcceptor.java
trunk/src/main/org/hornetq/integration/transports/netty/NettyConnector.java
trunk/src/main/org/hornetq/utils/VersionLoader.java
trunk/tests/src/org/hornetq/tests/unit/core/version/impl/VersionImplTest.java
Log:
updated netty version and added netty version logging
Modified: trunk/build-hornetq.xml
===================================================================
--- trunk/build-hornetq.xml 2009-09-10 03:14:38 UTC (rev 7948)
+++ trunk/build-hornetq.xml 2009-09-10 09:11:37 UTC (rev 7949)
@@ -268,8 +268,6 @@
</path>
<path id="jms.test.execution.classpath">
- <pathelement location="${test.dir}/config"/>
- <pathelement location="${src.config.dir}/common"/>
<pathelement location="${src.schema.dir}"/>
<pathelement location="${test.jms.dir}/config"/>
<pathelement location="${test.jms.classes.dir}"/>
@@ -282,6 +280,8 @@
<path refid="apache.xerces.classpath"/>
<path refid="apache.logging.classpath"/>
<path refid="log4j.log4j.classpath"/>
+ <pathelement location="${test.dir}/config"/>
+ <pathelement location="${src.config.dir}/common"/>
</path>
<path id="joram.test.execution.classpath">
@@ -378,8 +378,15 @@
<javah class="org.hornetq.core.asyncio.impl.AsynchronousFileImpl"
classpath="${build.core.classes.dir}" destdir="./native/src"/>
+ <java classname="org.jboss.netty.util.Version" classpathref="org.jboss.netty.classpath"
+ outputproperty="netty.version" fork="true"/>
+ <echo>setting netty version ${netty.version}</echo>
<copy file="${src.config.dir}/common/hornetq-version.properties"
- tofile="${build.core.classes.dir}/hornetq-version.properties"/>
+ tofile="${build.core.classes.dir}/hornetq-version.properties" overwrite="true">
+ <filterset>
+ <filter token="NETTY.VERSION" value="${netty.version}"/>
+ </filterset>
+ </copy>
</target>
Modified: trunk/build-thirdparty.xml
===================================================================
--- trunk/build-thirdparty.xml 2009-09-10 03:14:38 UTC (rev 7948)
+++ trunk/build-thirdparty.xml 2009-09-10 09:11:37 UTC (rev 7949)
@@ -98,7 +98,7 @@
<maven basedir="${basedir}"
options="${maven.install.opts}"
- goal="install"
+ goal="initialize"
resultproperty="maven.install.result"/>
<fail message="Unable to build maven modules. See maven output for details.">
Modified: trunk/examples/javaee/hornetq-javaee-examples.iml
===================================================================
--- trunk/examples/javaee/hornetq-javaee-examples.iml 2009-09-10 03:14:38 UTC (rev 7948)
+++ trunk/examples/javaee/hornetq-javaee-examples.iml 2009-09-10 09:11:37 UTC (rev 7949)
@@ -1,90 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module relativePaths="true" type="JAVA_MODULE" version="4">
- <component name="FacetManager">
- <facet type="web" name="Web">
- <configuration>
- <descriptors>
- <deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/servlet-transport/config/WEB-INF/web.xml" optional="false" version="2.5" />
- </descriptors>
- <webroots>
- <root url="file://$MODULE_DIR$/servlet-transport/config/jms-servlet.war" relative="/" />
- </webroots>
- <sourceRoots>
- <root url="file://$MODULE_DIR$/ejb-jms-transaction/src" />
- <root url="file://$MODULE_DIR$/hajndi/src" />
- <root url="file://$MODULE_DIR$/jca-config/src" />
- <root url="file://$MODULE_DIR$/jms-bridge/src" />
- <root url="file://$MODULE_DIR$/mdb/src" />
- <root url="file://$MODULE_DIR$/servlet-transport/src" />
- <root url="file://$MODULE_DIR$/xarecovery/src" />
- </sourceRoots>
- <building>
- <setting name="EXPLODED_URL" value="file://" />
- <setting name="EXPLODED_ENABLED" value="false" />
- <setting name="JAR_URL" value="file://" />
- <setting name="JAR_ENABLED" value="false" />
- <setting name="EXCLUDE_EXPLODED_DIRECTORY" value="true" />
- </building>
- <packaging>
- <containerElement type="module" name="messaging-javaee-examples">
- <attribute name="method" value="1" />
- <attribute name="URI" value="/WEB-INF/classes" />
- </containerElement>
- </packaging>
- </configuration>
- </facet>
- <facet type="javaeeApplication" name="javaEEApplication">
- <configuration>
- <descriptors>
- <deploymentDescriptor name="application.xml" url="file://$MODULE_DIR$/servlet-transport/config/META-INF/application.xml" optional="false" version="5" />
- </descriptors>
- <building>
- <setting name="EXPLODED_URL" value="file://" />
- <setting name="EXPLODED_ENABLED" value="false" />
- <setting name="JAR_URL" value="file://" />
- <setting name="JAR_ENABLED" value="false" />
- <setting name="EXCLUDE_EXPLODED_DIRECTORY" value="true" />
- </building>
- </configuration>
- </facet>
- <facet type="javaeeApplication" name="javaEEApplication2">
- <configuration>
- <descriptors>
- <deploymentDescriptor name="application.xml" url="file://$MODULE_DIR$/servlet-ssl-example/config/META-INF/application.xml" optional="false" version="5" />
- </descriptors>
- <building>
- <setting name="EXPLODED_URL" value="file://" />
- <setting name="EXPLODED_ENABLED" value="false" />
- <setting name="JAR_URL" value="file://" />
- <setting name="JAR_ENABLED" value="false" />
- <setting name="EXCLUDE_EXPLODED_DIRECTORY" value="true" />
- </building>
- </configuration>
- </facet>
- <facet type="web" name="Web2">
- <configuration>
- <descriptors>
- <deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/servlet-ssl-example/config/WEB-INF/web.xml" optional="false" version="2.5" />
- </descriptors>
- <webroots>
- <root url="file://$MODULE_DIR$/servlet-ssl-example/config" relative="/" />
- </webroots>
- <building>
- <setting name="EXPLODED_URL" value="file://" />
- <setting name="EXPLODED_ENABLED" value="false" />
- <setting name="JAR_URL" value="file://" />
- <setting name="JAR_ENABLED" value="false" />
- <setting name="EXCLUDE_EXPLODED_DIRECTORY" value="true" />
- </building>
- <packaging>
- <containerElement type="module" name="messaging-javaee-examples">
- <attribute name="method" value="1" />
- <attribute name="URI" value="/WEB-INF/classes" />
- </containerElement>
- </packaging>
- </configuration>
- </facet>
- </component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/output/classes" />
<exclude-output />
Modified: trunk/hornetq.iml
===================================================================
--- trunk/hornetq.iml 2009-09-10 03:14:38 UTC (rev 7948)
+++ trunk/hornetq.iml 2009-09-10 09:11:37 UTC (rev 7949)
@@ -42,6 +42,7 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="messaging" level="project" />
<orderEntry type="library" name="messaging_jars" level="project" />
+ <orderEntry type="library" name="ant 1.7.1" level="project" />
</component>
<component name="VcsManagerConfiguration">
<option name="ACTIVE_VCS_NAME" value="svn" />
Modified: trunk/hornetq.ipr
===================================================================
--- trunk/hornetq.ipr 2009-09-10 03:14:38 UTC (rev 7948)
+++ trunk/hornetq.ipr 2009-09-10 09:11:37 UTC (rev 7949)
@@ -336,11 +336,21 @@
<facet-type id="javaeeApplication">
<modules>
<module name="messaging" />
+ <module name="hornetq-javaee-examples">
+ <files>
+ <file url="file://$PROJECT_DIR$/examples/javaee/servlet-transport/config/META-INF/application.xml" />
+ </files>
+ </module>
</modules>
</facet-type>
<facet-type id="web">
<modules>
<module name="messaging" />
+ <module name="hornetq-javaee-examples">
+ <files>
+ <file url="file://$PROJECT_DIR$/examples/javaee/servlet-transport/config/WEB-INF/web.xml" />
+ </files>
+ </module>
</modules>
</facet-type>
</autodetection-disabled>
@@ -725,6 +735,45 @@
<JAVADOC />
<SOURCES />
</library>
+ <library name="ant 1.7.1">
+ <CLASSES>
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-contrib/lib/commons-logging-1.0.4.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-commons-logging.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-contrib/ant-contrib-1.0b3.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-jai.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-apache-log4j.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-javamail.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-trax.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-antlr.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-jmf.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-apache-resolver.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-jdepend.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-nodeps.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-contrib.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-starteam.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-apache-bsf.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-stylebook.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-apache-oro.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-contrib/lib/commons-httpclient-3.0.1.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-jsch.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-commons-net.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/xml-apis.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-junit.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-contrib/lib/ivy-1.3.1.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-swing.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-launcher.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-testutil.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-contrib/lib/bcel-5.1.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-apache-regexp.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-weblogic.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/xercesImpl.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-apache-bcel.jar!/" />
+ <root url="jar:///home/andy/devtools/apache-ant-1.7.1/lib/ant-netrexx.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
</component>
</project>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-09-10 03:14:38 UTC (rev 7948)
+++ trunk/pom.xml 2009-09-10 09:11:37 UTC (rev 7949)
@@ -45,6 +45,7 @@
<executions>
<execution>
<id>build-thirdparty</id>
+ <phase>initialize</phase>
<goals>
<goal>build-thirdparty</goal>
</goals>
@@ -70,6 +71,92 @@
</mappedDependencies>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.3</version>
+ <executions>
+ <execution>
+ <id>clean</id>
+ <phase>pre-clean</phase>
+ <configuration>
+ <tasks name="distro"/>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>distro</id>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <property name="maven.build" value="true"/>
+ <ant target="distro"/>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.7.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant-launcher</artifactId>
+ <version>1.7.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant-nodeps</artifactId>
+ <version>1.7.1</version>
+ </dependency>
+ <dependency>
+ <groupId>ant-contrib</groupId>
+ <artifactId>ant-contrib</artifactId>
+ <version>1.0b3</version>
+ <exclusions>
+ <exclusion>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>sun.jdk</groupId>
+ <artifactId>tools</artifactId>
+ <version>1.5</version>
+ <scope>system</scope>
+ <systemPath>${java.home}/../lib/tools.jar</systemPath>
+ </dependency>
+ <dependency>
+ <groupId>net.java.dev.javacc</groupId>
+ <artifactId>javacc</artifactId>
+ <version>4.0</version>
+ </dependency>
+ <dependency>
+ <groupId>apache-xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.9.1</version>
+ </dependency>
+ <dependency>
+ <groupId>apache-xerces</groupId>
+ <artifactId>resolver</artifactId>
+ <version>2.9.1</version>
+ </dependency>
+ <dependency>
+ <groupId>apache-xerces</groupId>
+ <artifactId>xml-apis</artifactId>
+ <version>2.9.1</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+
</plugins>
</build>
@@ -135,7 +222,7 @@
<dependency>
<groupId>org.jboss.netty</groupId>
<artifactId>netty</artifactId>
- <version>3.1.0.GA</version>
+ <version>3.1.3.GA</version>
</dependency>
<!--needed to compile the logging jar-->
<dependency>
Modified: trunk/src/config/common/hornetq-version.properties
===================================================================
--- trunk/src/config/common/hornetq-version.properties 2009-09-10 03:14:38 UTC (rev 7948)
+++ trunk/src/config/common/hornetq-version.properties 2009-09-10 09:11:37 UTC (rev 7949)
@@ -5,3 +5,4 @@
hornetq.version.incrementingVersion=108
hornetq.version.versionSuffix=BETA5
hornetq.version.versionTag=beta5
+hornetq.netty.version=(a)NETTY.VERSION@
Modified: trunk/src/main/org/hornetq/core/version/Version.java
===================================================================
--- trunk/src/main/org/hornetq/core/version/Version.java 2009-09-10 03:14:38 UTC (rev 7948)
+++ trunk/src/main/org/hornetq/core/version/Version.java 2009-09-10 09:11:37 UTC (rev 7949)
@@ -35,4 +35,6 @@
String getVersionSuffix();
int getIncrementingVersion();
+
+ String getNettyVersion();
}
Modified: trunk/src/main/org/hornetq/core/version/impl/VersionImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/version/impl/VersionImpl.java 2009-09-10 03:14:38 UTC (rev 7948)
+++ trunk/src/main/org/hornetq/core/version/impl/VersionImpl.java 2009-09-10 09:11:37 UTC (rev 7949)
@@ -47,11 +47,13 @@
private String versionSuffix;
+ private String nettyVersion;
+
// Constructors --------------------------------------------------
public VersionImpl(final String versionName, final int majorVersion, final int minorVersion,
- final int microVersion, final int incrementingVersion, final String versionSuffix)
+ final int microVersion, final int incrementingVersion, final String versionSuffix, String nettyVersion)
{
this.versionName = versionName;
@@ -64,6 +66,8 @@
this.incrementingVersion = incrementingVersion;
this.versionSuffix = versionSuffix;
+
+ this.nettyVersion = nettyVersion;
}
// Version implementation ------------------------------------------
@@ -104,6 +108,11 @@
return incrementingVersion;
}
+ public String getNettyVersion()
+ {
+ return nettyVersion;
+ }
+
// Public -------------------------------------------------------
public boolean equals(Object other)
Modified: trunk/src/main/org/hornetq/integration/transports/netty/NettyAcceptor.java
===================================================================
--- trunk/src/main/org/hornetq/integration/transports/netty/NettyAcceptor.java 2009-09-10 03:14:38 UTC (rev 7948)
+++ trunk/src/main/org/hornetq/integration/transports/netty/NettyAcceptor.java 2009-09-10 09:11:37 UTC (rev 7949)
@@ -37,6 +37,7 @@
import org.hornetq.core.remoting.spi.Connection;
import org.hornetq.core.remoting.spi.ConnectionLifeCycleListener;
import org.hornetq.utils.ConfigurationHelper;
+import org.hornetq.utils.VersionLoader;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelFactory;
@@ -57,6 +58,7 @@
import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
import org.jboss.netty.handler.ssl.SslHandler;
+import org.jboss.netty.util.Version;
/**
* A Netty TCP Acceptor that supports SSL
@@ -295,6 +297,13 @@
startServerChannels();
paused = false;
+
+ if(!Version.ID.equals(VersionLoader.getVersion().getNettyVersion()))
+ {
+ log.warn("Unexpected Netty Version was expecting " + VersionLoader.getVersion().getNettyVersion() + " using " + Version.ID);
+ }
+
+ log.info("Started Netty Acceptor version " + Version.ID);
}
private void startServerChannels()
Modified: trunk/src/main/org/hornetq/integration/transports/netty/NettyConnector.java
===================================================================
--- trunk/src/main/org/hornetq/integration/transports/netty/NettyConnector.java 2009-09-10 03:14:38 UTC (rev 7948)
+++ trunk/src/main/org/hornetq/integration/transports/netty/NettyConnector.java 2009-09-10 09:11:37 UTC (rev 7949)
@@ -40,6 +40,7 @@
import org.hornetq.core.remoting.spi.Connector;
import org.hornetq.utils.ConfigurationHelper;
import org.hornetq.utils.Future;
+import org.hornetq.utils.VersionLoader;
import org.jboss.netty.bootstrap.ClientBootstrap;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.channel.Channel;
@@ -70,6 +71,7 @@
import org.jboss.netty.handler.codec.http.HttpResponseDecoder;
import org.jboss.netty.handler.codec.http.HttpVersion;
import org.jboss.netty.handler.ssl.SslHandler;
+import org.jboss.netty.util.Version;
/**
* A NettyConnector
@@ -310,6 +312,11 @@
return pipeline;
}
});
+ if(!Version.ID.equals(VersionLoader.getVersion().getNettyVersion()))
+ {
+ log.warn("Unexpected Netty Version was expecting " + VersionLoader.getVersion().getNettyVersion() + " using " + Version.ID);
+ }
+ log.debug("Started Netty Connector version " + Version.ID);
}
public synchronized void close()
Modified: trunk/src/main/org/hornetq/utils/VersionLoader.java
===================================================================
--- trunk/src/main/org/hornetq/utils/VersionLoader.java 2009-09-10 03:14:38 UTC (rev 7948)
+++ trunk/src/main/org/hornetq/utils/VersionLoader.java 2009-09-10 09:11:37 UTC (rev 7949)
@@ -80,12 +80,14 @@
int microVersion = Integer.valueOf(versionProps.getProperty("hornetq.version.microVersion"));
int incrementingVersion = Integer.valueOf(versionProps.getProperty("hornetq.version.incrementingVersion"));
String versionSuffix = versionProps.getProperty("hornetq.version.versionSuffix");
+ String nettyVersion=versionProps.getProperty("hornetq.netty.version");
return new VersionImpl(versionName,
majorVersion,
minorVersion,
microVersion,
incrementingVersion,
- versionSuffix);
+ versionSuffix,
+ nettyVersion);
}
catch (IOException e)
{
Modified: trunk/tests/src/org/hornetq/tests/unit/core/version/impl/VersionImplTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/core/version/impl/VersionImplTest.java 2009-09-10 03:14:38 UTC (rev 7948)
+++ trunk/tests/src/org/hornetq/tests/unit/core/version/impl/VersionImplTest.java 2009-09-10 09:11:37 UTC (rev 7949)
@@ -48,7 +48,7 @@
int microVersion = 1;
int incrementingVersion = 10;
String versionSuffix = "suffix";
- VersionImpl version = new VersionImpl(versionName, majorVersion, minorVersion, microVersion, incrementingVersion, versionSuffix);
+ VersionImpl version = new VersionImpl(versionName, majorVersion, minorVersion, microVersion, incrementingVersion, versionSuffix, nettyVersion);
assertEquals(versionName, version.getVersionName());
assertEquals(majorVersion, version.getMajorVersion());
@@ -60,9 +60,9 @@
public void testEquals() throws Exception
{
- VersionImpl version = new VersionImpl("HORNETQ", 2, 0, 1, 10, "suffix");
- VersionImpl sameVersion = new VersionImpl("HORNETQ", 2, 0, 1, 10, "suffix");
- VersionImpl differentVersion = new VersionImpl("HORNETQ", 2, 0, 1, 11, "suffix");
+ VersionImpl version = new VersionImpl("HORNETQ", 2, 0, 1, 10, "suffix", nettyVersion);
+ VersionImpl sameVersion = new VersionImpl("HORNETQ", 2, 0, 1, 10, "suffix", nettyVersion);
+ VersionImpl differentVersion = new VersionImpl("HORNETQ", 2, 0, 1, 11, "suffix", nettyVersion);
assertFalse(version.equals(new Object()));
@@ -73,7 +73,7 @@
public void testSerialize() throws Exception
{
- VersionImpl version = new VersionImpl("uyiuy", 3, 7, 6, 12, "uhuhuh");
+ VersionImpl version = new VersionImpl("uyiuy", 3, 7, 6, 12, "uhuhuh", nettyVersion);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(version);
15 years, 3 months
JBoss hornetq SVN: r7948 - in trunk: src/main/org/hornetq/core/journal and 6 other directories.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2009-09-09 23:14:38 -0400 (Wed, 09 Sep 2009)
New Revision: 7948
Added:
trunk/tests/src/org/hornetq/tests/integration/journal/MultiThreadCompactorTest.java
Modified:
trunk/src/main/org/hornetq/core/asyncio/impl/TimedBuffer.java
trunk/src/main/org/hornetq/core/journal/SequentialFile.java
trunk/src/main/org/hornetq/core/journal/impl/AIOSequentialFile.java
trunk/src/main/org/hornetq/core/journal/impl/AIOSequentialFileFactory.java
trunk/src/main/org/hornetq/core/journal/impl/JournalCompactor.java
trunk/src/main/org/hornetq/core/journal/impl/JournalImpl.java
trunk/src/main/org/hornetq/core/journal/impl/NIOSequentialFile.java
trunk/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageHeaderTestBase.java
trunk/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageTestBase.java
trunk/tests/src/org/hornetq/tests/integration/client/CompactingTest.java
trunk/tests/src/org/hornetq/tests/integration/jms/client/ResendTest.java
trunk/tests/src/org/hornetq/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java
Log:
HORNETQ-124 - Fixing races on compacting
Modified: trunk/src/main/org/hornetq/core/asyncio/impl/TimedBuffer.java
===================================================================
--- trunk/src/main/org/hornetq/core/asyncio/impl/TimedBuffer.java 2009-09-09 16:37:43 UTC (rev 7947)
+++ trunk/src/main/org/hornetq/core/asyncio/impl/TimedBuffer.java 2009-09-10 03:14:38 UTC (rev 7948)
@@ -179,12 +179,12 @@
this.bufferObserver = observer;
}
- public void lock()
+ public void disableAutoFlush()
{
lock.lock();
}
- public void unlock()
+ public void enableAutoFlush()
{
lock.unlock();
}
Modified: trunk/src/main/org/hornetq/core/journal/SequentialFile.java
===================================================================
--- trunk/src/main/org/hornetq/core/journal/SequentialFile.java 2009-09-09 16:37:43 UTC (rev 7947)
+++ trunk/src/main/org/hornetq/core/journal/SequentialFile.java 2009-09-10 03:14:38 UTC (rev 7948)
@@ -81,8 +81,8 @@
void renameTo(String newFileName) throws Exception;
- void lockBuffer();
+ void disableAutoFlush();
- void unlockBuffer();
+ void enableAutoFlush();
}
Modified: trunk/src/main/org/hornetq/core/journal/impl/AIOSequentialFile.java
===================================================================
--- trunk/src/main/org/hornetq/core/journal/impl/AIOSequentialFile.java 2009-09-09 16:37:43 UTC (rev 7947)
+++ trunk/src/main/org/hornetq/core/journal/impl/AIOSequentialFile.java 2009-09-10 03:14:38 UTC (rev 7948)
@@ -127,14 +127,14 @@
return timedBuffer.checkSize(size);
}
- public void lockBuffer()
+ public void disableAutoFlush()
{
- timedBuffer.lock();
+ timedBuffer.disableAutoFlush();
}
- public void unlockBuffer()
+ public void enableAutoFlush()
{
- timedBuffer.unlock();
+ timedBuffer.enableAutoFlush();
}
public synchronized void close() throws Exception
Modified: trunk/src/main/org/hornetq/core/journal/impl/AIOSequentialFileFactory.java
===================================================================
--- trunk/src/main/org/hornetq/core/journal/impl/AIOSequentialFileFactory.java 2009-09-09 16:37:43 UTC (rev 7947)
+++ trunk/src/main/org/hornetq/core/journal/impl/AIOSequentialFileFactory.java 2009-09-10 03:14:38 UTC (rev 7948)
@@ -91,14 +91,14 @@
public void activate(SequentialFile file)
{
final AIOSequentialFile sequentialFile = (AIOSequentialFile)file;
- timedBuffer.lock();
+ timedBuffer.disableAutoFlush();
try
{
sequentialFile.setTimedBuffer(timedBuffer);
}
finally
{
- timedBuffer.unlock();
+ timedBuffer.enableAutoFlush();
}
}
Modified: trunk/src/main/org/hornetq/core/journal/impl/JournalCompactor.java
===================================================================
--- trunk/src/main/org/hornetq/core/journal/impl/JournalCompactor.java 2009-09-09 16:37:43 UTC (rev 7947)
+++ trunk/src/main/org/hornetq/core/journal/impl/JournalCompactor.java 2009-09-10 03:14:38 UTC (rev 7948)
@@ -548,9 +548,8 @@
ByteBuffer bufferWrite = fileFactory.newBuffer(journal.getFileSize());
writingChannel = ChannelBuffers.wrappedBuffer(bufferWrite);
- currentFile = journal.getFile(false, false, false);
+ currentFile = journal.getFile(false, false, false, true);
sequentialFile = currentFile.getFile();
- sequentialFile.renameTo(sequentialFile.getFileName() + ".cmp");
sequentialFile.open(1);
fileID = nextOrderingID++;
Modified: trunk/src/main/org/hornetq/core/journal/impl/JournalImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/journal/impl/JournalImpl.java 2009-09-09 16:37:43 UTC (rev 7947)
+++ trunk/src/main/org/hornetq/core/journal/impl/JournalImpl.java 2009-09-10 03:14:38 UTC (rev 7948)
@@ -202,7 +202,8 @@
private ExecutorService filesExecutor = null;
- private final Semaphore lock = new Semaphore(1);
+ // Lock used during the append of records
+ private final Semaphore lockAppend = new Semaphore(1);
/** We don't lock the journal while compacting, however we need to lock it while taking and updating snapshots */
private final ReadWriteLock compactingLock = new ReentrantReadWriteLock();
@@ -835,7 +836,7 @@
callback = getSyncCallback(sync);
- lock.acquire();
+ lockAppend.acquire();
try
{
JournalFile usedFile = appendRecord(bb, false, sync, null, callback);
@@ -844,7 +845,7 @@
}
finally
{
- lock.release();
+ lockAppend.release();
}
}
finally
@@ -895,7 +896,7 @@
callback = getSyncCallback(sync);
- lock.acquire();
+ lockAppend.acquire();
try
{
JournalFile usedFile = appendRecord(bb, false, sync, null, callback);
@@ -913,7 +914,7 @@
}
finally
{
- lock.release();
+ lockAppend.release();
}
}
finally
@@ -962,7 +963,7 @@
callback = getSyncCallback(sync);
- lock.acquire();
+ lockAppend.acquire();
try
{
JournalFile usedFile = appendRecord(bb, false, sync, null, callback);
@@ -981,7 +982,7 @@
}
finally
{
- lock.release();
+ lockAppend.release();
}
}
finally
@@ -1024,7 +1025,7 @@
JournalTransaction tx = getTransactionInfo(txID);
- lock.acquire();
+ lockAppend.acquire();
try
{
JournalFile usedFile = appendRecord(bb, false, false, tx, null);
@@ -1033,7 +1034,7 @@
}
finally
{
- lock.release();
+ lockAppend.release();
}
}
finally
@@ -1073,7 +1074,7 @@
JournalTransaction tx = getTransactionInfo(txID);
- lock.acquire();
+ lockAppend.acquire();
try
{
JournalFile usedFile = appendRecord(bb, false, false, tx, null);
@@ -1082,7 +1083,7 @@
}
finally
{
- lock.release();
+ lockAppend.release();
}
}
finally
@@ -1115,7 +1116,7 @@
JournalTransaction tx = getTransactionInfo(txID);
- lock.acquire();
+ lockAppend.acquire();
try
{
JournalFile usedFile = appendRecord(bb, false, false, tx, null);
@@ -1124,7 +1125,7 @@
}
finally
{
- lock.release();
+ lockAppend.release();
}
}
finally
@@ -1158,6 +1159,8 @@
throw new IllegalStateException("Journal must be loaded first");
}
+ compactingLock.readLock().lock();
+
JournalTransaction tx = getTransactionInfo(txID);
if (sync)
@@ -1165,8 +1168,6 @@
tx.syncPreviousFiles(fileFactory.isSupportsCallbacks(), currentFile);
}
- compactingLock.readLock().lock();
-
try
{
@@ -1175,7 +1176,7 @@
writeTransaction(-1, PREPARE_RECORD, txID, tx, transactionData, size, -1, bb);
- lock.acquire();
+ lockAppend.acquire();
try
{
JournalFile usedFile = appendRecord(bb, true, sync, tx, null);
@@ -1184,7 +1185,7 @@
}
finally
{
- lock.release();
+ lockAppend.release();
}
}
@@ -1221,10 +1222,10 @@
throw new IllegalStateException("Journal must be loaded first");
}
+ compactingLock.readLock().lock();
+
JournalTransaction tx = transactions.remove(txID);
- compactingLock.readLock().lock();
-
try
{
@@ -1237,7 +1238,7 @@
writeTransaction(-1, COMMIT_RECORD, txID, tx, null, SIZE_COMPLETE_TRANSACTION_RECORD, -1, bb);
- lock.acquire();
+ lockAppend.acquire();
try
{
JournalFile usedFile = appendRecord(bb, true, sync, tx, null);
@@ -1246,7 +1247,7 @@
}
finally
{
- lock.release();
+ lockAppend.release();
}
}
@@ -1291,7 +1292,7 @@
bb.writeLong(txID);
bb.writeInt(size);
- lock.acquire();
+ lockAppend.acquire();
try
{
JournalFile usedFile = appendRecord(bb, false, sync, tx, null);
@@ -1300,7 +1301,7 @@
}
finally
{
- lock.release();
+ lockAppend.release();
}
}
@@ -1406,6 +1407,8 @@
try
{
+ log.info("Starting compacting operation on journal");
+
// We need to guarantee that the journal is frozen for this short time
// We don't freeze the journal as we compact, only for the short time where we replace records
compactingLock.writeLock().lock();
@@ -1459,10 +1462,13 @@
Collections.sort(dataFilesToProcess, new JournalFileComparator());
+ // This is where most of the work is done, taking most of the time of the compacting routine.
+ // Notice there are no locks while this is being done.
+
// Read the files, and use the JournalCompactor class to create the new outputFiles, and the new collections as
// well
for (final JournalFile file : dataFilesToProcess)
- {
+ {
readJournalFile(fileFactory, file, compactor);
}
@@ -1518,7 +1524,7 @@
{
if (trace)
{
- trace("Merging pending transaction " + newTransaction + " after compacting to the journal");
+ trace("Merging pending transaction " + newTransaction + " after compacting the journal");
}
JournalTransaction liveTransaction = transactions.get(newTransaction.getId());
if (liveTransaction == null)
@@ -1541,6 +1547,8 @@
renameFiles(dataFilesToProcess, newDatafiles);
deleteControlFile(controlFile);
+ log.info("Finished compacting on journal");
+
}
finally
{
@@ -1929,7 +1937,7 @@
for (int i = 0; i < filesToCreate; i++)
{
// Keeping all files opened can be very costly (mainly on AIO)
- freeFiles.add(createFile(false, false, true));
+ freeFiles.add(createFile(false, false, true, false));
}
}
@@ -2234,19 +2242,27 @@
// In some tests we need to force the journal to move to a next file
public void forceMoveNextFile() throws Exception
{
- lock.acquire();
+ compactingLock.readLock().lock();
try
{
- moveNextFile(true);
- if (autoReclaim)
+ lockAppend.acquire();
+ try
{
- checkAndReclaimFiles();
+ moveNextFile(true);
+ if (autoReclaim)
+ {
+ checkAndReclaimFiles();
+ }
+ debugWait();
}
- debugWait();
+ finally
+ {
+ lockAppend.release();
+ }
}
finally
{
- lock.release();
+ compactingLock.readLock().unlock();
}
}
@@ -2286,7 +2302,7 @@
throw new IllegalStateException("Journal is already stopped");
}
- lock.acquire();
+ lockAppend.acquire();
try
{
@@ -2321,7 +2337,7 @@
}
finally
{
- lock.release();
+ lockAppend.release();
}
}
@@ -2501,9 +2517,6 @@
return recordSize;
}
- /**
- * This method requires bufferControl disabled, or the reads are going to be invalid
- * */
private List<JournalFile> orderFiles() throws Exception
{
@@ -2522,7 +2535,7 @@
file.read(bb);
int fileID = bb.getInt();
-
+
fileFactory.releaseBuffer(bb);
bb = null;
@@ -2532,6 +2545,16 @@
nextFileID.set(fileID);
}
+ int fileNameID = getFileNameID(fileName);
+
+ // The compactor could create a fileName but use a previously assigned ID.
+ // Because of that we need to take both parts into account
+ if (nextFileID.get() < fileNameID)
+ {
+ nextFileID.set(fileNameID);
+ }
+
+
orderedFiles.add(new JournalFileImpl(file, fileID));
file.close();
@@ -2571,14 +2594,14 @@
throw new IllegalArgumentException("Record is too large to store " + size);
}
- // The buffer on the file can't be flushed or the currentFile could be affected
- currentFile.getFile().lockBuffer();
+ // Disable auto flush on the timer. The Timer should'nt flush anything
+ currentFile.getFile().disableAutoFlush();
if (!currentFile.getFile().fits(size))
{
- currentFile.getFile().unlockBuffer();
+ currentFile.getFile().enableAutoFlush();
moveNextFile(false);
- currentFile.getFile().lockBuffer();
+ currentFile.getFile().disableAutoFlush();
// The same check needs to be done at the new file also
if (!currentFile.getFile().fits(size))
@@ -2642,10 +2665,24 @@
}
finally
{
- currentFile.getFile().unlockBuffer();
+ currentFile.getFile().enableAutoFlush();
}
}
+
+ /** Get the ID part of the name */
+ private int getFileNameID(String fileName)
+ {
+ try
+ {
+ return Integer.parseInt(fileName.substring(filePrefix.length()+1, fileName.indexOf('.')));
+ }
+ catch (Throwable e)
+ {
+ log.warn("Impossible to get the ID part of the file name " + fileName, e);
+ return 0;
+ }
+ }
/**
* This method will create a new file on the file system, pre-fill it with FILL_CHARACTER
@@ -2653,12 +2690,24 @@
* @return
* @throws Exception
*/
- private JournalFile createFile(final boolean keepOpened, final boolean multiAIO, final boolean fill) throws Exception
+ private JournalFile createFile(final boolean keepOpened,
+ final boolean multiAIO,
+ final boolean fill,
+ final boolean tmpCompact) throws Exception
{
int fileID = generateFileID();
- String fileName = filePrefix + "-" + fileID + "." + fileExtension;
+ String fileName;
+ if (tmpCompact)
+ {
+ fileName = filePrefix + "-" + fileID + "." + fileExtension + ".cmp";
+ }
+ else
+ {
+ fileName = filePrefix + "-" + fileID + "." + fileExtension;
+ }
+
if (trace)
{
trace("Creating file " + fileName);
@@ -2820,7 +2869,7 @@
* */
private void pushOpenedFile() throws Exception
{
- JournalFile nextOpenedFile = getFile(true, true, true);
+ JournalFile nextOpenedFile = getFile(true, true, true, false);
openedFiles.offer(nextOpenedFile);
}
@@ -2829,12 +2878,20 @@
* @return
* @throws Exception
*/
- JournalFile getFile(final boolean keepOpened, final boolean multiAIO, final boolean fill) throws Exception
+ JournalFile getFile(final boolean keepOpened,
+ final boolean multiAIO,
+ final boolean fill,
+ final boolean tmpCompactExtension) throws Exception
{
JournalFile nextOpenedFile = null;
try
{
nextOpenedFile = freeFiles.remove();
+ if (tmpCompactExtension)
+ {
+ SequentialFile sequentialFile = nextOpenedFile.getFile();
+ sequentialFile.renameTo(sequentialFile.getFileName() + ".cmp");
+ }
}
catch (NoSuchElementException ignored)
{
@@ -2842,7 +2899,7 @@
if (nextOpenedFile == null)
{
- nextOpenedFile = createFile(keepOpened, multiAIO, fill);
+ nextOpenedFile = createFile(keepOpened, multiAIO, fill, tmpCompactExtension);
}
else
{
@@ -2951,7 +3008,7 @@
{
for (String dataFile : dataFiles)
{
- SequentialFile file = fileFactory.createSequentialFile(dataFile, 1);
+ SequentialFile file = fileFactory.createSequentialFile(dataFile, 1);
if (file.exists())
{
file.delete();
@@ -2960,7 +3017,7 @@
for (String newFile : newFiles)
{
- SequentialFile file = fileFactory.createSequentialFile(newFile, 1);
+ SequentialFile file = fileFactory.createSequentialFile(newFile, 1);
if (file.exists())
{
final String originalName = file.getFileName();
@@ -3179,7 +3236,7 @@
{
try
{
- lock.acquire();
+ lockAppend.acquire();
HornetQBuffer bb = newBuffer(128 * 1024);
@@ -3188,7 +3245,7 @@
appendRecord(bb, false, false, null, null);
}
- lock.release();
+ lockAppend.release();
}
catch (Exception e)
{
Modified: trunk/src/main/org/hornetq/core/journal/impl/NIOSequentialFile.java
===================================================================
--- trunk/src/main/org/hornetq/core/journal/impl/NIOSequentialFile.java 2009-09-09 16:37:43 UTC (rev 7947)
+++ trunk/src/main/org/hornetq/core/journal/impl/NIOSequentialFile.java 2009-09-10 03:14:38 UTC (rev 7948)
@@ -292,14 +292,14 @@
/* (non-Javadoc)
* @see org.hornetq.core.journal.SequentialFile#lockBuffer()
*/
- public void lockBuffer()
+ public void disableAutoFlush()
{
}
/* (non-Javadoc)
* @see org.hornetq.core.journal.SequentialFile#unlockBuffer()
*/
- public void unlockBuffer()
+ public void enableAutoFlush()
{
}
Modified: trunk/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageHeaderTestBase.java
===================================================================
--- trunk/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageHeaderTestBase.java 2009-09-09 16:37:43 UTC (rev 7947)
+++ trunk/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageHeaderTestBase.java 2009-09-10 03:14:38 UTC (rev 7948)
@@ -47,7 +47,7 @@
*
* $Id: MessageImplTestBase.java 2883 2007-07-12 23:36:16Z timfox $
*/
-public class MessageHeaderTestBase extends HornetQServerTestCase
+public abstract class MessageHeaderTestBase extends HornetQServerTestCase
{
// Constants -----------------------------------------------------
Modified: trunk/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageTestBase.java
===================================================================
--- trunk/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageTestBase.java 2009-09-09 16:37:43 UTC (rev 7947)
+++ trunk/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageTestBase.java 2009-09-10 03:14:38 UTC (rev 7948)
@@ -29,7 +29,7 @@
*
* $Id$
*/
-public class MessageTestBase extends HornetQServerTestCase
+public abstract class MessageTestBase extends HornetQServerTestCase
{
// Constants -----------------------------------------------------
Modified: trunk/tests/src/org/hornetq/tests/integration/client/CompactingTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/client/CompactingTest.java 2009-09-09 16:37:43 UTC (rev 7947)
+++ trunk/tests/src/org/hornetq/tests/integration/client/CompactingTest.java 2009-09-10 03:14:38 UTC (rev 7948)
@@ -47,10 +47,16 @@
private static final String AD2 = "ad2";
+ private static final String AD3 = "ad3";
+
private static final String Q1 = "q1";
private static final String Q2 = "q2";
+ private static final String Q3 = "q3";
+
+ private static final int TOT_AD3 = 5000;
+
private HornetQServer server;
private ClientSessionFactory sf;
@@ -76,6 +82,36 @@
setupServer(journalType);
+ ClientSession session = sf.createSession(false, false);
+
+ try
+ {
+ ClientProducer producer = session.createProducer(AD3);
+
+ byte[] buffer = new byte[10 * 1024];
+
+ ClientMessage msg = session.createClientMessage(true);
+ msg.setBody(ChannelBuffers.wrappedBuffer(buffer));
+ for (int i = 0; i < TOT_AD3; i++)
+ {
+ producer.send(msg);
+ if (i % 100 == 0)
+ {
+ session.commit();
+ }
+ }
+
+ session.commit();
+ }
+ finally
+ {
+ session.close();
+ }
+
+ server.stop();
+
+ setupServer(journalType);
+
final AtomicInteger numberOfMessages = new AtomicInteger(0);
final int NUMBER_OF_FAST_MESSAGES = 100000;
final int SLOW_INTERVAL = 100;
@@ -224,7 +260,7 @@
try
{
-
+
sess = sf.createSession(true, true);
ClientConsumer cons = sess.createConsumer(Q1);
@@ -246,6 +282,19 @@
assertNull(cons.receive(100));
+ cons.close();
+
+ cons = sess.createConsumer(Q3);
+
+ for (int i = 0; i < TOT_AD3; i++)
+ {
+ ClientMessage msg = cons.receive(60000);
+ assertNotNull(msg);
+ msg.acknowledge();
+ }
+
+ assertNull(cons.receiveImmediate());
+
}
finally
{
@@ -305,6 +354,14 @@
{
}
+ try
+ {
+ sess.createQueue(AD3, Q3, true);
+ }
+ catch (Exception ignored)
+ {
+ }
+
sess.close();
sf = createInVMFactory();
Modified: trunk/tests/src/org/hornetq/tests/integration/jms/client/ResendTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/client/ResendTest.java 2009-09-09 16:37:43 UTC (rev 7947)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/client/ResendTest.java 2009-09-10 03:14:38 UTC (rev 7948)
@@ -13,9 +13,30 @@
package org.hornetq.tests.integration.jms.client;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_THREAD_POOL_MAX_SIZE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_USE_GLOBAL_POOLS;
+
import java.io.Serializable;
import java.util.ArrayList;
+import java.util.List;
+import javax.jms.BytesMessage;
import javax.jms.Connection;
import javax.jms.MapMessage;
import javax.jms.Message;
@@ -26,7 +47,11 @@
import javax.jms.Session;
import javax.jms.TextMessage;
+import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
+import org.hornetq.core.config.TransportConfiguration;
+import org.hornetq.jms.client.HornetQMessage;
import org.hornetq.tests.util.JMSTestBase;
+import org.hornetq.utils.Pair;
/**
* Receive Messages and resend them, like the bridge would do
@@ -62,6 +87,11 @@
for (int i = 0; i < 10; i++)
{
+ BytesMessage bm = sess.createBytesMessage();
+ bm.setObjectProperty(HornetQMessage.JMS_HORNETQ_INPUT_STREAM,
+ createFakeLargeStream(2 * ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE));
+ msgs.add(bm);
+
MapMessage mm = sess.createMapMessage();
mm.setBoolean("boolean", true);
mm.setByte("byte", (byte)3);
@@ -125,8 +155,17 @@
sess.commit();
- if (copiedMessage instanceof MapMessage)
+ if (copiedMessage instanceof BytesMessage)
{
+ BytesMessage copiedBytes = (BytesMessage)copiedMessage;
+
+ for (int i = 0; i < copiedBytes.getBodyLength(); i++)
+ {
+ assertEquals(getSamplebyte(i), copiedBytes.readByte());
+ }
+ }
+ else if (copiedMessage instanceof MapMessage)
+ {
MapMessage copiedMap = (MapMessage)copiedMessage;
MapMessage originalMap = (MapMessage)originalMessage;
assertEquals(originalMap.getString("str"), copiedMap.getString("str"));
@@ -209,7 +248,46 @@
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
+ protected void createCF(List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
+ List<String> jndiBindings) throws Exception
+ {
+ int retryInterval = 1000;
+ double retryIntervalMultiplier = 1.0;
+ int reconnectAttempts = -1;
+ boolean failoverOnServerShutdown = true;
+ int callTimeout = 30000;
+ jmsServer.createConnectionFactory("ManualReconnectionToSingleServerTest",
+ connectorConfigs,
+ null,
+ DEFAULT_CLIENT_FAILURE_CHECK_PERIOD,
+ DEFAULT_CONNECTION_TTL,
+ callTimeout,
+ DEFAULT_MAX_CONNECTIONS,
+ true,
+ DEFAULT_MIN_LARGE_MESSAGE_SIZE,
+ DEFAULT_CONSUMER_WINDOW_SIZE,
+ DEFAULT_CONSUMER_MAX_RATE,
+ DEFAULT_PRODUCER_WINDOW_SIZE,
+ DEFAULT_PRODUCER_MAX_RATE,
+ DEFAULT_BLOCK_ON_ACKNOWLEDGE,
+ DEFAULT_BLOCK_ON_PERSISTENT_SEND,
+ DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
+ DEFAULT_AUTO_GROUP,
+ DEFAULT_PRE_ACKNOWLEDGE,
+ DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
+ DEFAULT_ACK_BATCH_SIZE,
+ DEFAULT_ACK_BATCH_SIZE,
+ DEFAULT_USE_GLOBAL_POOLS,
+ DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE,
+ DEFAULT_THREAD_POOL_MAX_SIZE,
+ retryInterval,
+ retryIntervalMultiplier,
+ reconnectAttempts,
+ failoverOnServerShutdown,
+ jndiBindings);
+ }
+
@Override
protected void setUp() throws Exception
{
Added: trunk/tests/src/org/hornetq/tests/integration/journal/MultiThreadCompactorTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/journal/MultiThreadCompactorTest.java (rev 0)
+++ trunk/tests/src/org/hornetq/tests/integration/journal/MultiThreadCompactorTest.java 2009-09-10 03:14:38 UTC (rev 7948)
@@ -0,0 +1,493 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.tests.integration.journal;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+
+import org.hornetq.core.buffers.ChannelBuffers;
+import org.hornetq.core.client.ClientConsumer;
+import org.hornetq.core.client.ClientMessage;
+import org.hornetq.core.client.ClientProducer;
+import org.hornetq.core.client.ClientSession;
+import org.hornetq.core.client.ClientSessionFactory;
+import org.hornetq.core.config.Configuration;
+import org.hornetq.core.config.impl.ConfigurationImpl;
+import org.hornetq.core.exception.HornetQException;
+import org.hornetq.core.journal.PreparedTransactionInfo;
+import org.hornetq.core.journal.RecordInfo;
+import org.hornetq.core.journal.impl.AIOSequentialFileFactory;
+import org.hornetq.core.journal.impl.JournalImpl;
+import org.hornetq.core.server.HornetQServer;
+import org.hornetq.core.server.JournalType;
+import org.hornetq.tests.util.ServiceTestBase;
+import org.hornetq.utils.SimpleString;
+
+/**
+ * A MultiThreadConsumerStressTest
+ *
+ * @author <mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class MultiThreadCompactorTest extends ServiceTestBase
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ final SimpleString ADDRESS = new SimpleString("SomeAddress");
+
+ final SimpleString QUEUE = new SimpleString("SomeQueue");
+
+ private HornetQServer server;
+
+ private ClientSessionFactory sf;
+
+ protected int getNumberOfIterations()
+ {
+ return 3;
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ stopServer();
+ super.tearDown();
+ }
+
+ public void testMultiThreadCompact() throws Throwable
+ {
+ setupServer(JournalType.ASYNCIO);
+ for (int i = 0; i < getNumberOfIterations(); i++)
+ {
+ System.out.println("######################################");
+ System.out.println("test # " + i);
+ internalTestProduceAndConsume();
+ stopServer();
+
+ AIOSequentialFileFactory factory = new AIOSequentialFileFactory(getJournalDir());
+ JournalImpl journal = new JournalImpl(ConfigurationImpl.DEFAULT_JOURNAL_FILE_SIZE,
+ 2,
+ 0,
+ 0,
+ factory,
+ "hornetq-data",
+ "hq",
+ 100);
+ List<RecordInfo> committedRecords = new ArrayList<RecordInfo>();
+ List<PreparedTransactionInfo> preparedTransactions = new ArrayList<PreparedTransactionInfo>();
+ journal.start();
+ journal.load(committedRecords, preparedTransactions);
+
+ assertEquals(0, committedRecords.size());
+ assertEquals(0, preparedTransactions.size());
+
+ System.out.println("DataFiles = " + journal.getDataFilesCount());
+
+ if (i % 2 == 0 && i > 0)
+ {
+ System.out.println("DataFiles = " + journal.getDataFilesCount());
+ journal.forceMoveNextFile();
+ assertEquals(0, journal.getDataFilesCount());
+ }
+
+ journal.stop();
+ journal = null;
+
+ setupServer(JournalType.ASYNCIO);
+ }
+ }
+
+ public void internalTestProduceAndConsume() throws Throwable
+ {
+
+ addBogusData(100, "LAZY-QUEUE");
+
+ System.out.println(getTemporaryDir());
+ boolean transactionalOnConsume = true;
+ boolean transactionalOnProduce = true;
+ int numberOfConsumers = 30;
+ // this test assumes numberOfConsumers == numberOfProducers
+ int numberOfProducers = numberOfConsumers;
+ int produceMessage = 5000;
+ int commitIntervalProduce = 100;
+ int consumeMessage = (int)(produceMessage * 0.9);
+ int commitIntervalConsume = 100;
+
+ System.out.println("ConsumeMessages = " + consumeMessage + " produceMessage = " + produceMessage);
+
+ // Number of messages expected to be received after restart
+ int numberOfMessagesExpected = (produceMessage - consumeMessage) * numberOfConsumers;
+
+ CountDownLatch latchReady = new CountDownLatch(numberOfConsumers + numberOfProducers);
+
+ CountDownLatch latchStart = new CountDownLatch(1);
+
+ ArrayList<BaseThread> threads = new ArrayList<BaseThread>();
+
+ ProducerThread[] prod = new ProducerThread[numberOfProducers];
+ for (int i = 0; i < numberOfProducers; i++)
+ {
+ prod[i] = new ProducerThread(i,
+ latchReady,
+ latchStart,
+ transactionalOnConsume,
+ produceMessage,
+ commitIntervalProduce);
+ prod[i].start();
+ threads.add(prod[i]);
+ }
+
+ ConsumerThread[] cons = new ConsumerThread[numberOfConsumers];
+
+ for (int i = 0; i < numberOfConsumers; i++)
+ {
+ cons[i] = new ConsumerThread(i,
+ latchReady,
+ latchStart,
+ transactionalOnProduce,
+ consumeMessage,
+ commitIntervalConsume);
+ cons[i].start();
+ threads.add(cons[i]);
+ }
+
+ latchReady.await();
+ latchStart.countDown();
+
+ for (BaseThread t : threads)
+ {
+ t.join();
+ if (t.e != null)
+ {
+ throw t.e;
+ }
+ }
+
+ server.stop();
+
+ setupServer(JournalType.ASYNCIO);
+
+ drainQueue(numberOfMessagesExpected, QUEUE);
+ drainQueue(100, new SimpleString("LAZY-QUEUE"));
+
+ server.stop();
+
+ setupServer(JournalType.ASYNCIO);
+ drainQueue(0, QUEUE);
+ drainQueue(0, new SimpleString("LAZY-QUEUE"));
+
+ }
+
+ /**
+ * @param numberOfMessagesExpected
+ * @param queue
+ * @throws HornetQException
+ */
+ private void drainQueue(int numberOfMessagesExpected, SimpleString queue) throws HornetQException
+ {
+ ClientSession sess = sf.createSession(true, true);
+
+ ClientConsumer consumer = sess.createConsumer(queue);
+
+ sess.start();
+
+ for (int i = 0; i < numberOfMessagesExpected; i++)
+ {
+ ClientMessage msg = consumer.receive(5000);
+ assertNotNull(msg);
+
+ if (i % 100 == 0)
+ {
+ System.out.println("Received #" + i + " on thread after start");
+ }
+ msg.acknowledge();
+ }
+
+ assertNull(consumer.receiveImmediate());
+
+ sess.close();
+ }
+
+ /**
+ * @throws HornetQException
+ */
+ private void addBogusData(int nmessages, String queue) throws HornetQException
+ {
+ ClientSession session = sf.createSession(false, false);
+ try
+ {
+ session.createQueue(queue, queue, true);
+ }
+ catch (Exception ignored)
+ {
+ }
+
+ ClientProducer prod = session.createProducer(queue);
+ for (int i = 0; i < nmessages; i++)
+ {
+ ClientMessage msg = session.createClientMessage(true);
+ msg.getBody().writeBytes(new byte[1024]);
+ prod.send(msg);
+ }
+ session.commit();
+
+ session.start();
+
+ ClientConsumer cons = session.createConsumer(queue);
+ assertNotNull(cons.receive(1000));
+ session.rollback();
+ session.close();
+ }
+
+ protected void stopServer() throws Exception
+ {
+ try
+ {
+ if (server != null && server.isStarted())
+ {
+ server.stop();
+ }
+ }
+ catch (Throwable e)
+ {
+ e.printStackTrace(System.out); // System.out => junit reports
+ }
+
+ sf = null;
+ }
+
+ private void setupServer(JournalType journalType) throws Exception, HornetQException
+ {
+ if (server == null)
+ {
+ Configuration config = createDefaultConfig(true);
+ config.setJournalFileSize(ConfigurationImpl.DEFAULT_JOURNAL_FILE_SIZE);
+
+ config.setJournalType(journalType);
+ config.setJMXManagementEnabled(false);
+
+ config.setJournalFileSize(ConfigurationImpl.DEFAULT_JOURNAL_FILE_SIZE);
+ config.setJournalMinFiles(ConfigurationImpl.DEFAULT_JOURNAL_MIN_FILES);
+
+ config.setJournalCompactMinFiles(ConfigurationImpl.DEFAULT_JOURNAL_COMPACT_MIN_FILES);
+ config.setJournalCompactPercentage(ConfigurationImpl.DEFAULT_JOURNAL_COMPACT_PERCENTAGE);
+
+ // config.setJournalCompactMinFiles(0);
+ // config.setJournalCompactPercentage(0);
+
+ server = createServer(true, config);
+ }
+
+ server.start();
+
+ sf = createNettyFactory();
+
+ ClientSession sess = sf.createSession();
+
+ try
+ {
+ sess.createQueue(ADDRESS, QUEUE, true);
+ }
+ catch (Exception ignored)
+ {
+ }
+
+ sess.close();
+
+ sf = createInVMFactory();
+ }
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ class BaseThread extends Thread
+ {
+ Throwable e;
+
+ final CountDownLatch latchReady;
+
+ final CountDownLatch latchStart;
+
+ final int numberOfMessages;
+
+ final int commitInterval;
+
+ final boolean transactional;
+
+ BaseThread(String name,
+ CountDownLatch latchReady,
+ CountDownLatch latchStart,
+ boolean transactional,
+ int numberOfMessages,
+ int commitInterval)
+ {
+ super(name);
+ this.transactional = transactional;
+ this.latchReady = latchReady;
+ this.latchStart = latchStart;
+ this.commitInterval = commitInterval;
+ this.numberOfMessages = numberOfMessages;
+ }
+
+ }
+
+ class ProducerThread extends BaseThread
+ {
+ ProducerThread(int id,
+ CountDownLatch latchReady,
+ CountDownLatch latchStart,
+ boolean transactional,
+ int numberOfMessages,
+ int commitInterval)
+ {
+ super("ClientProducer:" + id, latchReady, latchStart, transactional, numberOfMessages, commitInterval);
+ }
+
+ public void run()
+ {
+ ClientSession session = null;
+ latchReady.countDown();
+ try
+ {
+ latchStart.await();
+ session = sf.createSession(!transactional, !transactional);
+ ClientProducer prod = session.createProducer(ADDRESS);
+ for (int i = 0; i < numberOfMessages; i++)
+ {
+ if (transactional)
+ {
+ if (i % commitInterval == 0)
+ {
+ session.commit();
+ }
+ }
+ if (i % 100 == 0)
+ {
+ // System.out.println(Thread.currentThread().getName() + "::sent #" + i);
+ }
+ ClientMessage msg = session.createClientMessage(true);
+ msg.setBody(ChannelBuffers.wrappedBuffer(new byte[1024]));
+ prod.send(msg);
+ }
+
+ if (transactional)
+ {
+ session.commit();
+ }
+
+ System.out.println("Thread " + Thread.currentThread().getName() +
+ " sent " +
+ numberOfMessages +
+ " messages");
+ }
+ catch (Throwable e)
+ {
+ e.printStackTrace();
+ this.e = e;
+ }
+ finally
+ {
+ try
+ {
+ session.close();
+ }
+ catch (Throwable e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ class ConsumerThread extends BaseThread
+ {
+ ConsumerThread(int id,
+ CountDownLatch latchReady,
+ CountDownLatch latchStart,
+ boolean transactional,
+ int numberOfMessages,
+ int commitInterval)
+ {
+ super("ClientConsumer:" + id, latchReady, latchStart, transactional, numberOfMessages, commitInterval);
+ }
+
+ public void run()
+ {
+ ClientSession session = null;
+ latchReady.countDown();
+ try
+ {
+ latchStart.await();
+ session = sf.createSession(!transactional, !transactional);
+ session.start();
+ ClientConsumer cons = session.createConsumer(QUEUE);
+ for (int i = 0; i < numberOfMessages; i++)
+ {
+ ClientMessage msg = cons.receive(60 * 1000);
+ msg.acknowledge();
+ if (i % commitInterval == 0)
+ {
+ session.commit();
+ }
+ if (i % 100 == 0)
+ {
+ // System.out.println(Thread.currentThread().getName() + "::received #" + i);
+ }
+ }
+
+ System.out.println("Thread " + Thread.currentThread().getName() +
+ " received " +
+ numberOfMessages +
+ " messages");
+
+ session.commit();
+ }
+ catch (Throwable e)
+ {
+ this.e = e;
+ }
+ finally
+ {
+ try
+ {
+ session.close();
+ }
+ catch (Throwable e)
+ {
+ this.e = e;
+ }
+ }
+ }
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Modified: trunk/tests/src/org/hornetq/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java 2009-09-09 16:37:43 UTC (rev 7947)
+++ trunk/tests/src/org/hornetq/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java 2009-09-10 03:14:38 UTC (rev 7948)
@@ -585,14 +585,14 @@
/* (non-Javadoc)
* @see org.hornetq.core.journal.SequentialFile#lockBuffer()
*/
- public void lockBuffer()
+ public void disableAutoFlush()
{
}
/* (non-Javadoc)
* @see org.hornetq.core.journal.SequentialFile#unlockBuffer()
*/
- public void unlockBuffer()
+ public void enableAutoFlush()
{
}
15 years, 3 months
JBoss hornetq SVN: r7947 - trunk/docs/user-manual/en.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2009-09-09 12:37:43 -0400 (Wed, 09 Sep 2009)
New Revision: 7947
Modified:
trunk/docs/user-manual/en/appserver-integration.xml
Log:
fixing typo
Modified: trunk/docs/user-manual/en/appserver-integration.xml
===================================================================
--- trunk/docs/user-manual/en/appserver-integration.xml 2009-09-09 16:29:42 UTC (rev 7946)
+++ trunk/docs/user-manual/en/appserver-integration.xml 2009-09-09 16:37:43 UTC (rev 7947)
@@ -390,7 +390,8 @@
<row>
<entry>TransactionManagerLocatorMethod</entry>
<entry>String</entry>
- <entry>The method to invoke on the TransactionManagerLocatorClass to get the transaction manager</entry>
+ <entry>The method to invoke on the TransactionManagerLocatorClass to get
+ the transaction manager</entry>
</row>
<row>
<entry>useLocalTx</entry>
@@ -573,7 +574,7 @@
factories that are used by Java EE components. These Connection Factories can be
defined inside a configuration file that matches the name <literal
>*-ds.xml</literal>. You'll find a default <literal>jms-ds.xml</literal>
- configuration under the <literal>messaging.sar</literal> directory in the Jboss AS
+ configuration under the <literal>hornetq.sar</literal> directory in the Jboss AS
deployment. The connection factories defined in the config file inherit their
properties from the main <literal>ra.xml</literal> configuration but can also be
overridden, the following example show how to define one.</para>
15 years, 3 months
JBoss hornetq SVN: r7946 - branches.
by do-not-reply@jboss.org
Author: timfox
Date: 2009-09-09 12:29:42 -0400 (Wed, 09 Sep 2009)
New Revision: 7946
Added:
branches/Branch_Replication_Changes/
Log:
Create branch for latest repl changes
Copied: branches/Branch_Replication_Changes (from rev 7945, trunk)
15 years, 3 months