JBoss hornetq SVN: r10966 - in branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster: util and 1 other directory.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-07-11 22:03:17 -0400 (Mon, 11 Jul 2011)
New Revision: 10966
Modified:
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/util/RemoteProcessHornetQServer.java
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/util/SameProcessHornetQServer.java
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/util/TestableServer.java
Log:
fixing tests
Modified: branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java
===================================================================
--- branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java 2011-07-12 01:58:04 UTC (rev 10965)
+++ branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java 2011-07-12 02:03:17 UTC (rev 10966)
@@ -98,13 +98,15 @@
clearData();
createConfigs();
- liveServer.getServer().setIdentity(this.getClass().getSimpleName() + "/liveServer");
+
+
+ liveServer.setIdentity(this.getClass().getSimpleName() + "/liveServer");
liveServer.start();
if (backupServer != null)
{
- backupServer.getServer().setIdentity(this.getClass().getSimpleName() + "/backupServer");
+ backupServer.setIdentity(this.getClass().getSimpleName() + "/backupServer");
backupServer.start();
}
}
Modified: branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/util/RemoteProcessHornetQServer.java
===================================================================
--- branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/util/RemoteProcessHornetQServer.java 2011-07-12 01:58:04 UTC (rev 10965)
+++ branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/util/RemoteProcessHornetQServer.java 2011-07-12 02:03:17 UTC (rev 10966)
@@ -186,4 +186,11 @@
{
return null;
}
+
+ /* (non-Javadoc)
+ * @see org.hornetq.tests.integration.cluster.util.TestableServer#setIdentity(java.lang.String)
+ */
+ public void setIdentity(String identity)
+ {
+ }
}
Modified: branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/util/SameProcessHornetQServer.java
===================================================================
--- branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/util/SameProcessHornetQServer.java 2011-07-12 01:58:04 UTC (rev 10965)
+++ branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/util/SameProcessHornetQServer.java 2011-07-12 02:03:17 UTC (rev 10966)
@@ -54,6 +54,11 @@
//To change body of implemented methods use File | Settings | File Templates.
}
+ public void setIdentity(String identity)
+ {
+ server.setIdentity(identity);
+ }
+
public boolean isStarted()
{
return server.isStarted();
Modified: branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/util/TestableServer.java
===================================================================
--- branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/util/TestableServer.java 2011-07-12 01:58:04 UTC (rev 10965)
+++ branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/util/TestableServer.java 2011-07-12 02:03:17 UTC (rev 10966)
@@ -28,6 +28,8 @@
{
HornetQServer getServer();
+
+ public void setIdentity(String identity);
public void start() throws Exception;
13 years, 5 months
JBoss hornetq SVN: r10965 - in branches/Branch_2_2_EAP_cluster_clean2: src/main/org/hornetq/core/server/cluster/impl and 3 other directories.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-07-11 21:58:04 -0400 (Mon, 11 Jul 2011)
New Revision: 10965
Modified:
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/client/impl/Topology.java
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/ClusterManagerImpl.java
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/distribution/SimpleSymmetricClusterTest.java
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/failover/FailBackAutoTest.java
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java
Log:
Fixing FailBackAutoTest
Modified: branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/client/impl/Topology.java
===================================================================
--- branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/client/impl/Topology.java 2011-07-08 17:30:48 UTC (rev 10964)
+++ branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/client/impl/Topology.java 2011-07-12 01:58:04 UTC (rev 10965)
@@ -70,8 +70,7 @@
if (debug)
{
log.debug(this + "::adding = " + nodeId + ":" + member.getConnector(), new Exception ("trace"));
- log.debug("before----------------------------------");
- log.debug(describe());
+ log.debug(describe("Before:"));
}
if(currentMember == null)
{
@@ -103,7 +102,7 @@
if(debug)
{
log.debug(this + "::Topology updated=" + replaced);
- log.debug(describe());
+ log.debug(describe("After:"));
}
return replaced;
}
@@ -163,11 +162,15 @@
}
return count;
}
-
public synchronized String describe()
{
+ return describe("");
+ }
- String desc = "";
+ public synchronized String describe(String text)
+ {
+
+ String desc = text + "\n";
for (Entry<String, TopologyMember> entry : new HashMap<String, TopologyMember>(topology).entrySet())
{
desc += "\t" + entry.getKey() + " => " + entry.getValue() + "\n";
Modified: branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java
===================================================================
--- branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java 2011-07-08 17:30:48 UTC (rev 10964)
+++ branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java 2011-07-12 01:58:04 UTC (rev 10965)
@@ -1174,7 +1174,14 @@
@Override
public String toString()
{
- return "ClusterConnectionImpl [nodeUUID=" + nodeUUID + ", connector=" + connector + ", address=" + address + "]";
+ return "ClusterConnectionImpl [nodeUUID=" + nodeUUID +
+ ", connector=" +
+ connector +
+ ", address=" +
+ address +
+ ", server=" +
+ server +
+ "]";
}
public String describe()
@@ -1215,6 +1222,10 @@
{
if(tcConfigs != null && tcConfigs.length > 0)
{
+ if (log.isDebugEnabled())
+ {
+ log.debug(ClusterConnectionImpl.this + "Creating a serverLocator for " + Arrays.toString(tcConfigs));
+ }
return (ServerLocatorInternal) HornetQClient.createServerLocatorWithHA(tcConfigs);
}
else
Modified: branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/ClusterManagerImpl.java
===================================================================
--- branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/ClusterManagerImpl.java 2011-07-08 17:30:48 UTC (rev 10964)
+++ branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/ClusterManagerImpl.java 2011-07-12 01:58:04 UTC (rev 10965)
@@ -152,7 +152,7 @@
out.println("Information on " + this);
out.println("*******************************************************");
- out.println("Topology: " + topology.describe());
+ out.println("Topology: " + topology.describe("Toopology on " + this));
for (ClusterConnection conn : this.clusterConnections.values())
{
@@ -166,7 +166,7 @@
public String toString()
{
- return "ClusterManagerImpl[server=" + server + "]";
+ return "ClusterManagerImpl[server=" + server + "]@" + System.identityHashCode(this);
}
public synchronized void start() throws Exception
@@ -282,6 +282,11 @@
{
TopologyMember member = new TopologyMember(connectorPair);
boolean updated = topology.addMember(nodeID, member);
+
+ if (log.isDebugEnabled())
+ {
+ log.debug(this + "::NodeUp " + nodeID + connectorPair);
+ }
if (!updated)
{
@@ -887,6 +892,10 @@
{
try
{
+ if (log.isDebugEnabled())
+ {
+ log.debug(ClusterManagerImpl.this + ":: announcing " + connector + " to " + backupServerLocator);
+ }
ClientSessionFactory backupSessionFactory = backupServerLocator.connect();
if (backupSessionFactory != null)
{
Modified: branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
--- branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-07-08 17:30:48 UTC (rev 10964)
+++ branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-07-12 01:58:04 UTC (rev 10965)
@@ -444,8 +444,13 @@
{
try
{
+ log.debug(HornetQServerImpl.this + "::Stopping live node in favor of failback");
stop(true);
+ // We need to wait some time before we start the backup again
+ // otherwise we may eventually start before the live had a chance to get it
+ Thread.sleep(configuration.getFailbackDelay());
configuration.setBackup(true);
+ log.debug(HornetQServerImpl.this + "::Starting backup node now after failback");
start();
}
catch (Exception e)
@@ -601,7 +606,7 @@
}
started = true;
- HornetQServerImpl.log.info("HornetQ Server version " + getVersion().getFullVersion() + " [" + nodeManager.getNodeId() + "] started");
+ HornetQServerImpl.log.info("HornetQ Server version " + getVersion().getFullVersion() + " [" + nodeManager.getNodeId() + "]" + (this.identity != null ? " (" + identity : ")") + " started");
}
Modified: branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/distribution/SimpleSymmetricClusterTest.java
===================================================================
--- branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/distribution/SimpleSymmetricClusterTest.java 2011-07-08 17:30:48 UTC (rev 10964)
+++ branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/distribution/SimpleSymmetricClusterTest.java 2011-07-12 01:58:04 UTC (rev 10965)
@@ -278,6 +278,8 @@
public void testSimpleRoundRobbin() throws Exception
{
+
+ //TODO make this test to crash a node
setupServer(0, true, isNetty());
setupServer(1, true, isNetty());
setupServer(2, true, isNetty());
@@ -361,6 +363,7 @@
public void testSimpleRoundRobbinNoFailure() throws Exception
{
+ //TODO make this test to crash a node
setupServer(0, true, isNetty());
setupServer(1, true, isNetty());
setupServer(2, true, isNetty());
Modified: branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/failover/FailBackAutoTest.java
===================================================================
--- branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/failover/FailBackAutoTest.java 2011-07-08 17:30:48 UTC (rev 10964)
+++ branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/failover/FailBackAutoTest.java 2011-07-12 01:58:04 UTC (rev 10965)
@@ -13,23 +13,29 @@
package org.hornetq.tests.integration.cluster.failover;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
import junit.framework.Assert;
+
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.SimpleString;
import org.hornetq.api.core.TransportConfiguration;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.SessionFailureListener;
import org.hornetq.core.client.impl.ClientSessionFactoryInternal;
import org.hornetq.core.client.impl.ServerLocatorInternal;
import org.hornetq.core.config.ClusterConnectionConfiguration;
+import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.impl.InVMNodeManager;
import org.hornetq.jms.client.HornetQTextMessage;
-import org.hornetq.utils.ReusableLatch;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
/**
* @author <a href="mailto:andy.taylor@jboss.com">Andy Taylor</a>
* Date: Dec 21, 2010
@@ -37,6 +43,7 @@
*/
public class FailBackAutoTest extends FailoverTestBase
{
+ Logger log = Logger.getLogger(FailBackAutoTest.class);
private ServerLocatorInternal locator;
@Override
@@ -62,7 +69,7 @@
}
super.tearDown();
}
-
+
public void testAutoFailback() throws Exception
{
locator.setBlockOnNonDurableSend(true);
@@ -78,12 +85,8 @@
session.addFailureListener(listener);
- backupServer.stop();
-
liveServer.crash();
- backupServer.start();
-
assertTrue(latch.await(5, TimeUnit.SECONDS));
ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
@@ -102,6 +105,7 @@
session.addFailureListener(listener);
+ log.info("******* starting live server back");
liveServer.start();
assertTrue(latch2.await(5, TimeUnit.SECONDS));
@@ -136,12 +140,8 @@
session.addFailureListener(listener);
- backupServer.stop();
-
liveServer.crash();
- backupServer.start();
-
assertTrue(latch.await(5, TimeUnit.SECONDS));
ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
@@ -160,8 +160,9 @@
session.addFailureListener(listener);
+ log.info("restarting live node now");
liveServer.start();
-
+
assertTrue(latch2.await(5, TimeUnit.SECONDS));
message = session.createMessage(true);
@@ -178,7 +179,7 @@
session.addFailureListener(listener);
- waitForBackup(sf, 5);
+ waitForBackup(sf, 10);
liveServer.crash();
@@ -204,6 +205,7 @@
backupConfig.setSharedStore(true);
backupConfig.setBackup(true);
backupConfig.setClustered(true);
+ backupConfig.setFailbackDelay(1000);
TransportConfiguration liveConnector = getConnectorTransportConfiguration(true);
TransportConfiguration backupConnector = getConnectorTransportConfiguration(false);
backupConfig.getConnectorConfigurations().put(liveConnector.getName(), liveConnector);
@@ -220,6 +222,7 @@
liveConfig.getAcceptorConfigurations().add(getAcceptorTransportConfiguration(true));
liveConfig.setSecurityEnabled(false);
liveConfig.setSharedStore(true);
+ liveConfig.setFailbackDelay(1000);
liveConfig.setClustered(true);
List<String> pairs = new ArrayList<String>();
pairs.add(backupConnector.getName());
Modified: branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java
===================================================================
--- branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java 2011-07-08 17:30:48 UTC (rev 10964)
+++ branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java 2011-07-12 01:58:04 UTC (rev 10965)
@@ -97,11 +97,14 @@
super.setUp();
clearData();
createConfigs();
+
+ liveServer.getServer().setIdentity(this.getClass().getSimpleName() + "/liveServer");
liveServer.start();
if (backupServer != null)
{
+ backupServer.getServer().setIdentity(this.getClass().getSimpleName() + "/backupServer");
backupServer.start();
}
}
13 years, 5 months
JBoss hornetq SVN: r10964 - in branches/Branch_2_2_AS7: tests/src/org/hornetq/tests/integration/client and 1 other directories.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-07-08 13:30:48 -0400 (Fri, 08 Jul 2011)
New Revision: 10964
Added:
branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/integration/client/JMSMessageCounterTest.java
Modified:
branches/Branch_2_2_AS7/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/util/JMSTestBase.java
Log:
HORNETQ-735 - fixing HTML counter
Modified: branches/Branch_2_2_AS7/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
--- branches/Branch_2_2_AS7/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-07-08 17:28:41 UTC (rev 10963)
+++ branches/Branch_2_2_AS7/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-07-08 17:30:48 UTC (rev 10964)
@@ -74,6 +74,7 @@
import org.hornetq.core.postoffice.Binding;
import org.hornetq.core.postoffice.DuplicateIDCache;
import org.hornetq.core.postoffice.PostOffice;
+import org.hornetq.core.postoffice.QueueBinding;
import org.hornetq.core.postoffice.impl.DivertBinding;
import org.hornetq.core.postoffice.impl.LocalQueueBinding;
import org.hornetq.core.postoffice.impl.PostOfficeImpl;
@@ -1673,13 +1674,13 @@
final boolean temporary,
final boolean ignoreIfExists) throws Exception
{
- Binding binding = postOffice.getBinding(queueName);
+ QueueBinding binding = (QueueBinding)postOffice.getBinding(queueName);
if (binding != null)
{
if (ignoreIfExists)
{
- return null;
+ return binding.getQueue();
}
else
{
Added: branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/integration/client/JMSMessageCounterTest.java
===================================================================
--- branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/integration/client/JMSMessageCounterTest.java (rev 0)
+++ branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/integration/client/JMSMessageCounterTest.java 2011-07-08 17:30:48 UTC (rev 10964)
@@ -0,0 +1,83 @@
+/*
+ * 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.client;
+
+import javax.jms.Connection;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.hornetq.api.core.SimpleString;
+import org.hornetq.api.core.management.ResourceNames;
+import org.hornetq.api.jms.management.JMSQueueControl;
+import org.hornetq.core.logging.Logger;
+import org.hornetq.tests.util.JMSTestBase;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
+ * @author <a href="mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
+ */
+public class JMSMessageCounterTest extends JMSTestBase
+{
+ private static final Logger log = Logger.getLogger(JMSMessageCounterTest.class);
+
+ private final SimpleString QUEUE = new SimpleString("ConsumerTestQueue");
+
+
+
+ protected boolean usePersistence()
+ {
+ return true;
+ }
+
+
+
+ public void testMessageCounter() throws Exception
+ {
+
+ Connection conn = cf.createConnection();
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ Queue queue = createQueue(true, "Test");
+
+ MessageProducer producer = sess.createProducer(queue);
+
+ final int numMessages = 100;
+
+ for (int i = 0; i < numMessages; i++)
+ {
+ TextMessage mess = sess.createTextMessage("msg" + i);
+ producer.send(mess);
+ }
+
+ conn.close();
+
+ JMSQueueControl control = (JMSQueueControl)server.getManagementService().getResource(ResourceNames.JMS_QUEUE + queue.getQueueName());
+ assertNotNull(control);
+
+ System.out.println(control.listMessageCounterAsHTML());
+
+ jmsServer.stop();
+
+ restartServer();
+
+ control = (JMSQueueControl)server.getManagementService().getResource(ResourceNames.JMS_QUEUE + queue.getQueueName());
+ assertNotNull(control);
+
+ System.out.println(control.listMessageCounterAsHTML());
+
+
+ }
+
+}
Modified: branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/util/JMSTestBase.java
===================================================================
--- branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/util/JMSTestBase.java 2011-07-08 17:28:41 UTC (rev 10963)
+++ branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/util/JMSTestBase.java 2011-07-08 17:30:48 UTC (rev 10964)
@@ -89,14 +89,28 @@
*/
protected Queue createQueue(final String name) throws Exception, NamingException
{
- jmsServer.createQueue(false, name, null, true, "/jms/" + name);
+ return createQueue(false, name);
+ }
+ protected Topic createTopic(final String name) throws Exception, NamingException
+ {
+ return createTopic(false, name);
+ }
+
+ /**
+ * @throws Exception
+ * @throws NamingException
+ */
+ protected Queue createQueue(final boolean storeConfig, final String name) throws Exception, NamingException
+ {
+ jmsServer.createQueue(storeConfig, name, null, true, "/jms/" + name);
+
return (Queue)context.lookup("/jms/" + name);
}
- protected Topic createTopic(final String name) throws Exception, NamingException
+ protected Topic createTopic(final boolean storeConfig, final String name) throws Exception, NamingException
{
- jmsServer.createTopic(false, name, "/jms/" + name);
+ jmsServer.createTopic(storeConfig, name, "/jms/" + name);
return (Topic)context.lookup("/jms/" + name);
}
@@ -136,10 +150,10 @@
protected void restartServer() throws Exception
{
+ context = new InVMContext();
+ jmsServer.setContext(context);
jmsServer.start();
jmsServer.activated();
- context = new InVMContext();
- jmsServer.setContext(context);
registerConnectionFactory();
}
13 years, 6 months
JBoss hornetq SVN: r10963 - in branches/Branch_2_2_EAP: tests/src/org/hornetq/tests/integration/client and 1 other directories.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-07-08 13:28:41 -0400 (Fri, 08 Jul 2011)
New Revision: 10963
Added:
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/JMSMessageCounterTest.java
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/JMSTestBase.java
Log:
HORNETQ-735 - fixing HTML counter
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-07-08 11:10:17 UTC (rev 10962)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-07-08 17:28:41 UTC (rev 10963)
@@ -72,6 +72,7 @@
import org.hornetq.core.postoffice.Binding;
import org.hornetq.core.postoffice.DuplicateIDCache;
import org.hornetq.core.postoffice.PostOffice;
+import org.hornetq.core.postoffice.QueueBinding;
import org.hornetq.core.postoffice.impl.DivertBinding;
import org.hornetq.core.postoffice.impl.LocalQueueBinding;
import org.hornetq.core.postoffice.impl.PostOfficeImpl;
@@ -1694,13 +1695,13 @@
final boolean temporary,
final boolean ignoreIfExists) throws Exception
{
- Binding binding = postOffice.getBinding(queueName);
+ QueueBinding binding = (QueueBinding)postOffice.getBinding(queueName);
if (binding != null)
{
if (ignoreIfExists)
{
- return null;
+ return binding.getQueue();
}
else
{
Added: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/JMSMessageCounterTest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/JMSMessageCounterTest.java (rev 0)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/JMSMessageCounterTest.java 2011-07-08 17:28:41 UTC (rev 10963)
@@ -0,0 +1,83 @@
+/*
+ * 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.client;
+
+import javax.jms.Connection;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.hornetq.api.core.SimpleString;
+import org.hornetq.api.core.management.ResourceNames;
+import org.hornetq.api.jms.management.JMSQueueControl;
+import org.hornetq.core.logging.Logger;
+import org.hornetq.tests.util.JMSTestBase;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
+ * @author <a href="mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
+ */
+public class JMSMessageCounterTest extends JMSTestBase
+{
+ private static final Logger log = Logger.getLogger(JMSMessageCounterTest.class);
+
+ private final SimpleString QUEUE = new SimpleString("ConsumerTestQueue");
+
+
+
+ protected boolean usePersistence()
+ {
+ return true;
+ }
+
+
+
+ public void testMessageCounter() throws Exception
+ {
+
+ Connection conn = cf.createConnection();
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ Queue queue = createQueue(true, "Test");
+
+ MessageProducer producer = sess.createProducer(queue);
+
+ final int numMessages = 100;
+
+ for (int i = 0; i < numMessages; i++)
+ {
+ TextMessage mess = sess.createTextMessage("msg" + i);
+ producer.send(mess);
+ }
+
+ conn.close();
+
+ JMSQueueControl control = (JMSQueueControl)server.getManagementService().getResource(ResourceNames.JMS_QUEUE + queue.getQueueName());
+ assertNotNull(control);
+
+ System.out.println(control.listMessageCounterAsHTML());
+
+ jmsServer.stop();
+
+ restartServer();
+
+ control = (JMSQueueControl)server.getManagementService().getResource(ResourceNames.JMS_QUEUE + queue.getQueueName());
+ assertNotNull(control);
+
+ System.out.println(control.listMessageCounterAsHTML());
+
+
+ }
+
+}
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/JMSTestBase.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/JMSTestBase.java 2011-07-08 11:10:17 UTC (rev 10962)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/JMSTestBase.java 2011-07-08 17:28:41 UTC (rev 10963)
@@ -89,14 +89,28 @@
*/
protected Queue createQueue(final String name) throws Exception, NamingException
{
- jmsServer.createQueue(false, name, null, true, "/jms/" + name);
+ return createQueue(false, name);
+ }
+ protected Topic createTopic(final String name) throws Exception, NamingException
+ {
+ return createTopic(false, name);
+ }
+
+ /**
+ * @throws Exception
+ * @throws NamingException
+ */
+ protected Queue createQueue(final boolean storeConfig, final String name) throws Exception, NamingException
+ {
+ jmsServer.createQueue(storeConfig, name, null, true, "/jms/" + name);
+
return (Queue)context.lookup("/jms/" + name);
}
- protected Topic createTopic(final String name) throws Exception, NamingException
+ protected Topic createTopic(final boolean storeConfig, final String name) throws Exception, NamingException
{
- jmsServer.createTopic(false, name, "/jms/" + name);
+ jmsServer.createTopic(storeConfig, name, "/jms/" + name);
return (Topic)context.lookup("/jms/" + name);
}
@@ -136,10 +150,10 @@
protected void restartServer() throws Exception
{
+ context = new InVMContext();
+ jmsServer.setContext(context);
jmsServer.start();
jmsServer.activated();
- context = new InVMContext();
- jmsServer.setContext(context);
registerConnectionFactory();
}
13 years, 6 months
JBoss hornetq SVN: r10962 - branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/server/impl.
by do-not-reply@jboss.org
Author: borges
Date: 2011-07-08 07:10:17 -0400 (Fri, 08 Jul 2011)
New Revision: 10962
Modified:
branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java
Log:
Set 'started=true' at replicated backup before waiting for live to stop.
Check earlier for 'started'==true at start()
Modified: branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
--- branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-07-08 11:09:48 UTC (rev 10961)
+++ branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-07-08 11:10:17 UTC (rev 10962)
@@ -564,13 +564,13 @@
log.info("HornetQ Backup Server version " + getVersion().getFullVersion() + " [" + nodeManager.getNodeId() +
"] started, waiting live to fail before it gets active");
+ started = true;
nodeManager.awaitLiveNode();
// Server node (i.e. Life node) is not running, now the backup takes over.
replicationEndpoint.stop();
configuration.setBackup(false);
initialisePart2();
- started = true;
}
catch (Exception e)
@@ -614,20 +614,21 @@
{
initialiseLogging();
+ if (started)
+ {
+ log.info((configuration.isBackup() ? "backup" : "live") + " is already started, ignoring the call to start..");
+ return;
+ }
+
checkJournalDirectory();
nodeManager = createNodeManager(configuration.getJournalDirectory());
nodeManager.start();
- if (started)
- {
- HornetQServerImpl.log.info((configuration.isBackup() ? "backup" : "live") + " is already started, ignoring the call to start..");
- return;
- }
+ HornetQServerImpl.log.info((configuration.isBackup() ? "backup" : "live") +
+ " server is starting with configuration " + configuration);
- HornetQServerImpl.log.info((configuration.isBackup() ? "backup" : "live") + " server is starting with configuration " + configuration);
-
if (configuration.isRunSyncSpeedTest())
{
SyncSpeedTest test = new SyncSpeedTest();
13 years, 6 months
JBoss hornetq SVN: r10961 - branches/HORNETQ-720_Replication/hornetq-journal/src/main/java/org/hornetq/core/journal/impl.
by do-not-reply@jboss.org
Author: borges
Date: 2011-07-08 07:09:48 -0400 (Fri, 08 Jul 2011)
New Revision: 10961
Modified:
branches/HORNETQ-720_Replication/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/JournalImpl.java
Log:
Move journal state transitions to a method (as it allows easier logging)
Modified: branches/HORNETQ-720_Replication/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/JournalImpl.java
===================================================================
--- branches/HORNETQ-720_Replication/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/JournalImpl.java 2011-07-08 11:09:20 UTC (rev 10960)
+++ branches/HORNETQ-720_Replication/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/JournalImpl.java 2011-07-08 11:09:48 UTC (rev 10961)
@@ -1083,6 +1083,12 @@
}
}
+ private void setJournalState(JournalState newState)
+ {
+ // log.info(this + " state=" + newState);
+ state = newState;
+ }
+
public void appendUpdateRecordTransactional(final long txID,
final long id,
final byte recordType,
@@ -1863,7 +1869,7 @@
{
if (state != JournalState.STARTED)
{
- throw new IllegalStateException("Journal must be in started state");
+ throw new IllegalStateException("Journal " + this + " must be in started state, was " + state);
}
checkControlFile();
@@ -2177,7 +2183,7 @@
filesRepository.pushOpenedFile();
- state = JournalState.LOADED;
+ setJournalState(JournalState.LOADED);
for (TransactionHolder transaction : loadTransactions.values())
{
@@ -2515,7 +2521,7 @@
{
if (state != JournalState.STOPPED)
{
- throw new IllegalStateException("Journal is not stopped");
+ throw new IllegalStateException("Journal " + this + " is not stopped, state is " + state);
}
filesExecutor = Executors.newSingleThreadExecutor(new ThreadFactory()
@@ -2540,7 +2546,7 @@
fileFactory.start();
- state = JournalState.STARTED;
+ setJournalState(JournalState.STARTED);
}
public synchronized void stop() throws Exception
@@ -2557,7 +2563,7 @@
try
{
- state = JournalState.STOPPED;
+ setJournalState(JournalState.STOPPED);
compactorExecutor.shutdown();
13 years, 6 months
JBoss hornetq SVN: r10960 - branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/util.
by do-not-reply@jboss.org
Author: borges
Date: 2011-07-08 07:09:20 -0400 (Fri, 08 Jul 2011)
New Revision: 10960
Modified:
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/util/SameProcessHornetQServer.java
Log:
improve test failure message
Modified: branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/util/SameProcessHornetQServer.java
===================================================================
--- branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/util/SameProcessHornetQServer.java 2011-07-08 11:08:44 UTC (rev 10959)
+++ branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/util/SameProcessHornetQServer.java 2011-07-08 11:09:20 UTC (rev 10960)
@@ -104,7 +104,7 @@
// Wait to be informed of failure
boolean ok = latch.await(10000, TimeUnit.MILLISECONDS);
- Assert.assertTrue("failed to stop the server", ok);
+ Assert.assertTrue("Failed to stop the server! Latch count is " + latch.getCount(), ok);
}
/* (non-Javadoc)
13 years, 6 months
JBoss hornetq SVN: r10959 - branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/server/impl.
by do-not-reply@jboss.org
Author: borges
Date: 2011-07-08 07:08:44 -0400 (Fri, 08 Jul 2011)
New Revision: 10959
Modified:
branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java
Log:
Remove unused variables and unused imports.
Modified: branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
--- branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-07-08 11:06:04 UTC (rev 10958)
+++ branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-07-08 11:08:44 UTC (rev 10959)
@@ -41,7 +41,6 @@
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.api.core.client.ClientSessionFactory;
import org.hornetq.api.core.client.HornetQClient;
-import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.asyncio.impl.AsynchronousFileImpl;
import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
import org.hornetq.core.client.impl.ServerLocatorInternal;
@@ -83,7 +82,6 @@
import org.hornetq.core.protocol.core.Channel;
import org.hornetq.core.protocol.core.CoreRemotingConnection;
import org.hornetq.core.protocol.core.impl.ChannelImpl.CHANNEL_ID;
-import org.hornetq.core.protocol.core.impl.wireformat.HaBackupRegistrationMessage;
import org.hornetq.core.remoting.server.RemotingService;
import org.hornetq.core.remoting.server.impl.RemotingServiceImpl;
import org.hornetq.core.replication.ReplicationEndpoint;
@@ -555,14 +553,14 @@
throw new RuntimeException("Need to retry...");
}
CoreRemotingConnection liveConnection = liveServerSessionFactory.getConnection();
- Channel liveChannel = liveConnection.getChannel(CHANNEL_ID.PING.id, -1);
+ Channel pingChannel = liveConnection.getChannel(CHANNEL_ID.PING.id, -1);
Channel replicationChannel = liveConnection.getChannel(CHANNEL_ID.REPLICATION.id, -1);
replicationChannel.setHandler(replicationEndpoint);
connectToReplicationEndpoint(replicationChannel);
replicationEndpoint.start();
- clusterManager.announceReplicatingBackup(liveChannel);
+ clusterManager.announceReplicatingBackup(pingChannel);
log.info("HornetQ Backup Server version " + getVersion().getFullVersion() + " [" + nodeManager.getNodeId() +
"] started, waiting live to fail before it gets active");
@@ -612,8 +610,6 @@
private Activation activation;
- private ServerLocator serverLocator;
-
public synchronized void start() throws Exception
{
initialiseLogging();
13 years, 6 months
JBoss hornetq SVN: r10958 - branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/server/impl.
by do-not-reply@jboss.org
Author: ataylor
Date: 2011-07-08 07:06:04 -0400 (Fri, 08 Jul 2011)
New Revision: 10958
Modified:
branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java
Log:
handled close on backup activation
Modified: branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
--- branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-07-08 10:36:02 UTC (rev 10957)
+++ branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-07-08 11:06:04 UTC (rev 10958)
@@ -583,6 +583,28 @@
public void close(final boolean permanently) throws Exception
{
+ if (configuration.isBackup())
+ {
+ long timeout = 30000;
+
+ long start = System.currentTimeMillis();
+
+ while (backupActivationThread.isAlive() && System.currentTimeMillis() - start < timeout)
+ {
+ nodeManager.interrupt();
+
+ backupActivationThread.interrupt();
+
+ Thread.sleep(1000);
+ }
+
+ if (System.currentTimeMillis() - start >= timeout)
+ {
+ log.warn("Timed out waiting for backup activation to exit");
+ }
+
+ nodeManager.stopBackup();
+ }
}
}
13 years, 6 months
JBoss hornetq SVN: r10957 - in branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core: protocol/core/impl and 1 other directories.
by do-not-reply@jboss.org
Author: ataylor
Date: 2011-07-08 06:36:02 -0400 (Fri, 08 Jul 2011)
New Revision: 10957
Modified:
branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/HornetQPacketHandler.java
branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java
Log:
stop re3plication endpoint and initialise2 after failover
Modified: branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
===================================================================
--- branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2011-07-07 15:54:23 UTC (rev 10956)
+++ branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2011-07-08 10:36:02 UTC (rev 10957)
@@ -282,14 +282,9 @@
throw new IllegalArgumentException("Unsupported journal type " + config.getJournalType());
}
- if (config.isBackup() && !config.isSharedStore())
- {
- idGenerator = null;
- }
- else
- {
- idGenerator = new BatchingIDGenerator(0, JournalStorageManager.CHECKPOINT_BATCH_SIZE, bindingsJournal);
- }
+
+ idGenerator = new BatchingIDGenerator(0, JournalStorageManager.CHECKPOINT_BATCH_SIZE, bindingsJournal);
+
Journal localMessage = new JournalImpl(config.getJournalFileSize(),
config.getJournalMinFiles(),
config.getJournalCompactMinFiles(),
Modified: branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/HornetQPacketHandler.java
===================================================================
--- branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/HornetQPacketHandler.java 2011-07-07 15:54:23 UTC (rev 10956)
+++ branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/HornetQPacketHandler.java 2011-07-08 10:36:02 UTC (rev 10957)
@@ -156,11 +156,11 @@
throw new HornetQException(HornetQException.SESSION_CREATION_REJECTED, "Server not started");
}
- if (!server.checkActivate())
+ /*if (!server.checkActivate())
{
throw new HornetQException(HornetQException.SESSION_CREATION_REJECTED,
"Server will not accept create session requests");
- }
+ }*/
Channel channel = connection.getChannel(request.getSessionChannelID(), request.getWindowSize());
@@ -239,7 +239,7 @@
ServerSessionPacketHandler sessionHandler = protocolManager.getSessionHandler(request.getName());
- if (!server.checkActivate() || sessionHandler == null)
+ if (sessionHandler == null)
{
response = new ReattachSessionResponseMessage(-1, false);
}
Modified: branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
--- branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-07-07 15:54:23 UTC (rev 10956)
+++ branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-07-08 10:36:02 UTC (rev 10957)
@@ -535,9 +535,6 @@
initialisePart1();
clusterManager.start();
- // XXX this really belongs to this point?
- initialisePart2();
- started = true;
String liveConnectorName = configuration.getLiveConnectorName();
if (liveConnectorName == null)
@@ -571,9 +568,12 @@
"] started, waiting live to fail before it gets active");
nodeManager.awaitLiveNode();
// Server node (i.e. Life node) is not running, now the backup takes over.
-
+ replicationEndpoint.stop();
configuration.setBackup(false);
+ initialisePart2();
+ started = true;
+
}
catch (Exception e)
{
13 years, 6 months