[jboss-cvs] JBoss Messaging SVN: r5387 - in trunk: src/main/org/jboss/messaging/core/client/impl and 55 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Nov 19 02:23:24 EST 2008
Author: clebert.suconic at jboss.com
Date: 2008-11-19 02:23:23 -0500 (Wed, 19 Nov 2008)
New Revision: 5387
Added:
trunk/src/main/org/jboss/messaging/core/client/FileClientMessage.java
trunk/src/main/org/jboss/messaging/core/client/impl/FileClientMessageImpl.java
trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalLargeMessageImpl.java
trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageLargeMessageImpl.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionSendChunkMessage.java
trunk/src/main/org/jboss/messaging/core/server/ServerLargeMessage.java
trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/
trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/ChunkTestBase.java
trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/MessageChunkTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/
trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/MockConnector.java
trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/MockConnectorFactory.java
trunk/tests/src/org/jboss/messaging/tests/soak/chunk/
trunk/tests/src/org/jboss/messaging/tests/soak/chunk/MessageChunkSoakTest.java
trunk/tests/src/org/jboss/messaging/tests/stress/chunk/
trunk/tests/src/org/jboss/messaging/tests/stress/chunk/MessageChunkStressTest.java
trunk/tests/src/org/jboss/messaging/tests/util/ServiceTestBase.java
Removed:
trunk/tests/src/org/jboss/messaging/tests/integration/base/IntegrationTestBase.java
trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/ChunkTestBase.java
trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/MessageChunkTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/
trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/MockConnector.java
trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/MockConnectorFactory.java
trunk/tests/src/org/jboss/messaging/tests/soak/chunk/MessageChunkSoakTest.java
trunk/tests/src/org/jboss/messaging/tests/stress/chunk/MessageChunkStressTest.java
Modified:
trunk/src/main/org/jboss/messaging/core/client/ClientConsumer.java
trunk/src/main/org/jboss/messaging/core/client/ClientMessage.java
trunk/src/main/org/jboss/messaging/core/client/ClientSession.java
trunk/src/main/org/jboss/messaging/core/client/ClientSessionFactory.java
trunk/src/main/org/jboss/messaging/core/client/impl/ClientConsumerImpl.java
trunk/src/main/org/jboss/messaging/core/client/impl/ClientConsumerInternal.java
trunk/src/main/org/jboss/messaging/core/client/impl/ClientMessageImpl.java
trunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java
trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java
trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java
trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionInternal.java
trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionPacketHandler.java
trunk/src/main/org/jboss/messaging/core/config/Configuration.java
trunk/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java
trunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java
trunk/src/main/org/jboss/messaging/core/exception/MessagingException.java
trunk/src/main/org/jboss/messaging/core/journal/SequentialFile.java
trunk/src/main/org/jboss/messaging/core/journal/SequentialFileFactory.java
trunk/src/main/org/jboss/messaging/core/journal/impl/AIOSequentialFile.java
trunk/src/main/org/jboss/messaging/core/journal/impl/AIOSequentialFileFactory.java
trunk/src/main/org/jboss/messaging/core/journal/impl/JournalFile.java
trunk/src/main/org/jboss/messaging/core/journal/impl/JournalFileImpl.java
trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java
trunk/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFile.java
trunk/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFileFactory.java
trunk/src/main/org/jboss/messaging/core/message/Message.java
trunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java
trunk/src/main/org/jboss/messaging/core/paging/PageMessage.java
trunk/src/main/org/jboss/messaging/core/paging/PagingManager.java
trunk/src/main/org/jboss/messaging/core/paging/impl/PageMessageImpl.java
trunk/src/main/org/jboss/messaging/core/paging/impl/PageTransactionInfoImpl.java
trunk/src/main/org/jboss/messaging/core/paging/impl/PagingManagerImpl.java
trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java
trunk/src/main/org/jboss/messaging/core/persistence/StorageManager.java
trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java
trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java
trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java
trunk/src/main/org/jboss/messaging/core/remoting/Packet.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateSessionMessage.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ReplicateCreateSessionMessage.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionReceiveMessage.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionSendMessage.java
trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java
trunk/src/main/org/jboss/messaging/core/server/Queue.java
trunk/src/main/org/jboss/messaging/core/server/ServerMessage.java
trunk/src/main/org/jboss/messaging/core/server/ServerSession.java
trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java
trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServiceImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/ServerMessageImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java
trunk/src/main/org/jboss/messaging/core/settings/impl/QueueSettings.java
trunk/src/main/org/jboss/messaging/core/transaction/impl/TransactionImpl.java
trunk/src/main/org/jboss/messaging/jms/client/JBossBytesMessage.java
trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java
trunk/src/main/org/jboss/messaging/jms/client/JBossMapMessage.java
trunk/src/main/org/jboss/messaging/jms/client/JBossMessage.java
trunk/src/main/org/jboss/messaging/jms/client/JBossObjectMessage.java
trunk/src/main/org/jboss/messaging/jms/client/JBossStreamMessage.java
trunk/src/main/org/jboss/messaging/jms/client/JBossTextMessage.java
trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java
trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerDeployer.java
trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java
trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java
trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java
trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/CTSMiscellaneousTest.java
trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTest.java
trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTestCase.java
trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/String64KLimitTest.java
trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
trunk/tests/src/org/jboss/messaging/tests/integration/clientcrash/ClientCrashTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReplicateConnectionFailureTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/JMSFailoverTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSQueueControlTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSUtil.java
trunk/tests/src/org/jboss/messaging/tests/integration/paging/PagingManagerIntegrationTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/remoting/DestroyConsumerTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/scheduling/ScheduledMessageTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/xa/BasicXaRecoveryTest.java
trunk/tests/src/org/jboss/messaging/tests/stress/paging/PageStressTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/ReclaimerTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PageImplTestBase.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PageManagerImplTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingStoreImplTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingStoreTestBase.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/persistence/impl/journal/JournalStorageManagerTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/PostOfficeImplTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/MessageReferenceImplTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueImplTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/ServerMessageImplTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/settings/impl/QueueSettingsTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/transaction/impl/TransactionImplTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/jms/client/JBossMessageConsumerTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/jms/client/JBossMessageTest.java
trunk/tests/src/org/jboss/messaging/tests/util/UnitTestCase.java
Log:
https://jira.jboss.org/jira/browse/JBMESSAGING-379 - Message Chunk and some other pieces
Modified: trunk/src/main/org/jboss/messaging/core/client/ClientConsumer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/ClientConsumer.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/client/ClientConsumer.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -18,10 +18,12 @@
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
+ */
package org.jboss.messaging.core.client;
+import java.io.File;
+
import org.jboss.messaging.core.exception.MessagingException;
/**
@@ -30,20 +32,23 @@
* @author <a href="mailto:ataylor at redhat.com">Andy Taylor</a>
*/
public interface ClientConsumer
-{
- ClientMessage receive() throws MessagingException;
-
+{
+ ClientMessage receive() throws MessagingException;
+
ClientMessage receive(long timeout) throws MessagingException;
-
+
ClientMessage receiveImmediate() throws MessagingException;
-
+
MessageHandler getMessageHandler() throws MessagingException;
void setMessageHandler(MessageHandler handler) throws MessagingException;
-
+
void close() throws MessagingException;
boolean isClosed();
+
+ boolean isFileConsumer();
+
Exception getLastException();
}
Modified: trunk/src/main/org/jboss/messaging/core/client/ClientMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/ClientMessage.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/client/ClientMessage.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -44,4 +44,8 @@
void onReceipt(ClientConsumerInternal consumer);
void acknowledge() throws MessagingException;
+
+ void setLargeMessage(boolean largeMessage);
+
+ boolean isLargeMessage();
}
Modified: trunk/src/main/org/jboss/messaging/core/client/ClientSession.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/ClientSession.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/client/ClientSession.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -22,6 +22,8 @@
package org.jboss.messaging.core.client;
+import java.io.File;
+
import javax.transaction.xa.XAResource;
import org.jboss.messaging.core.exception.MessagingException;
@@ -64,11 +66,27 @@
ClientConsumer createConsumer(SimpleString queueName, SimpleString filterString, boolean browseOnly) throws MessagingException;
ClientConsumer createConsumer(SimpleString queueName,
- SimpleString filterString,
+ SimpleString filterString,
int windowSize,
int maxRate,
boolean browseOnly) throws MessagingException;
+ ClientConsumer createFileConsumer(File directory, SimpleString queueName) throws MessagingException;
+
+ ClientConsumer createFileConsumer(File directory, SimpleString queueName, SimpleString filterString) throws MessagingException;
+
+ ClientConsumer createFileConsumer(File directory,
+ SimpleString queueName,
+ SimpleString filterString,
+ boolean browseOnly) throws MessagingException;
+
+ ClientConsumer createFileConsumer(File directory,
+ SimpleString queueName,
+ SimpleString filterString,
+ int windowSize,
+ int maxRate,
+ boolean browseOnly) throws MessagingException;
+
ClientProducer createProducer(SimpleString address) throws MessagingException;
ClientProducer createProducer(SimpleString address,
@@ -106,6 +124,8 @@
ClientMessage createClientMessage(final boolean durable);
+ FileClientMessage createFileMessage(final boolean durable);
+
void start() throws MessagingException;
void stop() throws MessagingException;
Modified: trunk/src/main/org/jboss/messaging/core/client/ClientSessionFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/ClientSessionFactory.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/client/ClientSessionFactory.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -61,6 +61,10 @@
int getProducerMaxRate();
+ int getMinLargeMessageSize();
+
+ void setMinLargeMessageSize(final int minLargeMessageSize);
+
boolean isBlockOnPersistentSend();
void setBlockOnPersistentSend(final boolean blocking);
Copied: trunk/src/main/org/jboss/messaging/core/client/FileClientMessage.java (from rev 5358, branches/Branch_Chunk_3/src/main/org/jboss/messaging/core/client/FileClientMessage.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/FileClientMessage.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/client/FileClientMessage.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.core.client;
+
+import java.io.File;
+import java.nio.channels.FileChannel;
+
+import org.jboss.messaging.core.exception.MessagingException;
+
+/**
+ * A FileClientMessage
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ * Created Oct 14, 2008 3:21:15 PM
+ *
+ *
+ */
+public interface FileClientMessage extends ClientMessage
+{
+ File getFile();
+
+ void setFile(File file);
+
+ FileChannel getChannel() throws MessagingException;
+
+ void closeChannel() throws MessagingException;
+
+
+}
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientConsumerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientConsumerImpl.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientConsumerImpl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -12,17 +12,24 @@
package org.jboss.messaging.core.client.impl;
+import java.io.File;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
import java.util.LinkedList;
import java.util.Queue;
import java.util.concurrent.Executor;
import org.jboss.messaging.core.client.ClientMessage;
+import org.jboss.messaging.core.client.FileClientMessage;
import org.jboss.messaging.core.client.MessageHandler;
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.remoting.Channel;
+import org.jboss.messaging.core.remoting.impl.ByteBufferWrapper;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionConsumerCloseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionConsumerFlowCreditMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendChunkMessage;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
import org.jboss.messaging.util.Future;
/**
@@ -62,7 +69,12 @@
private final Queue<ClientMessage> buffer = new LinkedList<ClientMessage>();
private final Runner runner = new Runner();
+
+ private File directory;
+ private ClientMessage currentChunkMessage;
+
+
private volatile Thread receiverThread;
private volatile Thread onMessageThread;
@@ -89,7 +101,8 @@
final int clientWindowSize,
final int ackBatchSize,
final Executor executor,
- final Channel channel)
+ final Channel channel,
+ final File directory)
{
this.id = id;
@@ -102,6 +115,8 @@
this.clientWindowSize = clientWindowSize;
this.ackBatchSize = ackBatchSize;
+
+ this.directory = directory;
}
// ClientConsumer implementation
@@ -169,7 +184,11 @@
{
boolean expired = m.isExpired();
- flowControl(m.getEncodeSize());
+ // Chunk messages will execute the flow control while receiving the chunks
+ if (!m.isLargeMessage())
+ {
+ flowControl(m.getEncodeSize());
+ }
if (expired)
{
@@ -199,6 +218,31 @@
}
}
+
+ public ClientMessage createFileMessage(MessagingBuffer propertiesBuffer) throws Exception
+ {
+ if (isFileConsumer())
+ {
+ if (!this.directory.exists())
+ {
+ directory.mkdirs();
+ }
+
+ FileClientMessageImpl message = new FileClientMessageImpl();
+ message.decodeProperties(propertiesBuffer);
+ message.setFile(new File(this.directory, message.getMessageID() + "-" + this.session.getName() + "-" + this.getID() + ".jbm"));
+ message.setLargeMessage(true);
+ return message;
+ }
+ else
+ {
+ ClientMessageImpl message = new ClientMessageImpl();
+ message.decodeProperties(propertiesBuffer);
+ message.setLargeMessage(true);
+ return message;
+ }
+ }
+
public ClientMessage receive() throws MessagingException
{
return receive(0);
@@ -264,6 +308,14 @@
return closed;
}
+ /* (non-Javadoc)
+ * @see org.jboss.messaging.core.client.ClientConsumer#isLargeMessagesAsFiles()
+ */
+ public boolean isFileConsumer()
+ {
+ return directory != null;
+ }
+
public Exception getLastException()
{
return lastException;
@@ -284,26 +336,101 @@
// This is ok - we just ignore the message
return;
}
+
+ ClientMessage messageToHandle = message;
+
+
+ if (isFileConsumer())
+ {
+ messageToHandle = cloneAsFileMessage(message);
+ }
- message.onReceipt(this);
+ messageToHandle.onReceipt(this);
if (handler != null)
{
// Execute using executor
- buffer.add(message);
+ buffer.add(messageToHandle);
queueExecutor();
}
else
{
// Add it to the buffer
- buffer.add(message);
+ buffer.add(messageToHandle);
notify();
}
}
+ public void handleChunk(SessionSendChunkMessage chunk) throws Exception
+ {
+ if (closed)
+ {
+ return;
+ }
+
+ flowControl(chunk.getBody().length);
+
+ if (chunk.getHeader() != null)
+ {
+
+ // The Header only comes on the first message, so a buffer has to be created on the client
+ // to hold either a file or a big message
+ MessagingBuffer header = new ByteBufferWrapper(ByteBuffer.wrap(chunk.getHeader()));
+
+ currentChunkMessage = createFileMessage(header);
+
+ if (currentChunkMessage instanceof FileClientMessage)
+ {
+ FileClientMessage fileMessage = (FileClientMessage)currentChunkMessage;
+ addBytesBody(fileMessage, chunk.getBody());
+ }
+ else
+ {
+ MessagingBuffer initialBody = new ByteBufferWrapper(ByteBuffer.wrap(chunk.getBody()));
+ currentChunkMessage.setBody(initialBody);
+ }
+ }
+ else
+ {
+ // No header.. this is then a continuation of a previous message
+ ByteBuffer body = ByteBuffer.wrap(chunk.getBody());
+
+ if (currentChunkMessage instanceof FileClientMessage)
+ {
+ FileClientMessage fileMessage = (FileClientMessage)currentChunkMessage;
+ addBytesBody(fileMessage, chunk.getBody());
+ }
+ else
+ {
+ MessagingBuffer currentBody = currentChunkMessage.getBody();
+
+ MessagingBuffer newBody = new ByteBufferWrapper(ByteBuffer.allocate(currentBody.limit() + body.limit()));
+
+ newBody.putBytes(currentBody.array());
+ newBody.putBytes(body.array());
+
+ currentChunkMessage.setBody(newBody);
+ }
+ }
+
+ if (!chunk.isContinues())
+ {
+ // Close the file that was being generated
+ if (currentChunkMessage instanceof FileClientMessage)
+ {
+ ((FileClientMessage)currentChunkMessage).closeChannel();
+ }
+ ClientMessage msgToSend = currentChunkMessage;
+ currentChunkMessage = null;
+ handleMessage(msgToSend);
+ }
+
+ }
+
+
public void clear()
{
synchronized (this)
@@ -427,6 +554,7 @@
// ordering. If we just added a Runnable with the message to the executor immediately as we get it
// we could not do that
+
ClientMessage message;
// Must store handler in local variable since might get set to null
@@ -515,6 +643,44 @@
}
+ private FileClientMessage cloneAsFileMessage(ClientMessage message) throws Exception
+ {
+ int propertiesSize = message.getPropertiesEncodeSize();
+ MessagingBuffer bufferProperties = message.getBody().createNewBuffer(propertiesSize);
+
+ // FIXME: Find a better way to clone this ClientMessageImpl as FileClientMessageImpl without using the MessagingBuffer.
+ // There is no direct access into the Properties, and I couldn't add a direct cast to this method without loose abstraction
+ message.encodeProperties(bufferProperties);
+
+ bufferProperties.rewind();
+
+ FileClientMessageImpl cloneMessage = new FileClientMessageImpl();
+
+ cloneMessage.decodeProperties(bufferProperties);
+
+ cloneMessage.setDeliveryCount(message.getDeliveryCount());
+
+ cloneMessage.setLargeMessage(message.isLargeMessage());
+
+ cloneMessage.setFile(new File(this.directory, cloneMessage.getMessageID() + "-" + this.session.getName() + "-" + this.getID() + ".jbm"));
+
+ addBytesBody(cloneMessage, message.getBody().array());
+
+ cloneMessage.closeChannel();
+
+
+ return cloneMessage;
+ }
+
+
+
+
+ private void addBytesBody(FileClientMessage fileMessage, byte[] body) throws Exception
+ {
+ FileChannel channel = fileMessage.getChannel();
+ channel.write(ByteBuffer.wrap(body));
+ }
+
// Inner classes
// --------------------------------------------------------------------------------
@@ -534,4 +700,5 @@
}
}
}
+
}
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientConsumerInternal.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientConsumerInternal.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientConsumerInternal.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -25,6 +25,8 @@
import org.jboss.messaging.core.client.ClientConsumer;
import org.jboss.messaging.core.client.ClientMessage;
import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendChunkMessage;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
/**
*
@@ -38,6 +40,8 @@
long getID();
void handleMessage(ClientMessage message) throws Exception;
+
+ void handleChunk(SessionSendChunkMessage chunk) throws Exception;
void clear();
@@ -49,6 +53,8 @@
void cleanUp() throws Exception;
+ ClientMessage createFileMessage(MessagingBuffer propertiesBuffer) throws Exception;
+
void acknowledge(ClientMessage message) throws MessagingException;
void flushAcks() throws MessagingException;
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientMessageImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientMessageImpl.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientMessageImpl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -18,12 +18,13 @@
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
+ */
package org.jboss.messaging.core.client.impl;
import org.jboss.messaging.core.client.ClientMessage;
import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.message.Message;
import org.jboss.messaging.core.message.impl.MessageImpl;
import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
@@ -38,58 +39,64 @@
public class ClientMessageImpl extends MessageImpl implements ClientMessage
{
private int deliveryCount;
-
+
private ClientConsumerInternal consumer;
-
+
+ private boolean largeMessage;
+
+
/*
* Constructor for when reading from network
*/
public ClientMessageImpl(final int deliveryCount)
- {
+ {
super();
-
+
this.deliveryCount = deliveryCount;
}
-
+
/*
* Construct messages before sending
*/
- public ClientMessageImpl(final byte type, final boolean durable, final long expiration,
- final long timestamp, final byte priority, MessagingBuffer body)
+ public ClientMessageImpl(final byte type,
+ final boolean durable,
+ final long expiration,
+ final long timestamp,
+ final byte priority,
+ MessagingBuffer body)
{
super(type, durable, expiration, timestamp, priority, body);
}
-
+
public ClientMessageImpl(final byte type, final boolean durable, MessagingBuffer body)
{
super(type, durable, 0, System.currentTimeMillis(), (byte)4, body);
}
-
+
public ClientMessageImpl(final boolean durable, MessagingBuffer body)
{
- super((byte) 0, durable, 0, System.currentTimeMillis(), (byte)4, body);
+ super((byte)0, durable, 0, System.currentTimeMillis(), (byte)4, body);
}
-
- /* Only used in testing */
+
public ClientMessageImpl()
- {
+ {
}
-
+
public void onReceipt(final ClientConsumerInternal consumer)
{
this.consumer = consumer;
}
-
+
public void setDeliveryCount(final int deliveryCount)
{
this.deliveryCount = deliveryCount;
}
-
+
public int getDeliveryCount()
{
return this.deliveryCount;
}
-
+
public void acknowledge() throws MessagingException
{
if (consumer != null)
@@ -97,4 +104,21 @@
consumer.acknowledge(this);
}
}
+
+ /**
+ * @return the largeMessage
+ */
+ public boolean isLargeMessage()
+ {
+ return largeMessage;
+ }
+
+ /**
+ * @param largeMessage the largeMessage to set
+ */
+ public void setLargeMessage(boolean largeMessage)
+ {
+ this.largeMessage = largeMessage;
+ }
+
}
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -1,25 +1,40 @@
/*
- * JBoss, Home of Professional Open Source Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors by
- * the @authors tag. See the copyright.txt in the distribution for a full listing of individual contributors. This is
- * free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
- * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- * details. You should have received a copy of the GNU Lesser General Public License along with this software; if not,
- * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
- * site: http://www.fsf.org.
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.messaging.core.client.impl;
+import java.nio.ByteBuffer;
+
import org.jboss.messaging.core.client.AcknowledgementHandler;
-import org.jboss.messaging.core.client.ClientMessage;
+import org.jboss.messaging.core.client.FileClientMessage;
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.message.Message;
import org.jboss.messaging.core.message.impl.MessageImpl;
import org.jboss.messaging.core.remoting.Channel;
+import org.jboss.messaging.core.remoting.impl.ByteBufferWrapper;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendChunkMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendMessage;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
import org.jboss.messaging.util.SimpleString;
import org.jboss.messaging.util.TokenBucketLimiter;
import org.jboss.messaging.util.UUIDGenerator;
@@ -59,6 +74,8 @@
private final boolean blockOnPersistentSend;
private final SimpleString groupID;
+
+ private final int minLargeMessageSize;
// Static ---------------------------------------------------------------------------------------
@@ -70,6 +87,7 @@
final boolean blockOnNonPersistentSend,
final boolean blockOnPersistentSend,
final boolean autoGroup,
+ final int minLargeMessageSize,
final Channel channel)
{
this.channel = channel;
@@ -92,6 +110,9 @@
{
this.groupID = null;
}
+
+ this.minLargeMessageSize = minLargeMessageSize;
+
}
// ClientProducer implementation ----------------------------------------------------------------
@@ -207,6 +228,11 @@
SessionSendMessage message = new SessionSendMessage(msg, sendBlocking);
+ if (msg.getEncodeSize() > minLargeMessageSize)
+ {
+ sendMessageInChunks(true, msg);
+ }
+ else
if (sendBlocking)
{
channel.sendBlocking(message);
@@ -217,6 +243,79 @@
}
}
+ /**
+ * @param msg
+ * @throws MessagingException
+ */
+ private void sendMessageInChunks(final boolean sendBlocking, final Message msg) throws MessagingException
+ {
+ int headerSize = msg.getPropertiesEncodeSize();
+
+ if (headerSize > minLargeMessageSize)
+ {
+ throw new MessagingException(MessagingException.ILLEGAL_STATE,
+ "Header size is too big, use the messageBody for large data");
+ }
+
+ MessagingBuffer headerBuffer = new ByteBufferWrapper(ByteBuffer.allocate(headerSize));
+ msg.encodeProperties(headerBuffer);
+
+ final int bodySize = msg.getBodySize();
+
+ int bodyLength = minLargeMessageSize - headerSize;
+
+ MessagingBuffer bodyBuffer = new ByteBufferWrapper(ByteBuffer.allocate(bodyLength));
+
+ msg.encodeBody(bodyBuffer, 0, bodyLength);
+
+ SessionSendChunkMessage chunk = new SessionSendChunkMessage(-1,
+ headerBuffer.array(),
+ bodyBuffer.array(),
+ bodyLength < bodySize,
+ sendBlocking);
+
+ if (sendBlocking)
+ {
+ channel.sendBlocking(chunk);
+ }
+ else
+ {
+ channel.send(chunk);
+ }
+
+ for (int pos = bodyLength; pos < bodySize;)
+ {
+ bodyLength = Math.min(bodySize - pos, minLargeMessageSize);
+ bodyBuffer = new ByteBufferWrapper(ByteBuffer.allocate(bodyLength));
+
+ msg.encodeBody(bodyBuffer, pos, bodyLength);
+
+ chunk = new SessionSendChunkMessage(-1, null, bodyBuffer.array(), pos + bodyLength < bodySize, sendBlocking);
+
+ if (sendBlocking)
+ {
+ channel.sendBlocking(chunk);
+ }
+ else
+ {
+ channel.send(chunk);
+ }
+
+ pos += bodyLength;
+ }
+
+ if (msg instanceof FileClientMessage)
+ {
+ try
+ {
+ ((FileClientMessage)msg).closeChannel();
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ }
+
private void checkClosed() throws MessagingException
{
if (closed)
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -29,6 +29,7 @@
import org.jboss.messaging.core.remoting.Packet;
import org.jboss.messaging.core.remoting.RemotingConnection;
import org.jboss.messaging.core.remoting.impl.ConnectionManagerImpl;
+import org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory;
import org.jboss.messaging.core.remoting.impl.wireformat.CreateSessionMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.CreateSessionResponseMessage;
import org.jboss.messaging.core.remoting.spi.ConnectorFactory;
@@ -57,6 +58,9 @@
public static final long DEFAULT_PING_PERIOD = 5000;
+ // Any message beyond this size is considered a big message (to be chunked)
+ public static final int DEFAULT_BIG_MESSAGE_SIZE = 100 * 1024;
+
public static final int DEFAULT_CONSUMER_WINDOW_SIZE = 1024 * 1024;
public static final int DEFAULT_CONSUMER_MAX_RATE = -1;
@@ -102,6 +106,8 @@
private volatile ConnectionManager connectionManager;
private volatile ConnectionManager backupConnectionManager;
+
+ private volatile int minLargeMessageSize;
private volatile int consumerWindowSize;
@@ -149,6 +155,7 @@
final int consumerMaxRate,
final int sendWindowSize,
final int producerMaxRate,
+ final int minLargeMessageSize,
final boolean blockOnAcknowledge,
final boolean blockOnNonPersistentSend,
final boolean blockOnPersistentSend,
@@ -194,6 +201,7 @@
this.blockOnAcknowledge = blockOnAcknowledge;
this.blockOnNonPersistentSend = blockOnNonPersistentSend;
this.blockOnPersistentSend = blockOnPersistentSend;
+ this.minLargeMessageSize = minLargeMessageSize;
this.autoGroup = autoGroup;
this.maxConnections = maxConnections;
this.ackBatchSize = ackBatchSize;
@@ -210,13 +218,13 @@
DEFAULT_CONSUMER_MAX_RATE,
DEFAULT_SEND_WINDOW_SIZE,
DEFAULT_PRODUCER_MAX_RATE,
+ DEFAULT_BIG_MESSAGE_SIZE,
DEFAULT_BLOCK_ON_ACKNOWLEDGE,
DEFAULT_BLOCK_ON_PERSISTENT_SEND,
DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
DEFAULT_AUTO_GROUP,
DEFAULT_MAX_CONNECTIONS,
DEFAULT_ACK_BATCH_SIZE);
-
}
/**
@@ -372,6 +380,22 @@
return maxConnections;
}
+ /**
+ * @return the minLargeMessageSize
+ */
+ public int getMinLargeMessageSize()
+ {
+ return minLargeMessageSize;
+ }
+
+ /**
+ * @param minLargeMessageSize the minLargeMessageSize to set
+ */
+ public void setMinLargeMessageSize(int minLargeMessageSize)
+ {
+ this.minLargeMessageSize = minLargeMessageSize;
+ }
+
// ClientSessionFactoryInternal implementation
// ------------------------------------------
@@ -580,6 +604,7 @@
clientVersion.getIncrementingVersion(),
username,
password,
+ minLargeMessageSize,
xa,
autoCommitSends,
autoCommitAcks,
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -21,6 +21,7 @@
*/
package org.jboss.messaging.core.client.impl;
+import java.io.File;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -36,6 +37,7 @@
import org.jboss.messaging.core.client.ClientConsumer;
import org.jboss.messaging.core.client.ClientMessage;
import org.jboss.messaging.core.client.ClientProducer;
+import org.jboss.messaging.core.client.FileClientMessage;
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.remoting.Channel;
@@ -59,6 +61,7 @@
import org.jboss.messaging.core.remoting.impl.wireformat.SessionQueueQueryMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionQueueQueryResponseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionRemoveDestinationMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendChunkMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXACommitMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAEndMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAForgetMessage;
@@ -205,7 +208,12 @@
{
checkClosed();
- SessionCreateQueueMessage request = new SessionCreateQueueMessage(address, queueName, filterString, durable, temp, fanout);
+ SessionCreateQueueMessage request = new SessionCreateQueueMessage(address,
+ queueName,
+ filterString,
+ durable,
+ temp,
+ fanout);
channel.sendBlocking(request);
}
@@ -300,56 +308,59 @@
final int maxRate,
final boolean browseOnly) throws MessagingException
{
+ return internalCreateConsumer(queueName, filterString, windowSize, browseOnly, null);
+ }
+
+ public ClientConsumer createFileConsumer(final File directory, final SimpleString queueName) throws MessagingException
+ {
checkClosed();
- SessionCreateConsumerMessage request = new SessionCreateConsumerMessage(queueName, filterString, browseOnly);
+ return createFileConsumer(directory, queueName, null, false);
+ }
- channel.sendBlocking(request);
+ public ClientConsumer createFileConsumer(final File directory,
+ final SimpleString queueName,
+ final SimpleString filterString) throws MessagingException
+ {
+ checkClosed();
- // The actual windows size that gets used is determined by the user since
- // could be overridden on the queue settings
- // The value we send is just a hint
+ return createFileConsumer(directory,
+ queueName,
+ filterString,
+ sessionFactory.getConsumerWindowSize(),
+ sessionFactory.getConsumerMaxRate(),
+ false);
+ }
- int clientWindowSize;
- if (windowSize == -1)
- {
- // No flow control - buffer can increase without bound! Only use with
- // caution for very fast consumers
- clientWindowSize = -1;
- }
- else if (windowSize == 1)
- {
- // Slow consumer - no buffering
- clientWindowSize = 1;
- }
- else if (windowSize > 1)
- {
- // Client window size is half server window size
- clientWindowSize = windowSize >> 1;
- }
- else
- {
- throw new IllegalArgumentException("Invalid window size " + windowSize);
- }
+ public ClientConsumer createFileConsumer(final File directory,
+ final SimpleString queueName,
+ final SimpleString filterString,
+ final boolean browseOnly) throws MessagingException
+ {
+ return createFileConsumer(directory,
+ queueName,
+ filterString,
+ sessionFactory.getConsumerWindowSize(),
+ sessionFactory.getConsumerMaxRate(),
+ browseOnly);
+ }
- long consumerID = idGenerator.generateID();
-
- ClientConsumerInternal consumer = new ClientConsumerImpl(this,
- consumerID,
- clientWindowSize,
- ackBatchSize,
- executor,
- channel);
-
- addConsumer(consumer);
-
- // Now we send window size credits to start the consumption
- // We even send it if windowSize == -1, since we need to start the
- // consumer
-
- channel.send(new SessionConsumerFlowCreditMessage(consumerID, windowSize));
-
- return consumer;
+ /*
+ * Note, we DO NOT currently support direct consumers (i.e. consumers we're delivery occurs on the remoting thread.
+ * Direct consumers have issues with blocking and failover.
+ * E.g. if direct then inside MessageHandler call a blocking method like rollback or acknowledge (blocking)
+ * This can block until failove completes, which disallows the thread to be used to deliver any responses to the client
+ * during that period, so failover won't occur.
+ * If we want direct consumers we need to rethink how they work
+ */
+ public ClientConsumer createFileConsumer(final File directory,
+ final SimpleString queueName,
+ final SimpleString filterString,
+ final int windowSize,
+ final int maxRate,
+ final boolean browseOnly) throws MessagingException
+ {
+ return internalCreateConsumer(queueName, filterString, windowSize, browseOnly, directory);
}
public ClientProducer createProducer(final SimpleString address) throws MessagingException
@@ -381,6 +392,7 @@
autoCommitSends && blockOnNonPersistentSend,
autoCommitSends && blockOnPersistentSend,
autoGroup,
+ sessionFactory.getMinLargeMessageSize(),
channel);
addProducer(producer);
@@ -459,6 +471,11 @@
return new ClientMessageImpl(durable, body);
}
+ public FileClientMessage createFileMessage(final boolean durable)
+ {
+ return new FileClientMessageImpl(durable);
+ }
+
public boolean isClosed()
{
return closed;
@@ -587,6 +604,17 @@
}
}
+ public void handleReceiveChunk(final long consumerID, final SessionSendChunkMessage chunk) throws Exception
+ {
+ ClientConsumerInternal consumer = consumers.get(consumerID);
+
+ if (consumer != null)
+ {
+ consumer.handleChunk(chunk);
+ }
+
+ }
+
public void close() throws MessagingException
{
if (closed)
@@ -988,6 +1016,73 @@
// Private
// ----------------------------------------------------------------------------
+ /**
+ * @param queueName
+ * @param filterString
+ * @param windowSize
+ * @param browseOnly
+ * @return
+ * @throws MessagingException
+ */
+ private ClientConsumer internalCreateConsumer(final SimpleString queueName,
+ final SimpleString filterString,
+ final int windowSize,
+ final boolean browseOnly,
+ final File directory) throws MessagingException
+ {
+ checkClosed();
+
+ SessionCreateConsumerMessage request = new SessionCreateConsumerMessage(queueName, filterString, browseOnly);
+
+ channel.sendBlocking(request);
+
+ // The actual windows size that gets used is determined by the user since
+ // could be overridden on the queue settings
+ // The value we send is just a hint
+
+ int clientWindowSize;
+ if (windowSize == -1)
+ {
+ // No flow control - buffer can increase without bound! Only use with
+ // caution for very fast consumers
+ clientWindowSize = -1;
+ }
+ else if (windowSize == 1)
+ {
+ // Slow consumer - no buffering
+ clientWindowSize = 1;
+ }
+ else if (windowSize > 1)
+ {
+ // Client window size is half server window size
+ clientWindowSize = windowSize >> 1;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Invalid window size " + windowSize);
+ }
+
+ long consumerID = idGenerator.generateID();
+
+ ClientConsumerInternal consumer = new ClientConsumerImpl(this,
+ consumerID,
+ clientWindowSize,
+ ackBatchSize,
+ executor,
+ channel,
+ directory);
+
+ addConsumer(consumer);
+
+ // Now we send window size credits to start the consumption
+ // We even send it if windowSize == -1, since we need to start the
+ // consumer
+
+ channel.send(new SessionConsumerFlowCreditMessage(consumerID, windowSize));
+
+ return consumer;
+ }
+
private void checkXA() throws XAException
{
if (!xa)
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionInternal.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionInternal.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionInternal.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -16,6 +16,7 @@
import org.jboss.messaging.core.client.ClientSession;
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.remoting.RemotingConnection;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendChunkMessage;
/**
* A ClientSessionInternal
@@ -39,6 +40,8 @@
void removeProducer(ClientProducerInternal producer);
void handleReceiveMessage(long consumerID, ClientMessage message) throws Exception;
+
+ void handleReceiveChunk(long consumerID, SessionSendChunkMessage chunk) throws Exception;
void handleFailover();
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionPacketHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionPacketHandler.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionPacketHandler.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -23,6 +23,7 @@
package org.jboss.messaging.core.client.impl;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.EXCEPTION;
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_CHUNK_SEND;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_RECEIVE_MSG;
import org.jboss.messaging.core.logging.Logger;
@@ -31,6 +32,7 @@
import org.jboss.messaging.core.remoting.Packet;
import org.jboss.messaging.core.remoting.impl.wireformat.MessagingExceptionMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionReceiveMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendChunkMessage;
/**
*
@@ -48,20 +50,27 @@
private final Channel channel;
public ClientSessionPacketHandler(final ClientSessionInternal clientSesssion, final Channel channel)
- {
+ {
this.clientSession = clientSesssion;
this.channel = channel;
}
-
+
public void handlePacket(final Packet packet)
{
byte type = packet.getType();
-
+
try
{
switch (type)
{
+ case SESS_CHUNK_SEND:
+ {
+ SessionSendChunkMessage chunk = (SessionSendChunkMessage)packet;
+ clientSession.handleReceiveChunk(chunk.getTargetID(), chunk);
+
+ break;
+ }
case SESS_RECEIVE_MSG:
{
SessionReceiveMessage message = (SessionReceiveMessage) packet;
Copied: trunk/src/main/org/jboss/messaging/core/client/impl/FileClientMessageImpl.java (from rev 5358, branches/Branch_Chunk_3/src/main/org/jboss/messaging/core/client/impl/FileClientMessageImpl.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/FileClientMessageImpl.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/FileClientMessageImpl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -0,0 +1,256 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.core.client.impl;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
+
+import org.jboss.messaging.core.client.ClientMessage;
+import org.jboss.messaging.core.client.FileClientMessage;
+import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.message.Message;
+import org.jboss.messaging.core.remoting.impl.ByteBufferWrapper;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+
+/**
+ * A FileClientMessageImpl
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ * Created Oct 13, 2008 4:33:56 PM
+ *
+ *
+ */
+public class FileClientMessageImpl extends ClientMessageImpl implements FileClientMessage
+{
+
+ File file;
+
+ FileChannel currentChannel;
+
+ /**
+ *
+ */
+ public FileClientMessageImpl()
+ {
+ super();
+ }
+
+ public FileClientMessageImpl(final boolean durable)
+ {
+ super(durable, null);
+ }
+
+ /**
+ * @param type
+ * @param durable
+ * @param expiration
+ * @param timestamp
+ * @param priority
+ * @param body
+ */
+ public FileClientMessageImpl(final byte type,
+ final boolean durable,
+ final long expiration,
+ final long timestamp,
+ final byte priority,
+ final MessagingBuffer body)
+ {
+ super(type, durable, expiration, timestamp, priority, body);
+ }
+
+ /**
+ * @param type
+ * @param durable
+ * @param body
+ */
+ public FileClientMessageImpl(final byte type, final boolean durable, final MessagingBuffer body)
+ {
+ super(type, durable, body);
+ }
+
+ /**
+ * @param deliveryCount
+ */
+ public FileClientMessageImpl(final int deliveryCount)
+ {
+ super(deliveryCount);
+ }
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ /**
+ * @return the file
+ */
+ public File getFile()
+ {
+ return file;
+ }
+
+ /**
+ * @param file the file to set
+ */
+ public void setFile(final File file)
+ {
+ this.file = file;
+ }
+
+ @Override
+ public MessagingBuffer getBody()
+ {
+ // TODO: Throw an unsuported exception. (Make sure no tests are using this method first)
+
+ FileChannel channel = null;
+ try
+ {
+ // We open a new channel on getBody.
+ // for a better performance, users should be using the channels when using file
+ channel = newChannel();
+
+ ByteBuffer buffer = ByteBuffer.allocate((int)channel.size());
+
+ channel.position(0);
+ channel.read(buffer);
+
+ return new ByteBufferWrapper(buffer);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ try
+ {
+ channel.close();
+ }
+ catch (Throwable ignored)
+ {
+
+ }
+ }
+ }
+
+ @Override
+ public synchronized void encodeBody(final MessagingBuffer buffer, final long start, final int size)
+ {
+ try
+ {
+ FileChannel channel = getChannel();
+
+ ByteBuffer bufferRead = ByteBuffer.allocate(size);
+
+ channel.position(start);
+ channel.read(bufferRead);
+
+ buffer.putBytes(bufferRead.array());
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+
+ }
+
+ @Override
+ public void setBody(final MessagingBuffer body)
+ {
+
+ throw new RuntimeException("Not supported");
+ }
+
+ public synchronized FileChannel getChannel() throws MessagingException
+ {
+ if (currentChannel == null)
+ {
+ currentChannel = newChannel();
+ }
+
+ return currentChannel;
+ }
+
+ public synchronized void closeChannel() throws MessagingException
+ {
+ if (currentChannel != null)
+ {
+ try
+ {
+ currentChannel.close();
+ }
+ catch (IOException e)
+ {
+ throw new MessagingException(MessagingException.INTERNAL_ERROR, e.getMessage(), e);
+ }
+ currentChannel = null;
+ }
+
+ }
+
+ @Override
+ public synchronized int getBodySize()
+ {
+ return (int)file.length();
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ /**
+ * @return
+ * @throws FileNotFoundException
+ * @throws IOException
+ */
+ private FileChannel newChannel() throws MessagingException
+ {
+ try
+ {
+ RandomAccessFile randomFile = new RandomAccessFile(getFile(), "rw");
+ randomFile.seek(0);
+
+ FileChannel channel = randomFile.getChannel();
+ return channel;
+ }
+ catch (IOException e)
+ {
+ throw new MessagingException(MessagingException.INTERNAL_ERROR, e.getMessage(), e);
+ }
+ }
+
+ // Inner classes -------------------------------------------------
+
+}
Modified: trunk/src/main/org/jboss/messaging/core/config/Configuration.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/config/Configuration.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/config/Configuration.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -41,8 +41,7 @@
*/
public interface Configuration extends Serializable
{
- // General attributes
- // -------------------------------------------------------------------
+ // General attributes -------------------------------------------------------------------
boolean isClustered();
@@ -108,9 +107,9 @@
void setManagementAddress(SimpleString address);
- // Journal related attributes
- // ------------------------------------------------------------
+ // Journal related attributes ------------------------------------------------------------
+
String getBindingsDirectory();
void setBindingsDirectory(String dir);
@@ -119,10 +118,6 @@
void setJournalDirectory(String dir);
- String getPagingDirectory();
-
- void setPagingDirectory(String dir);
-
JournalType getJournalType();
void setJournalType(JournalType type);
@@ -159,9 +154,26 @@
void setCreateJournalDir(boolean create);
+
+ // Paging Properties --------------------------------------------------------------------
+
+ String getPagingDirectory();
+
+ void setPagingDirectory(String dir);
+
long getPagingMaxGlobalSizeBytes();
void setPagingMaxGlobalSizeBytes(long maxGlobalSize);
+
+ long getPagingDefaultSize();
+
+ void setPagingDefaultSize(long pageSize);
+
+ // Large Messages Properties ------------------------------------------------------------
+
+ String getLargeMessagesDirectory();
+
+ void setLargeMessagesDirectory(String directory);
boolean isWildcardRoutingEnabled();
Modified: trunk/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -60,6 +60,10 @@
public static final String DEFAULT_JOURNAL_DIR = "data/journal";
public static final String DEFAULT_PAGING_DIR = "data/paging";
+
+ public static final long DEFAULT_DEFAULT_PAGE_SIZE = 10 * 1024 * 1024;
+
+ public static final String DEFAULT_LARGEMESSAGES_DIR = "data/largemessages";
public static final boolean DEFAULT_CREATE_JOURNAL_DIR = true;
@@ -127,15 +131,19 @@
protected Set<DiscoveryGroupConfiguration> discoveryGroupConfigurations = new HashSet<DiscoveryGroupConfiguration>();
-
- // Paging related attributes
+ // Paging related attributes ------------------------------------------------------------
protected long pagingMaxGlobalSize = -1;
+
+ protected long pagingDefaultSize = DEFAULT_DEFAULT_PAGE_SIZE;
protected String pagingDirectory = DEFAULT_PAGING_DIR;
+
- // Journal related attributes
+ // File related attributes -----------------------------------------------------------
+ protected String largeMessagesDirectory = DEFAULT_LARGEMESSAGES_DIR;
+
protected String bindingsDirectory = DEFAULT_BINDINGS_DIRECTORY;
protected boolean createBindingsDir = DEFAULT_CREATE_BINDINGS_DIR;
@@ -478,7 +486,35 @@
{
pagingMaxGlobalSize = maxGlobalSize;
}
+
+ /* (non-Javadoc)
+ * @see org.jboss.messaging.core.config.Configuration#getPagingDefaultSize()
+ */
+ public long getPagingDefaultSize()
+ {
+ return pagingDefaultSize;
+ }
+ /* (non-Javadoc)
+ * @see org.jboss.messaging.core.config.Configuration#setPagingDefaultSize(long)
+ */
+ public void setPagingDefaultSize(long pageSize)
+ {
+ this.pagingDefaultSize = pageSize;
+ }
+
+
+ public String getLargeMessagesDirectory()
+ {
+ return largeMessagesDirectory;
+ }
+
+ public void setLargeMessagesDirectory(final String directory)
+ {
+ this.largeMessagesDirectory = directory;
+ }
+
+
public boolean isMessageCounterEnabled()
{
return messageCounterEnabled;
@@ -517,6 +553,7 @@
cother.isRequireDestinations() == isRequireDestinations() &&
cother.isSecurityEnabled() == isSecurityEnabled() &&
cother.isWildcardRoutingEnabled() == isWildcardRoutingEnabled() &&
+ cother.getLargeMessagesDirectory().equals(getLargeMessagesDirectory()) &&
cother.getBindingsDirectory().equals(getBindingsDirectory()) &&
cother.getJournalDirectory().equals(getJournalDirectory()) &&
cother.getJournalFileSize() == getJournalFileSize() &&
@@ -525,9 +562,13 @@
cother.getJournalType() == getJournalType() &&
cother.getScheduledThreadPoolMaxSize() == getScheduledThreadPoolMaxSize() &&
cother.getSecurityInvalidationInterval() == getSecurityInvalidationInterval() &&
- cother.getManagementAddress().equals(getManagementAddress());
+ cother.getManagementAddress().equals(getManagementAddress()) &&
+ cother.getPagingDefaultSize() == getPagingDefaultSize();
}
+
+
+
}
Modified: trunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -174,6 +174,8 @@
// Persistence config
+ largeMessagesDirectory = getString(e, "large-messages-directory", largeMessagesDirectory);
+
bindingsDirectory = getString(e, "bindings-directory", bindingsDirectory);
createBindingsDir = getBoolean(e, "create-bindings-dir", createBindingsDir);
@@ -183,6 +185,8 @@
pagingDirectory = getString(e, "paging-directory", pagingDirectory);
pagingMaxGlobalSize = getLong(e, "paging-max-global-size-bytes", pagingMaxGlobalSize);
+
+ pagingDefaultSize = getLong(e, "paging-default-size", pagingDefaultSize);
createJournalDir = getBoolean(e, "create-journal-dir", createJournalDir);
Modified: trunk/src/main/org/jboss/messaging/core/exception/MessagingException.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/exception/MessagingException.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/exception/MessagingException.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -84,6 +84,13 @@
this.code = code;
}
+ public MessagingException(int code, String msg, Throwable cause)
+ {
+ super(msg, cause);
+
+ this.code = code;
+ }
+
public int getCode()
{
return code;
Modified: trunk/src/main/org/jboss/messaging/core/journal/SequentialFile.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/journal/SequentialFile.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/journal/SequentialFile.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -38,6 +38,8 @@
* Creates the file if it doesn't already exist, then opens it
*/
void open() throws Exception;
+
+ boolean isOpen();
/**
* For certain operations (like loading) we don't need open the file with full maxIO
@@ -66,14 +68,16 @@
int read(ByteBuffer bytes) throws Exception;
- void position(int pos) throws Exception;
+ void position(long pos) throws Exception;
- int position() throws Exception;
+ long position() throws Exception;
void close() throws Exception;
void sync() throws Exception;
long size() throws Exception;
+
+ void renameTo(SequentialFile file) throws Exception;
}
Modified: trunk/src/main/org/jboss/messaging/core/journal/SequentialFileFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/journal/SequentialFileFactory.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/journal/SequentialFileFactory.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -35,7 +35,7 @@
*/
public interface SequentialFileFactory
{
- SequentialFile createSequentialFile(String fileName, int maxIO) throws Exception;
+ SequentialFile createSequentialFile(String fileName, int maxIO);
List<String> listFiles(String extension) throws Exception;
Modified: trunk/src/main/org/jboss/messaging/core/journal/impl/AIOSequentialFile.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/journal/impl/AIOSequentialFile.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/journal/impl/AIOSequentialFile.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -67,13 +67,18 @@
// AIO using a single thread.
private ExecutorService executor;
- public AIOSequentialFile(final String journalDir, final String fileName, final int maxIO) throws Exception
+ public AIOSequentialFile(final String journalDir, final String fileName, final int maxIO)
{
this.journalDir = journalDir;
this.fileName = fileName;
this.maxIO = maxIO;
}
+ public boolean isOpen()
+ {
+ return opened;
+ }
+
public int getAlignment() throws Exception
{
checkOpened();
@@ -174,6 +179,14 @@
open(maxIO);
}
+ /* (non-Javadoc)
+ * @see org.jboss.messaging.core.journal.SequentialFile#renameTo(org.jboss.messaging.core.journal.SequentialFile)
+ */
+ public void renameTo(SequentialFile file) throws Exception
+ {
+ throw new IllegalStateException ("method rename not supported on AIO");
+
+ }
public synchronized void open(final int currentMaxIO) throws Exception
{
opened = true;
@@ -189,14 +202,14 @@
aioFile.setBufferCallback(callback);
}
- public void position(final int pos) throws Exception
+ public void position(final long pos) throws Exception
{
position.set(pos);
}
- public int position() throws Exception
+ public long position() throws Exception
{
- return (int)position.get();
+ return position.get();
}
public int read(final ByteBuffer bytes, final IOCallback callback) throws Exception
@@ -363,4 +376,5 @@
return;
}
}
+
}
Modified: trunk/src/main/org/jboss/messaging/core/journal/impl/AIOSequentialFileFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/journal/impl/AIOSequentialFileFactory.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/journal/impl/AIOSequentialFileFactory.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -41,7 +41,7 @@
super(journalDir);
}
- public SequentialFile createSequentialFile(final String fileName, final int maxIO) throws Exception
+ public SequentialFile createSequentialFile(final String fileName, final int maxIO)
{
return new AIOSequentialFile(journalDir, fileName, maxIO);
}
Modified: trunk/src/main/org/jboss/messaging/core/journal/impl/JournalFile.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/journal/impl/JournalFile.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/journal/impl/JournalFile.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -51,11 +51,11 @@
void extendOffset(final int delta);
- int getOffset();
+ long getOffset();
int getOrderingID();
- void setOffset(final int offset);
+ void setOffset(final long offset);
SequentialFile getFile();
}
Modified: trunk/src/main/org/jboss/messaging/core/journal/impl/JournalFileImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/journal/impl/JournalFileImpl.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/journal/impl/JournalFileImpl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -46,7 +46,7 @@
private final int orderingID;
- private int offset;
+ private long offset;
private final AtomicInteger posCount = new AtomicInteger(0);
@@ -110,7 +110,7 @@
offset += delta;
}
- public int getOffset()
+ public long getOffset()
{
return offset;
}
@@ -120,7 +120,7 @@
return orderingID;
}
- public void setOffset(final int offset)
+ public void setOffset(final long offset)
{
this.offset = offset;
}
Modified: trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -801,8 +801,6 @@
int lastDataPos = SIZE_HEADER;
- long maxTransactionID = -1;
-
long maxID = -1;
for (JournalFile file : orderedFiles)
@@ -879,8 +877,6 @@
}
transactionID = bb.getLong();
-
- maxTransactionID = Math.max(maxTransactionID, transactionID);
}
long recordID = 0;
Modified: trunk/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFile.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFile.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFile.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -43,11 +43,6 @@
public class NIOSequentialFile implements SequentialFile
{
private static final Logger log = Logger.getLogger(NIOSequentialFile.class);
-
- private final String journalDir;
-
- private final String fileName;
-
private File file;
private FileChannel channel;
@@ -58,9 +53,7 @@
public NIOSequentialFile(final String journalDir, final String fileName)
{
- this.journalDir = journalDir;
-
- this.fileName = fileName;
+ this.file = new File(journalDir + "/" + fileName);
}
public int getAlignment()
@@ -75,13 +68,16 @@
public String getFileName()
{
- return fileName;
+ return file.getName();
}
+
+ public synchronized boolean isOpen()
+ {
+ return channel != null;
+ }
public synchronized void open() throws Exception
{
- file = new File(journalDir + "/" + fileName);
-
rfile = new RandomAccessFile(file, "rw");
channel = rfile.getChannel();
@@ -119,22 +115,29 @@
public void close() throws Exception
{
- channel.close();
+ if (channel != null)
+ {
+ channel.close();
+ }
- rfile.close();
+ if (rfile != null)
+ {
+ rfile.close();
+ }
channel = null;
rfile = null;
-
- file = null;
}
public void delete() throws Exception
{
+ if (isOpen())
+ {
+ close();
+ }
+
file.delete();
-
- close();
}
public int read(final ByteBuffer bytes) throws Exception
@@ -207,7 +210,8 @@
throw e;
}
}
-
+
+
public void sync() throws Exception
{
channel.force(false);
@@ -218,14 +222,30 @@
return channel.size();
}
- public void position(final int pos) throws Exception
+ public void position(final long pos) throws Exception
{
channel.position(pos);
}
- public int position() throws Exception
+ public long position() throws Exception
{
- return (int)channel.position();
+ return channel.position();
}
+ public void renameTo(SequentialFile newFile) throws Exception
+ {
+ close();
+ this.file.renameTo(((NIOSequentialFile)newFile).file);
+ file = ((NIOSequentialFile)newFile).file;
+ }
+
+
+
+ public String toString()
+ {
+ return "NIOSequentialFile " + this.file;
+ }
+
+
+
}
Modified: trunk/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFileFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFileFactory.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFileFactory.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -40,6 +40,11 @@
public NIOSequentialFileFactory(final String journalDir)
{
super(journalDir);
+
+ if (journalDir == null)
+ {
+ new Exception ("journalDir is null").printStackTrace();
+ }
}
// maxIO is ignored on NIO
Modified: trunk/src/main/org/jboss/messaging/core/message/Message.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/message/Message.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/message/Message.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -73,6 +73,26 @@
void decode(MessagingBuffer buffer);
+
+ int getPropertiesEncodeSize();
+
+ void encodeProperties(MessagingBuffer buffer);
+
+ void decodeProperties(MessagingBuffer buffer);
+
+
+ int getBodySize();
+
+
+ // Used on Message chunk
+ void encodeBody(MessagingBuffer buffer, long start, int size);
+
+ void encodeBody(MessagingBuffer buffer);
+
+ void decodeBody(MessagingBuffer buffer);
+
+
+
// Properties
// ------------------------------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -18,7 +18,7 @@
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
+ */
package org.jboss.messaging.core.message.impl;
@@ -59,17 +59,17 @@
public static final SimpleString HDR_ACTUAL_EXPIRY_TIME = new SimpleString("JBM_ACTUAL_EXPIRY");
public static final SimpleString HDR_ORIGIN_QUEUE = new SimpleString("JBM_ORIG_DESTINATION");
-
+
public static final SimpleString HDR_ORIG_MESSAGE_ID = new SimpleString("JBM_ORIG_MESSAGE_ID");
public static final SimpleString HDR_GROUP_ID = new SimpleString("JBM_GROUP_ID");
-
+
public static final SimpleString HDR_SCHEDULED_DELIVERY_TIME = new SimpleString("JBM_SCHED_DELIVERY");
// Attributes ----------------------------------------------------
protected long messageID;
-
+
private SimpleString destination;
private byte type;
@@ -91,7 +91,7 @@
protected MessageImpl()
{
- this.properties = new TypedProperties();
+ properties = new TypedProperties();
}
/**
@@ -103,8 +103,12 @@
* @param priority
* @param body
*/
- protected MessageImpl(final byte type, final boolean durable, final long expiration,
- final long timestamp, final byte priority, MessagingBuffer body)
+ protected MessageImpl(final byte type,
+ final boolean durable,
+ final long expiration,
+ final long timestamp,
+ final byte priority,
+ final MessagingBuffer body)
{
this();
this.type = type;
@@ -132,6 +136,7 @@
this.body = other.body;
}
+
protected MessageImpl(final long messageID)
{
this();
@@ -140,34 +145,67 @@
// Message implementation ----------------------------------------
- public void encode(MessagingBuffer buff)
+ public void encode(final MessagingBuffer buffer)
{
- buff.putLong(messageID);
- buff.putSimpleString(destination);
- buff.putByte(type);
- buff.putBoolean(durable);
- buff.putLong(expiration);
- buff.putLong(timestamp);
- buff.putByte(priority);
- properties.encode(buff);
- buff.putInt(body.limit());
- buff.putBytes(body.array(), 0, body.limit());
+ encodeProperties(buffer);
+ buffer.putInt(getBodySize());
+ encodeBody(buffer);
}
public int getEncodeSize()
{
- return SIZE_LONG + /* Destination */ SimpleString.sizeofString(destination) +
- /* Type */ SIZE_BYTE +
- /* Durable */ SIZE_BOOLEAN +
- /* Expiration */ SIZE_LONG +
- /* Timestamp */ SIZE_LONG +
- /* Priority */ SIZE_BYTE +
- /* PropertySize and Properties */ properties.getEncodeSize() +
- /* BodySize and Body */ SIZE_INT + body.limit();
+ return getPropertiesEncodeSize() + SIZE_INT + getBodySize();
}
+ public int getPropertiesEncodeSize()
+ {
+ return SIZE_LONG + /* Destination */SimpleString.sizeofString(destination) +
+ /* Type */SIZE_BYTE +
+ /* Durable */SIZE_BOOLEAN +
+ /* Expiration */SIZE_LONG +
+ /* Timestamp */SIZE_LONG +
+ /* Priority */SIZE_BYTE +
+ /* PropertySize and Properties */properties.getEncodeSize();
+ }
+
+ public int getBodySize()
+ {
+ return /* BodySize and Body */body.limit();
+ }
+
+ public void encodeProperties(MessagingBuffer buffer)
+ {
+ buffer.putLong(messageID);
+ buffer.putSimpleString(destination);
+ buffer.putByte(type);
+ buffer.putBoolean(durable);
+ buffer.putLong(expiration);
+ buffer.putLong(timestamp);
+ buffer.putByte(priority);
+ properties.encode(buffer);
+ }
+
+ public void encodeBody(MessagingBuffer buffer)
+ {
+ MessagingBuffer localBody = getBody();
+ buffer.putBytes(localBody.array(), 0, localBody.limit());
+ }
+
+ // Used on Message chunk
+ public void encodeBody(MessagingBuffer buffer, long start, int size)
+ {
+ buffer.putBytes(body.array(), (int)start, size);
+ }
+
public void decode(final MessagingBuffer buffer)
{
+ decodeProperties(buffer);
+
+ decodeBody(buffer);
+ }
+
+ public void decodeProperties(final MessagingBuffer buffer)
+ {
messageID = buffer.getLong();
destination = buffer.getSimpleString();
type = buffer.getByte();
@@ -175,32 +213,37 @@
expiration = buffer.getLong();
timestamp = buffer.getLong();
priority = buffer.getByte();
+ properties.decode(buffer);
+ }
- properties.decode(buffer);
+ public void decodeBody(final MessagingBuffer buffer)
+ {
int len = buffer.getInt();
-
- //TODO - this can be optimised
+ // TODO - this can be optimised
byte[] bytes = new byte[len];
buffer.getBytes(bytes);
+ // body = new ByteBufferWrapper(ByteBuffer.wrap(bytes));
+ // body.position(body.limit());
body = buffer.createNewBuffer(len);
- body.putBytes(bytes);
+ body.putBytes(bytes);
+
}
-
+
public long getMessageID()
{
return messageID;
}
-
+
public SimpleString getDestination()
{
return destination;
}
-
- public void setDestination(SimpleString destination)
+
+ public void setDestination(final SimpleString destination)
{
this.destination = destination;
}
-
+
public byte getType()
{
return type;
@@ -210,7 +253,7 @@
{
return durable;
}
-
+
public void setDurable(final boolean durable)
{
this.durable = durable;
@@ -230,12 +273,12 @@
{
return timestamp;
}
-
+
public void setTimestamp(final long timestamp)
{
this.timestamp = timestamp;
}
-
+
public byte getPriority()
{
return priority;
@@ -245,105 +288,110 @@
{
this.priority = priority;
}
-
+
public boolean isExpired()
{
if (expiration == 0)
{
return false;
}
-
+
return System.currentTimeMillis() - expiration >= 0;
}
-
- // Properties
+
+ // Properties
// ---------------------------------------------------------------------------------------
-
+
public void putBooleanProperty(final SimpleString key, final boolean value)
{
properties.putBooleanProperty(key, value);
}
-
+
public void putByteProperty(final SimpleString key, final byte value)
{
properties.putByteProperty(key, value);
}
-
+
public void putBytesProperty(final SimpleString key, final byte[] value)
{
properties.putBytesProperty(key, value);
}
-
+
public void putShortProperty(final SimpleString key, final short value)
{
properties.putShortProperty(key, value);
}
-
+
public void putIntProperty(final SimpleString key, final int value)
{
properties.putIntProperty(key, value);
}
-
+
public void putLongProperty(final SimpleString key, final long value)
{
properties.putLongProperty(key, value);
}
-
+
public void putFloatProperty(final SimpleString key, final float value)
{
properties.putFloatProperty(key, value);
}
-
+
public void putDoubleProperty(final SimpleString key, final double value)
{
properties.putDoubleProperty(key, value);
}
-
+
public void putStringProperty(final SimpleString key, final SimpleString value)
{
properties.putStringProperty(key, value);
}
-
+
public Object getProperty(final SimpleString key)
{
return properties.getProperty(key);
- }
-
+ }
+
public Object removeProperty(final SimpleString key)
{
return properties.removeProperty(key);
}
-
+
public boolean containsProperty(final SimpleString key)
{
return properties.containsProperty(key);
}
-
+
public Set<SimpleString> getPropertyNames()
{
return properties.getPropertyNames();
}
-
+
// Body
// -------------------------------------------------------------------------------------
-
+
public MessagingBuffer getBody()
{
return body;
}
-
+
public void setBody(final MessagingBuffer body)
{
this.body = body;
}
-
+
// Public --------------------------------------------------------
-
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
+ protected TypedProperties getProperties()
+ {
+ return this.properties;
+ }
+
// Private -------------------------------------------------------
- // Inner classes -------------------------------------------------
+ // Inner classes -------------------------------------------------
}
Modified: trunk/src/main/org/jboss/messaging/core/paging/PageMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/paging/PageMessage.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/paging/PageMessage.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -23,6 +23,7 @@
package org.jboss.messaging.core.paging;
import org.jboss.messaging.core.journal.EncodingSupport;
+import org.jboss.messaging.core.persistence.StorageManager;
import org.jboss.messaging.core.server.ServerMessage;
/**
@@ -35,7 +36,7 @@
*/
public interface PageMessage extends EncodingSupport
{
- ServerMessage getMessage();
+ ServerMessage getMessage(StorageManager storageManager);
long getTransactionID();
}
Modified: trunk/src/main/org/jboss/messaging/core/paging/PagingManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/paging/PagingManager.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/paging/PagingManager.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -63,6 +63,13 @@
/** During startup PostOffice may set GlobalPageMode as true */
void setGlobalPageMode(boolean globalMode);
+ /**
+ * @param destination
+ * @return
+ * @throws Exception
+ */
+ PagingStore createPageStore(SimpleString destination) throws Exception;
+
/** To return the PageStore associated with the address */
PagingStore getPageStore(SimpleString address) throws Exception;
@@ -128,4 +135,9 @@
* @throws Exception
* */
void clearLastPageRecord(LastPageRecord lastRecord) throws Exception;
+ /**
+ * @return
+ */
+ long getDefaultPageSize();
+
}
Modified: trunk/src/main/org/jboss/messaging/core/paging/impl/PageMessageImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/paging/impl/PageMessageImpl.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/paging/impl/PageMessageImpl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -22,8 +22,13 @@
package org.jboss.messaging.core.paging.impl;
+import java.nio.ByteBuffer;
+
import org.jboss.messaging.core.paging.PageMessage;
+import org.jboss.messaging.core.persistence.StorageManager;
+import org.jboss.messaging.core.remoting.impl.ByteBufferWrapper;
import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+import org.jboss.messaging.core.server.ServerLargeMessage;
import org.jboss.messaging.core.server.ServerMessage;
import org.jboss.messaging.core.server.impl.ServerMessageImpl;
import org.jboss.messaging.util.DataConstants;
@@ -49,7 +54,10 @@
// Public --------------------------------------------------------
- private final ServerMessage message;
+ /** Large messages will need to be instatiated lazily during getMessage when the StorageManager is available */
+ private byte[] largeMessageLazyData;
+
+ private ServerMessage message;
private long transactionID = -1;
@@ -69,8 +77,15 @@
this(new ServerMessageImpl());
}
- public ServerMessage getMessage()
+ public ServerMessage getMessage(StorageManager storage)
{
+ if (this.largeMessageLazyData != null)
+ {
+ this.message = storage.createLargeMessageStorage();
+ MessagingBuffer buffer = new ByteBufferWrapper(ByteBuffer.wrap(largeMessageLazyData));
+ message.decode(buffer);
+ largeMessageLazyData = null;
+ }
return message;
}
@@ -84,18 +99,40 @@
public void decode(final MessagingBuffer buffer)
{
transactionID = buffer.getLong();
- message.decode(buffer);
+
+ boolean isLargeMessage = buffer.getBoolean();
+
+ if (isLargeMessage)
+ {
+ int largeMessageHeaderSize = buffer.getInt();
+
+ this.largeMessageLazyData = new byte[largeMessageHeaderSize];
+
+ buffer.getBytes(largeMessageLazyData);
+
+ }
+ else
+ {
+ buffer.getInt(); // This value is only used on LargeMessages for now
+ message = new ServerMessageImpl();
+ message.decode(buffer);
+ }
+
}
public void encode(final MessagingBuffer buffer)
{
buffer.putLong(transactionID);
+ buffer.putBoolean(message instanceof ServerLargeMessage);
+ buffer.putInt(message.getEncodeSize());
message.encode(buffer);
}
public int getEncodeSize()
{
- return DataConstants.SIZE_LONG + message.getEncodeSize();
+ return DataConstants.SIZE_LONG + DataConstants.SIZE_BYTE +
+ DataConstants.SIZE_INT +
+ message.getEncodeSize();
}
// Package protected ---------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/core/paging/impl/PageTransactionInfoImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/paging/impl/PageTransactionInfoImpl.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/paging/impl/PageTransactionInfoImpl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -130,13 +130,13 @@
{
complete = true;
/**
- * this is to avoid a race condition where the transaction still being committed another thread is depaging messages
+ * this is to avoid a race condition where the transaction still being committed while another thread is depaging messages
*/
countDownCompleted.countDown();
}
/**
- * this is to avoid a race condition where the transaction still being committed another thread is depaging messages
+ * this is to avoid a race condition where the transaction still being committed while another thread is depaging messages
*/
public boolean waitCompletion() throws InterruptedException
{
Modified: trunk/src/main/org/jboss/messaging/core/paging/impl/PagingManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/paging/impl/PagingManagerImpl.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/paging/impl/PagingManagerImpl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -58,7 +58,6 @@
{
// Constants -----------------------------------------------------
- private static final long WATERMARK_GLOBAL_PAGE = QueueSettings.DEFAULT_PAGE_SIZE_BYTES;
// Attributes ----------------------------------------------------
@@ -80,6 +79,8 @@
private final StorageManager storageManager;
+ private final long defaultPageSize;
+
private PostOffice postOffice;
private final ConcurrentMap</*TransactionID*/Long, PageTransactionInfo> transactions = new ConcurrentHashMap<Long, PageTransactionInfo>();
@@ -107,11 +108,13 @@
public PagingManagerImpl(final PagingStoreFactory pagingSPI,
final StorageManager storageManager,
final HierarchicalRepository<QueueSettings> queueSettingsRepository,
- final long maxGlobalSize)
+ final long maxGlobalSize,
+ final long defaultPageSize)
{
this.pagingSPI = pagingSPI;
this.queueSettingsRepository = queueSettingsRepository;
this.storageManager = storageManager;
+ this.defaultPageSize = defaultPageSize;
this.maxGlobalSize = maxGlobalSize;
}
@@ -131,8 +134,11 @@
this.globalMode.set(globalMode);
}
- // Synchronization of this method is done per ConcurrentHashMap
- public PagingStore getPageStore(final SimpleString storeName) throws Exception
+ /**
+ * @param destination
+ * @return
+ */
+ public synchronized PagingStore createPageStore(SimpleString storeName) throws Exception
{
PagingStore store = stores.get(storeName);
@@ -153,6 +159,20 @@
return store;
}
+
+
+ public PagingStore getPageStore(final SimpleString storeName) throws Exception
+ {
+ PagingStore store = stores.get(storeName);
+
+ if (store == null)
+ {
+ throw new IllegalStateException("Store " + storeName + " not found on paging");
+ }
+
+ return store;
+ }
+
/** this will be set by the postOffice itself.
* There is no way to set this on the constructor as the PagingManager is constructed before the postOffice.
* (There is a one-to-one relationship here) */
@@ -209,6 +229,10 @@
for (PageMessage msg : data)
{
+ ServerMessage pagedMessage = null;
+
+ pagedMessage = (ServerMessage)msg.getMessage(storageManager);
+
final long transactionIdDuringPaging = msg.getTransactionID();
if (transactionIdDuringPaging >= 0)
{
@@ -221,7 +245,7 @@
{
if (isTrace)
{
- trace("Transaction " + msg.getTransactionID() + " not found, ignoring message " + msg.getMessage());
+ trace("Transaction " + msg.getTransactionID() + " not found, ignoring message " + pagedMessage);
}
continue;
}
@@ -230,23 +254,23 @@
// before the commit arrived
if (!pageTransactionInfo.waitCompletion())
{
- trace("Rollback was called after prepare, ignoring message " + msg.getMessage());
+ trace("Rollback was called after prepare, ignoring message " + pagedMessage);
continue;
}
// / Update information about transactions
- if (msg.getMessage().isDurable())
+ if (pagedMessage.isDurable())
{
pageTransactionInfo.decrement();
pageTransactionsToUpdate.add(pageTransactionInfo);
}
}
- refsToAdd.addAll(postOffice.route(msg.getMessage()));
+ refsToAdd.addAll(postOffice.route(pagedMessage));
- if (msg.getMessage().getDurableRefCount() != 0)
+ if (pagedMessage.getDurableRefCount() != 0)
{
- storageManager.storeMessageTransactional(depageTransactionID, msg.getMessage());
+ storageManager.storeMessageTransactional(depageTransactionID, pagedMessage);
}
}
@@ -276,7 +300,8 @@
if (globalMode.get())
{
- return globalSize.get() < maxGlobalSize - WATERMARK_GLOBAL_PAGE && pagingStore.getMaxSizeBytes() <= 0 ||
+ // We use the Default Page Size when in global mode for the calculation of the Watermark
+ return globalSize.get() < maxGlobalSize - defaultPageSize && pagingStore.getMaxSizeBytes() <= 0 ||
pagingStore.getAddressSize() < pagingStore.getMaxSizeBytes();
}
else
@@ -288,6 +313,11 @@
}
+ public long getDefaultPageSize()
+ {
+ return defaultPageSize;
+ }
+
public void setLastPage(final LastPageRecord lastPage) throws Exception
{
trace("LastPage loaded was " + lastPage.getLastId() + " recordID = " + lastPage.getRecordId());
@@ -429,8 +459,22 @@
{
// When in Global mode, we use the default page size as the minimal
// watermark to start depage
- if (globalMode.get() && currentGlobalSize < maxGlobalSize - QueueSettings.DEFAULT_PAGE_SIZE_BYTES)
+
+ if (isTrace)
{
+ log.trace("globalMode.get = " + globalMode.get() +
+ " currentGlobalSize = " +
+ currentGlobalSize +
+ " defaultPageSize = " +
+ defaultPageSize +
+ " maxGlobalSize = " +
+ maxGlobalSize +
+ "maxGlobalSize - defaultPageSize = " +
+ (maxGlobalSize - defaultPageSize));
+ }
+
+ if (globalMode.get() && currentGlobalSize < maxGlobalSize - defaultPageSize)
+ {
startGlobalDepage();
}
else if (maxSize > 0 && addressSize < maxSize - pageSize)
Modified: trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -33,6 +33,7 @@
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
+import org.jboss.messaging.core.config.impl.ConfigurationImpl;
import org.jboss.messaging.core.journal.SequentialFile;
import org.jboss.messaging.core.journal.SequentialFileFactory;
import org.jboss.messaging.core.logging.Logger;
@@ -74,7 +75,7 @@
private final boolean dropMessagesOnSize;
private boolean droppedMessages;
-
+
private final PagingManager pagingManager;
private final ExecutorService executor;
@@ -115,7 +116,18 @@
this.fileFactory = fileFactory;
this.storeName = storeName;
maxSize = queueSettings.getMaxSizeBytes();
- pageSize = queueSettings.getPageSizeBytes();
+ if (queueSettings.getPageSizeBytes() != null)
+ {
+ this.pageSize = queueSettings.getPageSizeBytes();
+ }
+ else if (pagingManager != null)
+ {
+ this.pageSize = pagingManager.getDefaultPageSize();
+ }
+ else
+ {
+ this.pageSize = ConfigurationImpl.DEFAULT_DEFAULT_PAGE_SIZE;
+ }
dropMessagesOnSize = queueSettings.isDropMessagesWhenFull();
this.executor = executor;
this.pagingManager = pagingManager;
Modified: trunk/src/main/org/jboss/messaging/core/persistence/StorageManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/persistence/StorageManager.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/persistence/StorageManager.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -35,6 +35,7 @@
import org.jboss.messaging.core.server.MessagingComponent;
import org.jboss.messaging.core.server.Queue;
import org.jboss.messaging.core.server.QueueFactory;
+import org.jboss.messaging.core.server.ServerLargeMessage;
import org.jboss.messaging.core.server.ServerMessage;
import org.jboss.messaging.core.transaction.ResourceManager;
import org.jboss.messaging.util.SimpleString;
@@ -73,6 +74,9 @@
void updateScheduledDeliveryTimeTransactional(long txID, MessageReference ref) throws Exception;
void storeDeleteMessageTransactional(long txID, long queueID, long messageID) throws Exception;
+
+ /** Create an area that will get LargeMessage bytes on the server size*/
+ ServerLargeMessage createLargeMessageStorage();
void prepare(long txID, Xid xid) throws Exception;
Copied: trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalLargeMessageImpl.java (from rev 5358, branches/Branch_Chunk_3/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalServerLargeMessageImpl.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalLargeMessageImpl.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalLargeMessageImpl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -0,0 +1,250 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.core.persistence.impl.journal;
+
+import java.nio.ByteBuffer;
+
+import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.journal.SequentialFile;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+import org.jboss.messaging.core.server.ServerLargeMessage;
+import org.jboss.messaging.core.server.impl.ServerMessageImpl;
+
+/**
+ * A ServerLargeMessageImpl
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ * Created 30-Sep-08 12:02:45 PM
+ *
+ *
+ */
+public class JournalLargeMessageImpl extends ServerMessageImpl implements ServerLargeMessage
+{
+
+ // Constants -----------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(JournalLargeMessageImpl.class);
+
+ private static boolean isTrace = log.isTraceEnabled();
+
+ // Attributes ----------------------------------------------------
+
+ private final JournalStorageManager storageManager;
+
+ // We should only use the NIO implementation on the Journal
+ private volatile SequentialFile file;
+
+ private volatile boolean complete = false;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public JournalLargeMessageImpl(JournalStorageManager storageManager)
+ {
+ this.storageManager = storageManager;
+ }
+
+ // Public --------------------------------------------------------
+
+ /* (non-Javadoc)
+ * @see org.jboss.messaging.core.server.ServerLargeMessage#addBytes(byte[])
+ */
+ public synchronized void addBytes(final byte[] bytes) throws Exception
+ {
+ validateFile();
+
+ if (!file.isOpen())
+ {
+ file.open();
+ }
+
+ file.position(file.size());
+
+ file.write(ByteBuffer.wrap(bytes), false);
+
+ }
+
+ @Override
+ public synchronized void encodeBody(final MessagingBuffer bufferOut, final long start, final int size)
+ {
+ validateFile();
+
+ try
+ {
+ // This could maybe be optimized (maybe reading directly into bufferOut)
+ ByteBuffer bufferRead = ByteBuffer.allocate(size);
+ if (!file.isOpen())
+ {
+ file.open();
+ }
+
+ int bytesRead = 0;
+ file.position(start);
+
+ bytesRead = file.read(bufferRead);
+
+ bufferRead.flip();
+
+ if (bytesRead > 0)
+ {
+ bufferOut.putBytes(bufferRead.array(), 0, bytesRead);
+ }
+
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public synchronized int getBodySize()
+ {
+ validateFile();
+
+ try
+ {
+ if (!file.isOpen())
+ {
+ file.open();
+ }
+
+ return (int)file.size();
+ }
+
+ catch (Exception e)
+ {
+ throw new RuntimeException("Can't get the file size on " + file.getFileName());
+ }
+ }
+
+ @Override
+ public synchronized int getEncodeSize()
+ {
+ return getPropertiesEncodeSize();
+ }
+
+ @Override
+ public void encode(final MessagingBuffer buffer)
+ {
+ encodeProperties(buffer);
+ }
+
+ @Override
+ public void decode(final MessagingBuffer buffer)
+ {
+ file = null;
+ complete = true;
+ decodeProperties(buffer);
+ }
+
+ @Override
+ public int decrementRefCount()
+ {
+ int currentRefCount = super.decrementRefCount();
+
+ if (currentRefCount == 0)
+ {
+ if (isTrace)
+ {
+ log.trace("Deleting file " + file + " as the usage was complete");
+ }
+
+ try
+ {
+ deleteFile();
+ }
+ catch (Exception e)
+ {
+ log.error(e.getMessage(), e);
+ }
+ }
+
+ return currentRefCount;
+ }
+
+ public void deleteFile() throws MessagingException
+ {
+ this.storageManager.deleteFile(file);
+ }
+
+ @Override
+ public synchronized int getMemoryEstimate()
+ {
+ // The body won't be on memory (aways on-file), so we don't consider this for paging
+ return super.getPropertiesEncodeSize();
+ }
+
+ public synchronized void complete() throws Exception
+ {
+ releaseResources();
+
+ if (!complete)
+ {
+ SequentialFile fileToRename = storageManager.createFileForLargeMessage(this.getMessageID(), true);
+ file.renameTo(fileToRename);
+ }
+ }
+
+ public synchronized void releaseResources()
+ {
+ if (file.isOpen())
+ {
+ try
+ {
+ file.close();
+ }
+ catch (Exception e)
+ {
+ log.error(e.getMessage(), e);
+ }
+ }
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ private void validateFile()
+ {
+ if (file == null)
+ {
+ if (this.messageID <= 0)
+ {
+ throw new RuntimeException("MessageID not set on LargeMessage");
+ }
+
+ file = storageManager.createFileForLargeMessage(this.getMessageID(), complete);
+
+ }
+ }
+
+
+ // Inner classes -------------------------------------------------
+
+}
Property changes on: trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalLargeMessageImpl.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -22,6 +22,10 @@
package org.jboss.messaging.core.persistence.impl.journal;
+import static org.jboss.messaging.util.DataConstants.SIZE_BYTE;
+import static org.jboss.messaging.util.DataConstants.SIZE_INT;
+import static org.jboss.messaging.util.DataConstants.SIZE_LONG;
+
import static org.jboss.messaging.util.DataConstants.SIZE_BOOLEAN;
import java.io.File;
@@ -31,17 +35,22 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import javax.transaction.xa.Xid;
import org.jboss.messaging.core.config.Configuration;
+import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.filter.Filter;
import org.jboss.messaging.core.filter.impl.FilterImpl;
import org.jboss.messaging.core.journal.EncodingSupport;
import org.jboss.messaging.core.journal.Journal;
import org.jboss.messaging.core.journal.PreparedTransactionInfo;
import org.jboss.messaging.core.journal.RecordInfo;
+import org.jboss.messaging.core.journal.SequentialFile;
import org.jboss.messaging.core.journal.SequentialFileFactory;
import org.jboss.messaging.core.journal.impl.AIOSequentialFileFactory;
import org.jboss.messaging.core.journal.impl.JournalImpl;
@@ -63,12 +72,14 @@
import org.jboss.messaging.core.server.MessageReference;
import org.jboss.messaging.core.server.Queue;
import org.jboss.messaging.core.server.QueueFactory;
+import org.jboss.messaging.core.server.ServerLargeMessage;
import org.jboss.messaging.core.server.ServerMessage;
import org.jboss.messaging.core.server.impl.ServerMessageImpl;
import org.jboss.messaging.core.transaction.ResourceManager;
import org.jboss.messaging.core.transaction.Transaction;
import org.jboss.messaging.core.transaction.impl.TransactionImpl;
import org.jboss.messaging.util.IDGenerator;
+import org.jboss.messaging.util.JBMThreadFactory;
import org.jboss.messaging.util.SimpleString;
import org.jboss.messaging.util.TimeAndCounterIDGenerator;
@@ -85,12 +96,6 @@
{
private static final Logger log = Logger.getLogger(JournalStorageManager.class);
- private static final int SIZE_LONG = 8;
-
- private static final int SIZE_INT = 4;
-
- private static final int SIZE_BYTE = 1;
-
// Bindings journal record type
public static final byte BINDING_RECORD = 21;
@@ -102,6 +107,8 @@
// Message journal record types
+ public static final byte ADD_LARGE_MESSAGE = 30;
+
public static final byte ADD_MESSAGE = 31;
public static final byte ACKNOWLEDGE_REF = 32;
@@ -117,18 +124,23 @@
// This will produce a unique id **for this node only**
private final IDGenerator idGenerator = new TimeAndCounterIDGenerator();
- private final AtomicLong bindingIDSequence = new AtomicLong(0);
-
private final Journal messageJournal;
private final Journal bindingsJournal;
+ private final SequentialFileFactory largeMessagesFactory;
+
private final ConcurrentMap<SimpleString, Long> destinationIDMap = new ConcurrentHashMap<SimpleString, Long>();
private volatile boolean started;
-
+
+ private final ExecutorService executor;
+
+
public JournalStorageManager(final Configuration config)
{
+ this.executor = Executors.newCachedThreadPool(new JBMThreadFactory("JBM-journal-storage-manager"));
+
if (config.getJournalType() != JournalType.NIO && config.getJournalType() != JournalType.ASYNCIO)
{
throw new IllegalArgumentException("Only NIO and AsyncIO are supported journals");
@@ -154,7 +166,7 @@
throw new NullPointerException("journal-dir is null");
}
- checkAndCreateDir(journalDir, config.isCreateBindingsDir());
+ checkAndCreateDir(journalDir, config.isCreateJournalDir());
SequentialFileFactory journalFF = null;
@@ -191,13 +203,23 @@
"jbm",
config.getJournalMaxAIO(),
config.getJournalBufferReuseSize());
+
+ String largeMessagesDirectory = config.getLargeMessagesDirectory();
+
+ checkAndCreateDir(largeMessagesDirectory, config.isCreateJournalDir());
+
+ largeMessagesFactory = new NIOSequentialFileFactory(config.getLargeMessagesDirectory());
}
/* This constructor is only used for testing */
- public JournalStorageManager(final Journal messageJournal, final Journal bindingsJournal)
+ public JournalStorageManager(final Journal messageJournal,
+ final Journal bindingsJournal,
+ final SequentialFileFactory largeMessagesFactory)
{
+ this.executor = Executors.newCachedThreadPool(new JBMThreadFactory("JBM-journal-storage-manager"));
this.messageJournal = messageJournal;
this.bindingsJournal = bindingsJournal;
+ this.largeMessagesFactory = largeMessagesFactory;
}
public long generateUniqueID()
@@ -205,11 +227,31 @@
return idGenerator.generateID();
}
+ /** Create an area that will get LargeMessage bytes on the server size*/
+ public ServerLargeMessage createLargeMessageStorage()
+ {
+ return new JournalLargeMessageImpl(this);
+ }
+
// Non transactional operations
public void storeMessage(final ServerMessage message) throws Exception
{
- messageJournal.appendAddRecord(message.getMessageID(), ADD_MESSAGE, message);
+ if (message.getMessageID() <= 0)
+ {
+ throw new MessagingException(MessagingException.ILLEGAL_STATE, "MessageId was not assigned to Message");
+ }
+
+ if (message instanceof ServerLargeMessage)
+ {
+ messageJournal.appendAddRecord(message.getMessageID(),
+ ADD_LARGE_MESSAGE,
+ new LargeMessageEncoding((ServerLargeMessage)message));
+ }
+ else
+ {
+ messageJournal.appendAddRecord(message.getMessageID(), ADD_MESSAGE, message);
+ }
}
public void storeAcknowledge(final long queueID, final long messageID) throws Exception
@@ -234,7 +276,23 @@
public void storeMessageTransactional(final long txID, final ServerMessage message) throws Exception
{
- messageJournal.appendAddRecordTransactional(txID, message.getMessageID(), ADD_MESSAGE, message);
+ if (message.getMessageID() <= 0)
+ {
+ throw new MessagingException(MessagingException.ILLEGAL_STATE, "MessageId was not assigned to Message");
+ }
+
+ if (message instanceof ServerLargeMessage)
+ {
+ messageJournal.appendAddRecordTransactional(txID,
+ message.getMessageID(),
+ ADD_LARGE_MESSAGE,
+ new LargeMessageEncoding(((ServerLargeMessage)message)));
+ }
+ else
+ {
+ messageJournal.appendAddRecordTransactional(txID, message.getMessageID(), ADD_MESSAGE, message);
+ }
+
}
public void storePageTransaction(final long txID, final PageTransactionInfo pageTransaction) throws Exception
@@ -341,6 +399,23 @@
switch (recordType)
{
+ case ADD_LARGE_MESSAGE:
+ {
+ ServerLargeMessage largeMessage = this.createLargeMessageStorage();
+
+ LargeMessageEncoding messageEncoding = new LargeMessageEncoding(largeMessage);
+
+ messageEncoding.decode(buff);
+
+ List<MessageReference> refs = postOffice.route(largeMessage);
+
+ for (MessageReference ref : refs)
+ {
+ ref.getQueue().addLast(ref);
+ }
+
+ break;
+ }
case ADD_MESSAGE:
{
ServerMessage message = new ServerMessageImpl(record.id);
@@ -449,12 +524,8 @@
throw new IllegalStateException("Cannot find queue with id " + encoding.queueID);
}
// remove the reference and then add it back in with the scheduled time set.
- MessageReference removed = queue.removeReferenceWithID(messageID);
+ queue.rescheduleDelivery(messageID, encoding.scheduledDeliveryTime);
- removed.setScheduledDeliveryTime(encoding.scheduledDeliveryTime);
-
- queue.addLast(removed);
-
break;
}
default:
@@ -476,7 +547,7 @@
// We generate the queue id here
- long queueID = bindingIDSequence.getAndIncrement();
+ long queueID = idGenerator.generateID();
queue.setPersistenceID(queueID);
@@ -515,7 +586,7 @@
public boolean addDestination(final SimpleString destination) throws Exception
{
- long destinationID = bindingIDSequence.getAndIncrement();
+ long destinationID = idGenerator.generateID();
if (destinationIDMap.putIfAbsent(destination, destinationID) != null)
{
@@ -556,7 +627,7 @@
List<PreparedTransactionInfo> preparedTransactions = new ArrayList<PreparedTransactionInfo>();
- long maxID = bindingsJournal.load(records, preparedTransactions);
+ bindingsJournal.load(records, preparedTransactions);
for (RecordInfo record : records)
{
@@ -600,8 +671,6 @@
throw new IllegalStateException("Invalid record type " + rec);
}
}
-
- bindingIDSequence.set(maxID + 1);
}
// MessagingComponent implementation
@@ -613,6 +682,8 @@
{
return;
}
+
+ cleanupIncompleteFiles();
bindingsJournal.start();
@@ -627,11 +698,15 @@
{
return;
}
+
+ executor.shutdown();
bindingsJournal.stop();
messageJournal.stop();
+ executor.awaitTermination(60, TimeUnit.SECONDS);
+
started = false;
}
@@ -640,8 +715,7 @@
return started;
}
- // Public
- // -----------------------------------------------------------------------------------
+ // Public -----------------------------------------------------------------------------------
public Journal getMessageJournal()
{
@@ -653,9 +727,46 @@
return bindingsJournal;
}
- // Private
- // ----------------------------------------------------------------------------------
+ // Package protected ---------------------------------------------
+
+ // This should be accessed from this package only
+ void deleteFile(final SequentialFile file)
+ {
+ this.executor.execute(new Runnable() {
+ public void run()
+ {
+ try
+ {
+ file.delete();
+ }
+ catch (Exception e)
+ {
+ log.warn(e.getMessage(), e);
+ }
+ }
+
+ });
+ }
+
+ /**
+ * @param messageID
+ * @return
+ */
+ SequentialFile createFileForLargeMessage(final long messageID, final boolean completeFile)
+ {
+ if (completeFile)
+ {
+ return largeMessagesFactory.createSequentialFile(messageID + ".msg", -1);
+ }
+ else
+ {
+ return largeMessagesFactory.createSequentialFile(messageID + ".tmp", -1);
+ }
+ }
+
+ // Private ----------------------------------------------------------------------------------
+
private void loadPreparedTransactions(final PostOffice postOffice,
final Map<Long, Queue> queues,
final ResourceManager resourceManager,
@@ -838,6 +949,23 @@
}
}
+ /**
+ * @throws Exception
+ */
+ private void cleanupIncompleteFiles() throws Exception
+ {
+ if (largeMessagesFactory != null)
+ {
+ List<String> tmpFiles = this.largeMessagesFactory.listFiles("tmp");
+ for (String tmpFile : tmpFiles)
+ {
+ SequentialFile file = largeMessagesFactory.createSequentialFile(tmpFile, -1);
+ log.info("cleaning up file " + file);
+ file.delete();
+ }
+ }
+ }
+
// Inner Classes
// ----------------------------------------------------------------------------
@@ -951,6 +1079,42 @@
}
+ private static class LargeMessageEncoding implements EncodingSupport
+ {
+
+ private final ServerLargeMessage message;
+
+ public LargeMessageEncoding(ServerLargeMessage message)
+ {
+ this.message = message;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.messaging.core.journal.EncodingSupport#decode(org.jboss.messaging.core.remoting.spi.MessagingBuffer)
+ */
+ public void decode(final MessagingBuffer buffer)
+ {
+ message.decode(buffer);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.messaging.core.journal.EncodingSupport#encode(org.jboss.messaging.core.remoting.spi.MessagingBuffer)
+ */
+ public void encode(final MessagingBuffer buffer)
+ {
+ message.encode(buffer);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.messaging.core.journal.EncodingSupport#getEncodeSize()
+ */
+ public int getEncodeSize()
+ {
+ return message.getEncodeSize();
+ }
+
+ }
+
private static class DeliveryCountUpdateEncoding implements EncodingSupport
{
long queueID;
@@ -1046,6 +1210,7 @@
private static class ScheduledDeliveryEncoding extends QueueEncoding
{
+
long scheduledDeliveryTime;
private ScheduledDeliveryEncoding(long scheduledDeliveryTime, long queueID)
@@ -1075,4 +1240,5 @@
scheduledDeliveryTime = buffer.getLong();
}
}
+
}
Copied: trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageLargeMessageImpl.java (from rev 5358, branches/Branch_Chunk_3/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageServerLargeMessageImpl.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageLargeMessageImpl.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageLargeMessageImpl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.core.persistence.impl.nullpm;
+
+import java.nio.ByteBuffer;
+
+import org.jboss.messaging.core.remoting.impl.ByteBufferWrapper;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+import org.jboss.messaging.core.server.ServerLargeMessage;
+import org.jboss.messaging.core.server.impl.ServerMessageImpl;
+
+/**
+ * A NullStorageLargeMessageImpl
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ * Created 30-Sep-08 1:51:42 PM
+ *
+ *
+ */
+public class NullStorageLargeMessageImpl extends ServerMessageImpl implements ServerLargeMessage
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public NullStorageLargeMessageImpl()
+ {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.messaging.core.server.ServerLargeMessage#release()
+ */
+ public void releaseResources()
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.messaging.core.server.ServerLargeMessage#addBytes(byte[])
+ */
+ public synchronized void addBytes(final byte[] bytes)
+ {
+ MessagingBuffer buffer = this.getBody();
+
+ if (buffer != null)
+ {
+ ByteBuffer newBuffer = ByteBuffer.allocate(buffer.limit() + bytes.length);
+ newBuffer.put(buffer.array());
+ buffer = new ByteBufferWrapper(newBuffer);
+ this.setBody(buffer);
+ }
+ else
+ {
+ buffer = new ByteBufferWrapper(ByteBuffer.allocate(bytes.length));
+ this.setBody(buffer);
+ }
+
+ buffer.putBytes(bytes);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.messaging.core.server.ServerLargeMessage#deleteFile()
+ */
+ public void deleteFile() throws Exception
+ {
+ // nothing to be done here.. we don really have a file on this Storage
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.messaging.core.server.ServerLargeMessage#complete()
+ */
+ public void complete() throws Exception
+ {
+ // nothing to be done here.. we don really have a file on this Storage
+
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Property changes on: trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageLargeMessageImpl.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -36,6 +36,7 @@
import org.jboss.messaging.core.server.MessageReference;
import org.jboss.messaging.core.server.Queue;
import org.jboss.messaging.core.server.QueueFactory;
+import org.jboss.messaging.core.server.ServerLargeMessage;
import org.jboss.messaging.core.server.ServerMessage;
import org.jboss.messaging.core.transaction.ResourceManager;
import org.jboss.messaging.util.IDGenerator;
@@ -148,7 +149,16 @@
public void updateDeliveryCount(MessageReference ref) throws Exception
{
}
+
+ /* (non-Javadoc)
+ * @see org.jboss.messaging.core.persistence.StorageManager#createLargeMessageStorage(long, int, int)
+ */
+ public ServerLargeMessage createLargeMessageStorage()
+ {
+ return new NullStorageLargeMessageImpl();
+ }
+
public long generateUniqueID()
{
//FIXME - this needs to use Howard's ID generator from JBM 1.4
Modified: trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -159,6 +159,8 @@
public synchronized boolean addDestination(final SimpleString address, final boolean durable) throws Exception
{
+ pagingManager.createPageStore(address);
+
boolean added = addressManager.addDestination(address);
if (added)
@@ -223,6 +225,8 @@
{
storageManager.addBinding(binding);
}
+
+ pagingManager.createPageStore(address);
return binding;
}
@@ -453,9 +457,6 @@
queues.put(binding.getQueue().getPersistenceID(), binding.getQueue());
}
-
- storageManager.loadMessages(this, queues, resourceManager);
-
// TODO: This is related to http://www.jboss.com/index.html?module=bb&op=viewtopic&t=145597
HashSet<SimpleString> addresses = new HashSet<SimpleString>();
@@ -469,13 +470,21 @@
addresses.add(destination);
}
+ for (SimpleString destination : addresses)
+ {
+ pagingManager.createPageStore(destination);
+ }
+
// End TODO -------------------------------------
+
+ storageManager.loadMessages(this, queues, resourceManager);
+
for (SimpleString destination : addresses)
{
+ PagingStore store = pagingManager.getPageStore(destination);
if (!pagingManager.isGlobalPageMode())
{
- PagingStore store = pagingManager.getPageStore(destination);
if (store.isPaging() && store.getMaxSizeBytes() < 0)
{
pagingManager.setGlobalPageMode(true);
Modified: trunk/src/main/org/jboss/messaging/core/remoting/Packet.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/Packet.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/remoting/Packet.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -45,9 +45,12 @@
void decode(MessagingBuffer buffer);
+ int getPacketSize();
+
+ int getRequiredBufferSize();
+
+
boolean isRequiresConfirmations();
boolean isWriteAlways();
-
- int getPacketSize();
}
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -28,6 +28,7 @@
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_ADD_DESTINATION;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_BINDINGQUERY;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_BINDINGQUERY_RESP;
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_CHUNK_SEND;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_CLOSE;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_COMMIT;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_CONSUMER_CLOSE;
@@ -116,6 +117,7 @@
import org.jboss.messaging.core.remoting.impl.wireformat.SessionReceiveMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionRemoveDestinationMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionReplicateDeliveryMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendChunkMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXACommitMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAEndMessage;
@@ -758,6 +760,11 @@
packet = new NullResponseMessage();
break;
}
+ case SESS_CHUNK_SEND:
+ {
+ packet = new SessionSendChunkMessage();
+ break;
+ }
case SESS_REPLICATE_DELIVERY:
{
packet = new SessionReplicateDeliveryMessage();
@@ -902,7 +909,7 @@
{
packet.setChannelID(id);
- final MessagingBuffer buffer = connection.transportConnection.createBuffer(PacketImpl.INITIAL_BUFFER_SIZE);
+ final MessagingBuffer buffer = connection.transportConnection.createBuffer(packet.getRequiredBufferSize());
int size = packet.encode(buffer);
@@ -970,7 +977,7 @@
{
packet.setChannelID(id);
- final MessagingBuffer buffer = connection.transportConnection.createBuffer(PacketImpl.INITIAL_BUFFER_SIZE);
+ final MessagingBuffer buffer = connection.transportConnection.createBuffer(packet.getRequiredBufferSize());
int size = packet.encode(buffer);
@@ -1310,7 +1317,7 @@
private void doWrite(final Packet packet)
{
- final MessagingBuffer buffer = connection.transportConnection.createBuffer(PacketImpl.INITIAL_BUFFER_SIZE);
+ final MessagingBuffer buffer = connection.transportConnection.createBuffer(packet.getRequiredBufferSize());
packet.encode(buffer);
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -94,13 +94,12 @@
public Connection createConnection()
{
- Connection conn = new InVMConnection(acceptor.getHandler(), new Listener());
+ Connection conn = internalCreateConnection(acceptor.getHandler(), new Listener());
acceptor.connect((String)conn.getID(), handler, this);
return conn;
}
-
public synchronized void start()
{
started = true;
@@ -125,7 +124,16 @@
conn.close();
}
}
+
+
+ // This may be an injection point for mocks on tests
+ protected Connection internalCreateConnection(final BufferHandler handler, final ConnectionLifeCycleListener listener)
+ {
+ return new InVMConnection(handler, listener);
+ }
+
+
private class Listener implements ConnectionLifeCycleListener
{
public void connectionCreated(final Connection connection)
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateSessionMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateSessionMessage.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateSessionMessage.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -46,6 +46,8 @@
private String password;
+ private int minLargeMessageSize;
+
private boolean xa;
private boolean autoCommitSends;
@@ -60,6 +62,7 @@
public CreateSessionMessage(final String name, final long sessionChannelID,
final int version, final String username, final String password,
+ final int minLargeMessageSize,
final boolean xa, final boolean autoCommitSends,
final boolean autoCommitAcks, final int windowSize)
{
@@ -75,6 +78,8 @@
this.password = password;
+ this.minLargeMessageSize = minLargeMessageSize;
+
this.xa = xa;
this.autoCommitSends = autoCommitSends;
@@ -143,6 +148,7 @@
buffer.putInt(version);
buffer.putNullableString(username);
buffer.putNullableString(password);
+ buffer.putInt(minLargeMessageSize);
buffer.putBoolean(xa);
buffer.putBoolean(autoCommitSends);
buffer.putBoolean(autoCommitAcks);
@@ -156,6 +162,7 @@
version = buffer.getInt();
username = buffer.getNullableString();
password = buffer.getNullableString();
+ minLargeMessageSize = buffer.getInt();
xa = buffer.getBoolean();
autoCommitSends = buffer.getBoolean();
autoCommitAcks = buffer.getBoolean();
@@ -189,6 +196,14 @@
return false;
}
+ /**
+ * @return
+ */
+ public int getMinLargeMessageSize()
+ {
+ return minLargeMessageSize;
+ }
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -28,7 +28,10 @@
private static final Logger log = Logger.getLogger(PacketImpl.class);
- public static final int INITIAL_BUFFER_SIZE = 1024;
+ public static final int DEFAULT_PACKET_SIZE = 1024;
+
+ // The minimal size for all the packets, Common data for all the packets (look at PacketImpl.encode)
+ protected static final int BASIC_PACKET_SIZE = DataConstants.SIZE_INT + DataConstants.SIZE_BYTE + DataConstants.SIZE_LONG;
private long channelID;
@@ -142,6 +145,8 @@
public static final byte SESS_REPLICATE_DELIVERY = 81;
+ public static final byte SESS_CHUNK_SEND = 95;
+
// Static --------------------------------------------------------
public PacketImpl(final byte type)
@@ -151,6 +156,7 @@
// Public --------------------------------------------------------
+
public byte getType()
{
return type;
@@ -196,10 +202,15 @@
size = buffer.position();
}
- public int getPacketSize()
+ public final int getPacketSize()
{
return size;
}
+
+ public int getRequiredBufferSize()
+ {
+ return DEFAULT_PACKET_SIZE;
+ }
public boolean isResponse()
{
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ReplicateCreateSessionMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ReplicateCreateSessionMessage.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ReplicateCreateSessionMessage.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -45,6 +45,8 @@
private String username;
private String password;
+
+ private int minLargeMessageSize;
private boolean xa;
@@ -63,6 +65,7 @@
final int version,
final String username,
final String password,
+ final int minLargeMessageSize,
final boolean xa,
final boolean autoCommitSends,
final boolean autoCommitAcks,
@@ -79,6 +82,8 @@
this.username = username;
this.password = password;
+
+ this.minLargeMessageSize = minLargeMessageSize;
this.xa = xa;
@@ -120,6 +125,11 @@
{
return password;
}
+
+ public int getMinLargeMessageSize()
+ {
+ return minLargeMessageSize;
+ }
public boolean isXA()
{
@@ -148,6 +158,7 @@
buffer.putInt(version);
buffer.putNullableString(username);
buffer.putNullableString(password);
+ buffer.putInt(minLargeMessageSize);
buffer.putBoolean(xa);
buffer.putBoolean(autoCommitSends);
buffer.putBoolean(autoCommitAcks);
@@ -161,6 +172,7 @@
version = buffer.getInt();
username = buffer.getNullableString();
password = buffer.getNullableString();
+ minLargeMessageSize = buffer.getInt();
xa = buffer.getBoolean();
autoCommitSends = buffer.getBoolean();
autoCommitAcks = buffer.getBoolean();
@@ -184,6 +196,7 @@
this.autoCommitAcks == r.autoCommitAcks &&
(this.username == null ? r.username == null : this.username.equals(r.username)) &&
(this.password == null ? r.password == null : this.password.equals(r.password)) &&
+ this.minLargeMessageSize == r.minLargeMessageSize &&
this.windowSize == r.windowSize;
return matches;
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionReceiveMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionReceiveMessage.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionReceiveMessage.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -27,6 +27,7 @@
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
import org.jboss.messaging.core.server.ServerMessage;
+import org.jboss.messaging.util.DataConstants;
/**
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -95,6 +96,12 @@
return deliveryCount;
}
+
+ public int getRequiredBufferSize()
+ {
+ return BASIC_PACKET_SIZE + DataConstants.SIZE_LONG + DataConstants.SIZE_INT + serverMessage.getEncodeSize();
+ }
+
public void encodeBody(final MessagingBuffer buffer)
{
buffer.putLong(consumerID);
Copied: trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionSendChunkMessage.java (from rev 5358, branches/Branch_Chunk_3/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionSendChunkMessage.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionSendChunkMessage.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionSendChunkMessage.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -0,0 +1,197 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.core.remoting.impl.wireformat;
+
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+import org.jboss.messaging.util.DataConstants;
+
+/**
+ * @author <a href="mailto:clebert.suconic at jboss.com">Clebert Suconic</a>
+ *
+ * @version <tt>$Revision$</tt>
+ */
+public class SessionSendChunkMessage extends PacketImpl
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private long targetID;
+
+ private byte[] header;
+
+ private byte[] body;
+
+ private boolean continues;
+
+ private long messageID = 0;
+
+ private boolean requiresResponse;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public SessionSendChunkMessage(final long targetID,
+ final byte[] header,
+ final byte[] body,
+ final boolean continues,
+ final boolean requiresResponse)
+ {
+ super(SESS_CHUNK_SEND);
+ this.targetID = targetID;
+ this.header = header;
+ this.body = body;
+ this.continues = continues;
+ this.requiresResponse = requiresResponse;
+ }
+
+ public SessionSendChunkMessage()
+ {
+ super(SESS_CHUNK_SEND);
+ }
+
+ // Public --------------------------------------------------------
+
+ public long getTargetID()
+ {
+ return targetID;
+ }
+
+ public boolean isRequiresResponse()
+ {
+ return requiresResponse;
+ }
+
+ public byte[] getHeader()
+ {
+ return header;
+ }
+
+ public byte[] getBody()
+ {
+ return body;
+ }
+
+ public long getMessageID()
+ {
+ return messageID;
+ }
+
+ public void setMessageID(final long messageId)
+ {
+ messageID = messageId;
+ }
+
+ public boolean isContinues()
+ {
+ return continues;
+ }
+
+ @Override
+ public int getRequiredBufferSize()
+ {
+ return DEFAULT_PACKET_SIZE + DataConstants.SIZE_LONG /* TargetID */+
+ DataConstants.SIZE_INT /* HeaderLength */+
+ (header != null ? header.length : 0) /* Header bytes */+
+ DataConstants.SIZE_INT /* BodyLength */+
+ body.length /* Body bytes */+
+ DataConstants.SIZE_BOOLEAN /* hasContinuations */+
+ DataConstants.SIZE_BOOLEAN /* requiresResponse */+
+ DataConstants.SIZE_BOOLEAN /* has MessageId */+
+ (messageID > 0 ? DataConstants.SIZE_LONG : 0);
+ }
+
+ @Override
+ public void encodeBody(final MessagingBuffer buffer)
+ {
+ buffer.putLong(targetID);
+
+ if (header != null)
+ {
+ buffer.putInt(header.length);
+ buffer.putBytes(header);
+ }
+ else
+ {
+ buffer.putInt(0);
+ }
+
+ buffer.putInt(body.length);
+ buffer.putBytes(body);
+
+ buffer.putBoolean(continues);
+
+ buffer.putBoolean(requiresResponse);
+
+ buffer.putBoolean(messageID > 0);
+
+ if (messageID > 0)
+ {
+ buffer.putLong(messageID);
+ }
+
+ }
+
+ @Override
+ public void decodeBody(final MessagingBuffer buffer)
+ {
+ targetID = buffer.getLong();
+
+ final int headerLength = buffer.getInt();
+
+ if (headerLength > 0)
+ {
+ header = new byte[headerLength];
+ buffer.getBytes(header);
+ }
+ else
+ {
+ header = null;
+ }
+
+ final int bodyLength = buffer.getInt();
+
+ body = new byte[bodyLength];
+ buffer.getBytes(body);
+
+ continues = buffer.getBoolean();
+
+ requiresResponse = buffer.getBoolean();
+
+ final boolean hasMessageID = buffer.getBoolean();
+
+ if (hasMessageID)
+ {
+ messageID = buffer.getLong();
+ }
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionSendMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionSendMessage.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionSendMessage.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -22,12 +22,12 @@
package org.jboss.messaging.core.remoting.impl.wireformat;
-import org.jboss.messaging.core.client.ClientMessage;
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.message.Message;
import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
import org.jboss.messaging.core.server.ServerMessage;
import org.jboss.messaging.core.server.impl.ServerMessageImpl;
+import org.jboss.messaging.util.DataConstants;
/**
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -113,7 +113,19 @@
requiresResponse = buffer.getBoolean();
}
+ public int getRequiredBufferSize()
+ {
+ if (clientMessage != null)
+ {
+ return BASIC_PACKET_SIZE + clientMessage.getEncodeSize() + DataConstants.SIZE_BOOLEAN;
+ }
+ else
+ {
+ return BASIC_PACKET_SIZE + serverMessage.getEncodeSize() + DataConstants.SIZE_BOOLEAN;
+ }
+ }
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -68,6 +68,7 @@
long channelID,
String username,
String password,
+ int minLargeMessageSize,
int incrementingVersion,
RemotingConnection remotingConnection,
boolean autoCommitSends,
@@ -79,6 +80,7 @@
long channelID,
String username,
String password,
+ int minLargeMessageSize,
int incrementingVersion,
RemotingConnection remotingConnection,
boolean autoCommitSends,
Modified: trunk/src/main/org/jboss/messaging/core/server/Queue.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/Queue.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/server/Queue.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -103,6 +103,9 @@
MessageReference removeReferenceWithID(long id);
+ /** Remove message from queue, add it to the scheduled delivery list without affect reference counting */
+ void rescheduleDelivery(long id, long scheduledDeliveryTime);
+
MessageReference getReference(long id);
void deleteAllReferences(StorageManager storageManager) throws Exception;
Copied: trunk/src/main/org/jboss/messaging/core/server/ServerLargeMessage.java (from rev 5358, branches/Branch_Chunk_3/src/main/org/jboss/messaging/core/server/ServerLargeMessage.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/ServerLargeMessage.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/server/ServerLargeMessage.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.core.server;
+
+/**
+ * A LargeMessage
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ * Created 30-Sep-08 10:58:04 AM
+ *
+ *
+ */
+public interface ServerLargeMessage extends ServerMessage
+{
+ void addBytes(byte[] bytes) throws Exception;
+
+ /** Close the files if opened */
+ void releaseResources();
+
+ void complete() throws Exception;
+
+ void deleteFile() throws Exception;
+
+}
Modified: trunk/src/main/org/jboss/messaging/core/server/ServerMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/ServerMessage.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/server/ServerMessage.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -41,12 +41,12 @@
int decrementDurableRefCount();
- int incrementReference(boolean durable);
-
int getDurableRefCount();
int decrementRefCount();
+ int incrementDurableRefCount();
+
int getRefCount();
ServerMessage copy();
Modified: trunk/src/main/org/jboss/messaging/core/server/ServerSession.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/ServerSession.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/server/ServerSession.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -37,6 +37,7 @@
import org.jboss.messaging.core.remoting.impl.wireformat.SessionQueueQueryMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionRemoveDestinationMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionReplicateDeliveryMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendChunkMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXACommitMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAEndMessage;
@@ -63,6 +64,8 @@
String getUsername();
String getPassword();
+
+ int getMinLargeMessageSize();
void removeConsumer(ServerConsumer consumer) throws Exception;
@@ -124,6 +127,8 @@
void handleReceiveConsumerCredits(SessionConsumerFlowCreditMessage packet);
+ public void handleSendChunkMessage(SessionSendChunkMessage packet);
+
void handleSend(SessionSendMessage packet);
void handleFailedOver(Packet packet);
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -214,7 +214,8 @@
pagingManager = new PagingManagerImpl(storeFactory,
storageManager,
queueSettingsRepository,
- configuration.getPagingMaxGlobalSizeBytes());
+ configuration.getPagingMaxGlobalSizeBytes(),
+ configuration.getPagingDefaultSize());
storeFactory.setPagingManager(pagingManager);
@@ -263,6 +264,7 @@
"\"",
e);
}
+
Map<String, Object> backupConnectorParams = backupConnector.getParams();
// TODO don't hardcode ping interval and code timeout
@@ -523,20 +525,22 @@
}
public CreateSessionResponseMessage replicateCreateSession(final String name,
- final long channelID,
- final String username,
- final String password,
- final int incrementingVersion,
- final RemotingConnection connection,
- final boolean autoCommitSends,
- final boolean autoCommitAcks,
- final boolean xa,
- final int sendWindowSize) throws Exception
- {
+ final long channelID,
+ final String username,
+ final String password,
+ final int minLargeMessageSize,
+ final int incrementingVersion,
+ final RemotingConnection connection,
+ final boolean autoCommitSends,
+ final boolean autoCommitAcks,
+ final boolean xa,
+ final int sendWindowSize) throws Exception
+{
return doCreateSession(name,
channelID,
username,
password,
+ minLargeMessageSize,
incrementingVersion,
connection,
autoCommitSends,
@@ -549,6 +553,7 @@
final long channelID,
final String username,
final String password,
+ final int minLargeMessageSize,
final int incrementingVersion,
final RemotingConnection connection,
final boolean autoCommitSends,
@@ -562,6 +567,7 @@
channelID,
username,
password,
+ minLargeMessageSize,
incrementingVersion,
connection,
autoCommitSends,
@@ -626,6 +632,7 @@
final long channelID,
final String username,
final String password,
+ final int minLargeMessageSize,
final int incrementingVersion,
final RemotingConnection connection,
final boolean autoCommitSends,
@@ -667,6 +674,7 @@
channelID,
username,
password,
+ minLargeMessageSize,
autoCommitSends,
autoCommitAcks,
xa,
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -68,7 +68,8 @@
Packet replPacket = new ReplicateCreateSessionMessage(msg.getName(), msg.getSessionChannelID(),
msg.getVersion(), msg.getUsername(),
- msg.getPassword(), msg.isXA(),
+ msg.getPassword(), msg.getMinLargeMessageSize(),
+ msg.isXA(),
msg.isAutoCommitSends(),
msg.isAutoCommitAcks(),
msg.getWindowSize());
@@ -94,6 +95,7 @@
request.getSessionChannelID(),
request.getUsername(),
request.getPassword(),
+ request.getMinLargeMessageSize(),
request.getVersion(),
connection,
request.isAutoCommitSends(),
@@ -110,6 +112,7 @@
request.getSessionChannelID(),
request.getUsername(),
request.getPassword(),
+ request.getMinLargeMessageSize(),
request.getVersion(),
connection,
request.isAutoCommitSends(),
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServiceImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServiceImpl.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServiceImpl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -26,6 +26,7 @@
import org.jboss.messaging.core.config.Configuration;
import org.jboss.messaging.core.config.impl.ConfigurationImpl;
import org.jboss.messaging.core.journal.Journal;
+import org.jboss.messaging.core.journal.SequentialFileFactory;
import org.jboss.messaging.core.journal.impl.JournalImpl;
import org.jboss.messaging.core.journal.impl.NIOSequentialFileFactory;
import org.jboss.messaging.core.management.ManagementService;
@@ -78,7 +79,7 @@
return new MessagingServiceImpl(server, storageManager, remotingService);
}
- public static MessagingServiceImpl newNioStorageMessagingServer(final Configuration config, String journalDir, String bindingsDir)
+ public static MessagingServiceImpl newNioStorageMessagingServer(final Configuration config, String journalDir, String bindingsDir, String largeMessagesDir)
{
NIOSequentialFileFactory sequentialFileFactory = new NIOSequentialFileFactory(journalDir);
NIOSequentialFileFactory sequentialFileFactory2 = new NIOSequentialFileFactory(bindingsDir);
@@ -92,8 +93,10 @@
config.getJournalMinFiles(), config.isJournalSyncTransactional(),
config.isJournalSyncNonTransactional(), sequentialFileFactory,
"jbm-bindings", "jbm", config.getJournalMaxAIO(), 0);
+
+ SequentialFileFactory largeMessagesFactory = new NIOSequentialFileFactory(largeMessagesDir);
- StorageManager storageManager = new JournalStorageManager(msgs, bindings);
+ StorageManager storageManager = new JournalStorageManager(msgs, bindings, largeMessagesFactory);
RemotingService remotingService = new RemotingServiceImpl(config);
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -26,6 +26,7 @@
import org.jboss.messaging.core.list.PriorityLinkedList;
import org.jboss.messaging.core.list.impl.PriorityLinkedListImpl;
import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.paging.PagingManager;
import org.jboss.messaging.core.persistence.StorageManager;
import org.jboss.messaging.core.postoffice.Binding;
import org.jboss.messaging.core.postoffice.PostOffice;
@@ -92,6 +93,8 @@
private final Runnable deliverRunner = new DeliverRunner();
+ private final PagingManager pagingManager;
+
private volatile boolean backup;
private int consumersToFailover = -1;
@@ -119,6 +122,15 @@
this.postOffice = postOffice;
+ if (postOffice == null)
+ {
+ this.pagingManager = null;
+ }
+ else
+ {
+ this.pagingManager = postOffice.getPagingManager();
+ }
+
direct = true;
scheduledDeliveryHandler = new ScheduledDeliveryHandlerImpl(scheduledExecutor);
@@ -254,6 +266,15 @@
removed = ref;
+ try
+ {
+ referenceRemoved(removed);
+ }
+ catch (Exception e)
+ {
+ log.warn(e.getMessage(), e);
+ }
+
break;
}
}
@@ -267,6 +288,30 @@
return removed;
}
+ // Remove message from queue, add it to the scheduled delivery list without affect reference counting
+ public void rescheduleDelivery(final long id, final long scheduledDeliveryTime)
+ {
+ Iterator<MessageReference> iterator = messageReferences.iterator();
+ while (iterator.hasNext())
+ {
+ MessageReference ref = iterator.next();
+
+ if (ref.getMessage().getMessageID() == id)
+ {
+ iterator.remove();
+
+ ref.setScheduledDeliveryTime(scheduledDeliveryTime);
+
+ if (!scheduledDeliveryHandler.checkAndSchedule(ref, backup))
+ {
+ messageReferences.addFirst(ref, ref.getMessage().getPriority());
+ }
+
+ break;
+ }
+ }
+ }
+
public synchronized MessageReference getReference(final long id)
{
Iterator<MessageReference> iterator = messageReferences.iterator();
@@ -321,9 +366,9 @@
public void referenceAcknowledged(MessageReference ref) throws Exception
{
- deliveringCount.decrementAndGet();
- sizeBytes.addAndGet(-ref.getMessage().getEncodeSize());
+ referenceRemoved(ref);
+
}
public void referenceCancelled()
@@ -747,6 +792,23 @@
return status;
}
+ /**
+ * To be called when a reference is removed from the queue.
+ * @param ref
+ * @throws Exception
+ */
+ private void referenceRemoved(MessageReference ref) throws Exception
+ {
+ deliveringCount.decrementAndGet();
+
+ sizeBytes.addAndGet(-ref.getMessage().getEncodeSize());
+
+ if (ref.getMessage().decrementRefCount() == 0)
+ {
+ pagingManager.messageDone(ref.getMessage());
+ }
+ }
+
// Inner classes
// --------------------------------------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -22,6 +22,7 @@
package org.jboss.messaging.core.server.impl;
+import java.nio.ByteBuffer;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.concurrent.ConcurrentLinkedQueue;
@@ -38,14 +39,18 @@
import org.jboss.messaging.core.remoting.Channel;
import org.jboss.messaging.core.remoting.DelayedResult;
import org.jboss.messaging.core.remoting.Packet;
+import org.jboss.messaging.core.remoting.impl.ByteBufferWrapper;
import org.jboss.messaging.core.remoting.impl.wireformat.MessagingExceptionMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.NullResponseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionReceiveMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionReplicateDeliveryMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendChunkMessage;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
import org.jboss.messaging.core.server.HandleStatus;
import org.jboss.messaging.core.server.MessageReference;
import org.jboss.messaging.core.server.Queue;
import org.jboss.messaging.core.server.ServerConsumer;
+import org.jboss.messaging.core.server.ServerLargeMessage;
import org.jboss.messaging.core.server.ServerMessage;
import org.jboss.messaging.core.server.ServerSession;
import org.jboss.messaging.core.settings.HierarchicalRepository;
@@ -57,7 +62,8 @@
*
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
* @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- *
+ * @author <a href="mailto:clebert.suconic at jboss.com">Clebert Suconic</a>
+ *
* @version <tt>$Revision: 3783 $</tt> $Id: ServerConsumerImpl.java 3783 2008-02-25 12:15:14Z timfox $
*/
public class ServerConsumerImpl implements ServerConsumer
@@ -81,6 +87,8 @@
private final Filter filter;
+ private final int minLargeMessageSize;
+
private final ServerSession session;
private final Lock lock = new ReentrantLock();
@@ -88,6 +96,8 @@
private AtomicInteger availableCredits = new AtomicInteger(0);
private boolean started;
+
+ private volatile LargeMessageControl largeMessage = null;
/**
* if we are a browse only consumer we don't need to worry about acknowledgemenets or being started/stopeed by the session.
@@ -101,6 +111,8 @@
private final PostOffice postOffice;
private final java.util.Queue<MessageReference> deliveringRefs = new ConcurrentLinkedQueue<MessageReference>();
+
+
private final Channel channel;
@@ -146,6 +158,8 @@
this.pager = pager;
messageQueue.addConsumer(this);
+
+ this.minLargeMessageSize = session.getMinLargeMessageSize();
}
// ServerConsumer implementation
@@ -457,11 +471,6 @@
Queue queue = ref.getQueue();
- if (message.decrementRefCount() == 0)
- {
- pager.messageDone(message);
- }
-
if (message.isDurable() && queue.isDurable())
{
int count = message.decrementDurableRefCount();
@@ -481,7 +490,18 @@
private void promptDelivery()
{
- session.promptDelivery(messageQueue);
+ if (largeMessage != null)
+ {
+ if (largeMessage.sendLargeMessage())
+ {
+ // prompt Delivery only if chunk was finished
+ session.promptDelivery(messageQueue);
+ }
+ }
+ else
+ {
+ session.promptDelivery(messageQueue);
+ }
}
private HandleStatus doHandle(final MessageReference ref) throws Exception
@@ -495,6 +515,13 @@
try
{
+ // If there is a pendingLargeMessage we can't take another message
+ // This has to be checked inside the lock as the set to null is done inside the lock
+ if (largeMessage != null)
+ {
+ return HandleStatus.BUSY;
+ }
+
// If the consumer is stopped then we don't accept the message, it
// should go back into the
// queue for delivery later.
@@ -510,35 +537,21 @@
return HandleStatus.NO_MATCH;
}
- if (availableCredits != null)
- {
- availableCredits.addAndGet(-message.getEncodeSize());
- }
-
- final SessionReceiveMessage packet = new SessionReceiveMessage(id, message, ref.getDeliveryCount() + 1);
-
- DelayedResult result = channel.replicatePacket(new SessionReplicateDeliveryMessage(id, message.getMessageID()));
-
if (!browseOnly)
{
deliveringRefs.add(ref);
}
- if (result == null)
+
+ if (message instanceof ServerLargeMessage)
{
- // Not replicated - just send now
- channel.send(packet);
+ // TODO: How to inform the backup node about the LargeMessage being sent?
+ largeMessage = new LargeMessageControl((ServerLargeMessage)message);
+ largeMessage.sendLargeMessage();
}
else
{
- // Send when replicate delivery response comes back
- result.setResultRunner(new Runnable()
- {
- public void run()
- {
- channel.send(packet);
- }
- });
+ sendRegularMessage(ref, message);
}
return HandleStatus.HANDLED;
@@ -549,7 +562,184 @@
}
}
+ /**
+ * @param ref
+ * @param message
+ */
+ private void sendRegularMessage(final MessageReference ref, final ServerMessage message)
+ {
+ if (availableCredits != null)
+ {
+ availableCredits.addAndGet(-message.getEncodeSize());
+ }
+
+ final SessionReceiveMessage packet = new SessionReceiveMessage(id, message, ref.getDeliveryCount() + 1);
+
+ DelayedResult result = channel.replicatePacket(new SessionReplicateDeliveryMessage(id, message.getMessageID()));
+
+ if (result == null)
+ {
+ // Not replicated - just send now
+ channel.send(packet);
+ }
+ else
+ {
+ // Send when replicate delivery response comes back
+ result.setResultRunner(new Runnable()
+ {
+ public void run()
+ {
+ channel.send(packet);
+ }
+ });
+ }
+ }
+
+
+
+
+
+
// Inner classes
// ------------------------------------------------------------------------
+
+
+ /** Internal encapsulation of the logic on sending LargeMessages.
+ * This Inner class was created to avoid a bunch of loose properties about the current LargeMessage being sent*/
+ class LargeMessageControl
+ {
+ private volatile long sizePendingLargeMessage;
+ /** The current message being processed */
+ private volatile ServerLargeMessage pendingLargeMessage;
+
+ /** The current position on the message being processed */
+ private volatile long positionPendingLargeMessage;
+
+ private SessionSendChunkMessage readAheadChunk = null;
+
+ public LargeMessageControl(ServerLargeMessage message)
+ {
+ pendingLargeMessage = (ServerLargeMessage)message;
+ positionPendingLargeMessage = 0;
+ sizePendingLargeMessage = pendingLargeMessage.getBodySize();
+ }
+
+
+ public boolean sendLargeMessage()
+ {
+
+ lock.lock();
+
+ try
+ {
+
+ if (pendingLargeMessage == null)
+ {
+ return true;
+ }
+
+ if (availableCredits != null && availableCredits.get() <= 0)
+ {
+ return false;
+ }
+
+ if (readAheadChunk != null)
+ {
+ int chunkLen = readAheadChunk.getBody().length;
+ positionPendingLargeMessage += chunkLen;
+ channel.send(readAheadChunk);
+ readAheadChunk = null;
+ if (availableCredits != null)
+ {
+ availableCredits.addAndGet(-chunkLen);
+ }
+ }
+
+ while (positionPendingLargeMessage < sizePendingLargeMessage)
+ {
+
+ if (availableCredits != null && availableCredits.get() <= 0)
+ {
+ if (readAheadChunk == null)
+ {
+ readAheadChunk = createChunkSend();
+ }
+ return false;
+ }
+
+ SessionSendChunkMessage chunk = createChunkSend();
+
+ int chunkLen = chunk.getBody().length;
+
+ if (availableCredits != null)
+ {
+ availableCredits.addAndGet(-chunkLen);
+ }
+
+ channel.send(chunk);
+
+ positionPendingLargeMessage += chunkLen;
+ }
+
+ pendingLargeMessage.releaseResources();
+
+ ServerConsumerImpl.this.largeMessage = null;
+
+ return true;
+ }
+ finally
+ {
+ lock.unlock();
+ }
+
+
+ }
+
+ private SessionSendChunkMessage createChunkSend()
+ {
+ SessionSendChunkMessage chunk;
+
+ int localChunkLen = 0;
+
+ if (positionPendingLargeMessage == 0)
+ {
+ int headerSize = pendingLargeMessage.getPropertiesEncodeSize();
+
+ localChunkLen = minLargeMessageSize - headerSize;
+
+ MessagingBuffer headerBuffer = new ByteBufferWrapper(ByteBuffer.allocate(pendingLargeMessage.getPropertiesEncodeSize()));
+ pendingLargeMessage.encodeProperties(headerBuffer);
+
+ MessagingBuffer bodyBuffer = new ByteBufferWrapper(ByteBuffer.allocate((int)localChunkLen));
+ pendingLargeMessage.encodeBody(bodyBuffer, 0, localChunkLen);
+
+
+ chunk = new SessionSendChunkMessage(id,
+ headerBuffer.array(),
+ bodyBuffer.array(),
+ localChunkLen < sizePendingLargeMessage,
+ false);
+ }
+ else
+ {
+ localChunkLen = (int)Math.min(sizePendingLargeMessage - positionPendingLargeMessage, minLargeMessageSize);
+
+ MessagingBuffer bodyBuffer = new ByteBufferWrapper(ByteBuffer.allocate((int)localChunkLen));
+
+ pendingLargeMessage.encodeBody(bodyBuffer, positionPendingLargeMessage, localChunkLen);
+
+ chunk = new SessionSendChunkMessage(id,
+ null,
+ bodyBuffer.array(),
+ positionPendingLargeMessage + localChunkLen < sizePendingLargeMessage,
+ false);
+ }
+
+ return chunk;
+
+ }
+
+ }
+
}
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerMessageImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerMessageImpl.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerMessageImpl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -108,16 +108,11 @@
return durableRefCount.decrementAndGet();
}
- public int incrementReference(final boolean durable)
+ public int incrementDurableRefCount()
{
- if (durable)
- {
- durableRefCount.incrementAndGet();
- }
-
- return refCount.incrementAndGet();
+ return durableRefCount.incrementAndGet();
}
-
+
public int decrementRefCount()
{
return refCount.decrementAndGet();
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -63,6 +63,7 @@
import org.jboss.messaging.core.remoting.impl.wireformat.SessionQueueQueryResponseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionRemoveDestinationMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionReplicateDeliveryMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendChunkMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXACommitMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAEndMessage;
@@ -77,6 +78,7 @@
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXASetTimeoutMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXASetTimeoutResponseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAStartMessage;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
import org.jboss.messaging.core.security.CheckType;
import org.jboss.messaging.core.security.SecurityStore;
import org.jboss.messaging.core.server.MessageReference;
@@ -84,6 +86,7 @@
import org.jboss.messaging.core.server.Queue;
import org.jboss.messaging.core.server.SendLock;
import org.jboss.messaging.core.server.ServerConsumer;
+import org.jboss.messaging.core.server.ServerLargeMessage;
import org.jboss.messaging.core.server.ServerMessage;
import org.jboss.messaging.core.server.ServerSession;
import org.jboss.messaging.core.settings.HierarchicalRepository;
@@ -112,9 +115,9 @@
// Static -------------------------------------------------------------------------------
public static void moveReferencesBackToHeadOfQueues(List<MessageReference> references,
- PostOffice postOffice,
- StorageManager storageManager,
- HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception
+ PostOffice postOffice,
+ StorageManager storageManager,
+ HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception
{
Map<Queue, LinkedList<MessageReference>> queueMap = new HashMap<Queue, LinkedList<MessageReference>>();
@@ -144,7 +147,7 @@
entry.getKey().addListFirst(refs);
}
}
-
+
// Attributes ----------------------------------------------------------------------------
private final boolean trace = log.isTraceEnabled();
@@ -155,6 +158,8 @@
private final String password;
+ private final int minLargeMessageSize;
+
private final boolean autoCommitSends;
private final boolean autoCommitAcks;
@@ -195,12 +200,15 @@
private final SimpleString managementAddress;
+ private ServerLargeMessage largeMessage;
+
// Constructors ---------------------------------------------------------------------------------
public ServerSessionImpl(final String name,
final long id,
final String username,
final String password,
+ final int minLargeMessageSize,
final boolean autoCommitSends,
final boolean autoCommitAcks,
final boolean xa,
@@ -213,7 +221,7 @@
final Executor executor,
final Channel channel,
final ManagementService managementService,
- final MessagingServer server,
+ final MessagingServer server,
final SimpleString managementAddress) throws Exception
{
this.id = id;
@@ -222,6 +230,8 @@
this.password = password;
+ this.minLargeMessageSize = minLargeMessageSize;
+
this.autoCommitSends = autoCommitSends;
this.autoCommitAcks = autoCommitAcks;
@@ -270,6 +280,11 @@
return password;
}
+ public int getMinLargeMessageSize()
+ {
+ return minLargeMessageSize;
+ }
+
public long getID()
{
return id;
@@ -295,15 +310,29 @@
}
consumers.clear();
-
+
server.removeSession(name);
+
+ if (largeMessage != null)
+ {
+ try
+ {
+ largeMessage.deleteFile();
+ }
+ catch (Throwable error)
+ {
+ log.warn(error.toString(), error);
+
+ }
+ }
+
}
public void promptDelivery(final Queue queue)
{
queue.deliverAsync(executor);
}
-
+
public void doHandleCreateConsumer(final SessionCreateConsumerMessage packet)
{
SimpleString queueName = packet.getQueueName();
@@ -356,7 +385,7 @@
ServerConsumer consumer = new ServerConsumerImpl(idGenerator.generateID(),
this,
theQueue,
- filter,
+ filter,
started,
browseOnly,
storageManager,
@@ -366,8 +395,8 @@
pager);
consumers.put(consumer.getID(), consumer);
-
- response = new NullResponseMessage();
+
+ response = new NullResponseMessage();
}
catch (Exception e)
{
@@ -382,7 +411,7 @@
response = new MessagingExceptionMessage(new MessagingException(MessagingException.INTERNAL_ERROR));
}
}
-
+
channel.confirm(packet);
channel.send(response);
@@ -391,14 +420,14 @@
public void handleCreateConsumer(final SessionCreateConsumerMessage packet)
{
DelayedResult result = channel.replicatePacket(packet);
-
+
if (result == null)
{
doHandleCreateConsumer(packet);
}
else
{
- //Don't process until result has come back from backup
+ // Don't process until result has come back from backup
result.setResultRunner(new Runnable()
{
public void run()
@@ -414,13 +443,13 @@
SimpleString address = packet.getAddress();
SimpleString queueName = packet.getQueueName();
-
+
SimpleString filterString = packet.getFilterString();
boolean temporary = packet.isTemporary();
boolean durable = packet.isDurable();
-
+
boolean fanout = packet.isFanout();
Packet response = null;
@@ -490,12 +519,11 @@
response = new MessagingExceptionMessage(new MessagingException(MessagingException.INTERNAL_ERROR));
}
}
-
+
channel.confirm(packet);
-
- channel.send(response);
+
+ channel.send(response);
}
-
public void handleCreateQueue(final SessionCreateQueueMessage packet)
{
@@ -503,35 +531,35 @@
if (channel.getReplicatingChannel() != null)
{
lock = postOffice.getAddressLock(packet.getAddress());
-
+
lock.lock();
}
else
{
lock = null;
}
-
+
DelayedResult result = channel.replicatePacket(packet);
-
+
if (result == null)
{
doHandleCreateQueue(packet);
}
else
{
- //Don't process until result has come back from backup
+ // Don't process until result has come back from backup
result.setResultRunner(new Runnable()
{
public void run()
{
- doHandleCreateQueue(packet);
-
- lock.unlock();
+ doHandleCreateQueue(packet);
+
+ lock.unlock();
}
});
}
}
-
+
public void handleDeleteQueue(final SessionDeleteQueueMessage packet)
{
final SendLock lock;
@@ -539,36 +567,35 @@
{
Binding binding = postOffice.getBinding(packet.getQueueName());
lock = postOffice.getAddressLock(binding.getAddress());
-
+
lock.lock();
}
else
{
lock = null;
}
-
+
DelayedResult result = channel.replicatePacket(packet);
-
-
+
if (result == null)
{
doHandleDeleteQueue(packet);
}
else
{
- //Don't process until result has come back from backup
+ // Don't process until result has come back from backup
result.setResultRunner(new Runnable()
{
public void run()
{
- doHandleDeleteQueue(packet);
-
+ doHandleDeleteQueue(packet);
+
lock.unlock();
}
});
- }
+ }
}
-
+
public void doHandleDeleteQueue(final SessionDeleteQueueMessage packet)
{
SimpleString queueName = packet.getQueueName();
@@ -611,23 +638,23 @@
response = new MessagingExceptionMessage(new MessagingException(MessagingException.INTERNAL_ERROR));
}
}
-
+
channel.confirm(packet);
-
+
channel.send(response);
}
-
+
public void handleExecuteQueueQuery(final SessionQueueQueryMessage packet)
{
DelayedResult result = channel.replicatePacket(packet);
-
+
if (result == null)
{
doHandleExecuteQueueQuery(packet);
}
else
{
- //Don't process until result has come back from backup
+ // Don't process until result has come back from backup
result.setResultRunner(new Runnable()
{
public void run()
@@ -635,7 +662,7 @@
doHandleExecuteQueueQuery(packet);
}
});
- }
+ }
}
public void doHandleExecuteQueueQuery(final SessionQueueQueryMessage packet)
@@ -687,21 +714,21 @@
}
channel.confirm(packet);
-
+
channel.send(response);
}
-
+
public void handleExecuteBindingQuery(final SessionBindingQueryMessage packet)
{
DelayedResult result = channel.replicatePacket(packet);
-
+
if (result == null)
{
doHandleExecuteBindingQuery(packet);
}
else
{
- //Don't process until result has come back from backup
+ // Don't process until result has come back from backup
result.setResultRunner(new Runnable()
{
public void run()
@@ -709,7 +736,7 @@
doHandleExecuteBindingQuery(packet);
}
});
- }
+ }
}
public void doHandleExecuteBindingQuery(final SessionBindingQueryMessage packet)
@@ -754,23 +781,23 @@
response = new MessagingExceptionMessage(new MessagingException(MessagingException.INTERNAL_ERROR));
}
}
-
+
channel.confirm(packet);
-
+
channel.send(response);
}
public void handleAcknowledge(final SessionAcknowledgeMessage packet)
{
DelayedResult result = channel.replicatePacket(packet);
-
+
if (result == null)
{
doHandleAcknowledge(packet);
}
else
{
- //Don't process until result has come back from backup
+ // Don't process until result has come back from backup
result.setResultRunner(new Runnable()
{
public void run()
@@ -780,7 +807,7 @@
});
}
}
-
+
public void doHandleAcknowledge(final SessionAcknowledgeMessage packet)
{
Packet response = null;
@@ -788,7 +815,7 @@
try
{
ServerConsumer consumer = consumers.get(packet.getConsumerID());
-
+
consumer.acknowledge(autoCommitAcks, tx, packet.getMessageID());
if (packet.isRequiresResponse())
@@ -814,24 +841,24 @@
}
channel.confirm(packet);
-
+
if (response != null)
{
channel.send(response);
}
}
-
+
public void handleExpired(final SessionExpiredMessage packet)
{
DelayedResult result = channel.replicatePacket(packet);
-
+
if (result == null)
{
doHandleExpired(packet);
}
else
{
- //Don't process until result has come back from backup
+ // Don't process until result has come back from backup
result.setResultRunner(new Runnable()
{
public void run()
@@ -841,7 +868,7 @@
});
}
}
-
+
public void doHandleExpired(final SessionExpiredMessage packet)
{
try
@@ -861,18 +888,18 @@
channel.confirm(packet);
}
-
+
public void handleCommit(final Packet packet)
{
DelayedResult result = channel.replicatePacket(packet);
-
+
if (result == null)
{
doHandleCommit(packet);
}
else
{
- //Don't process until result has come back from backup
+ // Don't process until result has come back from backup
result.setResultRunner(new Runnable()
{
public void run()
@@ -910,23 +937,23 @@
{
tx = new TransactionImpl(storageManager, postOffice);
}
-
+
channel.confirm(packet);
-
+
channel.send(response);
}
-
+
public void handleRollback(final Packet packet)
- {
+ {
DelayedResult result = channel.replicatePacket(packet);
-
+
if (result == null)
{
doHandleRollback(packet);
}
else
{
- //Don't process until result has come back from backup
+ // Don't process until result has come back from backup
result.setResultRunner(new Runnable()
{
public void run()
@@ -938,7 +965,7 @@
}
public void doHandleRollback(final Packet packet)
- {
+ {
Packet response = null;
try
@@ -962,21 +989,21 @@
}
channel.confirm(packet);
-
+
channel.send(response);
}
public void handleXACommit(final SessionXACommitMessage packet)
{
DelayedResult result = channel.replicatePacket(packet);
-
+
if (result == null)
{
doHandleXACommit(packet);
}
else
{
- //Don't process until result has come back from backup
+ // Don't process until result has come back from backup
result.setResultRunner(new Runnable()
{
public void run()
@@ -986,7 +1013,7 @@
});
}
}
-
+
public void doHandleXACommit(final SessionXACommitMessage packet)
{
Packet response = null;
@@ -1046,21 +1073,21 @@
}
channel.confirm(packet);
-
+
channel.send(response);
}
-
+
public void handleXAEnd(final SessionXAEndMessage packet)
{
DelayedResult result = channel.replicatePacket(packet);
-
+
if (result == null)
{
doHandleXAEnd(packet);
}
else
{
- //Don't process until result has come back from backup
+ // Don't process until result has come back from backup
result.setResultRunner(new Runnable()
{
public void run()
@@ -1070,7 +1097,7 @@
});
}
}
-
+
public void doHandleXAEnd(final SessionXAEndMessage packet)
{
Packet response = null;
@@ -1141,21 +1168,21 @@
}
channel.confirm(packet);
-
+
channel.send(response);
}
-
+
public void handleXAForget(final SessionXAForgetMessage packet)
{
DelayedResult result = channel.replicatePacket(packet);
-
+
if (result == null)
{
doHandleXAForget(packet);
}
else
{
- //Don't process until result has come back from backup
+ // Don't process until result has come back from backup
result.setResultRunner(new Runnable()
{
public void run()
@@ -1174,21 +1201,21 @@
Packet response = new SessionXAResponseMessage(false, XAResource.XA_OK, null);
channel.confirm(packet);
-
+
channel.send(response);
}
public void handleXAJoin(final SessionXAJoinMessage packet)
{
DelayedResult result = channel.replicatePacket(packet);
-
+
if (result == null)
{
doHandleXAJoin(packet);
}
else
{
- //Don't process until result has come back from backup
+ // Don't process until result has come back from backup
result.setResultRunner(new Runnable()
{
public void run()
@@ -1198,7 +1225,7 @@
});
}
}
-
+
public void doHandleXAJoin(final SessionXAJoinMessage packet)
{
Packet response = null;
@@ -1244,7 +1271,7 @@
response = new MessagingExceptionMessage(new MessagingException(MessagingException.INTERNAL_ERROR));
}
}
-
+
channel.confirm(packet);
channel.send(response);
@@ -1253,14 +1280,14 @@
public void handleXAResume(final SessionXAResumeMessage packet)
{
DelayedResult result = channel.replicatePacket(packet);
-
+
if (result == null)
{
doHandleXAResume(packet);
}
else
{
- //Don't process until result has come back from backup
+ // Don't process until result has come back from backup
result.setResultRunner(new Runnable()
{
public void run()
@@ -1270,7 +1297,7 @@
});
}
}
-
+
public void doHandleXAResume(final SessionXAResumeMessage packet)
{
Packet response = null;
@@ -1329,21 +1356,21 @@
}
channel.confirm(packet);
-
+
channel.send(response);
}
-
+
public void handleXARollback(final SessionXARollbackMessage packet)
{
DelayedResult result = channel.replicatePacket(packet);
-
+
if (result == null)
{
doHandleXARollback(packet);
}
else
{
- //Don't process until result has come back from backup
+ // Don't process until result has come back from backup
result.setResultRunner(new Runnable()
{
public void run()
@@ -1413,21 +1440,21 @@
}
channel.confirm(packet);
-
+
channel.send(response);
}
public void handleXAStart(final SessionXAStartMessage packet)
{
DelayedResult result = channel.replicatePacket(packet);
-
+
if (result == null)
{
doHandleXAStart(packet);
}
else
{
- //Don't process until result has come back from backup
+ // Don't process until result has come back from backup
result.setResultRunner(new Runnable()
{
public void run()
@@ -1437,7 +1464,7 @@
});
}
}
-
+
public void doHandleXAStart(final SessionXAStartMessage packet)
{
Packet response = null;
@@ -1483,7 +1510,7 @@
response = new MessagingExceptionMessage(new MessagingException(MessagingException.INTERNAL_ERROR));
}
}
-
+
channel.confirm(packet);
channel.send(response);
@@ -1492,14 +1519,14 @@
public void handleXASuspend(final Packet packet)
{
DelayedResult result = channel.replicatePacket(packet);
-
+
if (result == null)
{
doHandleXASuspend(packet);
}
else
{
- //Don't process until result has come back from backup
+ // Don't process until result has come back from backup
result.setResultRunner(new Runnable()
{
public void run()
@@ -1509,7 +1536,7 @@
});
}
}
-
+
public void doHandleXASuspend(final Packet packet)
{
Packet response = null;
@@ -1555,21 +1582,21 @@
}
channel.confirm(packet);
-
+
channel.send(response);
}
public void handleXAPrepare(final SessionXAPrepareMessage packet)
{
DelayedResult result = channel.replicatePacket(packet);
-
+
if (result == null)
{
doHandleXAPrepare(packet);
}
else
{
- //Don't process until result has come back from backup
+ // Don't process until result has come back from backup
result.setResultRunner(new Runnable()
{
public void run()
@@ -1579,7 +1606,7 @@
});
}
}
-
+
public void doHandleXAPrepare(final SessionXAPrepareMessage packet)
{
Packet response = null;
@@ -1641,7 +1668,7 @@
response = new MessagingExceptionMessage(new MessagingException(MessagingException.INTERNAL_ERROR));
}
}
-
+
channel.confirm(packet);
channel.send(response);
@@ -1650,14 +1677,14 @@
public void handleGetInDoubtXids(final Packet packet)
{
DelayedResult result = channel.replicatePacket(packet);
-
+
if (result == null)
{
doHandleGetInDoubtXids(packet);
}
else
{
- //Don't process until result has come back from backup
+ // Don't process until result has come back from backup
result.setResultRunner(new Runnable()
{
public void run()
@@ -1667,27 +1694,27 @@
});
}
}
-
+
public void doHandleGetInDoubtXids(final Packet packet)
{
Packet response = new SessionXAGetInDoubtXidsResponseMessage(resourceManager.getPreparedTransactions());
channel.confirm(packet);
-
+
channel.send(response);
}
public void handleGetXATimeout(final Packet packet)
{
DelayedResult result = channel.replicatePacket(packet);
-
+
if (result == null)
{
doHandleGetXATimeout(packet);
}
else
{
- //Don't process until result has come back from backup
+ // Don't process until result has come back from backup
result.setResultRunner(new Runnable()
{
public void run()
@@ -1697,27 +1724,27 @@
});
}
}
-
+
public void doHandleGetXATimeout(final Packet packet)
{
Packet response = new SessionXAGetTimeoutResponseMessage(resourceManager.getTimeoutSeconds());
channel.confirm(packet);
-
+
channel.send(response);
}
public void handleSetXATimeout(final SessionXASetTimeoutMessage packet)
{
DelayedResult result = channel.replicatePacket(packet);
-
+
if (result == null)
{
doHandleSetXATimeout(packet);
}
else
{
- //Don't process until result has come back from backup
+ // Don't process until result has come back from backup
result.setResultRunner(new Runnable()
{
public void run()
@@ -1727,27 +1754,27 @@
});
}
}
-
+
public void doHandleSetXATimeout(final SessionXASetTimeoutMessage packet)
{
Packet response = new SessionXASetTimeoutResponseMessage(resourceManager.setTimeoutSeconds(packet.getTimeoutSeconds()));
channel.confirm(packet);
-
+
channel.send(response);
}
-
+
public void handleAddDestination(final SessionAddDestinationMessage packet)
{
DelayedResult result = channel.replicatePacket(packet);
-
+
if (result == null)
{
doHandleAddDestination(packet);
}
else
{
- //Don't process until result has come back from backup
+ // Don't process until result has come back from backup
result.setResultRunner(new Runnable()
{
public void run()
@@ -1818,21 +1845,21 @@
}
channel.confirm(packet);
-
+
channel.send(response);
}
-
+
public void handleRemoveDestination(final SessionRemoveDestinationMessage packet)
{
DelayedResult result = channel.replicatePacket(packet);
-
+
if (result == null)
{
doHandleRemoveDestination(packet);
}
else
{
- //Don't process until result has come back from backup
+ // Don't process until result has come back from backup
result.setResultRunner(new Runnable()
{
public void run()
@@ -1878,7 +1905,7 @@
}
channel.confirm(packet);
-
+
channel.send(response);
}
@@ -1901,23 +1928,23 @@
public void handleStart(final Packet packet)
{
boolean lock = this.channel.getReplicatingChannel() != null;
-
+
if (lock)
{
lockConsumers();
}
- //We need to prevent any delivery and replication of delivery occurring while the start/stop
- //is being processed.
- //Otherwise we can end up with start/stop being processed in different order on backup to live.
- //Which can result in, say, a delivery arriving at backup, but it's still not started!
+ // We need to prevent any delivery and replication of delivery occurring while the start/stop
+ // is being processed.
+ // Otherwise we can end up with start/stop being processed in different order on backup to live.
+ // Which can result in, say, a delivery arriving at backup, but it's still not started!
DelayedResult result = null;
try
{
result = channel.replicatePacket(packet);
-
- //note we process start before response is back from the backup
- setStarted(true);
+
+ // note we process start before response is back from the backup
+ setStarted(true);
}
finally
{
@@ -1926,14 +1953,14 @@
unlockConsumers();
}
}
-
+
if (result == null)
{
channel.confirm(packet);
}
else
{
- //Don't process until result has come back from backup
+ // Don't process until result has come back from backup
result.setResultRunner(new Runnable()
{
public void run()
@@ -1944,11 +1971,11 @@
}
}
- //TODO try removing the lock consumers and see what happens!!
+ // TODO try removing the lock consumers and see what happens!!
public void handleStop(final Packet packet)
{
boolean lock = channel.getReplicatingChannel() != null;
-
+
if (lock)
{
lockConsumers();
@@ -1958,10 +1985,10 @@
{
DelayedResult result = channel.replicatePacket(packet);
- //note we process stop before response is back from the backup
-
+ // note we process stop before response is back from the backup
+
final Packet response = new NullResponseMessage();
-
+
setStarted(false);
if (result == null)
@@ -1977,11 +2004,11 @@
public void run()
{
channel.confirm(packet);
-
+
channel.send(response);
}
});
- }
+ }
}
finally
{
@@ -2002,27 +2029,27 @@
consumer.failedOver();
}
}
-
+
public void handleClose(final Packet packet)
{
- //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
-
+ // 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);
}
-
+
DelayedResult result = channel.replicatePacket(packet);
-
+
if (result == null)
{
doHandleClose(packet);
}
else
{
- //Don't process until result has come back from backup
+ // Don't process until result has come back from backup
result.setResultRunner(new Runnable()
{
public void run()
@@ -2038,7 +2065,7 @@
Packet response = null;
try
- {
+ {
close();
response = new NullResponseMessage();
@@ -2056,11 +2083,11 @@
response = new MessagingExceptionMessage(new MessagingException(MessagingException.INTERNAL_ERROR));
}
}
-
+
channel.confirm(packet);
channel.send(response);
-
+
channel.close();
}
@@ -2075,34 +2102,33 @@
started = s;
}
-
+
public void handleCloseConsumer(final SessionConsumerCloseMessage packet)
{
- //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
-
- ServerConsumer consumer = consumers.get(packet.getConsumerID());
-
- consumer.handleClose(packet);
+ // 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
+
+ ServerConsumer consumer = consumers.get(packet.getConsumerID());
+
+ consumer.handleClose(packet);
}
-
public void handleReceiveConsumerCredits(final SessionConsumerFlowCreditMessage packet)
{
DelayedResult result = channel.replicatePacket(packet);
try
{
- //Note we don't wait for response before handling this
-
+ // Note we don't wait for response before handling this
+
consumers.get(packet.getConsumerID()).receiveCredits(packet.getCredits());
}
catch (Exception e)
{
log.error("Failed to receive credits", e);
}
-
+
if (result == null)
{
channel.confirm(packet);
@@ -2119,26 +2145,88 @@
}
}
+ public void handleSendChunkMessage(final SessionSendChunkMessage packet)
+ {
+
+ if (packet.getMessageID() == 0)
+ {
+ packet.setMessageID(storageManager.generateUniqueID());
+ }
+
+ Packet response = null;
+
+ // TODO: Replication on ChunkMessages
+
+ try
+ {
+ if (packet.getHeader() != null)
+ {
+ largeMessage = createLargeMessageStorage(packet.getTargetID(), packet.getMessageID(), packet.getHeader());
+ }
+
+ largeMessage.addBytes(packet.getBody());
+
+ if (!packet.isContinues())
+ {
+ final ServerLargeMessage message = largeMessage;
+ largeMessage = null;
+
+ message.complete();
+ send(message);
+ }
+
+ if (packet.isRequiresResponse())
+ {
+ response = new NullResponseMessage();
+ }
+
+ }
+ catch (Exception e)
+ {
+ log.error("Failed to send message", e);
+
+ if (packet.isRequiresResponse())
+ {
+ if (e instanceof MessagingException)
+ {
+ response = new MessagingExceptionMessage((MessagingException)e);
+ }
+ else
+ {
+ response = new MessagingExceptionMessage(new MessagingException(MessagingException.INTERNAL_ERROR));
+ }
+ }
+ }
+
+ channel.confirm(packet);
+
+ if (response != null)
+ {
+ channel.send(response);
+ }
+
+ }
+
public void handleSend(final SessionSendMessage packet)
- {
- //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
-
+ {
+ // 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
+
ServerMessage msg = packet.getServerMessage();
-
+
final SendLock lock;
-
+
if (channel.getReplicatingChannel() != null)
{
lock = postOffice.getAddressLock(msg.getDestination());
-
+
lock.beforeSend();
}
else
{
lock = null;
}
-
+
if (msg.getMessageID() == 0L)
{
// must generate message id here, so we know they are in sync on live and backup
@@ -2148,13 +2236,13 @@
}
DelayedResult result = channel.replicatePacket(packet);
-
- //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
-
+
+ // 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 (result == null)
{
- doSend(packet);
+ doSend(packet);
}
else
{
@@ -2163,13 +2251,13 @@
public void run()
{
doSend(packet);
-
+
lock.afterSend();
}
});
}
}
-
+
private void doSend(final SessionSendMessage packet)
{
Packet response = null;
@@ -2177,15 +2265,15 @@
try
{
ServerMessage message = packet.getServerMessage();
-
+
if (message.getDestination().equals(managementAddress))
{
- //It's a management message
-
+ // It's a management message
+
handleManagementMessage(message);
}
else
- {
+ {
send(message);
}
@@ -2210,19 +2298,19 @@
}
}
}
-
+
channel.confirm(packet);
-
+
if (response != null)
{
channel.send(response);
}
}
-
+
private void handleManagementMessage(final ServerMessage message) throws Exception
{
doSecurity(message);
-
+
if (message.containsProperty(ManagementHelper.HDR_JMX_SUBSCRIBE_TO_NOTIFICATIONS))
{
boolean subscribe = (Boolean)message.getProperty(ManagementHelper.HDR_JMX_SUBSCRIBE_TO_NOTIFICATIONS);
@@ -2251,7 +2339,7 @@
else
{
managementService.handleMessage(message);
-
+
message.setDestination((SimpleString)message.getProperty(ManagementHelper.HDR_JMX_REPLYTO));
send(message);
@@ -2298,7 +2386,7 @@
return serverLastReceivedCommandID;
}
-
+
public Channel getChannel()
{
return channel;
@@ -2324,9 +2412,9 @@
}
}
- //We call handleClose() since we need to replicate the close too, if there is a backup
+ // We call handleClose() since we need to replicate the close too, if there is a backup
handleClose(new PacketImpl(PacketImpl.SESS_CLOSE));
-
+
log.info("Cleared up resources for session " + name);
}
catch (Throwable t)
@@ -2365,6 +2453,20 @@
// Private
// ----------------------------------------------------------------------------
+ private ServerLargeMessage createLargeMessageStorage(long producerID, long messageID, byte[] header) throws Exception
+ {
+ ServerLargeMessage largeMessage = storageManager.createLargeMessageStorage();
+
+ MessagingBuffer headerBuffer = new ByteBufferWrapper(ByteBuffer.wrap(header));
+
+ largeMessage.decodeProperties(headerBuffer);
+
+ // client didn send the ID originally
+ largeMessage.setMessageID(messageID);
+
+ return largeMessage;
+ }
+
private void doRollback(final Transaction theTx) throws Exception
{
boolean wasStarted = started;
@@ -2382,7 +2484,7 @@
}
List<MessageReference> rolledBack = theTx.rollback(queueSettingsRepository);
-
+
rolledBack.addAll(toCancel);
if (wasStarted)
@@ -2417,18 +2519,18 @@
{
// check the user has write access to this address.
doSecurity(msg);
-
- Long scheduledDeliveryTime = (Long)msg.getProperty(MessageImpl.HDR_SCHEDULED_DELIVERY_TIME);
+ Long scheduledDeliveryTime = (Long)msg.getProperty(MessageImpl.HDR_SCHEDULED_DELIVERY_TIME);
+
if (autoCommitSends)
{
if (!pager.page(msg))
{
List<MessageReference> refs = postOffice.route(msg);
-
+
if (msg.getDurableRefCount() != 0)
{
- storageManager.storeMessage(msg);
+ storageManager.storeMessage(msg);
}
for (MessageReference ref : refs)
@@ -2436,13 +2538,13 @@
if (scheduledDeliveryTime != null)
{
ref.setScheduledDeliveryTime(scheduledDeliveryTime.longValue());
-
+
if (ref.getMessage().isDurable() && ref.getQueue().isDurable())
{
storageManager.updateScheduledDeliveryTime(ref);
}
}
-
+
ref.getQueue().addLast(ref);
}
}
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -15,6 +15,7 @@
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_ACKNOWLEDGE;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_ADD_DESTINATION;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_BINDINGQUERY;
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_CHUNK_SEND;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_CLOSE;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_COMMIT;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_CONSUMER_CLOSE;
@@ -59,6 +60,7 @@
import org.jboss.messaging.core.remoting.impl.wireformat.SessionExpiredMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionQueueQueryMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionRemoveDestinationMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendChunkMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionReplicateDeliveryMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXACommitMessage;
@@ -70,6 +72,8 @@
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXARollbackMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXASetTimeoutMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAStartMessage;
+import org.jboss.messaging.core.server.ServerLargeMessage;
+import org.jboss.messaging.core.server.ServerMessage;
import org.jboss.messaging.core.server.ServerSession;
/**
@@ -280,6 +284,12 @@
session.handleSend(message);
break;
}
+ case SESS_CHUNK_SEND:
+ {
+ SessionSendChunkMessage message = (SessionSendChunkMessage)packet;
+ session.handleSendChunkMessage(message);
+ break;
+ }
case SESS_REPLICATE_DELIVERY:
{
SessionReplicateDeliveryMessage message = (SessionReplicateDeliveryMessage)packet;
Modified: trunk/src/main/org/jboss/messaging/core/settings/impl/QueueSettings.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/settings/impl/QueueSettings.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/settings/impl/QueueSettings.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -49,8 +49,6 @@
public static final Boolean DEFAULT_DROP_MESSAGES_WHEN_FULL = Boolean.FALSE;
- public static final Integer DEFAULT_PAGE_SIZE_BYTES = 10 * 1024 * 1024; // 10M Bytes
-
public static final Integer DEFAULT_MAX_DELIVERY_ATTEMPTS = 10;
public static final Integer DEFAULT_MESSAGE_COUNTER_HISTORY_DAY_LIMIT = 0;
@@ -89,7 +87,7 @@
public Integer getPageSizeBytes()
{
- return pageSizeBytes != null ? pageSizeBytes : DEFAULT_PAGE_SIZE_BYTES;
+ return pageSizeBytes;
}
public Boolean isDropMessagesWhenFull()
Modified: trunk/src/main/org/jboss/messaging/core/transaction/impl/TransactionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/transaction/impl/TransactionImpl.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/core/transaction/impl/TransactionImpl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -196,11 +196,6 @@
ServerMessage message = acknowledgement.getMessage();
- if (message.decrementRefCount() == 0 && pagingManager != null)
- {
- pagingManager.messageDone(message);
- }
-
if (message.isDurable())
{
Queue queue = acknowledgement.getQueue();
@@ -364,6 +359,15 @@
for (MessageReference ref : acknowledgements)
{
+ Queue queue = ref.getQueue();
+
+ ServerMessage message = ref.getMessage();
+
+ if (message.isDurable() && queue.isDurable())
+ {
+ message.incrementDurableRefCount();
+
+ }
toCancel.add(ref);
}
Modified: trunk/src/main/org/jboss/messaging/jms/client/JBossBytesMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/client/JBossBytesMessage.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/jms/client/JBossBytesMessage.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -32,6 +32,7 @@
import org.jboss.messaging.core.client.ClientMessage;
import org.jboss.messaging.core.client.ClientSession;
import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
/**
* This class implements javax.jms.BytesMessage.
@@ -103,7 +104,7 @@
checkRead();
try
{
- return body.getBoolean();
+ return getBody().getBoolean();
}
catch (BufferUnderflowException e)
{
@@ -116,7 +117,7 @@
checkRead();
try
{
- return body.getByte();
+ return getBody().getByte();
}
catch (BufferUnderflowException e)
{
@@ -129,7 +130,7 @@
checkRead();
try
{
- return body.getUnsignedByte();
+ return getBody().getUnsignedByte();
}
catch (BufferUnderflowException e)
{
@@ -142,7 +143,7 @@
checkRead();
try
{
- return body.getShort();
+ return getBody().getShort();
}
catch (BufferUnderflowException e)
{
@@ -155,7 +156,7 @@
checkRead();
try
{
- return body.getUnsignedShort();
+ return getBody().getUnsignedShort();
}
catch (BufferUnderflowException e)
{
@@ -168,7 +169,7 @@
checkRead();
try
{
- return body.getChar();
+ return getBody().getChar();
}
catch (BufferUnderflowException e)
{
@@ -181,7 +182,7 @@
checkRead();
try
{
- return body.getInt();
+ return getBody().getInt();
}
catch (BufferUnderflowException e)
{
@@ -194,7 +195,7 @@
checkRead();
try
{
- return body.getLong();
+ return getBody().getLong();
}
catch (BufferUnderflowException e)
{
@@ -207,7 +208,7 @@
checkRead();
try
{
- return body.getFloat();
+ return getBody().getFloat();
}
catch (BufferUnderflowException e)
{
@@ -220,7 +221,7 @@
checkRead();
try
{
- return body.getDouble();
+ return getBody().getDouble();
}
catch (BufferUnderflowException e)
{
@@ -233,7 +234,7 @@
checkRead();
try
{
- return body.getUTF();
+ return getBody().getUTF();
}
catch (BufferUnderflowException e)
{
@@ -257,13 +258,13 @@
{
checkRead();
- if (body.remaining() == 0) { return -1; }
+ if (getBody().remaining() == 0) { return -1; }
- int read = Math.min(length, body.remaining());
+ int read = Math.min(length, getBody().remaining());
if (read != 0)
{
- body.getBytes(value, 0, read);
+ getBody().getBytes(value, 0, read);
}
return read;
@@ -272,49 +273,49 @@
public void writeBoolean(final boolean value) throws JMSException
{
checkWrite();
- body.putBoolean(value);
+ getBody().putBoolean(value);
}
public void writeByte(final byte value) throws JMSException
{
checkWrite();
- body.putByte(value);
+ getBody().putByte(value);
}
public void writeShort(final short value) throws JMSException
{
checkWrite();
- body.putShort(value);
+ getBody().putShort(value);
}
public void writeChar(final char value) throws JMSException
{
checkWrite();
- body.putChar(value);
+ getBody().putChar(value);
}
public void writeInt(final int value) throws JMSException
{
checkWrite();
- body.putInt(value);
+ getBody().putInt(value);
}
public void writeLong(final long value) throws JMSException
{
checkWrite();
- body.putLong(value);
+ getBody().putLong(value);
}
public void writeFloat(final float value) throws JMSException
{
checkWrite();
- body.putFloat(value);
+ getBody().putFloat(value);
}
public void writeDouble(final double value) throws JMSException
{
checkWrite();
- body.putDouble(value);
+ getBody().putDouble(value);
}
public void writeUTF(final String value) throws JMSException
@@ -322,7 +323,7 @@
checkWrite();
try
{
- body.putUTF(value);
+ getBody().putUTF(value);
}
catch (Exception e)
{
@@ -335,14 +336,14 @@
public void writeBytes(final byte[] value) throws JMSException
{
checkWrite();
- body.putBytes(value);
+ getBody().putBytes(value);
}
public void writeBytes(final byte[] value, final int offset, final int length)
throws JMSException
{
checkWrite();
- body.putBytes(value, offset, length);
+ getBody().putBytes(value, offset, length);
}
public void writeObject(final Object value) throws JMSException
@@ -401,11 +402,11 @@
{
readOnly = true;
- body.flip();
+ getBody().flip();
}
else
{
- body.rewind();
+ getBody().rewind();
}
}
@@ -414,22 +415,20 @@
public void clearBody() throws JMSException
{
super.clearBody();
-
- body = body.createNewBuffer(1024);
+ MessagingBuffer currentBody = message.getBody();
+ message.setBody(currentBody.createNewBuffer(1024));
}
public long getBodyLength() throws JMSException
{
checkRead();
- return body.limit();
+ return getBody().limit();
}
public void doBeforeSend() throws Exception
{
reset();
-
- message.setBody(body);
}
// Public --------------------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -85,6 +85,8 @@
private final int sendWindowSize;
private final int producerMaxRate;
+
+ private final int minLargeMessageSize;
private final boolean blockOnAcknowledge;
@@ -109,6 +111,7 @@
final int consumerMaxRate,
final int sendWindowSize,
final int producerMaxRate,
+ final int minLargeMessageSize,
final boolean blockOnAcknowledge,
final boolean blockOnNonPersistentSend,
final boolean blockOnPersistentSend,
@@ -127,6 +130,7 @@
this.producerMaxRate = producerMaxRate;
this.sendWindowSize = sendWindowSize;
this.blockOnAcknowledge = blockOnAcknowledge;
+ this.minLargeMessageSize = minLargeMessageSize;
this.blockOnNonPersistentSend = blockOnNonPersistentSend;
this.blockOnPersistentSend = blockOnPersistentSend;
this.autoGroup = autoGroup;
@@ -301,6 +305,7 @@
consumerMaxRate,
sendWindowSize,
producerMaxRate,
+ minLargeMessageSize,
blockOnAcknowledge,
blockOnNonPersistentSend,
blockOnPersistentSend,
Modified: trunk/src/main/org/jboss/messaging/jms/client/JBossMapMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/client/JBossMapMessage.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/jms/client/JBossMapMessage.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -443,7 +443,7 @@
public void doBeforeSend() throws Exception
{
- map.encode(body);
+ map.encode(message.getBody());
super.doBeforeSend();
}
@@ -452,7 +452,7 @@
{
super.doBeforeReceive();
- map.decode(body);
+ map.decode(message.getBody());
}
// Package protected ---------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/jms/client/JBossMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/client/JBossMessage.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/jms/client/JBossMessage.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -152,8 +152,6 @@
// The underlying message
protected ClientMessage message;
- protected MessagingBuffer body;
-
private ClientSession session;
// Read-only?
@@ -187,8 +185,6 @@
(byte)4,
new ByteBufferWrapper(ByteBuffer.allocate(1024)));
- // TODO - can we lazily create this?
- body = message.getBody();
}
public JBossMessage(byte type)
@@ -200,8 +196,6 @@
(byte)4,
new ByteBufferWrapper(ByteBuffer.allocate(1024)));
- // TODO - can we lazily create this?
- body = message.getBody();
}
/*
@@ -211,8 +205,6 @@
{
message = session.createClientMessage(type, true, 0, System.currentTimeMillis(), (byte)4);
- // TODO - can we lazily create this?
- body = message.getBody();
}
public JBossMessage(final ClientSession session)
@@ -230,8 +222,6 @@
this.readOnly = true;
this.session = session;
-
- this.body = message.getBody();
}
/*
@@ -917,14 +907,16 @@
public void doBeforeSend() throws Exception
{
- body.flip();
-
- message.setBody(body);
+ message.getBody().flip();
}
public void doBeforeReceive() throws Exception
{
- body = message.getBody();
+ MessagingBuffer body = message.getBody();
+ if (body != null)
+ {
+ body.rewind();
+ }
}
public byte getType()
@@ -966,6 +958,11 @@
throw new MessageNotReadableException("Message is write-only");
}
}
+
+ protected MessagingBuffer getBody()
+ {
+ return message.getBody();
+ }
// Private ------------------------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/jms/client/JBossObjectMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/client/JBossObjectMessage.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/jms/client/JBossObjectMessage.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -33,6 +33,7 @@
import org.jboss.messaging.core.client.ClientMessage;
import org.jboss.messaging.core.client.ClientSession;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
import org.jboss.messaging.util.ObjectInputStreamWithClassLoader;
/**
@@ -113,8 +114,8 @@
byte[] data = baos.toByteArray();
- body.putInt(data.length);
- body.putBytes(data);
+ getBody().putInt(data.length);
+ getBody().putBytes(data);
}
super.doBeforeSend();
@@ -137,9 +138,9 @@
{
try
{
- int len = body.getInt();
+ int len = getBody().getInt();
byte[] data = new byte[len];
- body.getBytes(data);
+ getBody().getBytes(data);
ByteArrayInputStream bais = new ByteArrayInputStream(data);
ObjectInputStream ois = new ObjectInputStreamWithClassLoader(bais);
object = (Serializable)ois.readObject();
Modified: trunk/src/main/org/jboss/messaging/jms/client/JBossStreamMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/client/JBossStreamMessage.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/jms/client/JBossStreamMessage.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -32,6 +32,7 @@
import org.jboss.messaging.core.client.ClientMessage;
import org.jboss.messaging.core.client.ClientSession;
import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
import org.jboss.messaging.util.DataConstants;
/**
@@ -118,14 +119,14 @@
checkRead();
try
{
- byte type = body.getByte();
+ byte type = getBody().getByte();
switch (type)
{
case DataConstants.BOOLEAN:
- return body.getBoolean();
+ return getBody().getBoolean();
case DataConstants.STRING:
- String s = body.getNullableString();
+ String s = getBody().getNullableString();
return Boolean.valueOf(s);
default:
throw new MessageFormatException("Invalid conversion");
@@ -142,13 +143,13 @@
checkRead();
try
{
- byte type = body.getByte();
+ byte type = getBody().getByte();
switch (type)
{
case DataConstants.BYTE:
- return body.getByte();
+ return getBody().getByte();
case DataConstants.STRING:
- String s = body.getNullableString();
+ String s = getBody().getNullableString();
return Byte.parseByte(s);
default:
throw new MessageFormatException("Invalid conversion");
@@ -165,15 +166,15 @@
checkRead();
try
{
- byte type = body.getByte();
+ byte type = getBody().getByte();
switch (type)
{
case DataConstants.BYTE:
- return body.getByte();
+ return getBody().getByte();
case DataConstants.SHORT:
- return body.getShort();
+ return getBody().getShort();
case DataConstants.STRING:
- String s = body.getNullableString();
+ String s = getBody().getNullableString();
return Short.parseShort(s);
default:
throw new MessageFormatException("Invalid conversion");
@@ -190,11 +191,11 @@
checkRead();
try
{
- byte type = body.getByte();
+ byte type = getBody().getByte();
switch (type)
{
case DataConstants.CHAR:
- return body.getChar();
+ return getBody().getChar();
default:
throw new MessageFormatException("Invalid conversion");
}
@@ -210,17 +211,17 @@
checkRead();
try
{
- byte type = body.getByte();
+ byte type = getBody().getByte();
switch (type)
{
case DataConstants.BYTE:
- return body.getByte();
+ return getBody().getByte();
case DataConstants.SHORT:
- return body.getShort();
+ return getBody().getShort();
case DataConstants.INT:
- return body.getInt();
+ return getBody().getInt();
case DataConstants.STRING:
- String s = body.getNullableString();
+ String s = getBody().getNullableString();
return Integer.parseInt(s);
default:
throw new MessageFormatException("Invalid conversion");
@@ -237,19 +238,19 @@
checkRead();
try
{
- byte type = body.getByte();
+ byte type = getBody().getByte();
switch (type)
{
case DataConstants.BYTE:
- return body.getByte();
+ return getBody().getByte();
case DataConstants.SHORT:
- return body.getShort();
+ return getBody().getShort();
case DataConstants.INT:
- return body.getInt();
+ return getBody().getInt();
case DataConstants.LONG:
- return body.getLong();
+ return getBody().getLong();
case DataConstants.STRING:
- String s = body.getNullableString();
+ String s = getBody().getNullableString();
return Long.parseLong(s);
default:
throw new MessageFormatException("Invalid conversion");
@@ -266,13 +267,13 @@
checkRead();
try
{
- byte type = body.getByte();
+ byte type = getBody().getByte();
switch (type)
{
case DataConstants.FLOAT:
- return body.getFloat();
+ return getBody().getFloat();
case DataConstants.STRING:
- String s = body.getNullableString();
+ String s = getBody().getNullableString();
return Float.parseFloat(s);
default:
throw new MessageFormatException("Invalid conversion");
@@ -289,15 +290,15 @@
checkRead();
try
{
- byte type = body.getByte();
+ byte type = getBody().getByte();
switch (type)
{
case DataConstants.FLOAT:
- return body.getFloat();
+ return getBody().getFloat();
case DataConstants.DOUBLE:
- return body.getDouble();
+ return getBody().getDouble();
case DataConstants.STRING:
- String s = body.getNullableString();
+ String s = getBody().getNullableString();
return Double.parseDouble(s);
default:
throw new MessageFormatException("Invalid conversion: " + type);
@@ -314,27 +315,27 @@
checkRead();
try
{
- byte type = body.getByte();
+ byte type = getBody().getByte();
switch (type)
{
case DataConstants.BOOLEAN:
- return String.valueOf(body.getBoolean());
+ return String.valueOf(getBody().getBoolean());
case DataConstants.BYTE:
- return String.valueOf(body.getByte());
+ return String.valueOf(getBody().getByte());
case DataConstants.SHORT:
- return String.valueOf(body.getShort());
+ return String.valueOf(getBody().getShort());
case DataConstants.CHAR:
- return String.valueOf(body.getChar());
+ return String.valueOf(getBody().getChar());
case DataConstants.INT:
- return String.valueOf(body.getInt());
+ return String.valueOf(getBody().getInt());
case DataConstants.LONG:
- return String.valueOf(body.getLong());
+ return String.valueOf(getBody().getLong());
case DataConstants.FLOAT:
- return String.valueOf(body.getFloat());
+ return String.valueOf(getBody().getFloat());
case DataConstants.DOUBLE:
- return String.valueOf(body.getDouble());
+ return String.valueOf(getBody().getDouble());
case DataConstants.STRING:
- return body.getNullableString();
+ return getBody().getNullableString();
default:
throw new MessageFormatException("Invalid conversion");
}
@@ -359,15 +360,15 @@
}
else if (len == 0)
{
- byte type = body.getByte();
+ byte type = getBody().getByte();
if (type != DataConstants.BYTES)
{
throw new MessageFormatException("Invalid conversion");
}
- len = body.getInt();
+ len = getBody().getInt();
}
int read = Math.min(value.length, len);
- body.getBytes(value, 0, read);
+ getBody().getBytes(value, 0, read);
len -= read;
if (len == 0)
{
@@ -384,31 +385,31 @@
public Object readObject() throws JMSException
{
checkRead();
- byte type = body.getByte();
+ byte type = getBody().getByte();
switch (type)
{
case DataConstants.BOOLEAN:
- return body.getBoolean();
+ return getBody().getBoolean();
case DataConstants.BYTE:
- return body.getByte();
+ return getBody().getByte();
case DataConstants.SHORT:
- return body.getShort();
+ return getBody().getShort();
case DataConstants.CHAR:
- return body.getChar();
+ return getBody().getChar();
case DataConstants.INT:
- return body.getInt();
+ return getBody().getInt();
case DataConstants.LONG:
- return body.getLong();
+ return getBody().getLong();
case DataConstants.FLOAT:
- return body.getFloat();
+ return getBody().getFloat();
case DataConstants.DOUBLE:
- return body.getDouble();
+ return getBody().getDouble();
case DataConstants.STRING:
- return body.getNullableString();
+ return getBody().getNullableString();
case DataConstants.BYTES:
- int len = body.getInt();
+ int len = getBody().getInt();
byte[] bytes = new byte[len];
- body.getBytes(bytes);
+ getBody().getBytes(bytes);
return bytes;
default:
throw new MessageFormatException("Invalid conversion");
@@ -418,81 +419,81 @@
public void writeBoolean(final boolean value) throws JMSException
{
checkWrite();
- body.putByte(DataConstants.BOOLEAN);
- body.putBoolean(value);
+ getBody().putByte(DataConstants.BOOLEAN);
+ getBody().putBoolean(value);
}
public void writeByte(final byte value) throws JMSException
{
checkWrite();
- body.putByte(DataConstants.BYTE);
- body.putByte(value);
+ getBody().putByte(DataConstants.BYTE);
+ getBody().putByte(value);
}
public void writeShort(final short value) throws JMSException
{
checkWrite();
- body.putByte(DataConstants.SHORT);
- body.putShort(value);
+ getBody().putByte(DataConstants.SHORT);
+ getBody().putShort(value);
}
public void writeChar(final char value) throws JMSException
{
checkWrite();
- body.putByte(DataConstants.CHAR);
- body.putChar(value);
+ getBody().putByte(DataConstants.CHAR);
+ getBody().putChar(value);
}
public void writeInt(final int value) throws JMSException
{
checkWrite();
- body.putByte(DataConstants.INT);
- body.putInt(value);
+ getBody().putByte(DataConstants.INT);
+ getBody().putInt(value);
}
public void writeLong(final long value) throws JMSException
{
checkWrite();
- body.putByte(DataConstants.LONG);
- body.putLong(value);
+ getBody().putByte(DataConstants.LONG);
+ getBody().putLong(value);
}
public void writeFloat(final float value) throws JMSException
{
checkWrite();
- body.putByte(DataConstants.FLOAT);
- body.putFloat(value);
+ getBody().putByte(DataConstants.FLOAT);
+ getBody().putFloat(value);
}
public void writeDouble(final double value) throws JMSException
{
checkWrite();
- body.putByte(DataConstants.DOUBLE);
- body.putDouble(value);
+ getBody().putByte(DataConstants.DOUBLE);
+ getBody().putDouble(value);
}
public void writeString(final String value) throws JMSException
{
checkWrite();
- body.putByte(DataConstants.STRING);
- body.putNullableString(value);
+ getBody().putByte(DataConstants.STRING);
+ getBody().putNullableString(value);
}
public void writeBytes(final byte[] value) throws JMSException
{
checkWrite();
- body.putByte(DataConstants.BYTES);
- body.putInt(value.length);
- body.putBytes(value);
+ getBody().putByte(DataConstants.BYTES);
+ getBody().putInt(value.length);
+ getBody().putBytes(value);
}
public void writeBytes(final byte[] value, final int offset, final int length)
throws JMSException
{
checkWrite();
- body.putByte(DataConstants.BYTES);
- body.putInt(length);
- body.putBytes(value, offset, length);
+ getBody().putByte(DataConstants.BYTES);
+ getBody().putInt(length);
+ getBody().putBytes(value, offset, length);
}
public void writeObject(final Object value) throws JMSException
@@ -553,11 +554,11 @@
{
readOnly = true;
- body.flip();
+ getBody().flip();
}
else
{
- body.rewind();
+ getBody().rewind();
}
}
@@ -566,15 +567,13 @@
public void clearBody() throws JMSException
{
super.clearBody();
-
- body = body.createNewBuffer(1024);
+ MessagingBuffer currentBody = message.getBody();
+ message.setBody(currentBody.createNewBuffer(1024));
}
public void doBeforeSend() throws Exception
{
reset();
-
- message.setBody(body);
}
// Package protected ---------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/jms/client/JBossTextMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/client/JBossTextMessage.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/jms/client/JBossTextMessage.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -124,7 +124,7 @@
public void doBeforeSend() throws Exception
{
- body.putNullableString(text);
+ getBody().putNullableString(text);
super.doBeforeSend();
}
@@ -133,7 +133,7 @@
{
super.doBeforeReceive();
- text = body.getNullableString();
+ text = getBody().getNullableString();
}
// Package protected ---------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -117,6 +117,7 @@
int consumerMaxRate,
int sendWindowSize,
int producerMaxRate,
+ int minLargeMessageSize,
boolean blockOnAcknowledge,
boolean blockOnNonPersistentSend,
boolean blockOnPersistentSend,
@@ -136,6 +137,7 @@
int consumerMaxRate,
int sendWindowSize,
int producerMaxRate,
+ int minLargeMessageSize,
boolean blockOnAcknowledge,
boolean blockOnNonPersistentSend,
boolean blockOnPersistentSend,
Modified: trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerDeployer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerDeployer.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerDeployer.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -40,7 +40,7 @@
private static final String CLIENTID_ELEMENT = "client-id";
private static final String PING_PERIOD_ELEMENT = "ping-period";
-
+
private static final String CALL_TIMEOUT_ELEMENT = "call-timeout";
private static final String DUPS_OK_BATCH_SIZE_ELEMENT = "dups-ok-batch-size";
@@ -54,7 +54,9 @@
private static final String SEND_WINDOW_SIZE = "send-window-size";
private static final String PRODUCER_MAX_RATE_ELEMENT = "producer-max-rate";
-
+
+ private static final String BIG_MESSAGE_ELEMENT = "big-message-size";
+
private static final String BLOCK_ON_ACKNOWLEDGE_ELEMENT = "block-on-acknowledge";
private static final String SEND_NP_MESSAGES_SYNCHRONOUSLY_ELEMENT = "send-np-messages-synchronously";
@@ -137,6 +139,7 @@
int consumerMaxRate = ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
int sendWindowSize = ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE;
int producerMaxRate = ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
+ int minLargeMessageSize = ClientSessionFactoryImpl.DEFAULT_BIG_MESSAGE_SIZE;
boolean blockOnAcknowledge = ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE;
boolean blockOnNonPersistentSend = ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND;
boolean blockOnPersistentSend = ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND;
@@ -174,6 +177,10 @@
{
producerMaxRate = Integer.parseInt(children.item(j).getTextContent().trim());
}
+ else if (BIG_MESSAGE_ELEMENT.equalsIgnoreCase(children.item(j).getNodeName()))
+ {
+ minLargeMessageSize = Integer.parseInt(children.item(j).getTextContent().trim());
+ }
else if (CLIENTID_ELEMENT.equalsIgnoreCase(children.item(j).getNodeName()))
{
clientID = children.item(j).getTextContent().trim();
@@ -407,6 +414,7 @@
consumerMaxRate,
sendWindowSize,
producerMaxRate,
+ minLargeMessageSize,
blockOnAcknowledge,
blockOnNonPersistentSend,
blockOnPersistentSend,
Modified: trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -32,6 +32,7 @@
import javax.naming.InitialContext;
import javax.naming.NamingException;
+import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
import org.jboss.messaging.core.config.TransportConfiguration;
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.management.MessagingServerControlMBean;
@@ -180,7 +181,7 @@
public boolean destroyQueue(final String name) throws Exception
{
undeployDestination(name);
-
+
destinations.remove(name);
managementService.unregisterQueue(name);
postOffice.removeDestination(JBossQueue.createAddressFromName(name), false);
@@ -203,7 +204,7 @@
public boolean createConnectionFactory(String name,
TransportConfiguration connectorConfig,
TransportConfiguration backupConnectorConfig,
- long pingPeriod,
+ long pingPeriod,
long callTimeout,
String clientID,
int dupsOKBatchSize,
@@ -212,6 +213,7 @@
int consumerMaxRate,
int sendWindowSize,
int producerMaxRate,
+ int minLargeMessageSize,
boolean blockOnAcknowledge,
boolean blockOnNonPersistentSend,
boolean blockOnPersistentSend,
@@ -219,48 +221,34 @@
int maxConnections,
String jndiBinding) throws Exception
{
- JBossConnectionFactory cf = connectionFactories.get(name);
- if (cf == null)
- {
- cf = new JBossConnectionFactory(connectorConfig,
- backupConnectorConfig,
- pingPeriod,
- callTimeout,
- clientID,
- dupsOKBatchSize,
- transactionBatchSize,
- consumerWindowSize,
- consumerMaxRate,
- sendWindowSize,
- producerMaxRate,
- blockOnAcknowledge,
- blockOnNonPersistentSend,
- blockOnPersistentSend,
- autoGroup,
- maxConnections);
- connectionFactories.put(name, cf);
- }
- if (!bindToJndi(jndiBinding, cf))
- {
- return false;
- }
- if (connectionFactoryBindings.get(name) == null)
- {
- connectionFactoryBindings.put(name, new ArrayList<String>());
- }
- connectionFactoryBindings.get(name).add(jndiBinding);
-
- List<String> bindings = new ArrayList<String>();
+ ArrayList<String> bindings = new ArrayList<String>(1);
bindings.add(jndiBinding);
- managementService.registerConnectionFactory(name, cf, bindings);
- return true;
+ return createConnectionFactory(name,
+ connectorConfig,
+ backupConnectorConfig,
+ pingPeriod,
+ callTimeout,
+ clientID,
+ dupsOKBatchSize,
+ transactionBatchSize,
+ consumerWindowSize,
+ consumerMaxRate,
+ sendWindowSize,
+ producerMaxRate,
+ minLargeMessageSize,
+ blockOnAcknowledge,
+ blockOnNonPersistentSend,
+ blockOnPersistentSend,
+ autoGroup,
+ maxConnections,
+ bindings);
}
public boolean createConnectionFactory(String name,
TransportConfiguration connectorConfig,
TransportConfiguration backupConnectorConfig,
- long pingPeriod,
+ long pingPeriod,
long callTimeout,
String clientID,
int dupsOKBatchSize,
@@ -269,6 +257,7 @@
int consumerMaxRate,
int sendWindowSize,
int producerMaxRate,
+ int minLargeMessageSize,
boolean blockOnAcknowledge,
boolean blockOnNonPersistentSend,
boolean blockOnPersistentSend,
@@ -281,7 +270,7 @@
{
cf = new JBossConnectionFactory(connectorConfig,
backupConnectorConfig,
- pingPeriod,
+ pingPeriod,
callTimeout,
clientID,
dupsOKBatchSize,
@@ -290,6 +279,8 @@
consumerMaxRate,
sendWindowSize,
producerMaxRate,
+ minLargeMessageSize == -1 ? ClientSessionFactoryImpl.DEFAULT_BIG_MESSAGE_SIZE
+ : minLargeMessageSize,
blockOnAcknowledge,
blockOnNonPersistentSend,
blockOnPersistentSend,
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -87,6 +87,8 @@
int producerWindowSize,
@Parameter(name = "producerMaxRate", desc = "Producer's max rate")
int producerMaxRate,
+ @Parameter(name = "minLargeMessageSize", desc = "Size of what is considered a big message requiring sending in chunks")
+ int minLargeMessageSize,
@Parameter(name = "blockOnAcknowledge", desc = "Does acknowlegment block?")
boolean blockOnAcknowledge,
@Parameter(name = "blockOnNonPersistentSend", desc = "Does sending non persistent messages block?")
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -88,6 +88,7 @@
int consumerMaxRate,
int producerWindowSize,
int producerMaxRate,
+ int minLargeMessageSize,
boolean blockOnAcknowledge,
boolean blockOnNonPersistentSend,
boolean blockOnPersistentSend,
@@ -110,6 +111,7 @@
consumerMaxRate,
producerWindowSize,
producerMaxRate,
+ minLargeMessageSize,
blockOnAcknowledge,
blockOnNonPersistentSend,
blockOnPersistentSend,
Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/CTSMiscellaneousTest.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/CTSMiscellaneousTest.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/CTSMiscellaneousTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -99,6 +99,7 @@
ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE,
ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
+ -1,
true,
true,
true,
Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTest.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTest.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -95,6 +95,8 @@
conn.start();
TextMessage rm = (TextMessage)cons.receive();
+
+ assertNotNull(rm);
assertEquals("message one", rm.getText());
}
Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTestCase.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTestCase.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTestCase.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -49,6 +49,7 @@
ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE,
ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
+ -1,
true,
true,
true,
Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/String64KLimitTest.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/String64KLimitTest.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/String64KLimitTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -21,7 +21,14 @@
*/
package org.jboss.test.messaging.jms;
+import javax.jms.Connection;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
/**
*
* There is a bug in JDK1.3, 1.4 whereby writeUTF fails if more than 64K bytes are written
@@ -64,169 +71,163 @@
return new String(chars);
}
- //Tests commented out until message chunking is complete
- //See http://jira.jboss.org/jira/browse/JBMESSAGING-379
- public void testFoo() throws Exception
- {
+ public void test64KLimitWithTextMessage() throws Exception
+ {
+ Connection conn = null;
+
+ try
+ {
+ conn = cf.createConnection();
+
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = sess.createProducer(queue1);
+
+ MessageConsumer cons = sess.createConsumer(queue1);
+
+ conn.start();
+
+ String s1 = genString(16 * 1024);
+
+ String s2 = genString(32 * 1024);
+
+ String s3 = genString(64 * 1024);
+
+ String s4 = genString(10 * 64 * 1024);
+
+ TextMessage tm1 = sess.createTextMessage(s1);
+
+ TextMessage tm2 = sess.createTextMessage(s2);
+
+ TextMessage tm3 = sess.createTextMessage(s3);
+
+ TextMessage tm4 = sess.createTextMessage(s4);
+
+ prod.send(tm1);
+
+ prod.send(tm2);
+
+ prod.send(tm3);
+
+ prod.send(tm4);
+
+ TextMessage rm1 = (TextMessage)cons.receive(1000);
+
+ assertNotNull(rm1);
+
+ TextMessage rm2 = (TextMessage)cons.receive(1000);
+
+ assertNotNull(rm2);
+
+ TextMessage rm3 = (TextMessage)cons.receive(1000);
+
+ assertNotNull(rm3);
+
+ TextMessage rm4 = (TextMessage)cons.receive(1000);
+
+ assertNotNull(rm4);
+
+ assertEquals(s1.length(), rm1.getText().length());
+
+ assertEquals(s1, rm1.getText());
+
+ assertEquals(s2.length(), rm2.getText().length());
+
+ assertEquals(s2, rm2.getText());
+
+ assertEquals(s3.length(), rm3.getText().length());
+
+ assertEquals(s3, rm3.getText());
+
+ assertEquals(s4.length(), rm4.getText().length());
+
+ assertEquals(s4, rm4.getText());
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ }
}
+
+ public void test64KLimitWithObjectMessage() throws Exception
+ {
+ Connection conn = null;
+
+ try
+ {
+ conn = cf.createConnection();
-// public void test64KLimitWithTextMessage() throws Exception
-// {
-// Connection conn = null;
-//
-// try
-// {
-// conn = cf.createConnection();
-//
-// Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-//
-// MessageProducer prod = sess.createProducer(queue1);
-//
-// MessageConsumer cons = sess.createConsumer(queue1);
-//
-// conn.start();
-//
-// String s1 = genString(16 * 1024);
-//
-// String s2 = genString(32 * 1024);
-//
-// String s3 = genString(64 * 1024);
-//
-// String s4 = genString(10 * 64 * 1024);
-//
-// TextMessage tm1 = sess.createTextMessage(s1);
-//
-// TextMessage tm2 = sess.createTextMessage(s2);
-//
-// TextMessage tm3 = sess.createTextMessage(s3);
-//
-// TextMessage tm4 = sess.createTextMessage(s4);
-//
-// prod.send(tm1);
-//
-// prod.send(tm2);
-//
-// prod.send(tm3);
-//
-// prod.send(tm4);
-//
-// TextMessage rm1 = (TextMessage)cons.receive(1000);
-//
-// assertNotNull(rm1);
-//
-// TextMessage rm2 = (TextMessage)cons.receive(1000);
-//
-// assertNotNull(rm2);
-//
-// TextMessage rm3 = (TextMessage)cons.receive(1000);
-//
-// assertNotNull(rm3);
-//
-// TextMessage rm4 = (TextMessage)cons.receive(1000);
-//
-// assertNotNull(rm4);
-//
-// assertEquals(s1.length(), rm1.getText().length());
-//
-// assertEquals(s1, rm1.getText());
-//
-// assertEquals(s2.length(), rm2.getText().length());
-//
-// assertEquals(s2, rm2.getText());
-//
-// assertEquals(s3.length(), rm3.getText().length());
-//
-// assertEquals(s3, rm3.getText());
-//
-// assertEquals(s4.length(), rm4.getText().length());
-//
-// assertEquals(s4, rm4.getText());
-// }
-// finally
-// {
-// if (conn != null)
-// {
-// conn.close();
-// }
-// }
-// }
-//
-// public void test64KLimitWithObjectMessage() throws Exception
-// {
-// Connection conn = null;
-//
-// try
-// {
-// conn = cf.createConnection();
-//
-// Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-//
-// MessageProducer prod = sess.createProducer(queue1);
-//
-// MessageConsumer cons = sess.createConsumer(queue1);
-//
-// conn.start();
-//
-// String s1 = genString(16 * 1024);
-//
-// String s2 = genString(32 * 1024);
-//
-// String s3 = genString(64 * 1024);
-//
-// String s4 = genString(10 * 64 * 1024);
-//
-// ObjectMessage om1 = sess.createObjectMessage();
-//
-// om1.setObject(s1);
-//
-// ObjectMessage om2 = sess.createObjectMessage();
-//
-// om2.setObject(s2);
-//
-// ObjectMessage om3 = sess.createObjectMessage();
-//
-// om3.setObject(s3);
-//
-// ObjectMessage om4 = sess.createObjectMessage();
-//
-// om4.setObject(s4);
-//
-// prod.send(om1);
-//
-// prod.send(om2);
-//
-// prod.send(om3);
-//
-// prod.send(om4);
-//
-// ObjectMessage rm1 = (ObjectMessage)cons.receive(1000);
-//
-// assertNotNull(rm1);
-//
-// ObjectMessage rm2 = (ObjectMessage)cons.receive(1000);
-//
-// assertNotNull(rm2);
-//
-// ObjectMessage rm3 = (ObjectMessage)cons.receive(1000);
-//
-// assertNotNull(rm3);
-//
-// ObjectMessage rm4 = (ObjectMessage)cons.receive(1000);
-//
-// assertNotNull(rm4);
-//
-// assertEquals(s1, rm1.getObject());
-//
-// assertEquals(s2, rm2.getObject());
-//
-// assertEquals(s3, rm3.getObject());
-//
-// assertEquals(s4, rm4.getObject());
-// }
-// finally
-// {
-// conn.close();
-// }
-// }
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = sess.createProducer(queue1);
+
+ MessageConsumer cons = sess.createConsumer(queue1);
+
+ conn.start();
+
+ String s1 = genString(16 * 1024);
+
+ String s2 = genString(32 * 1024);
+
+ String s3 = genString(64 * 1024);
+
+ String s4 = genString(10 * 64 * 1024);
+
+ ObjectMessage om1 = sess.createObjectMessage();
+
+ om1.setObject(s1);
+
+ ObjectMessage om2 = sess.createObjectMessage();
+
+ om2.setObject(s2);
+
+ ObjectMessage om3 = sess.createObjectMessage();
+
+ om3.setObject(s3);
+
+ ObjectMessage om4 = sess.createObjectMessage();
+
+ om4.setObject(s4);
+
+ prod.send(om1);
+
+ prod.send(om2);
+
+ prod.send(om3);
+
+ prod.send(om4);
+
+ ObjectMessage rm1 = (ObjectMessage)cons.receive(1000);
+
+ assertNotNull(rm1);
+
+ ObjectMessage rm2 = (ObjectMessage)cons.receive(1000);
+
+ assertNotNull(rm2);
+
+ ObjectMessage rm3 = (ObjectMessage)cons.receive(1000);
+
+ assertNotNull(rm3);
+
+ ObjectMessage rm4 = (ObjectMessage)cons.receive(1000);
+
+ assertNotNull(rm4);
+
+ assertEquals(s1, rm1.getObject());
+
+ assertEquals(s2, rm2.getObject());
+
+ assertEquals(s3, rm3.getObject());
+
+ assertEquals(s4, rm4.getObject());
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
}
Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -548,6 +548,7 @@
-1,
ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE,
-1,
+ -1,
blockOnAcknowledge,
true,
true,
Deleted: trunk/tests/src/org/jboss/messaging/tests/integration/base/IntegrationTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/base/IntegrationTestBase.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/base/IntegrationTestBase.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -1,183 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-
-package org.jboss.messaging.tests.integration.base;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.messaging.core.client.ClientMessage;
-import org.jboss.messaging.core.client.ClientSession;
-import org.jboss.messaging.core.client.ClientSessionFactory;
-import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
-import org.jboss.messaging.core.config.Configuration;
-import org.jboss.messaging.core.config.TransportConfiguration;
-import org.jboss.messaging.core.config.impl.ConfigurationImpl;
-import org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory;
-import org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory;
-import org.jboss.messaging.integration.transports.netty.NettyAcceptorFactory;
-import org.jboss.messaging.integration.transports.netty.NettyConnectorFactory;
-import org.jboss.messaging.core.server.MessagingService;
-import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
-import org.jboss.messaging.core.settings.impl.QueueSettings;
-import org.jboss.messaging.jms.client.JBossBytesMessage;
-import org.jboss.messaging.jms.client.JBossTextMessage;
-import org.jboss.messaging.tests.util.UnitTestCase;
-
-/**
- *
- * Base class with basic utilities on starting up a basic server
- *
- * @author <a href="mailto:clebert.suconic at jboss.com">Clebert Suconic</a>
- *
- */
-public class IntegrationTestBase extends UnitTestCase
-{
-
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- protected static final String INVM_ACCEPTOR_FACTORY = InVMAcceptorFactory.class.getCanonicalName();
- protected static final String INVM_CONNECTOR_FACTORY = InVMConnectorFactory.class.getCanonicalName();
-
- protected static final String NETTY_ACCEPTOR_FACTORY = NettyAcceptorFactory.class.getCanonicalName();
- protected static final String NETTY_CONNECTOR_FACTORY = NettyConnectorFactory.class.getCanonicalName();
-
- protected String journalDir = System.getProperty("java.io.tmpdir", "/tmp") + "/integration-test/journal";
- protected String bindingsDir = System.getProperty("java.io.tmpdir", "/tmp") + "/integration-test/bindings";
- protected String pageDir = System.getProperty("java.io.tmpdir", "/tmp") + "/integration-test/page";
- protected MessagingService messagingService;
-
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- protected void clearData()
- {
- File file = new File(journalDir);
- File file2 = new File(bindingsDir);
- File file3 = new File(pageDir);
- deleteDirectory(file);
- file.mkdirs();
- deleteDirectory(file2);
- file2.mkdirs();
- deleteDirectory(file3);
- file3.mkdirs();
- }
-
-
- protected MessagingService createService(boolean realFiles, boolean netty, Configuration configuration, Map<String, QueueSettings> settings)
- {
- TransportConfiguration transportConfig = new TransportConfiguration(INVM_ACCEPTOR_FACTORY);
- configuration.getAcceptorConfigurations().add(transportConfig);
-
- if (netty)
- {
- configuration.getAcceptorConfigurations().add(new TransportConfiguration(NETTY_ACCEPTOR_FACTORY));
- }
-
- MessagingService service;
-
- if (realFiles)
- {
- service = MessagingServiceImpl.newNioStorageMessagingServer(configuration, journalDir, bindingsDir);
- }
- else
- {
- service = MessagingServiceImpl.newNullStorageMessagingServer(configuration);
- }
-
-
- for (Map.Entry<String, QueueSettings> setting: settings.entrySet())
- {
- service.getServer().getQueueSettingsRepository().addMatch(setting.getKey(), setting.getValue());
- }
-
-
- return service;
- }
-
- protected MessagingService createService(boolean realFiles)
- {
- return createService(realFiles, false, createDefaultConfig(), new HashMap<String, QueueSettings>());
- }
-
-
- protected Configuration createDefaultConfig()
- {
- Configuration configuration = new ConfigurationImpl();
- configuration.setSecurityEnabled(false);
- configuration.setJournalMinFiles(2);
- configuration.setPagingDirectory(pageDir);
-
- return configuration;
- }
-
-
- protected ClientSessionFactory createInVMFactory()
- {
- return new ClientSessionFactoryImpl(new TransportConfiguration(INVM_CONNECTOR_FACTORY));
- }
-
- protected ClientSessionFactory createNettyFactory()
- {
- return new ClientSessionFactoryImpl(new TransportConfiguration(NETTY_CONNECTOR_FACTORY));
- }
-
- protected ClientMessage createTextMessage(ClientSession session, String s)
- {
- return createTextMessage(session, s, true);
- }
-
- protected ClientMessage createTextMessage(ClientSession session, String s, boolean durable)
- {
- ClientMessage message = session.createClientMessage(JBossTextMessage.TYPE, durable, 0, System.currentTimeMillis(), (byte) 1);
- message.getBody().putString(s);
- message.getBody().flip();
- return message;
- }
-
- protected ClientMessage createBytesMessage(ClientSession session, byte[] b, boolean durable)
- {
- ClientMessage message = session.createClientMessage(JBossBytesMessage.TYPE, durable, 0, System.currentTimeMillis(), (byte) 1);
- message.getBody().putBytes(b);
- message.getBody().flip();
- return message;
- }
-
-
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Copied: trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage (from rev 5358, branches/Branch_Chunk_3/tests/src/org/jboss/messaging/tests/integration/chunkmessage)
Deleted: trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/ChunkTestBase.java
===================================================================
--- branches/Branch_Chunk_3/tests/src/org/jboss/messaging/tests/integration/chunkmessage/ChunkTestBase.java 2008-11-14 02:52:55 UTC (rev 5358)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/ChunkTestBase.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -1,447 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.messaging.tests.integration.chunkmessage;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.nio.ByteBuffer;
-import java.nio.channels.FileChannel;
-
-import org.jboss.messaging.core.client.ClientConsumer;
-import org.jboss.messaging.core.client.ClientMessage;
-import org.jboss.messaging.core.client.ClientProducer;
-import org.jboss.messaging.core.client.ClientSession;
-import org.jboss.messaging.core.client.ClientSessionFactory;
-import org.jboss.messaging.core.client.FileClientMessage;
-import org.jboss.messaging.core.exception.MessagingException;
-import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.core.message.impl.MessageImpl;
-import org.jboss.messaging.core.remoting.impl.ByteBufferWrapper;
-import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
-import org.jboss.messaging.tests.util.ServiceTestBase;
-import org.jboss.messaging.util.DataConstants;
-import org.jboss.messaging.util.SimpleString;
-
-/**
- * A ChunkTestBase
- *
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- *
- * Created Oct 29, 2008 11:43:52 AM
- *
- *
- */
-public class ChunkTestBase extends ServiceTestBase
-{
-
- // Constants -----------------------------------------------------
- private static final Logger log = Logger.getLogger(ChunkTestBase.class);
-
- protected final SimpleString ADDRESS = new SimpleString("SimpleAddress");
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- @Override
- protected void tearDown() throws Exception
- {
- super.tearDown();
- deleteData();
- }
-
- protected void testChunks(final boolean realFiles,
- final boolean useFile,
- final int numberOfMessages,
- final int numberOfIntegers,
- final boolean sendingBlocking,
- final int waitOnConsumer,
- final long delayDelivery) throws Exception
- {
- testChunks(realFiles,
- useFile,
- numberOfMessages,
- numberOfIntegers,
- sendingBlocking,
- waitOnConsumer,
- delayDelivery,
- false);
- }
-
- protected void testChunks(final boolean realFiles,
- final boolean useFile,
- final int numberOfMessages,
- final int numberOfIntegers,
- final boolean sendingBlocking,
- final int waitOnConsumer,
- final long delayDelivery,
- final boolean testTime) throws Exception
- {
-
- clearData();
-
- messagingService = createService(realFiles);
- messagingService.start();
-
- try
- {
- ClientSessionFactory sf = createInVMFactory();
-
- if (sendingBlocking)
- {
- sf.setBlockOnNonPersistentSend(true);
- sf.setBlockOnPersistentSend(true);
- sf.setBlockOnAcknowledge(true);
- }
-
- ClientSession session = sf.createSession(false, true, true);
-
- session.createQueue(ADDRESS, ADDRESS, null, true, false, true);
-
- ClientProducer producer = session.createProducer(ADDRESS);
-
- if (useFile)
- {
- File tmpData = createLargeFile(temporaryDir, "someFile.dat", numberOfIntegers);
-
- for (int i = 0; i < numberOfMessages; i++)
- {
- ClientMessage message = session.createFileMessage(true);
- ((FileClientMessage)message).setFile(tmpData);
- message.putIntProperty(new SimpleString("counter-message"), i);
- long timeStart = System.currentTimeMillis();
- if (delayDelivery > 0)
- {
- long time = System.currentTimeMillis();
- message.putLongProperty(new SimpleString("original-time"), time);
- message.putLongProperty(MessageImpl.HDR_SCHEDULED_DELIVERY_TIME, time + 1000);
-
- producer.send(message);
- }
- else
- {
- producer.send(message);
- }
-
- if (testTime)
- {
- System.out.println("Message sent in " + (System.currentTimeMillis() - timeStart));
- }
- }
- }
- else
- {
- for (int i = 0; i < numberOfMessages; i++)
- {
- ClientMessage message = session.createClientMessage(true);
- message.putIntProperty(new SimpleString("counter-message"), i);
- message.setBody(createLargeBuffer(numberOfIntegers));
- long timeStart = System.currentTimeMillis();
- if (delayDelivery > 0)
- {
- long time = System.currentTimeMillis();
- message.putLongProperty(new SimpleString("original-time"), time);
- message.putLongProperty(MessageImpl.HDR_SCHEDULED_DELIVERY_TIME, time + 1000);
-
- producer.send(message);
- }
- else
- {
- producer.send(message);
- }
- if (testTime)
- {
- System.out.println("Message sent in " + (System.currentTimeMillis() - timeStart));
- }
- }
- }
-
- session.close();
-
- if (realFiles)
- {
- messagingService.stop();
-
- messagingService = createService(realFiles);
- messagingService.start();
-
- sf = createInVMFactory();
- }
-
- session = sf.createSession(false, true, true);
-
- ClientConsumer consumer = null;
-
- if (realFiles)
- {
- consumer = session.createFileConsumer(new File(clientLargeMessagesDir), ADDRESS);
- }
- else
- {
- consumer = session.createConsumer(ADDRESS);
- }
-
- session.start();
-
- for (int i = 0; i < numberOfMessages; i++)
- {
- long start = System.currentTimeMillis();
-
- ClientMessage message = consumer.receive(waitOnConsumer + delayDelivery);
-
- assertNotNull(message);
-
- if (testTime)
- {
- System.out.println("Message received in " + (System.currentTimeMillis() - start));
- }
- start = System.currentTimeMillis();
-
- if (delayDelivery > 0)
- {
- long originalTime = (Long)message.getProperty(new SimpleString("original-time"));
- assertTrue("difference = " + (System.currentTimeMillis() - originalTime),
- System.currentTimeMillis() - originalTime >= delayDelivery);
- }
-
- message.acknowledge();
-
- assertNotNull(message);
-
- if (delayDelivery <= 0)
- { // right now there is no guarantee of ordered delivered on multiple scheduledMessages
- assertEquals(i, ((Integer)message.getProperty(new SimpleString("counter-message"))).intValue());
- }
-
- if (!testTime)
- {
- if (message instanceof FileClientMessage)
- {
- checkFileRead(((FileClientMessage)message).getFile(), numberOfIntegers);
- }
- else
- {
- MessagingBuffer buffer = message.getBody();
- buffer.rewind();
- assertEquals(numberOfIntegers * DataConstants.SIZE_INT, buffer.limit());
- for (int b = 0; b < numberOfIntegers; b++)
- {
- assertEquals(b, buffer.getInt());
- }
- }
- }
- }
-
- session.close();
-
- validateNoFilesOnLargeDir();
- }
- finally
- {
- try
- {
- messagingService.stop();
- }
- catch (Throwable ignored)
- {
- }
- }
- }
-
- protected MessagingBuffer createLargeBuffer(final int numberOfIntegers)
- {
- ByteBuffer ioBuffer = ByteBuffer.allocate(DataConstants.SIZE_INT * numberOfIntegers);
- MessagingBuffer body = new ByteBufferWrapper(ioBuffer);
-
- for (int i = 0; i < numberOfIntegers; i++)
- {
- body.putInt(i);
- }
- body.flip();
-
- return body;
-
- }
-
- protected FileClientMessage createLargeClientMessage(final ClientSession session, final int numberOfIntegers) throws Exception
- {
-
- FileClientMessage clientMessage = session.createFileMessage(true);
-
- File tmpFile = createLargeFile(temporaryDir, "tmpUpload.data", numberOfIntegers);
-
- clientMessage.setFile(tmpFile);
-
- return clientMessage;
- }
-
- /**
- * @param name
- * @param numberOfIntegers
- * @return
- * @throws FileNotFoundException
- * @throws IOException
- */
- protected File createLargeFile(final String directory, final String name, final int numberOfIntegers) throws FileNotFoundException,
- IOException
- {
- File tmpFile = new File(directory + "/" + name);
-
- log.info("Creating file " + tmpFile);
-
- RandomAccessFile random = new RandomAccessFile(tmpFile, "rw");
- FileChannel channel = random.getChannel();
-
- ByteBuffer buffer = ByteBuffer.allocate(4 * 1000);
-
- for (int i = 0; i < numberOfIntegers; i++)
- {
- if (buffer.position() > 0 && i % 1000 == 0)
- {
- buffer.flip();
- channel.write(buffer);
- buffer.clear();
- }
- buffer.putInt(i);
- }
-
- if (buffer.position() > 0)
- {
- buffer.flip();
- channel.write(buffer);
- }
-
- channel.close();
- random.close();
-
- log.info("file " + tmpFile + " created");
-
- return tmpFile;
- }
-
- /**
- * @param session
- * @param queueToRead
- * @param numberOfIntegers
- * @throws MessagingException
- * @throws FileNotFoundException
- * @throws IOException
- */
- protected void readMessage(final ClientSession session, final SimpleString queueToRead, final int numberOfIntegers) throws MessagingException,
- FileNotFoundException,
- IOException
- {
- session.start();
-
- ClientConsumer consumer = session.createFileConsumer(new File(clientLargeMessagesDir), queueToRead);
-
- ClientMessage clientMessage = consumer.receive(5000);
-
- if (!(clientMessage instanceof FileClientMessage))
- {
- System.out.println("Size = " + clientMessage.getBodySize());
- }
-
- assertTrue(clientMessage instanceof FileClientMessage);
-
- FileClientMessage fileClientMessage = (FileClientMessage)clientMessage;
-
- assertNotNull(fileClientMessage);
- File receivedFile = fileClientMessage.getFile();
-
- checkFileRead(receivedFile, numberOfIntegers);
-
- clientMessage.acknowledge();
-
- consumer.close();
- }
-
- /**
- * @param receivedFile
- * @throws FileNotFoundException
- * @throws IOException
- */
- protected void checkFileRead(final File receivedFile, final int numberOfIntegers) throws FileNotFoundException,
- IOException
- {
- RandomAccessFile random2 = new RandomAccessFile(receivedFile, "r");
- FileChannel channel2 = random2.getChannel();
-
- ByteBuffer buffer2 = ByteBuffer.allocate(1000 * 4);
-
- channel2.position(0l);
-
- for (int i = 0; i < numberOfIntegers;)
- {
- channel2.read(buffer2);
-
- buffer2.flip();
- for (int j = 0; j < buffer2.limit() / 4; j++, i++)
- {
- assertEquals(i, buffer2.getInt());
- }
-
- buffer2.clear();
- }
-
- channel2.close();
- }
-
- /**
- * Deleting a file on LargeDire is an asynchronous process. Wee need to keep looking for a while if the file hasn't been deleted yet
- */
- protected void validateNoFilesOnLargeDir() throws Exception
- {
- File largeMessagesFileDir = new File(largeMessagesDir);
-
- // Deleting the file is async... we keep looking for a period of the time until the file is really gone
- for (int i = 0; i < 100; i++)
- {
- if (largeMessagesFileDir.listFiles().length > 0)
- {
- Thread.sleep(1000);
- }
- else
- {
- break;
- }
- }
-
- assertEquals(0, largeMessagesFileDir.listFiles().length);
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Copied: trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/ChunkTestBase.java (from rev 5358, branches/Branch_Chunk_3/tests/src/org/jboss/messaging/tests/integration/chunkmessage/ChunkTestBase.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/ChunkTestBase.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/ChunkTestBase.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -0,0 +1,461 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.tests.integration.chunkmessage;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
+
+import org.jboss.messaging.core.client.ClientConsumer;
+import org.jboss.messaging.core.client.ClientMessage;
+import org.jboss.messaging.core.client.ClientProducer;
+import org.jboss.messaging.core.client.ClientSession;
+import org.jboss.messaging.core.client.ClientSessionFactory;
+import org.jboss.messaging.core.client.FileClientMessage;
+import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.message.impl.MessageImpl;
+import org.jboss.messaging.core.remoting.impl.ByteBufferWrapper;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+import org.jboss.messaging.tests.util.ServiceTestBase;
+import org.jboss.messaging.util.DataConstants;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ * A ChunkTestBase
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ * Created Oct 29, 2008 11:43:52 AM
+ *
+ *
+ */
+public class ChunkTestBase extends ServiceTestBase
+{
+
+ // Constants -----------------------------------------------------
+ private static final Logger log = Logger.getLogger(ChunkTestBase.class);
+
+ protected final SimpleString ADDRESS = new SimpleString("SimpleAddress");
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ deleteData();
+ }
+
+ protected void testChunks(final boolean realFiles,
+ final boolean useFile,
+ final int numberOfMessages,
+ final int numberOfIntegers,
+ final boolean sendingBlocking,
+ final int waitOnConsumer,
+ final long delayDelivery) throws Exception
+ {
+ testChunks(realFiles,
+ useFile,
+ numberOfMessages,
+ numberOfIntegers,
+ sendingBlocking,
+ waitOnConsumer,
+ delayDelivery,
+ false);
+ }
+
+ protected void testChunks(final boolean realFiles,
+ final boolean useFile,
+ final int numberOfMessages,
+ final int numberOfIntegers,
+ final boolean sendingBlocking,
+ final int waitOnConsumer,
+ final long delayDelivery,
+ final boolean testTime) throws Exception
+ {
+
+ clearData();
+
+ messagingService = createService(realFiles);
+ messagingService.start();
+
+ try
+ {
+ ClientSessionFactory sf = createInVMFactory();
+
+ if (sendingBlocking)
+ {
+ sf.setBlockOnNonPersistentSend(true);
+ sf.setBlockOnPersistentSend(true);
+ sf.setBlockOnAcknowledge(true);
+ }
+
+ ClientSession session = sf.createSession(null, null, false, true, true, 0);
+
+ session.createQueue(ADDRESS, ADDRESS, null, true, false, true);
+
+ ClientProducer producer = session.createProducer(ADDRESS);
+
+ if (useFile)
+ {
+ File tmpData = createLargeFile(temporaryDir, "someFile.dat", numberOfIntegers);
+
+ for (int i = 0; i < numberOfMessages; i++)
+ {
+ ClientMessage message = session.createFileMessage(true);
+ ((FileClientMessage)message).setFile(tmpData);
+ message.putIntProperty(new SimpleString("counter-message"), i);
+ long timeStart = System.currentTimeMillis();
+ if (delayDelivery > 0)
+ {
+ long time = System.currentTimeMillis();
+ message.putLongProperty(new SimpleString("original-time"), time);
+ message.putLongProperty(MessageImpl.HDR_SCHEDULED_DELIVERY_TIME, time + delayDelivery);
+
+ producer.send(message);
+ }
+ else
+ {
+ producer.send(message);
+ }
+
+ if (testTime)
+ {
+ System.out.println("Message sent in " + (System.currentTimeMillis() - timeStart));
+ }
+ }
+ }
+ else
+ {
+ for (int i = 0; i < numberOfMessages; i++)
+ {
+ ClientMessage message = session.createClientMessage(true);
+ message.putIntProperty(new SimpleString("counter-message"), i);
+ message.setBody(createLargeBuffer(numberOfIntegers));
+ long timeStart = System.currentTimeMillis();
+ if (delayDelivery > 0)
+ {
+ long time = System.currentTimeMillis();
+ message.putLongProperty(new SimpleString("original-time"), time);
+ message.putLongProperty(MessageImpl.HDR_SCHEDULED_DELIVERY_TIME, time + delayDelivery);
+
+ producer.send(message);
+ }
+ else
+ {
+ producer.send(message);
+ }
+ if (testTime)
+ {
+ System.out.println("Message sent in " + (System.currentTimeMillis() - timeStart));
+ }
+ }
+ }
+
+ session.close();
+
+ if (realFiles)
+ {
+ messagingService.stop();
+
+ messagingService = createService(realFiles);
+ messagingService.start();
+
+ sf = createInVMFactory();
+ }
+
+ session = sf.createSession(null, null, false, true, true, 0);
+
+ ClientConsumer consumer = null;
+
+ if (realFiles)
+ {
+ consumer = session.createFileConsumer(new File(clientLargeMessagesDir), ADDRESS);
+ }
+ else
+ {
+ consumer = session.createConsumer(ADDRESS);
+ }
+
+ session.start();
+
+ for (int i = 0; i < numberOfMessages; i++)
+ {
+ long start = System.currentTimeMillis();
+
+ ClientMessage message = consumer.receive(waitOnConsumer + delayDelivery);
+
+ assertNotNull(message);
+
+ if (realFiles)
+ {
+ assertTrue (message instanceof FileClientMessage);
+ }
+
+ if (testTime)
+ {
+ System.out.println("Message received in " + (System.currentTimeMillis() - start));
+ }
+ start = System.currentTimeMillis();
+
+ if (delayDelivery > 0)
+ {
+ long originalTime = (Long)message.getProperty(new SimpleString("original-time"));
+ assertTrue((System.currentTimeMillis() - originalTime) + "<" + delayDelivery,
+ System.currentTimeMillis() - originalTime >= delayDelivery);
+ }
+
+ message.acknowledge();
+
+ assertNotNull(message);
+
+ if (delayDelivery <= 0)
+ { // right now there is no guarantee of ordered delivered on multiple scheduledMessages
+ assertEquals(i, ((Integer)message.getProperty(new SimpleString("counter-message"))).intValue());
+ }
+
+ if (!testTime)
+ {
+ if (message instanceof FileClientMessage)
+ {
+ checkFileRead(((FileClientMessage)message).getFile(), numberOfIntegers);
+ }
+ else
+ {
+ MessagingBuffer buffer = message.getBody();
+ buffer.rewind();
+ assertEquals(numberOfIntegers * DataConstants.SIZE_INT, buffer.limit());
+ for (int b = 0; b < numberOfIntegers; b++)
+ {
+ assertEquals(b, buffer.getInt());
+ }
+ }
+ }
+ }
+
+ session.close();
+
+ validateNoFilesOnLargeDir();
+ }
+ finally
+ {
+ try
+ {
+ messagingService.stop();
+ }
+ catch (Throwable ignored)
+ {
+ }
+ }
+ }
+
+ protected MessagingBuffer createLargeBuffer(final int numberOfIntegers)
+ {
+ ByteBuffer ioBuffer = ByteBuffer.allocate(DataConstants.SIZE_INT * numberOfIntegers);
+ MessagingBuffer body = new ByteBufferWrapper(ioBuffer);
+
+ for (int i = 0; i < numberOfIntegers; i++)
+ {
+ body.putInt(i);
+ }
+ body.flip();
+
+ return body;
+
+ }
+
+ protected FileClientMessage createLargeClientMessage(final ClientSession session, final int numberOfIntegers) throws Exception
+ {
+
+ FileClientMessage clientMessage = session.createFileMessage(true);
+
+ File tmpFile = createLargeFile(temporaryDir, "tmpUpload.data", numberOfIntegers);
+
+ clientMessage.setFile(tmpFile);
+
+ return clientMessage;
+ }
+
+ /**
+ * @param name
+ * @param numberOfIntegers
+ * @return
+ * @throws FileNotFoundException
+ * @throws IOException
+ */
+ protected File createLargeFile(final String directory, final String name, final int numberOfIntegers) throws FileNotFoundException,
+ IOException
+ {
+ File tmpFile = new File(directory + "/" + name);
+
+ log.info("Creating file " + tmpFile);
+
+ RandomAccessFile random = new RandomAccessFile(tmpFile, "rw");
+ FileChannel channel = random.getChannel();
+
+ ByteBuffer buffer = ByteBuffer.allocate(4 * 1000);
+
+ for (int i = 0; i < numberOfIntegers; i++)
+ {
+ if (buffer.position() > 0 && i % 1000 == 0)
+ {
+ buffer.flip();
+ channel.write(buffer);
+ buffer.clear();
+ }
+ buffer.putInt(i);
+ }
+
+ if (buffer.position() > 0)
+ {
+ buffer.flip();
+ channel.write(buffer);
+ }
+
+ channel.close();
+ random.close();
+
+ log.info("file " + tmpFile + " created");
+
+ return tmpFile;
+ }
+
+ /**
+ * @param session
+ * @param queueToRead
+ * @param numberOfIntegers
+ * @throws MessagingException
+ * @throws FileNotFoundException
+ * @throws IOException
+ */
+ protected void readMessage(final ClientSession session, final SimpleString queueToRead, final int numberOfIntegers) throws MessagingException,
+ FileNotFoundException,
+ IOException
+ {
+ session.start();
+
+ ClientConsumer consumer = session.createFileConsumer(new File(clientLargeMessagesDir), queueToRead);
+
+ ClientMessage clientMessage = consumer.receive(5000);
+
+ assertNotNull(clientMessage);
+
+ if (!(clientMessage instanceof FileClientMessage))
+ {
+ System.out.println("Size = " + clientMessage.getBodySize());
+ }
+
+
+ if (clientMessage instanceof FileClientMessage)
+ {
+ assertTrue(clientMessage instanceof FileClientMessage);
+
+ FileClientMessage fileClientMessage = (FileClientMessage)clientMessage;
+
+ assertNotNull(fileClientMessage);
+ File receivedFile = fileClientMessage.getFile();
+
+ checkFileRead(receivedFile, numberOfIntegers);
+
+ }
+
+ clientMessage.acknowledge();
+
+ session.commit();
+
+ consumer.close();
+ }
+
+ /**
+ * @param receivedFile
+ * @throws FileNotFoundException
+ * @throws IOException
+ */
+ protected void checkFileRead(final File receivedFile, final int numberOfIntegers) throws FileNotFoundException,
+ IOException
+ {
+ RandomAccessFile random2 = new RandomAccessFile(receivedFile, "r");
+ FileChannel channel2 = random2.getChannel();
+
+ ByteBuffer buffer2 = ByteBuffer.allocate(1000 * 4);
+
+ channel2.position(0l);
+
+ for (int i = 0; i < numberOfIntegers;)
+ {
+ channel2.read(buffer2);
+
+ buffer2.flip();
+ for (int j = 0; j < buffer2.limit() / 4; j++, i++)
+ {
+ assertEquals(i, buffer2.getInt());
+ }
+
+ buffer2.clear();
+ }
+
+ channel2.close();
+ }
+
+ /**
+ * Deleting a file on LargeDire is an asynchronous process. Wee need to keep looking for a while if the file hasn't been deleted yet
+ */
+ protected void validateNoFilesOnLargeDir() throws Exception
+ {
+ File largeMessagesFileDir = new File(largeMessagesDir);
+
+ // Deleting the file is async... we keep looking for a period of the time until the file is really gone
+ for (int i = 0; i < 100; i++)
+ {
+ if (largeMessagesFileDir.listFiles().length > 0)
+ {
+ Thread.sleep(10);
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ assertEquals(0, largeMessagesFileDir.listFiles().length);
+ }
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Deleted: trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/MessageChunkTest.java
===================================================================
--- branches/Branch_Chunk_3/tests/src/org/jboss/messaging/tests/integration/chunkmessage/MessageChunkTest.java 2008-11-14 02:52:55 UTC (rev 5358)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/MessageChunkTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -1,506 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.messaging.tests.integration.chunkmessage;
-
-import java.io.File;
-import java.nio.ByteBuffer;
-import java.util.HashMap;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import junit.framework.AssertionFailedError;
-
-import org.jboss.messaging.core.client.ClientConsumer;
-import org.jboss.messaging.core.client.ClientMessage;
-import org.jboss.messaging.core.client.ClientProducer;
-import org.jboss.messaging.core.client.ClientSession;
-import org.jboss.messaging.core.client.ClientSessionFactory;
-import org.jboss.messaging.core.client.FileClientMessage;
-import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
-import org.jboss.messaging.core.client.impl.ClientSessionImpl;
-import org.jboss.messaging.core.config.Configuration;
-import org.jboss.messaging.core.config.TransportConfiguration;
-import org.jboss.messaging.core.exception.MessagingException;
-import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.core.remoting.impl.ByteBufferWrapper;
-import org.jboss.messaging.core.remoting.impl.RemotingConnectionImpl;
-import org.jboss.messaging.core.remoting.impl.RemotingServiceImpl;
-import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
-import org.jboss.messaging.core.settings.impl.QueueSettings;
-import org.jboss.messaging.tests.integration.chunkmessage.mock.MockConnector;
-import org.jboss.messaging.tests.integration.chunkmessage.mock.MockConnectorFactory;
-import org.jboss.messaging.util.DataConstants;
-import org.jboss.messaging.util.SimpleString;
-
-/**
- * A TestMessageChunk
- *
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- *
- * Created 29-Sep-08 4:04:10 PM
- *
- *
- */
-public class MessageChunkTest extends ChunkTestBase
-{
-
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- static final SimpleString ADDRESS = new SimpleString("SimpleAddress");
-
- // Static --------------------------------------------------------
- private static final Logger log = Logger.getLogger(MessageChunkTest.class);
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public void testCleanup() throws Exception
- {
- clearData();
-
- createLargeFile(largeMessagesDir, "1234.tmp", 13333);
-
- Configuration config = createDefaultConfig();
-
- messagingService = createService(true, config, new HashMap<String, QueueSettings>());
-
- messagingService.start();
-
- try
- {
-
- File directoryLarge = new File(largeMessagesDir);
-
- assertEquals(0, directoryLarge.list().length);
- }
- finally
- {
- messagingService.stop();
- }
- }
-
- public void testFailureOnSendingFile() throws Exception
- {
- clearData();
-
- Configuration config = createDefaultConfig();
-
- config.setPagingMaxGlobalSizeBytes(20 * 1024);
- config.setPagingDefaultSize(10 * 1024);
-
- messagingService = createService(true, config, new HashMap<String, QueueSettings>());
-
- messagingService.start();
-
- final int numberOfIntegersBigMessage = 150000;
-
- ClientSession session = null;
-
- class LocalCallback implements MockConnector.MockCallback
- {
-
- AtomicInteger counter = new AtomicInteger(0);
-
- ClientSession session;
-
- public void onWrite(final MessagingBuffer buffer)
- {
- if (counter.incrementAndGet() == 5)
- {
- RemotingConnectionImpl conn = (RemotingConnectionImpl)((ClientSessionImpl)session).getConnection();
- RemotingServiceImpl remotingServiceImpl = (RemotingServiceImpl)messagingService.getServer()
- .getRemotingService();
- remotingServiceImpl.connectionException(conn.getID(),
- new MessagingException(MessagingException.NOT_CONNECTED, "blah!"));
- conn.fail(new MessagingException(MessagingException.NOT_CONNECTED, "blah"));
- throw new IllegalStateException("blah");
- }
- }
-
- }
-
- LocalCallback callback = new LocalCallback();
-
- try
- {
- HashMap<String, Object> parameters = new HashMap<String, Object>();
- parameters.put("callback", callback);
-
- TransportConfiguration transport = new TransportConfiguration(MockConnectorFactory.class.getCanonicalName(),
- parameters);
-
- ClientSessionFactory mockFactory = new ClientSessionFactoryImpl(transport);
-
- mockFactory.setBlockOnNonPersistentSend(false);
- mockFactory.setBlockOnPersistentSend(false);
- mockFactory.setBlockOnAcknowledge(false);
-
- session = mockFactory.createSession(false, true, true);
-
- callback.session = session;
-
- session.createQueue(ADDRESS, ADDRESS, null, true, false, true);
-
- ClientProducer producer = session.createProducer(ADDRESS);
-
- FileClientMessage clientLarge = createLargeClientMessage(session, numberOfIntegersBigMessage);
-
- try
- {
- producer.send(clientLarge);
- fail("Exception was expected!");
- }
- catch (Exception e)
- {
- }
-
- validateNoFilesOnLargeDir();
-
- }
- finally
- {
- try
- {
- messagingService.stop();
- }
- catch (Exception ignored)
- {
- ignored.printStackTrace();
- }
- }
-
- }
-
- // Validate the functions to create and verify files
- public void testFiles() throws Exception
- {
- clearData();
-
- File file = createLargeFile(temporaryDir, "test.tst", 13333);
-
- checkFileRead(file, 13333);
- }
-
- public void testMessageChunkFilePersistence() throws Exception
- {
- testChunks(true, false, 100, 262144, false, 1000, 0);
- }
-
- public void testMessageChunkFilePersistenceDelayed() throws Exception
- {
- testChunks(true, false, 1, 50000, false, 1000, 2000);
- }
-
- public void testMessageChunkNullPersistence() throws Exception
- {
- testChunks(false, false, 1, 50000, false, 1000, 0);
- }
-
- public void testMessageChunkNullPersistenceDelayed() throws Exception
- {
- testChunks(false, false, 100, 50000, false, 10000, 100);
- }
-
- public void testPageOnLargeMessage() throws Exception
- {
- testPageOnLargeMessage(true, false);
-
- }
-
- public void testPageOnLargeMessageNullPersistence() throws Exception
- {
- testPageOnLargeMessage(false, false);
-
- }
-
- public void testSendfileMessage() throws Exception
- {
- testChunks(true, true, 100, 50000, false, 1000, 0);
-
- }
-
- public void testSendfileMessageOnNullPersistence() throws Exception
- {
- testChunks(false, true, 100, 50000, false, 1000, 0);
- }
-
- public void testSendfileMessageOnNullPersistenceSmallMessage() throws Exception
- {
- testChunks(false, true, 100, 100, false, 1000, 0);
- }
-
- public void testSendfileMessageSmallMessage() throws Exception
- {
- testChunks(true, true, 100, 4, false, 1000, 0);
-
- }
-
- public void testSendRegularMessageNullPersistence() throws Exception
- {
- testChunks(false, false, 100, 100, false, 1000, 0);
- }
-
- public void testSendRegularMessageNullPersistenceDelayed() throws Exception
- {
- testChunks(false, false, 100, 100, false, 1000, 1000);
- }
-
- public void testSendRegularMessagePersistence() throws Exception
- {
- testChunks(true, false, 100, 100, false, 1000, 0);
- }
-
- public void testSendRegularMessagePersistenceDelayed() throws Exception
- {
- testChunks(true, false, 100, 100, false, 1000, 1000);
- }
-
- public void testTwoBindingsOneAckAndrestart() throws Exception
- {
- // there are two bindings.. one is ACKed, the other is not, the server is restarted
- // The other binding is acked... The file must be deleted
-
- clearData();
-
- try
- {
-
- messagingService = createService(true);
-
- messagingService.start();
-
- SimpleString queue[] = new SimpleString[] { new SimpleString("queue1"), new SimpleString("queue2") };
-
- ClientSessionFactory sf = createInVMFactory();
-
- ClientSession session = sf.createSession(false, true, true);
-
- session.createQueue(ADDRESS, queue[0], null, true, false, true);
- session.createQueue(ADDRESS, queue[1], null, true, false, true);
-
- int numberOfIntegers = 100000;
-
- FileClientMessage clientFile = createLargeClientMessage(session, numberOfIntegers);
-
- ClientProducer producer = session.createProducer(ADDRESS);
- producer.send(clientFile);
-
- producer.close();
-
- readMessage(session, queue[0], numberOfIntegers);
-
- session.close();
-
- messagingService.stop();
-
- messagingService = createService(true);
-
- messagingService.start();
-
- sf = createInVMFactory();
-
- session = sf.createSession(false, true, true);
-
- readMessage(session, queue[1], numberOfIntegers);
-
- session.close();
-
- validateNoFilesOnLargeDir();
- }
- finally
- {
- try
- {
- messagingService.stop();
- }
- catch (Throwable ignored)
- {
- }
- }
-
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- log.info("\n*********************************************************************************\n Starting " + this.getName() + "\n*********************************************************************************");
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- super.tearDown();
- log.info("\n*********************************************************************************\nDone with " + this.getName() + "\n*********************************************************************************" );
- }
-
- protected void testPageOnLargeMessage(final boolean realFiles, final boolean sendBlocking) throws Exception
- {
-
- clearData();
-
- Configuration config = createDefaultConfig();
-
- config.setPagingMaxGlobalSizeBytes(20 * 1024);
- config.setPagingDefaultSize(10 * 1024);
-
- messagingService = createService(realFiles, config, new HashMap<String, QueueSettings>());
-
- messagingService.start();
-
- final int numberOfIntegers = 256;
-
- final int numberOfIntegersBigMessage = 100000;
-
- try
- {
- ClientSessionFactory sf = createInVMFactory();
-
- if (sendBlocking)
- {
- sf.setBlockOnNonPersistentSend(true);
- sf.setBlockOnPersistentSend(true);
- sf.setBlockOnAcknowledge(true);
- }
-
- ClientSession session = sf.createSession(false, true, true);
-
- session.createQueue(ADDRESS, ADDRESS, null, true, false, true);
-
- ClientProducer producer = session.createProducer(ADDRESS);
-
- ByteBuffer ioBuffer = ByteBuffer.allocate(DataConstants.SIZE_INT * numberOfIntegers);
-
- // printBuffer("body to be sent : " , body);
-
- ClientMessage message = null;
-
- MessagingBuffer body = null;
-
- for (int i = 0; i < 100; i++)
- {
- MessagingBuffer bodyLocal = new ByteBufferWrapper(ioBuffer);
-
- for (int j = 1; j <= numberOfIntegers; j++)
- {
- bodyLocal.putInt(j);
- }
- bodyLocal.flip();
-
- if (i == 0)
- {
- body = bodyLocal;
- }
-
- message = session.createClientMessage(true);
- message.setBody(bodyLocal);
-
- producer.send(message);
- }
-
- FileClientMessage clientFile = createLargeClientMessage(session, numberOfIntegersBigMessage);
-
- producer.send(clientFile);
-
- session.close();
-
- if (realFiles)
- {
- messagingService.stop();
-
- messagingService = createService(true, config, new HashMap<String, QueueSettings>());
- messagingService.start();
-
- sf = createInVMFactory();
- }
-
- session = sf.createSession(false, true, true);
-
- ClientConsumer consumer = session.createConsumer(ADDRESS);
-
- // if (realFiles)
- // {
- // consumer.setLargeMessagesAsFiles(true);
- // consumer.setLargeMessagesDir(new File(clientLargeMessagesDir));
- // }
-
- session.start();
-
- for (int i = 0; i < 100; i++)
- {
- ClientMessage message2 = consumer.receive(10000);
-
- assertNotNull(message2);
-
- message2.acknowledge();
-
- assertNotNull(message2);
-
- try
- {
- assertEqualsByteArrays(body.limit(), body.array(), message2.getBody().array());
- }
- catch (AssertionFailedError e)
- {
- log.info("Expected buffer:" + dumbBytesHex(body.array(), 40));
- log.info("Arriving buffer:" + dumbBytesHex(message2.getBody().array(), 40));
- throw e;
- }
- }
-
- consumer.close();
-
- session.close();
-
- session = sf.createSession(false, true, true);
-
- readMessage(session, ADDRESS, numberOfIntegersBigMessage);
-
- // printBuffer("message received : ", message2.getBody());
-
- session.close();
- }
- finally
- {
- try
- {
- messagingService.stop();
- }
- catch (Throwable ignored)
- {
- }
- }
-
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Copied: trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/MessageChunkTest.java (from rev 5358, branches/Branch_Chunk_3/tests/src/org/jboss/messaging/tests/integration/chunkmessage/MessageChunkTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/MessageChunkTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/MessageChunkTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -0,0 +1,605 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.tests.integration.chunkmessage;
+
+import java.io.File;
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import junit.framework.AssertionFailedError;
+
+import org.jboss.messaging.core.client.ClientConsumer;
+import org.jboss.messaging.core.client.ClientMessage;
+import org.jboss.messaging.core.client.ClientProducer;
+import org.jboss.messaging.core.client.ClientSession;
+import org.jboss.messaging.core.client.ClientSessionFactory;
+import org.jboss.messaging.core.client.FileClientMessage;
+import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
+import org.jboss.messaging.core.client.impl.ClientSessionImpl;
+import org.jboss.messaging.core.config.Configuration;
+import org.jboss.messaging.core.config.TransportConfiguration;
+import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.message.Message;
+import org.jboss.messaging.core.remoting.impl.ByteBufferWrapper;
+import org.jboss.messaging.core.remoting.impl.RemotingConnectionImpl;
+import org.jboss.messaging.core.remoting.impl.RemotingServiceImpl;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+import org.jboss.messaging.core.settings.impl.QueueSettings;
+import org.jboss.messaging.tests.integration.chunkmessage.mock.MockConnector;
+import org.jboss.messaging.tests.integration.chunkmessage.mock.MockConnectorFactory;
+import org.jboss.messaging.util.DataConstants;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ * A TestMessageChunk
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ * Created 29-Sep-08 4:04:10 PM
+ *
+ *
+ */
+public class MessageChunkTest extends ChunkTestBase
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ static final SimpleString ADDRESS = new SimpleString("SimpleAddress");
+
+ // Static --------------------------------------------------------
+ private static final Logger log = Logger.getLogger(MessageChunkTest.class);
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public void testCleanup() throws Exception
+ {
+ clearData();
+
+ createLargeFile(largeMessagesDir, "1234.tmp", 13333);
+
+ Configuration config = createDefaultConfig();
+
+ messagingService = createService(true, config, new HashMap<String, QueueSettings>());
+
+ messagingService.start();
+
+ try
+ {
+
+ File directoryLarge = new File(largeMessagesDir);
+
+ assertEquals(0, directoryLarge.list().length);
+ }
+ finally
+ {
+ messagingService.stop();
+ }
+ }
+
+ public void testFailureOnSendingFile() throws Exception
+ {
+ clearData();
+
+ Configuration config = createDefaultConfig();
+
+ config.setPagingMaxGlobalSizeBytes(20 * 1024);
+ config.setPagingDefaultSize(10 * 1024);
+
+ messagingService = createService(true, config, new HashMap<String, QueueSettings>());
+
+ messagingService.start();
+
+ final int numberOfIntegersBigMessage = 150000;
+
+ ClientSession session = null;
+
+ class LocalCallback implements MockConnector.MockCallback
+ {
+
+ AtomicInteger counter = new AtomicInteger(0);
+
+ ClientSession session;
+
+ public void onWrite(final MessagingBuffer buffer)
+ {
+ if (counter.incrementAndGet() == 5)
+ {
+ RemotingConnectionImpl conn = (RemotingConnectionImpl)((ClientSessionImpl)session).getConnection();
+ RemotingServiceImpl remotingServiceImpl = (RemotingServiceImpl)messagingService.getServer()
+ .getRemotingService();
+ remotingServiceImpl.connectionException(conn.getID(),
+ new MessagingException(MessagingException.NOT_CONNECTED, "blah!"));
+ conn.fail(new MessagingException(MessagingException.NOT_CONNECTED, "blah"));
+ throw new IllegalStateException("blah");
+ }
+ }
+
+ }
+
+ LocalCallback callback = new LocalCallback();
+
+ try
+ {
+ HashMap<String, Object> parameters = new HashMap<String, Object>();
+ parameters.put("callback", callback);
+
+ TransportConfiguration transport = new TransportConfiguration(MockConnectorFactory.class.getCanonicalName(),
+ parameters);
+
+ ClientSessionFactory mockFactory = new ClientSessionFactoryImpl(transport);
+
+ mockFactory.setBlockOnNonPersistentSend(false);
+ mockFactory.setBlockOnPersistentSend(false);
+ mockFactory.setBlockOnAcknowledge(false);
+
+ session = mockFactory.createSession(null, null, false, true, true, 0);
+
+ callback.session = session;
+
+ session.createQueue(ADDRESS, ADDRESS, null, true, false, true);
+
+ ClientProducer producer = session.createProducer(ADDRESS);
+
+ FileClientMessage clientLarge = createLargeClientMessage(session, numberOfIntegersBigMessage);
+
+ try
+ {
+ producer.send(clientLarge);
+ fail("Exception was expected!");
+ }
+ catch (Exception e)
+ {
+ }
+
+ validateNoFilesOnLargeDir();
+
+ }
+ finally
+ {
+ try
+ {
+ messagingService.stop();
+ }
+ catch (Exception ignored)
+ {
+ ignored.printStackTrace();
+ }
+ }
+
+ }
+
+ // Validate the functions to create and verify files
+ public void testFiles() throws Exception
+ {
+ clearData();
+
+ File file = createLargeFile(temporaryDir, "test.tst", 13333);
+
+ checkFileRead(file, 13333);
+ }
+
+ public void testMessageChunkFilePersistence() throws Exception
+ {
+ testChunks(true, false, 100, 262144, false, 1000, 0);
+ }
+
+ public void testMessageChunkFilePersistenceDelayed() throws Exception
+ {
+ testChunks(true, false, 1, 50000, false, 1000, 2000);
+ }
+
+ public void testMessageChunkNullPersistence() throws Exception
+ {
+ testChunks(false, false, 1, 50000, false, 1000, 0);
+ }
+
+ public void testMessageChunkNullPersistenceDelayed() throws Exception
+ {
+ testChunks(false, false, 100, 50000, false, 10000, 100);
+ }
+
+ public void testPageOnLargeMessage() throws Exception
+ {
+ testPageOnLargeMessage(true, false);
+
+ }
+
+ public void testPageOnLargeMessageNullPersistence() throws Exception
+ {
+ testPageOnLargeMessage(false, false);
+
+ }
+
+ public void testSendfileMessage() throws Exception
+ {
+ testChunks(true, true, 100, 50000, false, 1000, 0);
+
+ }
+
+ public void testSendfileMessageOnNullPersistence() throws Exception
+ {
+ testChunks(false, true, 100, 50000, false, 1000, 0);
+ }
+
+ public void testSendfileMessageOnNullPersistenceSmallMessage() throws Exception
+ {
+ testChunks(false, true, 100, 100, false, 1000, 0);
+ }
+
+ public void testSendfileMessageSmallMessage() throws Exception
+ {
+ testChunks(true, true, 100, 4, false, 1000, 0);
+
+ }
+
+ public void testSendRegularMessageNullPersistence() throws Exception
+ {
+ testChunks(false, false, 100, 100, false, 1000, 0);
+ }
+
+ public void testSendRegularMessageNullPersistenceDelayed() throws Exception
+ {
+ testChunks(false, false, 100, 100, false, 1000, 1000);
+ }
+
+ public void testSendRegularMessagePersistence() throws Exception
+ {
+ testChunks(true, false, 100, 100, false, 1000, 0);
+ }
+
+ public void testSendRegularMessagePersistenceDelayed() throws Exception
+ {
+ testChunks(true, false, 100, 100, false, 1000, 1000);
+ }
+
+ public void testTwoBindingsTwoStartedConsumers() throws Exception
+ {
+ // there are two bindings.. one is ACKed, the other is not, the server is restarted
+ // The other binding is acked... The file must be deleted
+
+ clearData();
+
+ try
+ {
+
+ messagingService = createService(true);
+
+ messagingService.start();
+
+ SimpleString queue[] = new SimpleString[] { new SimpleString("queue1"), new SimpleString("queue2") };
+
+ ClientSessionFactory sf = createInVMFactory();
+
+ ClientSession session = sf.createSession(null, null, false, true, true, 0);
+
+ session.createQueue(ADDRESS, queue[0], null, true, false, true);
+ session.createQueue(ADDRESS, queue[1], null, true, false, true);
+
+
+ int numberOfIntegers = 100000;
+
+ Message clientFile = createLargeClientMessage(session, numberOfIntegers);
+ //Message clientFile = createLargeClientMessage(session, numberOfIntegers);
+
+ ClientProducer producer = session.createProducer(ADDRESS);
+
+
+
+ session.start();
+
+ producer.send(clientFile);
+
+ producer.close();
+
+
+ ClientConsumer consumer = session.createFileConsumer(new File(clientLargeMessagesDir), queue[1]);
+ ClientMessage msg = consumer.receive(5000);
+ assertNull(consumer.receive(1000));
+ assertNotNull(msg);
+
+ msg.acknowledge();
+ consumer.close();
+
+ System.out.println("Stopping");
+
+ session.stop();
+
+ ClientConsumer consumer1 = session.createFileConsumer(new File(clientLargeMessagesDir), queue[0]);
+
+ session.start();
+
+
+ msg = consumer1.receive(5000);
+ assertNotNull(msg);
+ msg.acknowledge();
+ consumer1.close();
+
+ session.commit();
+
+ session.close();
+
+ validateNoFilesOnLargeDir();
+ }
+ finally
+ {
+ try
+ {
+ messagingService.stop();
+ }
+ catch (Throwable ignored)
+ {
+ }
+ }
+
+ }
+
+ public void testTwoBindingsAndRestart() throws Exception
+ {
+ testTwoBindings(true);
+ }
+
+ public void testTwoBindingsNoRestart() throws Exception
+ {
+ testTwoBindings(false);
+ }
+
+ public void testTwoBindings(final boolean restart) throws Exception
+ {
+ // there are two bindings.. one is ACKed, the other is not, the server is restarted
+ // The other binding is acked... The file must be deleted
+
+ clearData();
+
+ try
+ {
+
+ messagingService = createService(true);
+
+ messagingService.start();
+
+ SimpleString queue[] = new SimpleString[] { new SimpleString("queue1"), new SimpleString("queue2") };
+
+ ClientSessionFactory sf = createInVMFactory();
+
+ ClientSession session = sf.createSession(null, null, false, true, true, 0);
+
+ session.createQueue(ADDRESS, queue[0], null, true, false, true);
+ session.createQueue(ADDRESS, queue[1], null, true, false, true);
+
+
+ int numberOfIntegers = 100000;
+
+ Message clientFile = createLargeClientMessage(session, numberOfIntegers);
+ //Message clientFile = createLargeClientMessage(session, numberOfIntegers);
+
+ ClientProducer producer = session.createProducer(ADDRESS);
+ producer.send(clientFile);
+
+ producer.close();
+
+ readMessage(session, queue[1], numberOfIntegers);
+
+ if (restart)
+ {
+ session.close();
+
+ messagingService.stop();
+
+ messagingService = createService(true);
+
+ messagingService.start();
+
+ sf = createInVMFactory();
+
+ session = sf.createSession(null, null, false, true, true, 0);
+ }
+
+ readMessage(session, queue[0], numberOfIntegers);
+
+ session.close();
+
+ validateNoFilesOnLargeDir();
+ }
+ finally
+ {
+ try
+ {
+ messagingService.stop();
+ }
+ catch (Throwable ignored)
+ {
+ }
+ }
+
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ log.info("\n*********************************************************************************\n Starting " + this.getName() +
+ "\n*********************************************************************************");
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ log.info("\n*********************************************************************************\nDone with " + this.getName() +
+ "\n*********************************************************************************");
+ }
+
+ protected void testPageOnLargeMessage(final boolean realFiles, final boolean sendBlocking) throws Exception
+ {
+
+ clearData();
+
+ Configuration config = createDefaultConfig();
+
+ config.setPagingMaxGlobalSizeBytes(20 * 1024);
+ config.setPagingDefaultSize(10 * 1024);
+
+ messagingService = createService(realFiles, config, new HashMap<String, QueueSettings>());
+
+ messagingService.start();
+
+ final int numberOfIntegers = 256;
+
+ final int numberOfIntegersBigMessage = 100000;
+
+ try
+ {
+ ClientSessionFactory sf = createInVMFactory();
+
+ if (sendBlocking)
+ {
+ sf.setBlockOnNonPersistentSend(true);
+ sf.setBlockOnPersistentSend(true);
+ sf.setBlockOnAcknowledge(true);
+ }
+
+ ClientSession session = sf.createSession(null, null, false, true, true, 0);
+
+ session.createQueue(ADDRESS, ADDRESS, null, true, false, true);
+
+ ClientProducer producer = session.createProducer(ADDRESS);
+
+ ByteBuffer ioBuffer = ByteBuffer.allocate(DataConstants.SIZE_INT * numberOfIntegers);
+
+ // printBuffer("body to be sent : " , body);
+
+ ClientMessage message = null;
+
+ MessagingBuffer body = null;
+
+ for (int i = 0; i < 100; i++)
+ {
+ MessagingBuffer bodyLocal = new ByteBufferWrapper(ioBuffer);
+
+ for (int j = 1; j <= numberOfIntegers; j++)
+ {
+ bodyLocal.putInt(j);
+ }
+ bodyLocal.flip();
+
+ if (i == 0)
+ {
+ body = bodyLocal;
+ }
+
+ message = session.createClientMessage(true);
+ message.setBody(bodyLocal);
+
+ producer.send(message);
+ }
+
+ FileClientMessage clientFile = createLargeClientMessage(session, numberOfIntegersBigMessage);
+
+ producer.send(clientFile);
+
+ session.close();
+
+ if (realFiles)
+ {
+ messagingService.stop();
+
+ messagingService = createService(true, config, new HashMap<String, QueueSettings>());
+ messagingService.start();
+
+ sf = createInVMFactory();
+ }
+
+ session = sf.createSession(null, null, false, true, true, 0);
+
+ ClientConsumer consumer = session.createConsumer(ADDRESS);
+
+ // if (realFiles)
+ // {
+ // consumer.setLargeMessagesAsFiles(true);
+ // consumer.setLargeMessagesDir(new File(clientLargeMessagesDir));
+ // }
+
+ session.start();
+
+ for (int i = 0; i < 100; i++)
+ {
+ ClientMessage message2 = consumer.receive(10000);
+
+ assertNotNull(message2);
+
+ message2.acknowledge();
+
+ assertNotNull(message2);
+
+ try
+ {
+ assertEqualsByteArrays(body.limit(), body.array(), message2.getBody().array());
+ }
+ catch (AssertionFailedError e)
+ {
+ log.info("Expected buffer:" + dumbBytesHex(body.array(), 40));
+ log.info("Arriving buffer:" + dumbBytesHex(message2.getBody().array(), 40));
+ throw e;
+ }
+ }
+
+ consumer.close();
+
+ session.close();
+
+ session = sf.createSession(null, null, false, true, true, 0);
+
+ readMessage(session, ADDRESS, numberOfIntegersBigMessage);
+
+ // printBuffer("message received : ", message2.getBody());
+
+ session.close();
+ }
+ finally
+ {
+ try
+ {
+ messagingService.stop();
+ }
+ catch (Throwable ignored)
+ {
+ }
+ }
+
+ }
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Copied: trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock (from rev 5358, branches/Branch_Chunk_3/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock)
Deleted: trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/MockConnector.java
===================================================================
--- branches/Branch_Chunk_3/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/MockConnector.java 2008-11-14 02:52:55 UTC (rev 5358)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/MockConnector.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -1,112 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.messaging.tests.integration.chunkmessage.mock;
-
-import java.util.Map;
-
-import org.jboss.messaging.core.remoting.impl.invm.InVMConnection;
-import org.jboss.messaging.core.remoting.impl.invm.InVMConnector;
-import org.jboss.messaging.core.remoting.spi.BufferHandler;
-import org.jboss.messaging.core.remoting.spi.Connection;
-import org.jboss.messaging.core.remoting.spi.ConnectionLifeCycleListener;
-import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
-
-/**
- * A MockConnector
- *
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- *
- * Created Oct 22, 2008 11:23:18 AM
- *
- *
- */
-public class MockConnector extends InVMConnector
-{
- private final MockCallback callback;
-
- /**
- * @param configuration
- * @param handler
- * @param listener
- */
- public MockConnector(final Map<String, Object> configuration,
- final BufferHandler handler,
- final ConnectionLifeCycleListener listener)
- {
- super(configuration, handler, listener);
- callback = (MockCallback)configuration.get("callback");
- }
-
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- @Override
- protected Connection internalCreateConnection(final BufferHandler handler, final ConnectionLifeCycleListener listener)
- {
- return new MockConnection(handler, listener);
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
- public static interface MockCallback
- {
- void onWrite(final MessagingBuffer buffer);
- }
-
- class MockConnection extends InVMConnection
- {
-
- /**
- * @param handler
- * @param listener
- */
- public MockConnection(final BufferHandler handler, final ConnectionLifeCycleListener listener)
- {
- super(handler, listener);
- }
-
- @Override
- public void write(final MessagingBuffer buffer)
- {
- if (callback != null)
- {
- callback.onWrite(buffer);
- }
-
- super.write(buffer);
- }
- }
-}
Copied: trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/MockConnector.java (from rev 5358, branches/Branch_Chunk_3/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/MockConnector.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/MockConnector.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/MockConnector.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.tests.integration.chunkmessage.mock;
+
+import java.util.Map;
+
+import org.jboss.messaging.core.remoting.impl.invm.InVMConnection;
+import org.jboss.messaging.core.remoting.impl.invm.InVMConnector;
+import org.jboss.messaging.core.remoting.spi.BufferHandler;
+import org.jboss.messaging.core.remoting.spi.Connection;
+import org.jboss.messaging.core.remoting.spi.ConnectionLifeCycleListener;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+
+/**
+ * A MockConnector
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ * Created Oct 22, 2008 11:23:18 AM
+ *
+ *
+ */
+public class MockConnector extends InVMConnector
+{
+ private final MockCallback callback;
+
+ /**
+ * @param configuration
+ * @param handler
+ * @param listener
+ */
+ public MockConnector(final Map<String, Object> configuration,
+ final BufferHandler handler,
+ final ConnectionLifeCycleListener listener)
+ {
+ super(configuration, handler, listener);
+ callback = (MockCallback)configuration.get("callback");
+ }
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ @Override
+ protected Connection internalCreateConnection(final BufferHandler handler, final ConnectionLifeCycleListener listener)
+ {
+ return new MockConnection(handler, listener);
+ }
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+ public static interface MockCallback
+ {
+ void onWrite(final MessagingBuffer buffer);
+ }
+
+ class MockConnection extends InVMConnection
+ {
+
+ /**
+ * @param handler
+ * @param listener
+ */
+ public MockConnection(final BufferHandler handler, final ConnectionLifeCycleListener listener)
+ {
+ super(handler, listener);
+ }
+
+ @Override
+ public void write(final MessagingBuffer buffer)
+ {
+ if (callback != null)
+ {
+ callback.onWrite(buffer);
+ }
+
+ super.write(buffer);
+ }
+ }
+}
Deleted: trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/MockConnectorFactory.java
===================================================================
--- branches/Branch_Chunk_3/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/MockConnectorFactory.java 2008-11-14 02:52:55 UTC (rev 5358)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/MockConnectorFactory.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -1,71 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.messaging.tests.integration.chunkmessage.mock;
-
-import java.util.Map;
-
-import org.jboss.messaging.core.remoting.spi.BufferHandler;
-import org.jboss.messaging.core.remoting.spi.ConnectionLifeCycleListener;
-import org.jboss.messaging.core.remoting.spi.Connector;
-import org.jboss.messaging.core.remoting.spi.ConnectorFactory;
-
-/**
- * A MockConnectorFactory
- *
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- *
- * Created Oct 22, 2008 12:04:11 PM
- *
- *
- */
-public class MockConnectorFactory implements ConnectorFactory
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- /* (non-Javadoc)
- * @see org.jboss.messaging.core.remoting.spi.ConnectorFactory#createConnector(java.util.Map, org.jboss.messaging.core.remoting.spi.BufferHandler, org.jboss.messaging.core.remoting.spi.ConnectionLifeCycleListener)
- */
- public Connector createConnector(final Map<String, Object> configuration,
- final BufferHandler handler,
- final ConnectionLifeCycleListener listener)
- {
- return new MockConnector(configuration, handler, listener);
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Copied: trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/MockConnectorFactory.java (from rev 5358, branches/Branch_Chunk_3/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/MockConnectorFactory.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/MockConnectorFactory.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/MockConnectorFactory.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.tests.integration.chunkmessage.mock;
+
+import java.util.Map;
+
+import org.jboss.messaging.core.remoting.spi.BufferHandler;
+import org.jboss.messaging.core.remoting.spi.ConnectionLifeCycleListener;
+import org.jboss.messaging.core.remoting.spi.Connector;
+import org.jboss.messaging.core.remoting.spi.ConnectorFactory;
+
+/**
+ * A MockConnectorFactory
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ * Created Oct 22, 2008 12:04:11 PM
+ *
+ *
+ */
+public class MockConnectorFactory implements ConnectorFactory
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ /* (non-Javadoc)
+ * @see org.jboss.messaging.core.remoting.spi.ConnectorFactory#createConnector(java.util.Map, org.jboss.messaging.core.remoting.spi.BufferHandler, org.jboss.messaging.core.remoting.spi.ConnectionLifeCycleListener)
+ */
+ public Connector createConnector(final Map<String, Object> configuration,
+ final BufferHandler handler,
+ final ConnectionLifeCycleListener listener)
+ {
+ return new MockConnector(configuration, handler, listener);
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/clientcrash/ClientCrashTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/clientcrash/ClientCrashTest.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/clientcrash/ClientCrashTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -24,6 +24,7 @@
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BIG_MESSAGE_SIZE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND;
@@ -33,7 +34,6 @@
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE;
-import junit.framework.TestCase;
import org.jboss.messaging.core.client.ClientConsumer;
import org.jboss.messaging.core.client.ClientMessage;
@@ -41,13 +41,12 @@
import org.jboss.messaging.core.client.ClientSession;
import org.jboss.messaging.core.client.ClientSessionFactory;
import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
+import org.jboss.messaging.core.config.Configuration;
import org.jboss.messaging.core.config.TransportConfiguration;
-import org.jboss.messaging.core.config.impl.ConfigurationImpl;
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.message.Message;
-import org.jboss.messaging.core.server.MessagingService;
-import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
import org.jboss.messaging.jms.client.JBossTextMessage;
+import org.jboss.messaging.tests.util.ServiceTestBase;
import org.jboss.messaging.tests.util.SpawnedVMSupport;
import org.jboss.messaging.util.SimpleString;
@@ -59,7 +58,7 @@
* @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
* @version <tt>$Revision: 4032 $</tt>
*/
-public class ClientCrashTest extends TestCase
+public class ClientCrashTest extends ServiceTestBase
{
// Constants -----------------------------------------------------
@@ -75,17 +74,10 @@
// Attributes ----------------------------------------------------
- private MessagingService messagingService;
-
private ClientSessionFactory sf;
// Constructors --------------------------------------------------
- public ClientCrashTest(String name)
- {
- super(name);
- }
-
// Public --------------------------------------------------------
public void testCrashClientWithOneConnection() throws Exception
@@ -153,11 +145,10 @@
{
super.setUp();
- ConfigurationImpl config = new ConfigurationImpl();
+
+ Configuration config = createDefaultConfig(true);
config.setSecurityEnabled(false);
- config.getAcceptorConfigurations()
- .add(new TransportConfiguration("org.jboss.messaging.integration.transports.netty.NettyAcceptorFactory"));
- messagingService = MessagingServiceImpl.newNullStorageMessagingServer(config);
+ messagingService = createService(false, config);
messagingService.start();
sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.integration.transports.netty.NettyConnectorFactory"),
@@ -168,12 +159,14 @@
DEFAULT_CONSUMER_MAX_RATE,
DEFAULT_SEND_WINDOW_SIZE,
DEFAULT_PRODUCER_MAX_RATE,
+ DEFAULT_BIG_MESSAGE_SIZE,
DEFAULT_BLOCK_ON_ACKNOWLEDGE,
DEFAULT_BLOCK_ON_PERSISTENT_SEND,
DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
DEFAULT_AUTO_GROUP,
DEFAULT_MAX_CONNECTIONS,
DEFAULT_ACK_BATCH_SIZE);
+
}
@Override
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReplicateConnectionFailureTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReplicateConnectionFailureTest.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReplicateConnectionFailureTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -87,12 +87,14 @@
ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE,
ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
+ ClientSessionFactoryImpl.DEFAULT_BIG_MESSAGE_SIZE,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND,
ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP,
ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS,
ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE);
+
sf1.setSendWindowSize(32 * 1024);
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/JMSFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/JMSFailoverTest.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/JMSFailoverTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -101,6 +101,7 @@
ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE,
ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
+ ClientSessionFactoryImpl.DEFAULT_BIG_MESSAGE_SIZE,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND,
@@ -179,6 +180,7 @@
ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE,
ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
+ ClientSessionFactoryImpl.DEFAULT_BIG_MESSAGE_SIZE,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
true,
@@ -197,6 +199,7 @@
ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE,
ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
+ ClientSessionFactoryImpl.DEFAULT_BIG_MESSAGE_SIZE,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND,
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSQueueControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSQueueControlTest.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSQueueControlTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -167,6 +167,7 @@
ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE,
ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
+ ClientSessionFactoryImpl.DEFAULT_BIG_MESSAGE_SIZE,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
true,
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSUtil.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSUtil.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSUtil.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -68,6 +68,7 @@
ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE,
ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
+ ClientSessionFactoryImpl.DEFAULT_BIG_MESSAGE_SIZE,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
true,
@@ -99,6 +100,7 @@
ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE,
ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
+ ClientSessionFactoryImpl.DEFAULT_BIG_MESSAGE_SIZE,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
true,
@@ -126,6 +128,7 @@
ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE,
ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
+ ClientSessionFactoryImpl.DEFAULT_BIG_MESSAGE_SIZE,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
true,
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/paging/PagingManagerIntegrationTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/paging/PagingManagerIntegrationTest.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/paging/PagingManagerIntegrationTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -69,10 +69,11 @@
PagingManagerImpl managerImpl = new PagingManagerImpl(new PagingManagerFactoryNIO(journalDir),
null,
queueSettings,
- -1);
+ -1,
+ 1024 * 1024);
managerImpl.start();
- PagingStore store = managerImpl.getPageStore(new SimpleString("simple-test"));
+ PagingStore store = managerImpl.createPageStore(new SimpleString("simple-test"));
ServerMessage msg = createMessage(1l, new SimpleString("simple-test"), createRandomBuffer(10));
@@ -92,7 +93,7 @@
assertEquals(1, msgs.length);
- assertEqualsByteArrays(msg.getBody().array(), msgs[0].getMessage().getBody().array());
+ assertEqualsByteArrays(msg.getBody().array(), (msgs[0].getMessage(null)).getBody().array());
assertTrue(store.isPaging());
@@ -115,8 +116,11 @@
PagingManagerImpl managerImpl = new PagingManagerImpl(new PagingManagerFactoryNIO(journalDir),
null,
queueSettings,
- -1);
+ -1,
+ 1024 * 1024);
managerImpl.start();
+
+ managerImpl.createPageStore(new SimpleString("simple-test"));
ServerMessage msg = createMessage(1l, new SimpleString("simple-test"), createRandomBuffer(100));
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/remoting/DestroyConsumerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/remoting/DestroyConsumerTest.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/remoting/DestroyConsumerTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -23,9 +23,9 @@
package org.jboss.messaging.tests.integration.remoting;
-import org.jboss.messaging.tests.integration.base.IntegrationTestBase;
+import org.jboss.messaging.tests.util.ServiceTestBase;
-public class DestroyConsumerTest extends IntegrationTestBase
+public class DestroyConsumerTest extends ServiceTestBase
{
// Constants -----------------------------------------------------
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -28,6 +28,7 @@
import junit.framework.TestCase;
+import org.jboss.messaging.core.config.Configuration;
import org.jboss.messaging.core.config.TransportConfiguration;
import org.jboss.messaging.core.config.impl.ConfigurationImpl;
import org.jboss.messaging.core.exception.MessagingException;
@@ -44,6 +45,7 @@
import org.jboss.messaging.core.remoting.spi.ConnectorFactory;
import org.jboss.messaging.core.server.MessagingService;
import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
+import org.jboss.messaging.tests.util.ServiceTestBase;
/**
* @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -52,7 +54,7 @@
*
* @version <tt>$Revision$</tt>
*/
-public class PingTest extends TestCase
+public class PingTest extends ServiceTestBase
{
// Constants -----------------------------------------------------
@@ -62,8 +64,6 @@
// Attributes ----------------------------------------------------
- private MessagingService messagingService;
-
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
@@ -73,9 +73,8 @@
@Override
protected void setUp() throws Exception
{
- ConfigurationImpl config = new ConfigurationImpl();
- config.getAcceptorConfigurations().add(new TransportConfiguration("org.jboss.messaging.integration.transports.netty.NettyAcceptorFactory"));
- messagingService = MessagingServiceImpl.newNullStorageMessagingServer(config);
+ Configuration config = createDefaultConfig(true);
+ messagingService = createService(false, config);
messagingService.start();
}
@@ -109,7 +108,7 @@
Map<String, Object> params = new HashMap<String, Object>();
ConnectionManager cm = new ConnectionManagerImpl(cf, params, PING_INTERVAL, 5000, 1);
-
+
RemotingConnection conn = cm.getConnection();
assertNotNull(conn);
assertEquals(1, cm.numConnections());
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/scheduling/ScheduledMessageTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/scheduling/ScheduledMessageTest.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/scheduling/ScheduledMessageTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -21,7 +21,6 @@
*/
package org.jboss.messaging.tests.integration.scheduling;
-import java.io.File;
import java.util.Calendar;
import javax.transaction.xa.XAResource;
@@ -32,60 +31,38 @@
import org.jboss.messaging.core.client.ClientProducer;
import org.jboss.messaging.core.client.ClientSession;
import org.jboss.messaging.core.client.ClientSessionFactory;
-import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
-import org.jboss.messaging.core.config.TransportConfiguration;
-import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import org.jboss.messaging.core.config.Configuration;
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.message.impl.MessageImpl;
-import org.jboss.messaging.core.server.MessagingService;
-import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
import org.jboss.messaging.core.settings.impl.QueueSettings;
import org.jboss.messaging.core.transaction.impl.XidImpl;
import org.jboss.messaging.jms.client.JBossTextMessage;
-import org.jboss.messaging.tests.util.UnitTestCase;
+import org.jboss.messaging.tests.util.ServiceTestBase;
import org.jboss.messaging.util.SimpleString;
import org.jboss.util.id.GUID;
/**
* @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
*/
-public class ScheduledMessageTest extends UnitTestCase
+public class ScheduledMessageTest extends ServiceTestBase
{
private static final Logger log = Logger.getLogger(ScheduledMessageTest.class);
- private static final String ACCEPTOR_FACTORY = "org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory";
-
- private static final String CONNECTOR_FACTORY = "org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory";
-
- private String journalDir = System.getProperty("java.io.tmpdir", "/tmp") + "/ScheduledMessageRecoveryTest/journal";
-
- private String bindingsDir = System.getProperty("java.io.tmpdir", "/tmp") + "/ScheduledMessageRecoveryTest/bindings";
-
- private String pageDir = System.getProperty("java.io.tmpdir", "/tmp") + "/ScheduledMessageRecoveryTest/page";
-
private SimpleString atestq = new SimpleString("ascheduledtestq");
private SimpleString atestq2 = new SimpleString("ascheduledtestq2");
- private MessagingService messagingService;
+ private Configuration configuration;
- private ConfigurationImpl configuration;
-
protected void setUp() throws Exception
{
- File file = new File(journalDir);
- File file2 = new File(bindingsDir);
- File file3 = new File(pageDir);
- deleteDirectory(file);
- file.mkdirs();
- deleteDirectory(file2);
- file2.mkdirs();
- deleteDirectory(file3);
- file3.mkdirs();
- configuration = new ConfigurationImpl();
+ super.clearData();
+ configuration = createDefaultConfig();
configuration.setSecurityEnabled(false);
configuration.setJournalMinFiles(2);
- configuration.setPagingDirectory(pageDir);
+ configuration.setPagingMaxGlobalSizeBytes(-1);
+ messagingService = createService(true, configuration);
+ messagingService.start();
}
protected void tearDown() throws Exception
@@ -102,9 +79,7 @@
// ignore
}
}
- new File(journalDir).delete();
- new File(bindingsDir).delete();
- new File(pageDir).delete();
+ deleteData();
}
public void testRecoveredMessageDeliveredCorrectly() throws Exception
@@ -159,14 +134,8 @@
public void testPagedMessageDeliveredCorrectly() throws Exception
{
- TransportConfiguration transportConfig = new TransportConfiguration(ACCEPTOR_FACTORY);
- configuration.getAcceptorConfigurations().add(transportConfig);
- configuration.setPagingMaxGlobalSizeBytes(0);
- messagingService = MessagingServiceImpl.newNioStorageMessagingServer(configuration, journalDir, bindingsDir);
- // start the server
- messagingService.start();
// then we create a client as normal
- ClientSessionFactory sessionFactory = new ClientSessionFactoryImpl(new TransportConfiguration(CONNECTOR_FACTORY));
+ ClientSessionFactory sessionFactory = createInVMFactory();
ClientSession session = sessionFactory.createSession(false, true, false);
session.createQueue(atestq, atestq, null, true, true, true);
ClientProducer producer = session.createProducer(atestq);
@@ -198,17 +167,11 @@
public void testPagedMessageDeliveredMultipleConsumersCorrectly() throws Exception
{
- TransportConfiguration transportConfig = new TransportConfiguration(ACCEPTOR_FACTORY);
- configuration.getAcceptorConfigurations().add(transportConfig);
- configuration.setPagingMaxGlobalSizeBytes(0);
- messagingService = MessagingServiceImpl.newNioStorageMessagingServer(configuration, journalDir, bindingsDir);
- // start the server
- messagingService.start();
QueueSettings qs = new QueueSettings();
qs.setRedeliveryDelay(5000l);
messagingService.getServer().getQueueSettingsRepository().addMatch(atestq2.toString(), qs);
// then we create a client as normal
- ClientSessionFactory sessionFactory = new ClientSessionFactoryImpl(new TransportConfiguration(CONNECTOR_FACTORY));
+ ClientSessionFactory sessionFactory = createInVMFactory();
ClientSession session = sessionFactory.createSession(false, true, false);
session.createQueue(atestq, atestq, null, true, true, true);
session.createQueue(atestq, atestq2, null, true, true, true);
@@ -253,17 +216,11 @@
public void testPagedMessageDeliveredMultipleConsumersAfterRecoverCorrectly() throws Exception
{
- TransportConfiguration transportConfig = new TransportConfiguration(ACCEPTOR_FACTORY);
- configuration.getAcceptorConfigurations().add(transportConfig);
- configuration.setPagingMaxGlobalSizeBytes(0);
- messagingService = MessagingServiceImpl.newNioStorageMessagingServer(configuration, journalDir, bindingsDir);
- // start the server
- messagingService.start();
QueueSettings qs = new QueueSettings();
qs.setRedeliveryDelay(5000l);
messagingService.getServer().getQueueSettingsRepository().addMatch(atestq2.toString(), qs);
// then we create a client as normal
- ClientSessionFactory sessionFactory = new ClientSessionFactoryImpl(new TransportConfiguration(CONNECTOR_FACTORY));
+ ClientSessionFactory sessionFactory = createInVMFactory();
ClientSession session = sessionFactory.createSession(false, true, false);
session.createQueue(atestq, atestq, null, true, true, true);
session.createQueue(atestq, atestq2, null, true, true, true);
@@ -289,9 +246,9 @@
session.close();
messagingService.stop();
messagingService = null;
- messagingService = MessagingServiceImpl.newNioStorageMessagingServer(configuration, journalDir, bindingsDir);
+ messagingService = createService(true, configuration);
messagingService.start();
- sessionFactory = new ClientSessionFactoryImpl(new TransportConfiguration(CONNECTOR_FACTORY));
+ sessionFactory = createInVMFactory();
session = sessionFactory.createSession(false, true, true);
consumer = session.createConsumer(atestq);
consumer2 = session.createConsumer(atestq2);
@@ -317,13 +274,8 @@
public void testMessageDeliveredCorrectly(boolean recover) throws Exception
{
- TransportConfiguration transportConfig = new TransportConfiguration(ACCEPTOR_FACTORY);
- configuration.getAcceptorConfigurations().add(transportConfig);
- messagingService = MessagingServiceImpl.newNioStorageMessagingServer(configuration, journalDir, bindingsDir);
- // start the server
- messagingService.start();
- // then we create a client as normal
- ClientSessionFactory sessionFactory = new ClientSessionFactoryImpl(new TransportConfiguration(CONNECTOR_FACTORY));
+ // then we create a client as normal
+ ClientSessionFactory sessionFactory = createInVMFactory();
ClientSession session = sessionFactory.createSession(false, true, false);
session.createQueue(atestq, atestq, null, true, true, true);
ClientProducer producer = session.createProducer(atestq);
@@ -347,9 +299,9 @@
session.close();
messagingService.stop();
messagingService = null;
- messagingService = MessagingServiceImpl.newNioStorageMessagingServer(configuration, journalDir, bindingsDir);
+ messagingService = createService(true, configuration);
messagingService.start();
- sessionFactory = new ClientSessionFactoryImpl(new TransportConfiguration(CONNECTOR_FACTORY));
+ sessionFactory = createInVMFactory();
session = sessionFactory.createSession(false, true, true);
}
ClientConsumer consumer = session.createConsumer(atestq);
@@ -373,13 +325,7 @@
public void testScheduledMessagesDeliveredCorrectly(boolean recover) throws Exception
{
- TransportConfiguration transportConfig = new TransportConfiguration(ACCEPTOR_FACTORY);
- configuration.getAcceptorConfigurations().add(transportConfig);
- messagingService = MessagingServiceImpl.newNioStorageMessagingServer(configuration, journalDir, bindingsDir);
- // start the server
- messagingService.start();
- // then we create a client as normal
- ClientSessionFactory sessionFactory = new ClientSessionFactoryImpl(new TransportConfiguration(CONNECTOR_FACTORY));
+ ClientSessionFactory sessionFactory = createInVMFactory();
ClientSession session = sessionFactory.createSession(false, true, false);
session.createQueue(atestq, atestq, null, true, true, true);
ClientProducer producer = session.createProducer(atestq);
@@ -411,10 +357,10 @@
session.close();
messagingService.stop();
messagingService = null;
- messagingService = MessagingServiceImpl.newNioStorageMessagingServer(configuration, journalDir, bindingsDir);
+ messagingService = createService(true, configuration);
messagingService.start();
- sessionFactory = new ClientSessionFactoryImpl(new TransportConfiguration(CONNECTOR_FACTORY));
+ sessionFactory = createInVMFactory();
session = sessionFactory.createSession(false, true, true);
}
@@ -459,13 +405,7 @@
public void testScheduledMessagesDeliveredCorrectlyDifferentOrder(boolean recover) throws Exception
{
- TransportConfiguration transportConfig = new TransportConfiguration(ACCEPTOR_FACTORY);
- configuration.getAcceptorConfigurations().add(transportConfig);
- messagingService = MessagingServiceImpl.newNioStorageMessagingServer(configuration, journalDir, bindingsDir);
- // start the server
- messagingService.start();
- // then we create a client as normal
- ClientSessionFactory sessionFactory = new ClientSessionFactoryImpl(new TransportConfiguration(CONNECTOR_FACTORY));
+ ClientSessionFactory sessionFactory = createInVMFactory();
ClientSession session = sessionFactory.createSession(false, true, false);
session.createQueue(atestq, atestq, null, true, true, true);
ClientProducer producer = session.createProducer(atestq);
@@ -498,10 +438,10 @@
session.close();
messagingService.stop();
messagingService = null;
- messagingService = MessagingServiceImpl.newNioStorageMessagingServer(configuration, journalDir, bindingsDir);
+ messagingService = createService(true, configuration);
messagingService.start();
- sessionFactory = new ClientSessionFactoryImpl(new TransportConfiguration(CONNECTOR_FACTORY));
+ sessionFactory = createInVMFactory();
session = sessionFactory.createSession(false, true, true);
@@ -546,13 +486,7 @@
public void testScheduledAndNormalMessagesDeliveredCorrectly(boolean recover) throws Exception
{
- TransportConfiguration transportConfig = new TransportConfiguration(ACCEPTOR_FACTORY);
- configuration.getAcceptorConfigurations().add(transportConfig);
- messagingService = MessagingServiceImpl.newNioStorageMessagingServer(configuration, journalDir, bindingsDir);
- // start the server
- messagingService.start();
- // then we create a client as normal
- ClientSessionFactory sessionFactory = new ClientSessionFactoryImpl(new TransportConfiguration(CONNECTOR_FACTORY));
+ ClientSessionFactory sessionFactory = createInVMFactory();
ClientSession session = sessionFactory.createSession(false, true, false);
session.createQueue(atestq, atestq, null, true, true, true);
ClientProducer producer = session.createProducer(atestq);
@@ -581,10 +515,10 @@
session.close();
messagingService.stop();
messagingService = null;
- messagingService = MessagingServiceImpl.newNioStorageMessagingServer(configuration, journalDir, bindingsDir);
+ messagingService = createService(true, configuration);
messagingService.start();
- sessionFactory = new ClientSessionFactoryImpl(new TransportConfiguration(CONNECTOR_FACTORY));
+ sessionFactory = createInVMFactory();
session = sessionFactory.createSession(false, true, true);
}
@@ -625,13 +559,9 @@
{
Xid xid = new XidImpl("xa1".getBytes(), 1, new GUID().toString().getBytes());
Xid xid2 = new XidImpl("xa2".getBytes(), 1, new GUID().toString().getBytes());
- TransportConfiguration transportConfig = new TransportConfiguration(ACCEPTOR_FACTORY);
- configuration.getAcceptorConfigurations().add(transportConfig);
- messagingService = MessagingServiceImpl.newNioStorageMessagingServer(configuration, journalDir, bindingsDir);
- // start the server
- messagingService.start();
- // then we create a client as normal
- ClientSessionFactory sessionFactory = new ClientSessionFactoryImpl(new TransportConfiguration(CONNECTOR_FACTORY));
+
+
+ ClientSessionFactory sessionFactory = createInVMFactory();
ClientSession session = sessionFactory.createSession(true, false, false);
session.createQueue(atestq, atestq, null, true, false, true);
session.start(xid, XAResource.TMNOFLAGS);
@@ -656,10 +586,10 @@
session.close();
messagingService.stop();
messagingService = null;
- messagingService = MessagingServiceImpl.newNioStorageMessagingServer(configuration, journalDir, bindingsDir);
+ messagingService = createService(true, configuration);
messagingService.start();
- sessionFactory = new ClientSessionFactoryImpl(new TransportConfiguration(CONNECTOR_FACTORY));
+ sessionFactory = createInVMFactory();
session = sessionFactory.createSession(true, false, false);
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/xa/BasicXaRecoveryTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/xa/BasicXaRecoveryTest.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/xa/BasicXaRecoveryTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -21,7 +21,6 @@
*/
package org.jboss.messaging.tests.integration.xa;
-import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@@ -34,69 +33,50 @@
import org.jboss.messaging.core.client.ClientProducer;
import org.jboss.messaging.core.client.ClientSession;
import org.jboss.messaging.core.client.ClientSessionFactory;
-import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
-import org.jboss.messaging.core.config.TransportConfiguration;
-import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import org.jboss.messaging.core.config.Configuration;
import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory;
+import org.jboss.messaging.core.remoting.spi.ConnectorFactory;
import org.jboss.messaging.core.server.MessagingService;
-import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
import org.jboss.messaging.core.settings.impl.QueueSettings;
import org.jboss.messaging.core.transaction.impl.XidImpl;
import org.jboss.messaging.jms.client.JBossBytesMessage;
import org.jboss.messaging.jms.client.JBossTextMessage;
-import org.jboss.messaging.tests.util.UnitTestCase;
+import org.jboss.messaging.tests.util.ServiceTestBase;
import org.jboss.messaging.util.SimpleString;
import org.jboss.util.id.GUID;
/**
* @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
*/
-public class BasicXaRecoveryTest extends UnitTestCase
+public class BasicXaRecoveryTest extends ServiceTestBase
{
- private static final String ACCEPTOR_FACTORY = "org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory";
- private static final String CONNECTOR_FACTORY = "org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory";
-
private Map<String, QueueSettings> queueSettings = new HashMap<String, QueueSettings>();
-
- private String journalDir = System.getProperty("java.io.tmpdir", "/tmp") + "/xa-recovery-test/journal";
- private String bindingsDir = System.getProperty("java.io.tmpdir", "/tmp") + "/xa-recovery-test/bindings";
- private String pageDir = System.getProperty("java.io.tmpdir", "/tmp") + "/xa-recovery-test/page";
private MessagingService messagingService;
private ClientSession clientSession;
private ClientProducer clientProducer;
private ClientConsumer clientConsumer;
private ClientSessionFactory sessionFactory;
- private ConfigurationImpl configuration;
+ private Configuration configuration;
private SimpleString atestq = new SimpleString("atestq");
protected void setUp() throws Exception
{
+ clearData();
queueSettings.clear();
- File file = new File(journalDir);
- File file2 = new File(bindingsDir);
- File file3 = new File(pageDir);
- deleteDirectory(file);
- file.mkdirs();
- deleteDirectory(file2);
- file2.mkdirs();
- deleteDirectory(file3);
- file3.mkdirs();
- configuration = new ConfigurationImpl();
+ configuration = createDefaultConfig();
configuration.setSecurityEnabled(false);
configuration.setJournalMinFiles(2);
configuration.setPagingDirectory(pageDir);
- TransportConfiguration transportConfig = new TransportConfiguration(ACCEPTOR_FACTORY);
- configuration.getAcceptorConfigurations().add(transportConfig);
- messagingService = MessagingServiceImpl.newNioStorageMessagingServer(configuration, journalDir, bindingsDir);
+ messagingService = createService(true, configuration, queueSettings);
+
//start the server
messagingService.start();
+
//then we create a client as normal
- sessionFactory = new ClientSessionFactoryImpl(new TransportConfiguration(CONNECTOR_FACTORY));
- clientSession = sessionFactory.createSession(true, false, false);
- clientSession.createQueue(atestq, atestq, null, true, true, true);
- clientProducer = clientSession.createProducer(atestq);
- clientConsumer = clientSession.createConsumer(atestq);
+ createClients(true, false);
}
protected void tearDown() throws Exception
@@ -129,6 +109,7 @@
public void testBasicSendWithCommit() throws Exception
{
+
testBasicSendWithCommit(false);
}
@@ -903,7 +884,7 @@
assertNotNull(m);
assertEquals(m.getBody().getString(), "m4");
clientSession.end(xid, XAResource.TMSUCCESS);
- clientSession.prepare(xid);
+ assertEquals("Expected XA_OK", XAResource.XA_OK, clientSession.prepare(xid));
if (stopServer)
{
@@ -1197,10 +1178,8 @@
clientSession = null;
messagingService.stop();
messagingService = null;
- messagingService = MessagingServiceImpl.newNioStorageMessagingServer(configuration, journalDir, bindingsDir);
+ messagingService = createService(true, configuration, queueSettings);
- addSettings();
-
messagingService.start();
createClients();
}
@@ -1241,11 +1220,21 @@
return message;
}
- private void createClients()
+ private void createClients() throws MessagingException
+ {
+ createClients(false, true);
+ }
+
+ private void createClients(boolean createQueue, boolean commitACKs)
throws MessagingException
{
- sessionFactory = new ClientSessionFactoryImpl(new TransportConfiguration(CONNECTOR_FACTORY));
- clientSession = sessionFactory.createSession(true, false, true);
+
+ sessionFactory = createInVMFactory();
+ clientSession = sessionFactory.createSession(true, false, commitACKs);
+ if (createQueue)
+ {
+ clientSession.createQueue(atestq, atestq, null, true, true, true);
+ }
clientProducer = clientSession.createProducer(atestq);
clientConsumer = clientSession.createConsumer(atestq);
}
Copied: trunk/tests/src/org/jboss/messaging/tests/soak/chunk (from rev 5358, branches/Branch_Chunk_3/tests/src/org/jboss/messaging/tests/soak/chunk)
Deleted: trunk/tests/src/org/jboss/messaging/tests/soak/chunk/MessageChunkSoakTest.java
===================================================================
--- branches/Branch_Chunk_3/tests/src/org/jboss/messaging/tests/soak/chunk/MessageChunkSoakTest.java 2008-11-14 02:52:55 UTC (rev 5358)
+++ trunk/tests/src/org/jboss/messaging/tests/soak/chunk/MessageChunkSoakTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -1,68 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.messaging.tests.soak.chunk;
-
-import org.jboss.messaging.tests.integration.chunkmessage.ChunkTestBase;
-
-/**
- * A MessageChunkSoakTest
- *
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- *
- * Created Oct 27, 2008 5:07:05 PM
- *
- *
- */
-public class MessageChunkSoakTest extends ChunkTestBase
-{
-
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public void testMessageChunkFilePersistence1G() throws Exception
- {
- testChunks(true, true, 2, 268435456, false, 120000, 0, true);
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- @Override
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Copied: trunk/tests/src/org/jboss/messaging/tests/soak/chunk/MessageChunkSoakTest.java (from rev 5358, branches/Branch_Chunk_3/tests/src/org/jboss/messaging/tests/soak/chunk/MessageChunkSoakTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/soak/chunk/MessageChunkSoakTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/soak/chunk/MessageChunkSoakTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.tests.soak.chunk;
+
+import org.jboss.messaging.tests.integration.chunkmessage.ChunkTestBase;
+
+/**
+ * A MessageChunkSoakTest
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ * Created Oct 27, 2008 5:07:05 PM
+ *
+ *
+ */
+public class MessageChunkSoakTest extends ChunkTestBase
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public void testMessageChunkFilePersistence1G() throws Exception
+ {
+ testChunks(true, true, 2, 268435456, false, 120000, 0, true);
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Copied: trunk/tests/src/org/jboss/messaging/tests/stress/chunk (from rev 5358, branches/Branch_Chunk_3/tests/src/org/jboss/messaging/tests/stress/chunk)
Deleted: trunk/tests/src/org/jboss/messaging/tests/stress/chunk/MessageChunkStressTest.java
===================================================================
--- branches/Branch_Chunk_3/tests/src/org/jboss/messaging/tests/stress/chunk/MessageChunkStressTest.java 2008-11-14 02:52:55 UTC (rev 5358)
+++ trunk/tests/src/org/jboss/messaging/tests/stress/chunk/MessageChunkStressTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -1,73 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.messaging.tests.stress.chunk;
-
-import org.jboss.messaging.tests.integration.chunkmessage.ChunkTestBase;
-
-/**
- * A MessageChunkSoakTest
- *
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- *
- * Created Oct 27, 2008 5:07:05 PM
- *
- *
- */
-public class MessageChunkStressTest extends ChunkTestBase
-{
-
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public void testMessageChunkFilePersistence100M() throws Exception
- {
- testChunks(true, true, 10, 26214400, false, 120000, 0);
- }
-
- public void testMessageChunkFilePersistence1M() throws Exception
- {
- testChunks(true, true, 1000, 262144, false, 120000, 0);
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- @Override
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Copied: trunk/tests/src/org/jboss/messaging/tests/stress/chunk/MessageChunkStressTest.java (from rev 5358, branches/Branch_Chunk_3/tests/src/org/jboss/messaging/tests/stress/chunk/MessageChunkStressTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/stress/chunk/MessageChunkStressTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/stress/chunk/MessageChunkStressTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.tests.stress.chunk;
+
+import org.jboss.messaging.tests.integration.chunkmessage.ChunkTestBase;
+
+/**
+ * A MessageChunkSoakTest
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ * Created Oct 27, 2008 5:07:05 PM
+ *
+ *
+ */
+public class MessageChunkStressTest extends ChunkTestBase
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public void testMessageChunkFilePersistence100M() throws Exception
+ {
+ testChunks(true, true, 10, 26214400, false, 120000, 0);
+ }
+
+ public void testMessageChunkFilePersistence1M() throws Exception
+ {
+ testChunks(true, true, 1000, 262144, false, 120000, 0);
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ //super.tearDown();
+ }
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Modified: trunk/tests/src/org/jboss/messaging/tests/stress/paging/PageStressTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/stress/paging/PageStressTest.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/stress/paging/PageStressTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -23,7 +23,7 @@
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.server.MessagingService;
import org.jboss.messaging.core.settings.impl.QueueSettings;
-import org.jboss.messaging.tests.integration.base.IntegrationTestBase;
+import org.jboss.messaging.tests.util.ServiceTestBase;
import org.jboss.messaging.util.SimpleString;
/**
@@ -31,7 +31,7 @@
*
* @author <a href="mailto:clebert.suconic at jboss.com">Clebert Suconic</a>
*/
-public class PageStressTest extends IntegrationTestBase
+public class PageStressTest extends ServiceTestBase
{
// Constants -----------------------------------------------------
@@ -59,11 +59,26 @@
public void testStopDuringDepage(boolean globalPage) throws Exception
{
+ Configuration config = createDefaultConfig();
+
HashMap<String, QueueSettings> settings = new HashMap<String, QueueSettings>();
- Configuration config = createConfig(globalPage, settings);
+ if (globalPage)
+ {
+ config.setPagingMaxGlobalSizeBytes(20 * 1024 * 1024);
+ QueueSettings setting = new QueueSettings();
+ setting.setMaxSizeBytes(-1);
+ settings.put("page-adr", setting);
+ }
+ else
+ {
+ config.setPagingMaxGlobalSizeBytes(-1);
+ QueueSettings setting = new QueueSettings();
+ setting.setMaxSizeBytes(20 * 1024 * 1024);
+ settings.put("page-adr", setting);
+ }
- service = createService(true, false, config, settings);
+ service = createService(true, config, settings);
service.start();
ClientSessionFactory factory = createInVMFactory();
@@ -122,10 +137,7 @@
System.out.println("server stopped, nr msgs: " + msgs);
- settings = new HashMap<String, QueueSettings>();
- config = createConfig(globalPage, settings);
-
- service = createService(true, false, config, settings);
+ service = createService(true, config, settings);
service.start();
@@ -176,11 +188,26 @@
public void testPageOnMultipleDestinations(boolean globalPage) throws Exception
{
+ Configuration config = createDefaultConfig();
+
HashMap<String, QueueSettings> settings = new HashMap<String, QueueSettings>();
- Configuration config = createConfig(globalPage, settings);
+ if (globalPage)
+ {
+ config.setPagingMaxGlobalSizeBytes(20 * 1024 * 1024);
+ QueueSettings setting = new QueueSettings();
+ setting.setMaxSizeBytes(-1);
+ settings.put("page-adr", setting);
+ }
+ else
+ {
+ config.setPagingMaxGlobalSizeBytes(-1);
+ QueueSettings setting = new QueueSettings();
+ setting.setMaxSizeBytes(20 * 1024 * 1024);
+ settings.put("page-adr", setting);
+ }
- service = createService(true, false, config, settings);
+ service = createService(true, config, settings);
service.start();
ClientSessionFactory factory = createInVMFactory();
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/ReclaimerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/ReclaimerTest.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/ReclaimerTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -757,7 +757,7 @@
return null;
}
- public int getOffset()
+ public long getOffset()
{
return 0;
}
@@ -767,7 +767,7 @@
return 0;
}
- public void setOffset(final int offset)
+ public void setOffset(final long offset)
{
}
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -82,7 +82,7 @@
// Public --------------------------------------------------------
- public SequentialFile createSequentialFile(final String fileName, final int maxAIO) throws Exception
+ public SequentialFile createSequentialFile(final String fileName, final int maxAIO)
{
FakeSequentialFile sf = fileMap.get(fileName);
@@ -416,7 +416,7 @@
return bytesRead.length;
}
- public void position(final int pos) throws Exception
+ public void position(final long pos) throws Exception
{
if (!open)
{
@@ -425,10 +425,10 @@
checkAlignment(pos);
- data.position(pos);
+ data.position((int)pos);
}
- public int position() throws Exception
+ public long position() throws Exception
{
return data.position();
}
@@ -546,7 +546,7 @@
return "FakeSequentialFile:" + fileName;
}
- private void checkAlignment(final int position)
+ private void checkAlignment(final long position)
{
if (position % alignment != 0)
{
@@ -554,6 +554,14 @@
}
}
+ /* (non-Javadoc)
+ * @see org.jboss.messaging.core.journal.SequentialFile#renameTo(org.jboss.messaging.core.journal.SequentialFile)
+ */
+ public void renameTo(SequentialFile file) throws Exception
+ {
+ throw new IllegalStateException("Method rename not supoprted on FakeSequentialFile");
+ }
+
}
}
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PageImplTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PageImplTestBase.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PageImplTestBase.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -119,11 +119,11 @@
for (int i = 0; i < msgs.length; i++)
{
- assertEquals(i, msgs[i].getMessage().getMessageID());
+ assertEquals(i, (msgs[i].getMessage(null)).getMessageID());
- assertEquals(simpleDestination, msgs[i].getMessage().getDestination());
+ assertEquals(simpleDestination, (msgs[i].getMessage(null)).getDestination());
- assertEqualsByteArrays(buffers.get(i).array(), msgs[i].getMessage().getBody().array());
+ assertEqualsByteArrays(buffers.get(i).array(), (msgs[i].getMessage(null)).getBody().array());
}
impl.delete();
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PageManagerImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PageManagerImplTest.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PageManagerImplTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -61,9 +61,6 @@
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
-
-
-
public void testOnDepage() throws Exception
{
long time = System.currentTimeMillis() + 10000;
@@ -77,7 +74,7 @@
PagingStoreFactory spi = EasyMock.createMock(PagingStoreFactory.class);
PagingStore store = EasyMock.createNiceMock(PagingStore.class);
StorageManager storageManager = EasyMock.createStrictMock(StorageManager.class);
- PagingManagerImpl manager = new PagingManagerImpl(spi, storageManager, queueSettings, -1);
+ PagingManagerImpl manager = new PagingManagerImpl(spi, storageManager, queueSettings, -1, 1024 * 1024);
manager.setPostOffice(po);
ServerMessage message = EasyMock.createStrictMock(ServerMessage.class);
@@ -97,7 +94,6 @@
EasyMock.verify(spi, store, message, storageManager, po, ref, queue);
}
-
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingStoreImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingStoreImplTest.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingStoreImplTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -163,8 +163,8 @@
for (int i = 0; i < 10; i++)
{
- assertEquals(0, msg[i].getMessage().getMessageID());
- assertEqualsByteArrays(buffers.get(i).array(), msg[i].getMessage().getBody().array());
+ assertEquals(0, (msg[i].getMessage(null)).getMessageID());
+ assertEqualsByteArrays(buffers.get(i).array(), (msg[i].getMessage(null)).getBody().array());
}
}
@@ -226,8 +226,8 @@
for (int i = 0; i < 5; i++)
{
- assertEquals(0, msg[i].getMessage().getMessageID());
- assertEqualsByteArrays(buffers.get(pageNr * 5 + i).array(), msg[i].getMessage().getBody().array());
+ assertEquals(0, (msg[i].getMessage(null)).getMessageID());
+ assertEqualsByteArrays(buffers.get(pageNr * 5 + i).array(), (msg[i].getMessage(null)).getBody().array());
}
}
@@ -269,9 +269,9 @@
assertEquals(1, msgs.length);
- assertEquals(0l, msgs[0].getMessage().getMessageID());
+ assertEquals(0l, (msgs[0].getMessage(null)).getMessageID());
- assertEqualsByteArrays(buffers.get(0).array(), msgs[0].getMessage().getBody().array());
+ assertEqualsByteArrays(buffers.get(0).array(), (msgs[0].getMessage(null)).getBody().array());
assertEquals(1, storeImpl.getNumberOfPages());
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingStoreTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingStoreTestBase.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingStoreTestBase.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -229,15 +229,16 @@
for (PageMessage msg : msgs)
{
- msg.getMessage().getBody().rewind();
- long id = msg.getMessage().getBody().getLong();
- msg.getMessage().getBody().rewind();
+ (msg.getMessage(null)).getBody().rewind();
+ long id = (msg.getMessage(null)).getBody().getLong();
+ (msg.getMessage(null)).getBody().rewind();
PageMessageImpl msgWritten = buffers.remove(id);
buffers2.put(id, msg);
assertNotNull(msgWritten);
- assertEquals(msg.getMessage().getDestination(), msgWritten.getMessage().getDestination());
- assertEqualsByteArrays(msgWritten.getMessage().getBody().array(), msg.getMessage().getBody().array());
+ assertEquals((msg.getMessage(null)).getDestination(), (msgWritten.getMessage(null)).getDestination());
+ assertEqualsByteArrays((msgWritten.getMessage(null)).getBody().array(), (msg.getMessage(null)).getBody()
+ .array());
}
}
@@ -293,12 +294,13 @@
for (PageMessage msg : msgs)
{
- msg.getMessage().getBody().rewind();
- long id = msg.getMessage().getBody().getLong();
+ (msg.getMessage(null)).getBody().rewind();
+ long id = (msg.getMessage(null)).getBody().getLong();
PageMessage msgWritten = buffers2.remove(id);
assertNotNull(msgWritten);
- assertEquals(msg.getMessage().getDestination(), msgWritten.getMessage().getDestination());
- assertEqualsByteArrays(msgWritten.getMessage().getBody().array(), msg.getMessage().getBody().array());
+ assertEquals((msg.getMessage(null)).getDestination(), (msgWritten.getMessage(null)).getDestination());
+ assertEqualsByteArrays((msgWritten.getMessage(null)).getBody().array(), (msg.getMessage(null)).getBody()
+ .array());
}
}
@@ -307,9 +309,10 @@
lastPage.close();
assertEquals(1, lastMessages.length);
- lastMessages[0].getMessage().getBody().rewind();
- assertEquals(lastMessages[0].getMessage().getBody().getLong(), lastMessageId);
- assertEqualsByteArrays(lastMessages[0].getMessage().getBody().array(), lastMsg.getMessage().getBody().array());
+ (lastMessages[0].getMessage(null)).getBody().rewind();
+ assertEquals((lastMessages[0].getMessage(null)).getBody().getLong(), lastMessageId);
+ assertEqualsByteArrays((lastMessages[0].getMessage(null)).getBody().array(), (lastMsg.getMessage(null)).getBody()
+ .array());
assertEquals(0, buffers2.size());
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/persistence/impl/journal/JournalStorageManagerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/persistence/impl/journal/JournalStorageManagerTest.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/persistence/impl/journal/JournalStorageManagerTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -76,11 +76,12 @@
Journal messageJournal = EasyMock.createStrictMock(Journal.class);
Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
- JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+ JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
ServerMessage msg = EasyMock.createStrictMock(ServerMessage.class);
long msgID = 1021092;
- EasyMock.expect(msg.getMessageID()).andReturn(msgID);
+ EasyMock.expect(msg.getMessageID()).andStubReturn(msgID);
+
messageJournal.appendAddRecord(msgID, JournalStorageManager.ADD_MESSAGE, msg);
EasyMock.replay(messageJournal, bindingsJournal, msg);
jsm.storeMessage(msg);
@@ -92,7 +93,7 @@
Journal messageJournal = EasyMock.createStrictMock(Journal.class);
Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
- JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+ JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
final long queueID = 1210981;
final long messageID = 101921092;
@@ -110,7 +111,7 @@
Journal messageJournal = EasyMock.createStrictMock(Journal.class);
Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
- JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+ JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
final long messageID = 101921092;
@@ -125,11 +126,11 @@
Journal messageJournal = EasyMock.createStrictMock(Journal.class);
Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
- JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+ JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
ServerMessage msg = EasyMock.createStrictMock(ServerMessage.class);
long msgID = 1021092;
- EasyMock.expect(msg.getMessageID()).andReturn(msgID);
+ EasyMock.expect(msg.getMessageID()).andStubReturn(msgID);
long txID = 192872;
messageJournal.appendAddRecordTransactional(txID, msgID, JournalStorageManager.ADD_MESSAGE, msg);
EasyMock.replay(messageJournal, bindingsJournal, msg);
@@ -142,7 +143,7 @@
Journal messageJournal = EasyMock.createStrictMock(Journal.class);
Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
- JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+ JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
final long queueID = 1210981;
final long messageID = 101921092;
@@ -162,7 +163,7 @@
Journal messageJournal = EasyMock.createStrictMock(Journal.class);
Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
- JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+ JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
final long messageID = 101921092;
final long txID = 1209373;
@@ -178,7 +179,7 @@
Journal messageJournal = EasyMock.createStrictMock(Journal.class);
Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
- JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+ JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
final long txID = 1209373;
@@ -196,7 +197,7 @@
Journal messageJournal = EasyMock.createStrictMock(Journal.class);
Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
- JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+ JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
final long txID = 1209373;
@@ -211,7 +212,7 @@
Journal messageJournal = EasyMock.createStrictMock(Journal.class);
Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
- JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+ JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
final long txID = 1209373;
@@ -226,7 +227,7 @@
Journal messageJournal = EasyMock.createStrictMock(Journal.class);
Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
- JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+ JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
final long msgID = 120912901;
final long queueID = 1283743;
@@ -254,7 +255,7 @@
Journal messageJournal = EasyMock.createStrictMock(Journal.class);
Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
- JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+ JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
messageJournal.load((List<RecordInfo>)EasyMock.anyObject(), (List<PreparedTransactionInfo>)EasyMock.anyObject());
@@ -422,7 +423,7 @@
Journal messageJournal = EasyMock.createStrictMock(Journal.class);
Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
- JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+ JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
Queue queue = EasyMock.createStrictMock(Queue.class);
SimpleString queueName = new SimpleString("saiohsiudh");
@@ -442,7 +443,7 @@
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream daos = new DataOutputStream(baos);
- queue.setPersistenceID(0);
+ queue.setPersistenceID(EasyMock.anyLong());
byte[] nameBytes = queueName.getData();
daos.writeInt(nameBytes.length);
@@ -464,7 +465,7 @@
log.debug("** data length is " + data.length);
log.debug(UnitTestCase.dumpBytes(data));
- bindingsJournal.appendAddRecord(EasyMock.eq(0L),
+ bindingsJournal.appendAddRecord(EasyMock.anyLong(),
EasyMock.eq(JournalStorageManager.BINDING_RECORD),
compareEncodingSupport(data));
@@ -494,7 +495,7 @@
Journal messageJournal = EasyMock.createStrictMock(Journal.class);
Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
- JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+ JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
Binding binding = EasyMock.createStrictMock(Binding.class);
Queue queue = EasyMock.createStrictMock(Queue.class);
@@ -516,7 +517,7 @@
Journal messageJournal = EasyMock.createStrictMock(Journal.class);
Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
- JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+ JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
Binding binding = EasyMock.createStrictMock(Binding.class);
Queue queue = EasyMock.createStrictMock(Queue.class);
@@ -544,7 +545,7 @@
Journal messageJournal = EasyMock.createStrictMock(Journal.class);
Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
- JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+ JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
SimpleString dest = new SimpleString("oaskokas");
@@ -555,7 +556,7 @@
daos.write(destBytes);
daos.flush();
byte[] data = baos.toByteArray();
- bindingsJournal.appendAddRecord(EasyMock.eq(0L),
+ bindingsJournal.appendAddRecord(EasyMock.anyLong(),
EasyMock.eq(JournalStorageManager.DESTINATION_RECORD),
compareEncodingSupport(data));
@@ -588,7 +589,7 @@
daos.write(destBytes);
daos.flush();
data = baos.toByteArray();
- bindingsJournal.appendAddRecord(EasyMock.eq(2L),
+ bindingsJournal.appendAddRecord(EasyMock.anyLong(),
EasyMock.eq(JournalStorageManager.DESTINATION_RECORD),
compareEncodingSupport(data));
@@ -600,7 +601,7 @@
EasyMock.reset(messageJournal, bindingsJournal);
- bindingsJournal.appendDeleteRecord(2);
+ bindingsJournal.appendDeleteRecord(EasyMock.anyLong());
EasyMock.replay(messageJournal, bindingsJournal);
@@ -669,7 +670,7 @@
Journal messageJournal = EasyMock.createStrictMock(Journal.class);
Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
- JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+ JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
bindingsJournal.load((List<RecordInfo>)EasyMock.anyObject(), (List<PreparedTransactionInfo>)EasyMock.anyObject());
@@ -736,7 +737,7 @@
Journal messageJournal = EasyMock.createStrictMock(Journal.class);
Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
- JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+ JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
assertFalse(jsm.isStarted());
bindingsJournal.start();
@@ -790,7 +791,7 @@
Journal messageJournal = EasyMock.createStrictMock(Journal.class);
Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
- JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+ JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
long id = jsm.generateUniqueID();
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/PostOfficeImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/PostOfficeImplTest.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/PostOfficeImplTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -317,7 +317,8 @@
PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
PagingStore store = EasyMock.createNiceMock(PagingStore.class);
- EasyMock.expect(pgm.getPageStore(address1)).andReturn(store);
+ EasyMock.expect(pgm.getPageStore(address1)).andStubReturn(store);
+ EasyMock.expect(pgm.createPageStore(address1)).andStubReturn(store);
PostOffice postOffice = new PostOfficeImpl(pm, pgm, qf, ms, true, null, wildCardRoutingEnabled, false);
@@ -330,6 +331,8 @@
(Map<Long, Queue>)EasyMock.anyObject(),
(ResourceManager)EasyMock.anyObject());
+ EasyMock.expect(pgm.isGlobalPageMode()).andStubReturn(false);
+
EasyMock.replay(pm, qf, binding, queue, pgm, store);
postOffice.start();
@@ -371,8 +374,10 @@
addresses[i] = new SimpleString("testAddress" + i);
queueNames[i] = new SimpleString("testQueueName" + i);
- EasyMock.expect(pgm.getPageStore(addresses[i])).andReturn(pgstore);
+ EasyMock.expect(pgm.getPageStore(addresses[i])).andStubReturn(pgstore);
+ EasyMock.expect(pgm.createPageStore(addresses[i])).andStubReturn(pgstore);
+
EasyMock.expect(bindings[i].getAddress()).andStubReturn(addresses[i]);
EasyMock.expect(bindings[i].getQueue()).andStubReturn(queues[i]);
EasyMock.expect(queues[i].getName()).andStubReturn(queueNames[i]);
@@ -432,7 +437,8 @@
queues[i] = EasyMock.createStrictMock(Queue.class);
addresses[i] = new SimpleString("testAddress" + i);
queueNames[i] = new SimpleString("testQueueName" + i);
- EasyMock.expect(pgm.getPageStore(addresses[i])).andReturn(pgstore);
+ EasyMock.expect(pgm.createPageStore(addresses[i])).andStubReturn(pgstore);
+ EasyMock.expect(pgm.getPageStore(addresses[i])).andStubReturn(pgstore);
EasyMock.expect(bindings[i].getAddress()).andStubReturn(addresses[i]);
EasyMock.expect(bindings[i].getQueue()).andStubReturn(queues[i]);
EasyMock.expect(queues[i].getName()).andStubReturn(queueNames[i]);
@@ -493,7 +499,8 @@
addresses[i] = new SimpleString("testAddress" + i);
queueNames[i] = new SimpleString("testQueueName" + i);
- EasyMock.expect(pgm.getPageStore(addresses[i])).andReturn(pgstore);
+ EasyMock.expect(pgm.getPageStore(addresses[i])).andStubReturn(pgstore);
+ EasyMock.expect(pgm.createPageStore(addresses[i])).andStubReturn(pgstore);
EasyMock.expect(bindings[i].getAddress()).andStubReturn(addresses[i]);
EasyMock.expect(bindings[i].getQueue()).andStubReturn(queues[i]);
@@ -549,7 +556,8 @@
addresses[i] = new SimpleString("testAddress" + i);
queueNames[i] = new SimpleString("testQueueName" + i);
- EasyMock.expect(pgm.getPageStore(addresses[i])).andReturn(pgstore);
+ EasyMock.expect(pgm.createPageStore(addresses[i])).andStubReturn(pgstore);
+ EasyMock.expect(pgm.getPageStore(addresses[i])).andStubReturn(pgstore);
EasyMock.expect(bindings[i].getAddress()).andStubReturn(addresses[i]);
EasyMock.expect(bindings[i].getQueue()).andStubReturn(queues[i]);
@@ -658,21 +666,23 @@
EasyMock.verify(qf, pm, filter);
- EasyMock.reset(qf, pm, filter);
+ EasyMock.reset(qf, pm, filter, pgm);
final boolean durable2 = false;
queue = queueFactory.createQueue(id, name, filter, durable2, false);
EasyMock.expect(qf.createQueue(-1, name, filter, durable2, false)).andReturn(queue);
+
+ EasyMock.expect(pgm.createPageStore((SimpleString)EasyMock.anyObject())).andStubReturn(null);
- EasyMock.replay(qf, pm, filter);
+ EasyMock.replay(qf, pm, pgm, filter);
po.addBinding(condition, name, filter, durable2, false, true);
po.removeBinding(name);
- EasyMock.verify(qf, pm, filter);
+ EasyMock.verify(qf, pm, pgm, filter);
}
public void testAddRemoveMultipleWithDifferentConditions() throws Exception
@@ -682,6 +692,9 @@
ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
+ EasyMock.expect(pgm.createPageStore(EasyMock.isA(SimpleString.class))).andStubReturn(null);
+ EasyMock.replay(pgm);
+
PostOffice po = new PostOfficeImpl(pm, pgm, qf, ms, false, null, wildCardRoutingEnabled, false);
final SimpleString condition1 = new SimpleString("queue.wibble");
@@ -796,6 +809,8 @@
QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
+ EasyMock.expect(pgm.createPageStore(EasyMock.isA(SimpleString.class))).andStubReturn(null);
+ EasyMock.replay(pgm);
PostOffice postOffice = new PostOfficeImpl(pm, pgm, qf, ms, true, null, wildCardRoutingEnabled, false);
@@ -858,6 +873,8 @@
ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
+ EasyMock.expect(pgm.createPageStore(EasyMock.isA(SimpleString.class))).andStubReturn(null);
+
PostOffice postOffice = new PostOfficeImpl(pm, pgm, qf, ms, true, null, wildCardRoutingEnabled, false);
qf.setPostOffice(postOffice);
@@ -871,7 +888,7 @@
EasyMock.expect(pm.addDestination(address3)).andReturn(true);
EasyMock.expect(pm.deleteDestination(address)).andReturn(true);
EasyMock.expect(pm.deleteDestination(address3)).andReturn(true);
- EasyMock.replay(pm, qf);
+ EasyMock.replay(pm, pgm, qf);
postOffice.start();
assertTrue(postOffice.addDestination(address, true));
assertTrue(postOffice.addDestination(address2, true));
@@ -947,7 +964,10 @@
pm.addBinding((Binding)EasyMock.anyObject());
pm.addBinding((Binding)EasyMock.anyObject());
pm.addBinding((Binding)EasyMock.anyObject());
- EasyMock.replay(pm, qf, queue, queue2, queue3);
+
+ EasyMock.expect(pgm.createPageStore((SimpleString)EasyMock.anyObject())).andStubReturn(null);
+
+ EasyMock.replay(pgm, pm, qf, queue, queue2, queue3);
postOffice.start();
postOffice.addBinding(new SimpleString("testAddress"), queueName, filter, true, false, true);
@@ -1015,7 +1035,10 @@
EasyMock.expect(queue.getName()).andStubReturn(queueName);
EasyMock.expect(queue2.getName()).andStubReturn(queueName2);
EasyMock.expect(queue3.getName()).andStubReturn(queueName3);
- EasyMock.replay(pm, qf, queue, queue2, queue3);
+
+ EasyMock.expect(pgm.createPageStore((SimpleString)EasyMock.anyObject())).andStubReturn(null);
+
+ EasyMock.replay(pgm, pm, qf, queue, queue2, queue3);
postOffice.start();
postOffice.addBinding(new SimpleString("testAddress"), queueName, filter, false, false, true);
@@ -1133,7 +1156,11 @@
pm.deleteBinding((Binding)EasyMock.anyObject());
EasyMock.expect(queue.isDurable()).andStubReturn(true);
EasyMock.expect(queue3.isDurable()).andStubReturn(true);
- EasyMock.replay(pm, qf, queue, queue2, queue3);
+
+
+ EasyMock.expect(pgm.createPageStore((SimpleString)EasyMock.anyObject())).andStubReturn(null);
+
+ EasyMock.replay(pgm, pm, qf, queue, queue2, queue3);
postOffice.start();
postOffice.addBinding(new SimpleString("testAddress"), queueName, filter, true, false, true);
@@ -1208,7 +1235,11 @@
EasyMock.expect(queue.isDurable()).andStubReturn(false);
EasyMock.expect(queue3.isDurable()).andStubReturn(false);
- EasyMock.replay(pm, qf, queue, queue2, queue3);
+
+ EasyMock.expect(pgm.createPageStore((SimpleString)EasyMock.anyObject())).andStubReturn(null);
+
+ EasyMock.replay(pgm, pm, qf, queue, queue2, queue3);
+
postOffice.start();
postOffice.addBinding(new SimpleString("testAddress"), queueName, filter, false, false, true);
@@ -1342,8 +1373,10 @@
EasyMock.expect(queue.getFilter()).andStubReturn(null);
EasyMock.expect(message.createReference(queue)).andReturn(messageReference);
+
+ EasyMock.expect(pgm.createPageStore((SimpleString)EasyMock.anyObject())).andStubReturn(null);
- EasyMock.replay(pm, qf, message, queue, messageReference);
+ EasyMock.replay(pgm, pm, qf, message, queue, messageReference);
postOffice.start();
postOffice.addBinding(address, queueName, null, false, false, true);
@@ -1388,6 +1421,8 @@
EasyMock.expect(qf.createQueue(-1, queueName, null, false, false)).andReturn(queue);
EasyMock.expect(queue.getName()).andStubReturn(queueName);
EasyMock.expect(queue.getFilter()).andStubReturn(null);
+
+ EasyMock.expect(pgm.createPageStore((SimpleString)EasyMock.anyObject())).andStubReturn(null);
EasyMock.replay(pm, pgm, qf, message, queue);
@@ -1428,9 +1463,13 @@
EasyMock.expect(queue.getFilter()).andStubReturn(filter);
EasyMock.expect(filter.match(message)).andReturn(true);
EasyMock.expect(message.createReference(queue)).andReturn(messageReference);
- EasyMock.replay(pm, qf, message, queue, messageReference, filter);
+
+ EasyMock.expect(pgm.createPageStore((SimpleString)EasyMock.anyObject())).andStubReturn(null);
+
+ EasyMock.replay(pgm, pm, qf, message, queue, messageReference, filter);
postOffice.start();
postOffice.addBinding(address, queueName, filter, false, false, true);
+
List<MessageReference> references = postOffice.route(message);
EasyMock.verify(pm, qf, message, queue, messageReference, filter);
assertTrue(postOffice.isStarted());
@@ -1464,11 +1503,15 @@
EasyMock.expect(queue.getName()).andStubReturn(queueName);
EasyMock.expect(queue.getFilter()).andStubReturn(filter);
EasyMock.expect(filter.match(message)).andReturn(false);
- EasyMock.replay(pm, qf, message, queue, messageReference, filter);
+
+ EasyMock.expect(pgm.createPageStore((SimpleString)EasyMock.anyObject())).andStubReturn(null);
+
+ EasyMock.replay(pgm, pm, qf, message, queue, messageReference, filter);
postOffice.start();
postOffice.addBinding(address, queueName, filter, false, false, true);
+
List<MessageReference> references = postOffice.route(message);
- EasyMock.verify(pm, qf, message, queue, messageReference, filter);
+ EasyMock.verify(pgm, pm, qf, message, queue, messageReference, filter);
assertTrue(postOffice.isStarted());
assertEquals(0, references.size());
}
@@ -1512,7 +1555,10 @@
EasyMock.expect(message.createReference(queue)).andReturn(messageReference);
EasyMock.expect(message.createReference(queue2)).andReturn(messageReference2);
EasyMock.expect(message.createReference(queue3)).andReturn(messageReference3);
- EasyMock.replay(pm, qf, message, queue, queue2, queue3, messageReference);
+
+ EasyMock.expect(pgm.createPageStore((SimpleString)EasyMock.anyObject())).andStubReturn(null);
+
+ EasyMock.replay(pgm, pm, qf, message, queue, queue2, queue3, messageReference);
postOffice.start();
postOffice.addBinding(address, queueName, null, false, false, true);
postOffice.addBinding(address, queueName2, null, false, false, true);
@@ -1568,7 +1614,10 @@
EasyMock.expect(filter2.match(message)).andReturn(true);
EasyMock.expect(message.createReference(queue2)).andReturn(messageReference2);
EasyMock.expect(message.createReference(queue3)).andReturn(messageReference3);
- EasyMock.replay(pm, qf, message, queue, queue2, queue3, messageReference, filter, filter2);
+
+ EasyMock.expect(pgm.createPageStore((SimpleString)EasyMock.anyObject())).andStubReturn(null);
+
+ EasyMock.replay(pgm, pm, qf, message, queue, queue2, queue3, messageReference, filter, filter2);
postOffice.start();
postOffice.addBinding(address, queueName, null, false, false, true);
postOffice.addBinding(address, queueName2, null, false, false, true);
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/MessageReferenceImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/MessageReferenceImplTest.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/MessageReferenceImplTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -180,7 +180,6 @@
EasyMock.expect(po.route(serverMessage)).andReturn(new ArrayList<MessageReference>());
EasyMock.expect(serverMessage.getDurableRefCount()).andReturn(0);
- EasyMock.expect(serverMessage.decrementRefCount()).andReturn(1);
EasyMock.expect(serverMessage.decrementDurableRefCount()).andReturn(0);
EasyMock.expect(sm.generateUniqueID()).andReturn(1l);
@@ -299,7 +298,6 @@
EasyMock.expect(repos.getMatch(queueName.toString())).andStubReturn(queueSettings);
EasyMock.expect(serverMessage.isDurable()).andStubReturn(true);
EasyMock.expect(serverMessage.getMessageID()).andStubReturn(999l);
- EasyMock.expect(serverMessage.decrementRefCount()).andReturn(1);
EasyMock.expect(queue.isDurable()).andStubReturn(true);
EasyMock.expect(serverMessage.decrementDurableRefCount()).andReturn(0);
EasyMock.expect(sm.generateUniqueID()).andReturn(1l);
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueImplTest.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueImplTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -450,7 +450,7 @@
public void testChangeConsumersAndDeliver() throws Exception
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, createMockPostOffice());
final int numMessages = 10;
@@ -720,7 +720,7 @@
public void testDeleteAllReferences() throws Exception
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, createMockPostOffice());
StorageManager storageManager = EasyMock.createStrictMock(StorageManager.class);
@@ -940,7 +940,7 @@
public void testConsumeWithFiltersAddAndRemoveConsumer() throws Exception
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, createMockPostOffice());
Filter filter = new FakeFilter("fruit", "orange");
@@ -1013,7 +1013,7 @@
private void testConsumerWithFilters(boolean direct) throws Exception
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, createMockPostOffice());
Filter filter = new FakeFilter("fruit", "orange");
@@ -1251,7 +1251,7 @@
{
long messageID = randomLong();
final SimpleString expiryQueue = new SimpleString("expiryQueue");
- Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, createMockPostOffice());
MessageReference messageReference = generateReference(queue, messageID);
StorageManager storageManager = EasyMock.createMock(StorageManager.class);
EasyMock.expect(storageManager.generateUniqueID()).andReturn(randomLong());
@@ -1309,7 +1309,7 @@
{
long messageID = randomLong();
final SimpleString dlqName = new SimpleString("dlq");
- Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, createMockPostOffice());
MessageReference messageReference = generateReference(queue, messageID);
StorageManager storageManager = createMock(StorageManager.class);
expect(storageManager.generateUniqueID()).andReturn(randomLong());
@@ -1368,7 +1368,7 @@
long newMessageID = randomLong();
long tid = randomLong();
final SimpleString toQueueName = new SimpleString("toQueueName");
- Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, createMockPostOffice());
Queue toQueue = createMock(Queue.class);
MessageReference messageReference = generateReference(queue, messageID);
@@ -1414,6 +1414,19 @@
EasyMock.verify(storageManager, postOffice, queueSettingsRepository, toBinding, pm);
}
+
+ /**
+ * @return
+ */
+ private PostOffice createMockPostOffice()
+ {
+ PagingManager niceManager = EasyMock.createNiceMock(PagingManager.class);
+ PostOffice nicePostOffice = EasyMock.createNiceMock(PostOffice.class);
+ EasyMock.expect(nicePostOffice.getPagingManager()).andStubReturn(niceManager);
+ EasyMock.replay(niceManager, nicePostOffice);
+ return nicePostOffice;
+ }
+
// Inner classes ---------------------------------------------------------------
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/ServerMessageImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/ServerMessageImplTest.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/ServerMessageImplTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -134,10 +134,10 @@
assertEquals(2, msg.getDurableRefCount());
- msg.incrementReference(true);
+ msg.incrementDurableRefCount();
assertEquals(3, msg.getDurableRefCount());
- msg.incrementReference(true);
+ msg.incrementDurableRefCount();
assertEquals(4, msg.getDurableRefCount());
msg.decrementDurableRefCount();
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/settings/impl/QueueSettingsTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/settings/impl/QueueSettingsTest.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/settings/impl/QueueSettingsTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -42,7 +42,7 @@
assertEquals(queueSettings.getExpiryQueue(), null);
assertEquals(queueSettings.getMaxDeliveryAttempts(), QueueSettings.DEFAULT_MAX_DELIVERY_ATTEMPTS);
assertEquals(queueSettings.getMaxSizeBytes(), QueueSettings.DEFAULT_MAX_SIZE_BYTES);
- assertEquals(queueSettings.getPageSizeBytes(), QueueSettings.DEFAULT_PAGE_SIZE_BYTES);
+ assertEquals(queueSettings.getPageSizeBytes(), null);
assertEquals(queueSettings.getMessageCounterHistoryDayLimit(), QueueSettings.DEFAULT_MESSAGE_COUNTER_HISTORY_DAY_LIMIT);
assertEquals(queueSettings.getRedeliveryDelay(), QueueSettings.DEFAULT_REDELIVER_DELAY);
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/transaction/impl/TransactionImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/transaction/impl/TransactionImplTest.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/transaction/impl/TransactionImplTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -30,6 +30,8 @@
import javax.transaction.xa.Xid;
import org.easymock.EasyMock;
+import org.jboss.messaging.core.paging.PagingManager;
+import org.jboss.messaging.core.paging.PagingStore;
import org.jboss.messaging.core.persistence.StorageManager;
import org.jboss.messaging.core.postoffice.PostOffice;
import org.jboss.messaging.core.server.MessageReference;
@@ -534,14 +536,24 @@
public void testAckCommit() throws Exception
{
+
+ PagingManager pagingManager = EasyMock.createStrictMock(PagingManager.class);
+ PostOffice postOffice = EasyMock.createMock(PostOffice.class);
+ PagingStore pagingStore = EasyMock.createStrictMock(PagingStore.class);
+
+ EasyMock.expect(pagingManager.getPageStore((SimpleString)EasyMock.anyObject())).andStubReturn(pagingStore);
+ EasyMock.expect(postOffice.getPagingManager()).andStubReturn(pagingManager);
+
+ EasyMock.replay(pagingManager, postOffice);
+
//Durable queue
- Queue queue1 = new QueueImpl(12, new SimpleString("queue1"), null, false, true, false, scheduledExecutor, null);
+ Queue queue1 = new QueueImpl(12, new SimpleString("queue1"), null, false, true, false, scheduledExecutor, postOffice);
//Durable queue
- Queue queue2 = new QueueImpl(34, new SimpleString("queue2"), null, false, true, false, scheduledExecutor, null);
+ Queue queue2 = new QueueImpl(34, new SimpleString("queue2"), null, false, true, false, scheduledExecutor, postOffice);
//Non durable queue
- Queue queue3 = new QueueImpl(65, new SimpleString("queue3"), null, false, false, false, scheduledExecutor, null);
+ Queue queue3 = new QueueImpl(65, new SimpleString("queue3"), null, false, false, false, scheduledExecutor, postOffice);
//Some refs to ack
@@ -570,7 +582,9 @@
EasyMock.expect(sm.generateUniqueID()).andReturn(txID);
- EasyMock.replay(sm);
+ EasyMock.reset(postOffice, pagingManager, pagingStore);
+
+ EasyMock.replay(sm, postOffice, pagingManager, pagingStore);
Transaction tx = new TransactionImpl(sm, po);
@@ -578,16 +592,16 @@
assertFalse(tx.isContainsPersistent());
- EasyMock.verify(sm);
+ EasyMock.verify(sm, postOffice, pagingManager, pagingStore);
- EasyMock.reset(sm);
+ EasyMock.reset(sm, postOffice, pagingManager, pagingStore);
//Expect:
sm.storeAcknowledgeTransactional(txID, queue1.getPersistenceID(), message1.getMessageID());
sm.storeDeleteMessageTransactional(txID, queue2.getPersistenceID(), message1.getMessageID());
- EasyMock.replay(sm);
+ EasyMock.replay(sm, postOffice, pagingManager, pagingStore);
tx.addAcknowledgement(ref3);
@@ -605,35 +619,39 @@
assertEquals(3, tx.getAcknowledgementsCount());
- EasyMock.verify(sm);
+ EasyMock.verify(sm, postOffice, pagingManager, pagingStore);
- EasyMock.reset(sm);
+ EasyMock.reset(sm, postOffice, pagingManager, pagingStore);
//Expect:
//Nothing
- EasyMock.replay(sm);
+ EasyMock.replay(sm, postOffice, pagingManager, pagingStore);
tx.addAcknowledgement(ref4);
assertEquals(4, tx.getAcknowledgementsCount());
- EasyMock.verify(sm);
+ EasyMock.verify(sm, postOffice, pagingManager, pagingStore);
- EasyMock.reset(sm);
+ EasyMock.reset(sm, postOffice, pagingManager, pagingStore);
//Expect:
sm.commit(txID);
- EasyMock.replay(sm);
+ pagingManager.messageDone(message1);
+ pagingManager.messageDone(message2);
+
+ EasyMock.replay(sm, postOffice, pagingManager, pagingStore);
+
tx.commit();
- EasyMock.verify(sm);
+ EasyMock.verify(sm, postOffice, pagingManager, pagingStore);
- EasyMock.reset(sm);
+ EasyMock.reset(sm, postOffice, pagingManager, pagingStore);
//TODO test messages are routed and refs count reduced
}
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/jms/client/JBossMessageConsumerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/client/JBossMessageConsumerTest.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/client/JBossMessageConsumerTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -366,6 +366,7 @@
MessagingBuffer body = createStrictMock(MessagingBuffer.class);
expect(clientMessage.getBody()).andStubReturn(body );
expect(clientConsumer.receive(0)).andReturn(clientMessage );
+ body.rewind();
replay(session, clientSession, clientConsumer, clientMessage, body);
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/jms/client/JBossMessageTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/client/JBossMessageTest.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/client/JBossMessageTest.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -151,7 +151,7 @@
clientSession = createStrictMock(ClientSession.class);
clientMessage = createStrictMock(ClientMessage.class);
MessagingBuffer buffer = createStrictMock(MessagingBuffer.class);
- expect(clientMessage.getBody()).andReturn(buffer);
+ expect(clientMessage.getBody()).andStubReturn(buffer);
expect(clientMessage.getProperty(JBossMessage.JBM_MESSAGE_ID)).andReturn(
messageID);
replay(clientSession, clientMessage, buffer);
@@ -409,7 +409,7 @@
clientSession = createStrictMock(ClientSession.class);
clientMessage = createStrictMock(ClientMessage.class);
MessagingBuffer buffer = createStrictMock(MessagingBuffer.class);
- expect(clientMessage.getBody()).andReturn(buffer);
+ expect(clientMessage.getBody()).andStubReturn(buffer);
clientMessage.putStringProperty(JBossMessage.JBM_MESSAGE_ID,
new SimpleString(messageID));
replay(clientSession, clientMessage, buffer);
@@ -427,7 +427,7 @@
clientSession = createStrictMock(ClientSession.class);
clientMessage = createStrictMock(ClientMessage.class);
MessagingBuffer buffer = createStrictMock(MessagingBuffer.class);
- expect(clientMessage.getBody()).andReturn(buffer);
+ expect(clientMessage.getBody()).andStubReturn(buffer);
replay(clientSession, clientMessage, buffer);
JBossMessage message = new JBossMessage(clientMessage, clientSession);
@@ -450,7 +450,7 @@
clientSession = createStrictMock(ClientSession.class);
clientMessage = createStrictMock(ClientMessage.class);
MessagingBuffer buffer = createStrictMock(MessagingBuffer.class);
- expect(clientMessage.getBody()).andReturn(buffer);
+ expect(clientMessage.getBody()).andStubReturn(buffer);
expect(clientMessage.removeProperty(JBossMessage.JBM_MESSAGE_ID))
.andReturn(null);
replay(clientSession, clientMessage, buffer);
@@ -1345,7 +1345,7 @@
clientMessage = createStrictMock(ClientMessage.class);
clientSession = createStrictMock(ClientSession.class);
MessagingBuffer buffer = createStrictMock(MessagingBuffer.class);
- expect(clientMessage.getBody()).andReturn(buffer);
+ expect(clientMessage.getBody()).andStubReturn(buffer);
clientSession.commit();
replay(clientMessage, clientSession, buffer);
@@ -1360,7 +1360,7 @@
clientMessage = createStrictMock(ClientMessage.class);
clientSession = createStrictMock(ClientSession.class);
MessagingBuffer buffer = createStrictMock(MessagingBuffer.class);
- expect(clientMessage.getBody()).andReturn(buffer);
+ expect(clientMessage.getBody()).andStubReturn(buffer);
clientSession.commit();
EasyMock.expectLastCall().andThrow(new MessagingException());
replay(clientMessage, clientSession, buffer);
@@ -1398,7 +1398,7 @@
clientMessage = createStrictMock(ClientMessage.class);
MessagingBuffer buffer = createStrictMock(MessagingBuffer.class);
expect(clientMessage.getType()).andReturn(expectedType);
- expect(clientMessage.getBody()).andReturn(buffer);
+ expect(clientMessage.getBody()).andStubReturn(buffer);
replay(clientSession, clientMessage, buffer);
JBossMessage message = JBossMessage.createMessage(clientMessage,
Copied: trunk/tests/src/org/jboss/messaging/tests/util/ServiceTestBase.java (from rev 5358, branches/Branch_Chunk_3/tests/src/org/jboss/messaging/tests/util/ServiceTestBase.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/util/ServiceTestBase.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/util/ServiceTestBase.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -0,0 +1,245 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.tests.util;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.messaging.core.client.ClientMessage;
+import org.jboss.messaging.core.client.ClientSession;
+import org.jboss.messaging.core.client.ClientSessionFactory;
+import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
+import org.jboss.messaging.core.config.Configuration;
+import org.jboss.messaging.core.config.TransportConfiguration;
+import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory;
+import org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory;
+import org.jboss.messaging.core.server.MessagingService;
+import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
+import org.jboss.messaging.core.settings.impl.QueueSettings;
+import org.jboss.messaging.integration.transports.netty.NettyAcceptorFactory;
+import org.jboss.messaging.integration.transports.netty.NettyConnectorFactory;
+import org.jboss.messaging.jms.client.JBossBytesMessage;
+import org.jboss.messaging.jms.client.JBossTextMessage;
+
+/**
+ *
+ * Base class with basic utilities on starting up a basic server
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.com">Clebert Suconic</a>
+ *
+ */
+public class ServiceTestBase extends UnitTestCase
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+
+ protected static final String INVM_ACCEPTOR_FACTORY = InVMAcceptorFactory.class.getCanonicalName();
+
+ protected static final String INVM_CONNECTOR_FACTORY = InVMConnectorFactory.class.getCanonicalName();
+
+ protected static final String NETTY_ACCEPTOR_FACTORY = NettyAcceptorFactory.class.getCanonicalName();
+
+ protected static final String NETTY_CONNECTOR_FACTORY = NettyConnectorFactory.class.getCanonicalName();
+
+ protected String baseDir = System.getProperty("java.io.tmpdir", "/tmp") + "/jbm-unit-test";
+
+ protected String journalDir = baseDir + "/journal";
+
+ protected String bindingsDir = baseDir + "/bindings";
+
+ protected String pageDir = baseDir + "/page";
+
+ protected String largeMessagesDir = baseDir + "/large-msg";
+
+ protected String clientLargeMessagesDir = baseDir + "/client-large-msg";
+
+ protected String temporaryDir = baseDir + "/temporary";
+
+ protected MessagingService messagingService;
+
+ // Static --------------------------------------------------------
+ private static final Logger log = Logger.getLogger(ServiceTestBase.class);
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ protected void clearData()
+ {
+ deleteAndCreateDir(journalDir);
+ deleteAndCreateDir(bindingsDir);
+ deleteAndCreateDir(pageDir);
+ deleteAndCreateDir(largeMessagesDir);
+ deleteAndCreateDir(clientLargeMessagesDir);
+ deleteAndCreateDir(temporaryDir);
+ }
+
+ protected void deleteData()
+ {
+ log.info("deleting directory " + baseDir);
+ deleteDirectory(new File(baseDir));
+ }
+
+ protected void deleteAndCreateDir(String directory)
+ {
+ File file = new File(directory);
+ deleteDirectory(file);
+ file.mkdirs();
+ }
+
+ protected MessagingService createService(final boolean realFiles,
+ final Configuration configuration,
+ final Map<String, QueueSettings> settings)
+ {
+
+ MessagingService service;
+
+ if (realFiles)
+ {
+ service = MessagingServiceImpl.newNioStorageMessagingServer(configuration,
+ journalDir,
+ bindingsDir,
+ largeMessagesDir);
+ }
+ else
+ {
+ service = MessagingServiceImpl.newNullStorageMessagingServer(configuration);
+ }
+
+ for (Map.Entry<String, QueueSettings> setting : settings.entrySet())
+ {
+ service.getServer().getQueueSettingsRepository().addMatch(setting.getKey(), setting.getValue());
+ }
+
+ return service;
+ }
+
+ protected MessagingService createService(final boolean realFiles)
+ {
+ return createService(realFiles, createDefaultConfig(), new HashMap<String, QueueSettings>());
+ }
+
+ protected MessagingService createService(final boolean realFiles, final Configuration configuration)
+ {
+ return createService(realFiles, configuration, new HashMap<String, QueueSettings>());
+ }
+
+ protected Configuration createDefaultConfig()
+ {
+ return createDefaultConfig(false);
+ }
+
+ protected Configuration createDefaultConfig(final boolean netty)
+ {
+ if (netty)
+ {
+ return createDefaultConfig(INVM_ACCEPTOR_FACTORY, NETTY_ACCEPTOR_FACTORY);
+ }
+ else
+ {
+ return createDefaultConfig(INVM_ACCEPTOR_FACTORY);
+ }
+
+ }
+
+ protected Configuration createDefaultConfig(final String... acceptors)
+ {
+ Configuration configuration = new ConfigurationImpl();
+ configuration.setSecurityEnabled(false);
+ configuration.setJournalMinFiles(2);
+ configuration.setJournalFileSize(100 * 1024);
+ configuration.setPagingDirectory(pageDir);
+ configuration.setLargeMessagesDirectory(largeMessagesDir);
+
+ configuration.getAcceptorConfigurations().clear();
+
+ for (String acceptor : acceptors)
+ {
+ TransportConfiguration transportConfig = new TransportConfiguration(acceptor);
+ configuration.getAcceptorConfigurations().add(transportConfig);
+ }
+
+ return configuration;
+ }
+
+ protected ClientSessionFactory createInVMFactory()
+ {
+ return createFactory(INVM_CONNECTOR_FACTORY);
+ }
+
+ protected ClientSessionFactory createNettyFactory()
+ {
+ return createFactory(NETTY_CONNECTOR_FACTORY);
+ }
+
+ protected ClientSessionFactory createFactory(final String connectorClass)
+ {
+ return new ClientSessionFactoryImpl(new TransportConfiguration(connectorClass),
+ null);
+
+ }
+
+ protected ClientMessage createTextMessage(final ClientSession session, final String s)
+ {
+ return createTextMessage(session, s, true);
+ }
+
+ protected ClientMessage createTextMessage(final ClientSession session, final String s, final boolean durable)
+ {
+ ClientMessage message = session.createClientMessage(JBossTextMessage.TYPE,
+ durable,
+ 0,
+ System.currentTimeMillis(),
+ (byte)1);
+ message.getBody().putString(s);
+ message.getBody().flip();
+ return message;
+ }
+
+ protected ClientMessage createBytesMessage(final ClientSession session, final byte[] b, final boolean durable)
+ {
+ ClientMessage message = session.createClientMessage(JBossBytesMessage.TYPE,
+ durable,
+ 0,
+ System.currentTimeMillis(),
+ (byte)1);
+ message.getBody().putBytes(b);
+ message.getBody().flip();
+ return message;
+ }
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Modified: trunk/tests/src/org/jboss/messaging/tests/util/UnitTestCase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/util/UnitTestCase.java 2008-11-19 06:24:31 UTC (rev 5386)
+++ trunk/tests/src/org/jboss/messaging/tests/util/UnitTestCase.java 2008-11-19 07:23:23 UTC (rev 5387)
@@ -93,6 +93,33 @@
return buff.toString();
}
+
+ public static String dumbBytesHex(final byte[] buffer, int bytesPerLine)
+ {
+
+ StringBuffer buff = new StringBuffer();
+
+ buff.append("[");
+
+ for (int i = 0; i < buffer.length; i++)
+ {
+ buff.append(String.format("%1$2X", buffer[i]));
+ if (i + 1 < buffer.length)
+ {
+ buff.append(", ");
+ }
+ if ((i + 1) % bytesPerLine == 0)
+ {
+ buff.append("\n ");
+ }
+ }
+ buff.append("]");
+
+ return buff.toString();
+ }
+
+
+
public static void assertEqualsByteArrays(byte[] expected, byte[] actual)
{
assertEquals(expected.length, actual.length);
More information about the jboss-cvs-commits
mailing list