JBoss hornetq SVN: r11502 - branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/server/impl.
by do-not-reply@jboss.org
Author: borges
Date: 2011-10-10 09:35:23 -0400 (Mon, 10 Oct 2011)
New Revision: 11502
Modified:
branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java
Log:
HORNETQ-720 Don't continue initialization if being stopped.
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-10-10 13:35:11 UTC (rev 11501)
+++ branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-10-10 13:35:23 UTC (rev 11502)
@@ -602,6 +602,8 @@
serverLocator.close();
replicationEndpoint.stop();
+ if (!started)
+ return;
if (!isRemoteBackupUpToDate())
{
/*
13 years, 2 months
JBoss hornetq SVN: r11501 - branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/replication/impl.
by do-not-reply@jboss.org
Author: borges
Date: 2011-10-10 09:35:11 -0400 (Mon, 10 Oct 2011)
New Revision: 11501
Modified:
branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/replication/impl/ReplicationEndpointImpl.java
Log:
HORNETQ-720 Make ReplicationEndpoint.stop() more robust, and do close all open files
Modified: branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/replication/impl/ReplicationEndpointImpl.java
===================================================================
--- branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/replication/impl/ReplicationEndpointImpl.java 2011-10-10 13:35:00 UTC (rev 11500)
+++ branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/replication/impl/ReplicationEndpointImpl.java 2011-10-10 13:35:11 UTC (rev 11501)
@@ -18,6 +18,7 @@
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
+import java.util.Arrays;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
@@ -91,7 +92,7 @@
/** Files reserved in each journal for synchronization of existing data from the 'live' server. */
private final Map<JournalContent, Map<Long, JournalSyncFile>> filesReservedForSync =
new HashMap<JournalContent, Map<Long, JournalSyncFile>>();
- private Map<Long, LargeServerMessage> largeMessagesOnSync = new HashMap<Long, LargeServerMessage>();
+ private final Map<Long, LargeServerMessage> largeMessagesOnSync = new HashMap<Long, LargeServerMessage>();
/**
* Used to hold the real Journals before the backup is synchronized. This field should be
@@ -144,6 +145,7 @@
*/
public void handlePacket(final Packet packet)
{
+
PacketImpl response = new ReplicationResponseMessage();
final byte type=packet.getType();
@@ -230,7 +232,7 @@
return started;
}
- public void start() throws Exception
+ public synchronized void start() throws Exception
{
Configuration config = server.getConfiguration();
@@ -263,22 +265,19 @@
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.HornetQComponent#stop()
- */
- public void stop() throws Exception
+ public synchronized void stop() throws Exception
{
- if(!started)
+ if (!started)
{
return;
}
+
// This could be null if the backup server is being
// shut down without any live server connecting here
if (channel != null)
{
channel.close();
}
- storage.stop();
for (ConcurrentMap<Integer, Page> map : pageIndex.values())
{
@@ -301,11 +300,28 @@
{
largeMessage.releaseResources();
}
-
largeMessages.clear();
+ for (LargeServerMessage largeMessage : largeMessagesOnSync.values())
+ {
+ largeMessage.releaseResources();
+ }
+ largeMessagesOnSync.clear();
+
+ for (Entry<JournalContent, Map<Long, JournalSyncFile>> entry : filesReservedForSync.entrySet())
+ {
+ for (JournalSyncFile filesReserved : entry.getValue().values())
+ {
+ filesReserved.close();
+ }
+ }
+
+ filesReservedForSync.clear();
pageManager.stop();
+ // Storage needs to be the last to stop
+ storage.stop();
+
started = false;
}
@@ -437,9 +453,9 @@
}
largeMessages.clear();
largeMessages.putAll(largeMessagesOnSync);
+ largeMessagesOnSync.clear();
}
}
- largeMessagesOnSync = null;
journalsHolder = null;
server.setRemoteBackupUpToDate();
log.info("Backup server " + server + " is synchronized with live-server.");
@@ -524,15 +540,23 @@
return;
}
+
final Journal journal = journalsHolder.get(packet.getJournalContentType());
+ synchronized (this)
+ {
+ if (!started)
+ return;
+ Map<Long, JournalSyncFile> mapToFill = filesReservedForSync.get(packet.getJournalContentType());
+ log.info("Journal " + packet.getJournalContentType() + ". Reserving fileIDs for synchronization: " +
+ Arrays.toString(packet.getFileIds()));
- Map<Long, JournalSyncFile> mapToFill = filesReservedForSync.get(packet.getJournalContentType());
for (Entry<Long, JournalFile> entry : journal.createFilesForBackupSync(packet.getFileIds()).entrySet())
{
mapToFill.put(entry.getKey(), new JournalSyncFile(entry.getValue()));
}
registerJournal(packet.getJournalContentType().typeByte, new FileWrapperJournal(journal));
- }
+ }
+ }
private void handleLargeMessageEnd(final ReplicationLargeMessageEndMessage packet)
{
@@ -601,9 +625,7 @@
log.warn("Large MessageID " + messageId +
" is not available on backup server. Ignoring replication message");
}
-
return message;
-
}
/**
@@ -845,7 +867,8 @@
void close() throws IOException
{
- channel.close();
+ if (channel != null)
+ channel.close();
}
@Override
13 years, 2 months
JBoss hornetq SVN: r11500 - branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/replication/impl.
by do-not-reply@jboss.org
Author: borges
Date: 2011-10-10 09:35:00 -0400 (Mon, 10 Oct 2011)
New Revision: 11500
Modified:
branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/replication/impl/ReplicationManagerImpl.java
Log:
HORNETQ-720 Close synchronization file when done
Modified: branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/replication/impl/ReplicationManagerImpl.java
===================================================================
--- branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/replication/impl/ReplicationManagerImpl.java 2011-10-10 13:34:43 UTC (rev 11499)
+++ branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/replication/impl/ReplicationManagerImpl.java 2011-10-10 13:35:00 UTC (rev 11500)
@@ -469,8 +469,15 @@
if (enabled)
{
SequentialFile file = jf.getFile().copy();
+ try {
log.info("Replication: sending " + jf + " (size=" + file.size() + ") to backup. " + file);
sendLargeFile(content, null, jf.getFileID(), file, Long.MAX_VALUE);
+ }
+ finally
+ {
+ if (file.isOpen())
+ file.close();
+ }
}
}
13 years, 2 months
JBoss hornetq SVN: r11499 - in branches/HORNETQ-720_Replication: hornetq-core/src/main/java/org/hornetq/core/server/impl and 2 other directories.
by do-not-reply@jboss.org
Author: borges
Date: 2011-10-10 09:34:43 -0400 (Mon, 10 Oct 2011)
New Revision: 11499
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/server/impl/HornetQServerImpl.java
branches/HORNETQ-720_Replication/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/AIOSequentialFileFactory.java
branches/HORNETQ-720_Replication/tests/unit-tests/src/test/java/org/hornetq/tests/util/ServiceTestBase.java
Log:
HORNETQ-720 stop sync'ing if the storageManager stops, stop ReplicationEndpoint first
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-10-10 13:34:06 UTC (rev 11498)
+++ branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2011-10-10 13:34:43 UTC (rev 11499)
@@ -428,6 +428,8 @@
{
for (Entry<SimpleString, Collection<Integer>> entry : pageFilesToSync.entrySet())
{
+ if (!started)
+ return;
PagingStore store = manager.getPageStore(entry.getKey());
store.sendPages(replicator, entry.getValue());
}
@@ -460,6 +462,8 @@
SequentialFile seqFile = largeMessagesFactory.createSequentialFile(fileName, 1);
if (!seqFile.exists())
continue;
+ if (!started)
+ return;
replicator.syncLargeMessageFile(seqFile, size, getLargeMessageIdFromFilename(fileName));
}
}
@@ -498,6 +502,8 @@
{
for (JournalFile jf : journalFiles)
{
+ if (!started)
+ return;
replicator.syncJournalFile(jf, type);
jf.setCanReclaim(true);
}
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-10-10 13:34:06 UTC (rev 11498)
+++ branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-10-10 13:34:43 UTC (rev 11499)
@@ -823,6 +823,12 @@
pagingManager.stop();
}
+ if (replicationEndpoint != null)
+ {
+ replicationEndpoint.stop();
+ replicationEndpoint = null;
+ }
+
if (storageManager != null)
{
storageManager.stop();
@@ -834,12 +840,6 @@
replicationManager = null;
}
- if (replicationEndpoint != null)
- {
- replicationEndpoint.stop();
- replicationEndpoint = null;
- }
-
if (securityManager != null)
{
securityManager.stop();
@@ -1669,7 +1669,10 @@
Filter filter = FilterImpl.createFilter(queueBindingInfo.getFilterString());
- PageSubscription subscription = pagingManager.getPageStore(queueBindingInfo.getAddress()).getCursorProvider().createSubscription(queueBindingInfo.getId(), filter, true);
+ PageSubscription subscription =
+ pagingManager.getPageStore(queueBindingInfo.getAddress())
+ .getCursorProvider()
+ .createSubscription(queueBindingInfo.getId(), filter, true);
Queue queue = queueFactory.createQueue(queueBindingInfo.getId(),
queueBindingInfo.getAddress(),
Modified: branches/HORNETQ-720_Replication/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/AIOSequentialFileFactory.java
===================================================================
--- branches/HORNETQ-720_Replication/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/AIOSequentialFileFactory.java 2011-10-10 13:34:06 UTC (rev 11498)
+++ branches/HORNETQ-720_Replication/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/AIOSequentialFileFactory.java 2011-10-10 13:34:43 UTC (rev 11499)
@@ -292,4 +292,11 @@
}
}
}
+
+ @Override
+ public String toString()
+ {
+ return AIOSequentialFileFactory.class.getSimpleName() + "(buffersControl.stopped=" + buffersControl.stopped +
+ "):" + super.toString();
+ }
}
Modified: branches/HORNETQ-720_Replication/tests/unit-tests/src/test/java/org/hornetq/tests/util/ServiceTestBase.java
===================================================================
--- branches/HORNETQ-720_Replication/tests/unit-tests/src/test/java/org/hornetq/tests/util/ServiceTestBase.java 2011-10-10 13:34:06 UTC (rev 11498)
+++ branches/HORNETQ-720_Replication/tests/unit-tests/src/test/java/org/hornetq/tests/util/ServiceTestBase.java 2011-10-10 13:34:43 UTC (rev 11499)
@@ -480,6 +480,7 @@
return locatorWithoutHA;
}
+ // XXX unused
protected ClientSessionFactoryImpl createFactory(final String connectorClass) throws Exception
{
ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(connectorClass));
13 years, 2 months
JBoss hornetq SVN: r11498 - branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/persistence/impl/journal.
by do-not-reply@jboss.org
Author: borges
Date: 2011-10-10 09:34:06 -0400 (Mon, 10 Oct 2011)
New Revision: 11498
Modified:
branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
Log:
Fix-up journal implementations broken in last commit.
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-10-10 13:33:52 UTC (rev 11497)
+++ branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2011-10-10 13:34:06 UTC (rev 11498)
@@ -505,17 +505,8 @@
private JournalFile[] prepareJournalForCopy(Journal journal, JournalContent contentType) throws Exception
{
- journal.setAutoReclaim(false);
- /*
- * XXX HORNETQ-720 need to check whether it is safe to proceed if compacting is running
- * (specially at the end of it)
- */
journal.forceMoveNextFile();
JournalFile[] datafiles = journal.getDataFiles();
- for (JournalFile jf : datafiles)
- {
- jf.setCanReclaim(false);
- }
replicator.sendStartSyncMessage(datafiles, contentType);
return datafiles;
}
13 years, 2 months
JBoss hornetq SVN: r11497 - branches/HORNETQ-720_Replication/tests/integration-tests.
by do-not-reply@jboss.org
Author: borges
Date: 2011-10-10 09:33:52 -0400 (Mon, 10 Oct 2011)
New Revision: 11497
Modified:
branches/HORNETQ-720_Replication/tests/integration-tests/pom.xml
Log:
run all integration tests
Modified: branches/HORNETQ-720_Replication/tests/integration-tests/pom.xml
===================================================================
--- branches/HORNETQ-720_Replication/tests/integration-tests/pom.xml 2011-10-07 12:28:01 UTC (rev 11496)
+++ branches/HORNETQ-720_Replication/tests/integration-tests/pom.xml 2011-10-10 13:33:52 UTC (rev 11497)
@@ -103,14 +103,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>${skipIntegrationTests}</skipTests>
- <excludes>
- <exclude>**/ReplicatedJMSFailoverTest.java</exclude>
- <exclude>org/hornetq/tests/util/*.java</exclude>
- <!-- exclude some replication tests for now -->
- <exclude>**/cluster/failover/Remote*.java</exclude>
- <exclude>**/failover/remote/**.java</exclude>
- </excludes>
- <argLine>-Djava.library.path=${user.dir}/distribution/hornetq/src/main/resources/bin</argLine>
+ <argLine>-Djava.library.path=${user.dir}/distribution/hornetq/src/main/resources/bin</argLine>
</configuration>
</plugin>
</plugins>
13 years, 2 months
JBoss hornetq SVN: r11496 - in branches/HORNETQ-720_Replication: hornetq-core/src/main/java/org/hornetq/core/settings/impl and 6 other directories.
by do-not-reply@jboss.org
Author: borges
Date: 2011-10-07 08:28:01 -0400 (Fri, 07 Oct 2011)
New Revision: 11496
Added:
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/core/
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/core/message/
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/core/message/impl/
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/core/message/impl/MessagePropertyTest.java
Removed:
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/core/message/
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/core/message/impl/
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/core/message/impl/MessagePropertyTest.java
Modified:
branches/HORNETQ-720_Replication/
branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/settings/impl/HierarchicalObjectRepository.java
branches/HORNETQ-720_Replication/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java
Log:
merge from trunk
Property changes on: branches/HORNETQ-720_Replication
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk:10878-11474
+ /trunk:10878-11495
Modified: branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/settings/impl/HierarchicalObjectRepository.java
===================================================================
--- branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/settings/impl/HierarchicalObjectRepository.java 2011-10-07 12:25:45 UTC (rev 11495)
+++ branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/settings/impl/HierarchicalObjectRepository.java 2011-10-07 12:28:01 UTC (rev 11496)
@@ -60,7 +60,7 @@
/**
* a regex comparator
*/
- private final MatchComparator<String> matchComparator = new MatchComparator<String>();
+ private final MatchComparator matchComparator = new MatchComparator();
/**
* a cache
@@ -263,7 +263,7 @@
/**
* compares to matches to see which one is more specific
*/
- private static class MatchComparator<T extends String> implements Comparator<T>
+ private static class MatchComparator implements Comparator<String>
{
public int compare(final String o1, final String o2)
{
Modified: branches/HORNETQ-720_Replication/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java
===================================================================
--- branches/HORNETQ-720_Replication/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java 2011-10-07 12:25:45 UTC (rev 11495)
+++ branches/HORNETQ-720_Replication/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java 2011-10-07 12:28:01 UTC (rev 11496)
@@ -78,12 +78,12 @@
import org.hornetq.utils.UUIDGenerator;
/**
- *
- * Helper base class for our unit tests
- *
+ * Helper base class for our unit tests.
+ * <p>
+ * See {@code org.hornetq.tests.util.ServiceTestBase} for a test case with server set-up.
+ * @see Service
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
* @author <a href="mailto:csuconic@redhat.com">Clebert</a>
- *
*/
public abstract class UnitTestCase extends TestCase
{
@@ -968,8 +968,9 @@
if (AsynchronousFileImpl.getTotalMaxIO() != 0)
{
+ int totalMaxAIO = AsynchronousFileImpl.getTotalMaxIO();
AsynchronousFileImpl.resetMaxAIO();
- Assert.fail("test did not close all its files " + AsynchronousFileImpl.getTotalMaxIO());
+ Assert.fail("test did not close all its files " + totalMaxAIO);
}
// We shutdown the global pools to give a better isolation between tests
Deleted: branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/core/message/impl/MessagePropertyTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/core/message/impl/MessagePropertyTest.java 2011-10-07 12:25:45 UTC (rev 11495)
+++ branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/core/message/impl/MessagePropertyTest.java 2011-10-07 12:28:01 UTC (rev 11496)
@@ -1,110 +0,0 @@
-package org.hornetq.core.message.impl;
-
-import org.hornetq.api.core.SimpleString;
-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.ServerLocator;
-import org.hornetq.core.server.HornetQServer;
-import org.hornetq.tests.util.ServiceTestBase;
-
-public class MessagePropertyTest extends ServiceTestBase
-{
- private HornetQServer server;
- private ServerLocator locator;
- private ClientSessionFactory sf;
- private final int numMessages = 20;
-
- private static final String ADDRESS = "aAddress123";
- private static final SimpleString SIMPLE_STRING_KEY = new SimpleString("StringToSimpleString");
-
- @Override
- public void setUp() throws Exception
- {
- super.setUp();
- server = createServer(true);
- server.start();
- locator = createInVMNonHALocator();
- sf = locator.createSessionFactory();
- }
-
- @Override
- public void tearDown() throws Exception
- {
- try
- {
- sf.close();
- locator.close();
- server.stop();
- }
- finally
- {
- super.tearDown();
- }
- }
-
- private void sendMessages() throws Exception
- {
- ClientSession session = sf.createSession(true, true);
- session.createQueue(ADDRESS, ADDRESS, null, true);
- ClientProducer producer = session.createProducer(ADDRESS);
-
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage message = session.createMessage(true);
- setBody(i, message);
- message.putIntProperty("int", i);
- message.putShortProperty("short", (short)i);
- message.putByteProperty("byte", (byte)i);
- message.putFloatProperty("float", floatValue(i));
- message.putStringProperty(SIMPLE_STRING_KEY, new SimpleString(Integer.toString(i)));
- message.putBytesProperty("byte[]", byteArray(i));
- producer.send(message);
- }
- session.commit();
- }
-
- private float floatValue(int i)
- {
- return (float)(i * 1.3);
- }
-
- private byte[] byteArray(int i)
- {
- return new byte[] { (byte)i, (byte)(i / 2) };
- }
-
- public void testProperties() throws Exception
- {
- sendMessages();
- receiveMessages();
- }
-
-
- private void receiveMessages() throws Exception
- {
- ClientSession session = sf.createSession(true, true);
- session.start();
- ClientConsumer consumer = session.createConsumer(ADDRESS);
- for (int i = 0; i < numMessages; i++)
- {
- ClientMessage message = consumer.receive(100);
- assertNotNull("Expecting a message " + i, message);
- assertMessageBody(i, message);
- assertEquals(i, message.getIntProperty("int").intValue());
- assertEquals((short)i, message.getShortProperty("short").shortValue());
- assertEquals((byte)i, message.getByteProperty("byte").byteValue());
- assertEquals(floatValue(i), message.getFloatProperty("float").floatValue(), 0.001);
- assertEquals(new SimpleString(Integer.toString(i)),
- message.getSimpleStringProperty(SIMPLE_STRING_KEY.toString()));
- assertEqualsByteArrays(byteArray(i), message.getBytesProperty("byte[]"));
- message.acknowledge();
- }
- assertNull("no more messages", consumer.receive(50));
- consumer.close();
- session.commit();
- }
-
-}
Copied: branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/core/message/impl/MessagePropertyTest.java (from rev 11495, trunk/tests/integration-tests/src/test/java/org/hornetq/core/message/impl/MessagePropertyTest.java)
===================================================================
--- branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/core/message/impl/MessagePropertyTest.java (rev 0)
+++ branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/core/message/impl/MessagePropertyTest.java 2011-10-07 12:28:01 UTC (rev 11496)
@@ -0,0 +1,110 @@
+package org.hornetq.core.message.impl;
+
+import org.hornetq.api.core.SimpleString;
+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.ServerLocator;
+import org.hornetq.core.server.HornetQServer;
+import org.hornetq.tests.util.ServiceTestBase;
+
+public class MessagePropertyTest extends ServiceTestBase
+{
+ private HornetQServer server;
+ private ServerLocator locator;
+ private ClientSessionFactory sf;
+ private final int numMessages = 20;
+
+ private static final String ADDRESS = "aAddress123";
+ private static final SimpleString SIMPLE_STRING_KEY = new SimpleString("StringToSimpleString");
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ server = createServer(true);
+ server.start();
+ locator = createInVMNonHALocator();
+ sf = locator.createSessionFactory();
+ }
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ try
+ {
+ sf.close();
+ locator.close();
+ server.stop();
+ }
+ finally
+ {
+ super.tearDown();
+ }
+ }
+
+ private void sendMessages() throws Exception
+ {
+ ClientSession session = sf.createSession(true, true);
+ session.createQueue(ADDRESS, ADDRESS, null, true);
+ ClientProducer producer = session.createProducer(ADDRESS);
+
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage message = session.createMessage(true);
+ setBody(i, message);
+ message.putIntProperty("int", i);
+ message.putShortProperty("short", (short)i);
+ message.putByteProperty("byte", (byte)i);
+ message.putFloatProperty("float", floatValue(i));
+ message.putStringProperty(SIMPLE_STRING_KEY, new SimpleString(Integer.toString(i)));
+ message.putBytesProperty("byte[]", byteArray(i));
+ producer.send(message);
+ }
+ session.commit();
+ }
+
+ private float floatValue(int i)
+ {
+ return (float)(i * 1.3);
+ }
+
+ private byte[] byteArray(int i)
+ {
+ return new byte[] { (byte)i, (byte)(i / 2) };
+ }
+
+ public void testProperties() throws Exception
+ {
+ sendMessages();
+ receiveMessages();
+ }
+
+
+ private void receiveMessages() throws Exception
+ {
+ ClientSession session = sf.createSession(true, true);
+ session.start();
+ ClientConsumer consumer = session.createConsumer(ADDRESS);
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage message = consumer.receive(100);
+ assertNotNull("Expecting a message " + i, message);
+ assertMessageBody(i, message);
+ assertEquals(i, message.getIntProperty("int").intValue());
+ assertEquals((short)i, message.getShortProperty("short").shortValue());
+ assertEquals((byte)i, message.getByteProperty("byte").byteValue());
+ assertEquals(floatValue(i), message.getFloatProperty("float").floatValue(), 0.001);
+ assertEquals(new SimpleString(Integer.toString(i)),
+ message.getSimpleStringProperty(SIMPLE_STRING_KEY.toString()));
+ assertEqualsByteArrays(byteArray(i), message.getBytesProperty("byte[]"));
+ message.acknowledge();
+ }
+ assertNull("no more messages", consumer.receive(50));
+ consumer.close();
+ session.commit();
+ }
+
+}
Modified: branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java
===================================================================
--- branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java 2011-10-07 12:25:45 UTC (rev 11495)
+++ branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java 2011-10-07 12:28:01 UTC (rev 11496)
@@ -145,7 +145,7 @@
config0.setSecurityEnabled(false);
config0.setSharedStore(true);
config0.setClustered(true);
- List<String> pairs = null;
+ List<String> pairs = new ArrayList<String>();
for (int node : otherLiveNodes)
{
TransportConfiguration otherLiveConnector =
13 years, 2 months
JBoss hornetq SVN: r11495 - trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover.
by do-not-reply@jboss.org
Author: borges
Date: 2011-10-07 08:25:45 -0400 (Fri, 07 Oct 2011)
New Revision: 11495
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java
Log:
FIX NullPointerException in test
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java 2011-10-07 12:25:28 UTC (rev 11494)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java 2011-10-07 12:25:45 UTC (rev 11495)
@@ -64,7 +64,7 @@
ClientSession session = sendAndConsume(sf, true);
System.out.println("failing node 0");
servers.get(0).crash(session);
-
+
session.close();
backupNode = waitForNewLive(5, true, servers, 1, 2, 3, 4, 5);
session = sendAndConsume(sf, false);
@@ -97,7 +97,7 @@
locator.close();
}
-
+
protected void createBackupConfig(int liveNode, int nodeid, int... nodes)
{
Configuration config1 = super.createDefaultConfig();
@@ -137,12 +137,12 @@
config0.setSecurityEnabled(false);
config0.setSharedStore(true);
config0.setClustered(true);
- List<String> pairs = null;
+ List<String> pairs = new ArrayList<String>();
for (int node : otherLiveNodes)
{
TransportConfiguration otherLiveConnector = createTransportConfiguration(isNetty(), false, generateParams(node, isNetty()));
config0.getConnectorConfigurations().put(otherLiveConnector.getName(), otherLiveConnector);
- pairs.add(otherLiveConnector.getName());
+ pairs.add(otherLiveConnector.getName());
}
ClusterConnectionConfiguration ccc0 = new ClusterConnectionConfiguration("cluster1", "jms", liveConnector.getName(), -1, false, false, 1, 1,
13 years, 2 months
JBoss hornetq SVN: r11494 - in trunk: tests/integration-tests/src/test/java/org/hornetq and 3 other directories.
by do-not-reply@jboss.org
Author: borges
Date: 2011-10-07 08:25:28 -0400 (Fri, 07 Oct 2011)
New Revision: 11494
Added:
trunk/tests/integration-tests/src/test/java/org/hornetq/core/
trunk/tests/integration-tests/src/test/java/org/hornetq/core/message/
trunk/tests/integration-tests/src/test/java/org/hornetq/core/message/impl/
trunk/tests/integration-tests/src/test/java/org/hornetq/core/message/impl/MessagePropertyTest.java
Modified:
trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java
Log:
Add (rather trivial) unit-tests for all untested/unused calls in Message
Modified: trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java
===================================================================
--- trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java 2011-10-07 12:25:03 UTC (rev 11493)
+++ trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java 2011-10-07 12:25:28 UTC (rev 11494)
@@ -78,12 +78,12 @@
import org.hornetq.utils.UUIDGenerator;
/**
- *
- * Helper base class for our unit tests
- *
+ * Helper base class for our unit tests.
+ * <p>
+ * See {@code org.hornetq.tests.util.ServiceTestBase} for a test case with server set-up.
+ * @see Service
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
* @author <a href="mailto:csuconic@redhat.com">Clebert</a>
- *
*/
public abstract class UnitTestCase extends TestCase
{
Added: trunk/tests/integration-tests/src/test/java/org/hornetq/core/message/impl/MessagePropertyTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/core/message/impl/MessagePropertyTest.java (rev 0)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/core/message/impl/MessagePropertyTest.java 2011-10-07 12:25:28 UTC (rev 11494)
@@ -0,0 +1,110 @@
+package org.hornetq.core.message.impl;
+
+import org.hornetq.api.core.SimpleString;
+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.ServerLocator;
+import org.hornetq.core.server.HornetQServer;
+import org.hornetq.tests.util.ServiceTestBase;
+
+public class MessagePropertyTest extends ServiceTestBase
+{
+ private HornetQServer server;
+ private ServerLocator locator;
+ private ClientSessionFactory sf;
+ private final int numMessages = 20;
+
+ private static final String ADDRESS = "aAddress123";
+ private static final SimpleString SIMPLE_STRING_KEY = new SimpleString("StringToSimpleString");
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ server = createServer(true);
+ server.start();
+ locator = createInVMNonHALocator();
+ sf = locator.createSessionFactory();
+ }
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ try
+ {
+ sf.close();
+ locator.close();
+ server.stop();
+ }
+ finally
+ {
+ super.tearDown();
+ }
+ }
+
+ private void sendMessages() throws Exception
+ {
+ ClientSession session = sf.createSession(true, true);
+ session.createQueue(ADDRESS, ADDRESS, null, true);
+ ClientProducer producer = session.createProducer(ADDRESS);
+
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage message = session.createMessage(true);
+ setBody(i, message);
+ message.putIntProperty("int", i);
+ message.putShortProperty("short", (short)i);
+ message.putByteProperty("byte", (byte)i);
+ message.putFloatProperty("float", floatValue(i));
+ message.putStringProperty(SIMPLE_STRING_KEY, new SimpleString(Integer.toString(i)));
+ message.putBytesProperty("byte[]", byteArray(i));
+ producer.send(message);
+ }
+ session.commit();
+ }
+
+ private float floatValue(int i)
+ {
+ return (float)(i * 1.3);
+ }
+
+ private byte[] byteArray(int i)
+ {
+ return new byte[] { (byte)i, (byte)(i / 2) };
+ }
+
+ public void testProperties() throws Exception
+ {
+ sendMessages();
+ receiveMessages();
+ }
+
+
+ private void receiveMessages() throws Exception
+ {
+ ClientSession session = sf.createSession(true, true);
+ session.start();
+ ClientConsumer consumer = session.createConsumer(ADDRESS);
+ for (int i = 0; i < numMessages; i++)
+ {
+ ClientMessage message = consumer.receive(100);
+ assertNotNull("Expecting a message " + i, message);
+ assertMessageBody(i, message);
+ assertEquals(i, message.getIntProperty("int").intValue());
+ assertEquals((short)i, message.getShortProperty("short").shortValue());
+ assertEquals((byte)i, message.getByteProperty("byte").byteValue());
+ assertEquals(floatValue(i), message.getFloatProperty("float").floatValue(), 0.001);
+ assertEquals(new SimpleString(Integer.toString(i)),
+ message.getSimpleStringProperty(SIMPLE_STRING_KEY.toString()));
+ assertEqualsByteArrays(byteArray(i), message.getBytesProperty("byte[]"));
+ message.acknowledge();
+ }
+ assertNull("no more messages", consumer.receive(50));
+ consumer.close();
+ session.commit();
+ }
+
+}
13 years, 2 months
JBoss hornetq SVN: r11493 - trunk/hornetq-core/src/test/java/org/hornetq/tests/util.
by do-not-reply@jboss.org
Author: borges
Date: 2011-10-07 08:25:03 -0400 (Fri, 07 Oct 2011)
New Revision: 11493
Modified:
trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java
Log:
Add number of open files to failure message
Modified: trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java
===================================================================
--- trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java 2011-10-07 09:37:56 UTC (rev 11492)
+++ trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java 2011-10-07 12:25:03 UTC (rev 11493)
@@ -968,8 +968,9 @@
if (AsynchronousFileImpl.getTotalMaxIO() != 0)
{
+ int totalMaxAIO = AsynchronousFileImpl.getTotalMaxIO();
AsynchronousFileImpl.resetMaxAIO();
- Assert.fail("test did not close all its files " + AsynchronousFileImpl.getTotalMaxIO());
+ Assert.fail("test did not close all its files " + totalMaxAIO);
}
// We shutdown the global pools to give a better isolation between tests
13 years, 2 months