[jboss-cvs] JBoss Messaging SVN: r5270 - in branches/Branch_Chunk: src/main/org/jboss/messaging/core/client/impl and 50 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Nov 4 18:26:11 EST 2008
Author: clebert.suconic at jboss.com
Date: 2008-11-04 18:26:10 -0500 (Tue, 04 Nov 2008)
New Revision: 5270
Added:
branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/FileClientMessage.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/FileClientMessageImpl.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalServerLargeMessageImpl.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageServerLargeMessageImpl.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionSendChunkMessage.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/ServerLargeMessage.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/ChunkTestBase.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/MessageChunkTest.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/MockConnector.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/MockConnectorFactory.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/soak/chunk/
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/soak/chunk/MessageChunkSoakTest.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/stress/chunk/
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/stress/chunk/MessageChunkStressTest.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/util/ServiceTestBase.java
Modified:
branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/ClientConsumer.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/ClientMessage.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/ClientSession.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/ClientSessionFactory.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientConsumerImpl.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientConsumerInternal.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientMessageImpl.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionInternal.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionPacketHandler.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/config/Configuration.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/exception/MessagingException.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/SequentialFile.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/SequentialFileFactory.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/impl/AIOSequentialFile.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/impl/AIOSequentialFileFactory.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/impl/JournalFile.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/impl/JournalFileImpl.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFile.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFileFactory.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/message/Message.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/paging/PageMessage.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/paging/PagingManager.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/paging/impl/PageMessageImpl.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/paging/impl/PagingManagerImpl.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/persistence/StorageManager.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/Packet.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateSessionMessage.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ReplicateCreateSessionMessage.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionReceiveMessage.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionScheduledSendMessage.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionSendMessage.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/MessagingServer.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/Queue.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/ServerMessage.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/ServerProducer.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/ServerSession.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/MessagingServiceImpl.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/ServerMessageImpl.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/ServerProducerImpl.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/settings/impl/QueueSettings.java
branches/Branch_Chunk/src/main/org/jboss/messaging/core/transaction/impl/TransactionImpl.java
branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossBytesMessage.java
branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java
branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossMapMessage.java
branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossMessage.java
branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossObjectMessage.java
branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossStreamMessage.java
branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossTextMessage.java
branches/Branch_Chunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java
branches/Branch_Chunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerDeployer.java
branches/Branch_Chunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java
branches/Branch_Chunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java
branches/Branch_Chunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java
branches/Branch_Chunk/tests/jms-tests/src/org/jboss/test/messaging/jms/CTSMiscellaneousTest.java
branches/Branch_Chunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTest.java
branches/Branch_Chunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTestCase.java
branches/Branch_Chunk/tests/jms-tests/src/org/jboss/test/messaging/jms/String64KLimitTest.java
branches/Branch_Chunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/base/IntegrationTestBase.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/clientcrash/ClientCrashTest.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/paging/PagingManagerIntegrationTest.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/remoting/DestroyConsumerTest.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/scheduling/ScheduledMessageTest.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/xa/BasicXaRecoveryTest.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/stress/paging/MultipleDestinationPagingTest.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/ReclaimerTest.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PageImplTestBase.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PageManagerImplTest.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingStoreImplTest.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingStoreTestBase.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/persistence/impl/journal/JournalStorageManagerTest.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/MessageReferenceImplTest.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueImplTest.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/ServerMessageImplTest.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/settings/impl/QueueSettingsTest.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/transaction/impl/TransactionImplTest.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/jms/client/JBossMessageConsumerTest.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/jms/client/JBossMessageTest.java
branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/util/UnitTestCase.java
Log:
New Branch update with changes
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/ClientConsumer.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/ClientConsumer.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/ClientConsumer.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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,22 +32,24 @@
* @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 isDirect();
+
+ boolean isFileConsumer();
- boolean isClosed();
-
- boolean isDirect();
-
Exception getLastException();
}
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/ClientMessage.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/ClientMessage.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/ClientMessage.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -44,4 +44,8 @@
void onReceipt(ClientSessionInternal session, long consumerID);
void acknowledge() throws MessagingException;
+
+ void setLargeMessage(boolean largeMessage);
+
+ boolean isLargeMessage();
}
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/ClientSession.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/ClientSession.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/ClientSession.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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;
@@ -69,6 +71,20 @@
int maxRate,
boolean browseOnly) throws MessagingException;
+ ClientConsumer createFileConsumer(File directory, SimpleString queueName) throws MessagingException;
+
+ ClientConsumer createFileConsumer(File directory, SimpleString queueName, SimpleString filterString, boolean direct) throws MessagingException;
+
+ ClientConsumer createFileConsumer(File directory, SimpleString queueName, SimpleString filterString, boolean direct, boolean browseOnly) throws MessagingException;
+
+ ClientConsumer createFileConsumer(File directory,
+ SimpleString queueName,
+ SimpleString filterString,
+ boolean direct,
+ int windowSize,
+ int maxRate,
+ boolean browseOnly) throws MessagingException;
+
ClientProducer createProducer(SimpleString address) throws MessagingException;
ClientProducer createProducer(SimpleString address,
@@ -107,6 +123,8 @@
ClientMessage createClientMessage(final byte type, final boolean durable);
ClientMessage createClientMessage(final boolean durable);
+
+ FileClientMessage createFileMessage(final boolean durable);
void start() throws MessagingException;
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/ClientSessionFactory.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/ClientSessionFactory.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/ClientSessionFactory.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -61,6 +61,10 @@
int getProducerMaxRate();
+ int getMinLargeMessageSize();
+
+ void setMinLargeMessageSize(final int minLargeMessageSize);
+
boolean isBlockOnPersistentSend();
void setBlockOnPersistentSend(final boolean blocking);
Added: branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/FileClientMessage.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/FileClientMessage.java (rev 0)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/FileClientMessage.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientConsumerImpl.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientConsumerImpl.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientConsumerImpl.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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 boolean direct;
private final Runner runner = new Runner();
+
+ private File directory;
+ private ClientMessage currentChunkMessage;
+
+
private volatile Thread receiverThread;
private volatile Thread onMessageThread;
@@ -83,7 +95,8 @@
final int clientWindowSize,
final boolean direct,
final Executor executor,
- final Channel channel)
+ final Channel channel,
+ final File directory)
{
this.id = id;
@@ -96,6 +109,8 @@
this.clientWindowSize = clientWindowSize;
this.direct = direct;
+
+ this.directory = directory;
}
// ClientConsumer implementation
@@ -151,7 +166,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)
{
@@ -181,6 +200,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);
@@ -251,6 +295,14 @@
return direct;
}
+ /* (non-Javadoc)
+ * @see org.jboss.messaging.core.client.ClientConsumer#isLargeMessagesAsFiles()
+ */
+ public boolean isFileConsumer()
+ {
+ return directory != null;
+ }
+
public Exception getLastException()
{
return lastException;
@@ -282,7 +334,12 @@
boolean expired = message.isExpired();
- flowControl(message.getEncodeSize());
+ // message chunk will call flowControl in a different method
+ // Message chunks will have already informed the flowControl
+ if (!message.isLargeMessage())
+ {
+ flowControl(message.getEncodeSize());
+ }
if (!expired)
{
@@ -310,7 +367,76 @@
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)
@@ -412,6 +538,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
@@ -483,6 +610,13 @@
}
}
+
+ private void addBytesBody(FileClientMessage fileMessage, byte[] body) throws Exception
+ {
+ FileChannel channel = fileMessage.getChannel();
+ channel.write(ByteBuffer.wrap(body));
+ }
+
// Inner classes
// --------------------------------------------------------------------------------
@@ -502,4 +636,5 @@
}
}
}
+
}
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientConsumerInternal.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientConsumerInternal.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientConsumerInternal.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -24,6 +24,8 @@
import org.jboss.messaging.core.client.ClientConsumer;
import org.jboss.messaging.core.client.ClientMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendChunkMessage;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
/**
*
@@ -37,6 +39,8 @@
long getID();
void handleMessage(ClientMessage message) throws Exception;
+
+ void handleChunk(SessionSendChunkMessage chunk) throws Exception;
void clear();
@@ -47,4 +51,6 @@
int getCreditsToSend();
void cleanUp() throws Exception;
+
+ ClientMessage createFileMessage(MessagingBuffer propertiesBuffer) throws Exception;
}
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientMessageImpl.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientMessageImpl.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientMessageImpl.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -42,6 +42,8 @@
private long consumerID;
private ClientSessionInternal session;
+
+ private boolean largeMessage;
/*
* Constructor for when reading from network
@@ -72,7 +74,6 @@
super((byte) 0, durable, 0, System.currentTimeMillis(), (byte)4, body);
}
- /* Only used in testing */
public ClientMessageImpl()
{
}
@@ -101,4 +102,22 @@
session.acknowledge(consumerID, messageID);
}
}
+
+ /**
+ * @return the largeMessage
+ */
+ public boolean isLargeMessage()
+ {
+ return largeMessage;
+ }
+
+ /**
+ * @param largeMessage the largeMessage to set
+ */
+ public void setLargeMessage(boolean largeMessage)
+ {
+ this.largeMessage = largeMessage;
+ }
+
+
}
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -1,27 +1,44 @@
/*
- * 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 java.util.concurrent.Semaphore;
+
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.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.SessionProducerCloseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionScheduledSendMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendChunkMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendManagementMessage;
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;
@@ -41,8 +58,6 @@
// Attributes -----------------------------------------------------------------------------------
- private final boolean trace = log.isTraceEnabled();
-
private final SimpleString address;
private final long id;
@@ -62,6 +77,8 @@
private final boolean blockOnPersistentSend;
private final SimpleString autoGroupId;
+
+ private final int minLargeMessageSize;
// Static ---------------------------------------------------------------------------------------
@@ -74,6 +91,7 @@
final boolean blockOnNonPersistentSend,
final boolean blockOnPersistentSend,
final SimpleString autoGroupId,
+ final int minLargeMessageSize,
final Channel channel)
{
this.channel = channel;
@@ -91,6 +109,9 @@
this.blockOnPersistentSend = blockOnPersistentSend;
this.autoGroupId = autoGroupId;
+
+ this.minLargeMessageSize = minLargeMessageSize;
+
}
// ClientProducer implementation ----------------------------------------------------------------
@@ -114,14 +135,14 @@
doSend(address, msg, 0);
}
- public void send(final ClientMessage msg, long scheduleDeliveryTime) throws MessagingException
+ public void send(final ClientMessage msg, final long scheduleDeliveryTime) throws MessagingException
{
checkClosed();
doSend(null, msg, scheduleDeliveryTime);
}
- public void send(final SimpleString address, final ClientMessage msg, long scheduleDeliveryTime) throws MessagingException
+ public void send(final SimpleString address, final ClientMessage msg, final long scheduleDeliveryTime) throws MessagingException
{
checkClosed();
@@ -133,29 +154,29 @@
public void sendManagement(final ClientMessage msg) throws MessagingException
{
checkClosed();
-
+
if (address != null)
{
msg.setDestination(address);
}
else
{
- msg.setDestination(this.address);
+ msg.setDestination(address);
}
-
+
if (rateLimiter != null)
{
// Rate flow control
-
+
rateLimiter.limit();
}
-
+
boolean sendBlocking = msg.isDurable() ? blockOnPersistentSend : blockOnNonPersistentSend;
-
+
SessionSendManagementMessage message = new SessionSendManagementMessage(id, msg, false);
-
+
if (sendBlocking)
- {
+ {
channel.sendBlocking(message);
}
else
@@ -255,7 +276,7 @@
closed = true;
}
- private void doSend(final SimpleString address, final ClientMessage msg, long scheduledDeliveryTime) throws MessagingException
+ private void doSend(final SimpleString address, final ClientMessage msg, final long scheduledDeliveryTime) throws MessagingException
{
if (address != null)
{
@@ -273,33 +294,119 @@
rateLimiter.limit();
}
- if(autoGroupId != null)
+ if (autoGroupId != null)
{
msg.putStringProperty(MessageImpl.GROUP_ID, autoGroupId);
}
boolean sendBlocking = msg.isDurable() ? blockOnPersistentSend : blockOnNonPersistentSend;
- SessionSendMessage message;
- //check to see if this message need to be scheduled.
- if(scheduledDeliveryTime <= 0)
+ if (msg.getEncodeSize() > minLargeMessageSize)
{
- message = new SessionSendMessage(id, msg, sendBlocking);
+ // TODO: We need to send message-chunks blocked until producer flow control is done.
+ // When sending really big messages, you could overuse the communication channel up to the point
+ // you get out of memory, or you don't let the pings to arrive properly on the server
+ // We will need to live with blocked sends until we enable producer flow control
+ sendMessageInChunks(true, msg, scheduledDeliveryTime);
+ //sendMessageInChunks(sendBlocking, msg, scheduledDeliveryTime);
}
else
{
- message = new SessionScheduledSendMessage(id, msg, sendBlocking, scheduledDeliveryTime);
+ SessionSendMessage message;
+
+ // check to see if this message need to be scheduled.
+ if (scheduledDeliveryTime <= 0)
+ {
+ message = new SessionSendMessage(id, msg, sendBlocking);
+ }
+ else
+ {
+ message = new SessionScheduledSendMessage(id, msg, sendBlocking, scheduledDeliveryTime);
+ }
+
+ if (sendBlocking)
+ {
+ channel.sendBlocking(message);
+ }
+ else
+ {
+ channel.send(message);
+ }
}
+ }
+ /**
+ * @param msg
+ * @throws MessagingException
+ */
+ private void sendMessageInChunks(final boolean sendBlocking, final ClientMessage msg, final long scheduledDelivery) 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(id,
+ headerBuffer.array(),
+ bodyBuffer.array(),
+ bodyLength < bodySize,
+ sendBlocking,
+ scheduledDelivery);
+
if (sendBlocking)
{
- channel.sendBlocking(message);
+ channel.sendBlocking(chunk);
}
else
{
- channel.send(message);
+ 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(id, null, bodyBuffer.array(), pos + bodyLength < bodySize, sendBlocking, scheduledDelivery);
+
+ 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
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -57,6 +57,11 @@
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_PING_POOL_SIZE = 5;
+
public static final int DEFAULT_CONSUMER_WINDOW_SIZE = 1024 * 1024;
public static final int DEFAULT_CONSUMER_MAX_RATE = -1;
@@ -101,6 +106,8 @@
private volatile ConnectionManager connectionManager;
private volatile ConnectionManager backupConnectionManager;
+
+ private volatile int minLargeMessageSize;
private volatile int consumerWindowSize;
@@ -146,6 +153,7 @@
final int consumerMaxRate,
final int sendWindowSize,
final int producerMaxRate,
+ final int minLargeMessageSize,
final boolean blockOnAcknowledge,
final boolean blockOnNonPersistentSend,
final boolean blockOnPersistentSend,
@@ -190,6 +198,7 @@
this.blockOnAcknowledge = blockOnAcknowledge;
this.blockOnNonPersistentSend = blockOnNonPersistentSend;
this.blockOnPersistentSend = blockOnPersistentSend;
+ this.minLargeMessageSize = minLargeMessageSize;
this.autoGroupId = autoGroupId;
this.maxConnections = maxConnections;
}
@@ -205,12 +214,12 @@
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_ID,
DEFAULT_MAX_CONNECTIONS);
-
}
/**
@@ -357,6 +366,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
// ------------------------------------------
@@ -556,6 +581,7 @@
clientVersion.getIncrementingVersion(),
username,
password,
+ minLargeMessageSize,
xa,
autoCommitSends,
autoCommitAcks,
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -21,6 +21,7 @@
*/
package org.jboss.messaging.core.client.impl;
+import java.io.File;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -38,6 +39,7 @@
import org.jboss.messaging.core.client.ClientMessage;
import org.jboss.messaging.core.client.ClientProducer;
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.remoting.Channel;
@@ -63,6 +65,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;
@@ -158,6 +161,8 @@
private volatile boolean started;
+ private Map<Long, ClientMessage> currentChunk = new ConcurrentHashMap<Long, ClientMessage>();
+
// Constructors ----------------------------------------------------------------------------
public ClientSessionImpl(final ClientSessionFactoryInternal sessionFactory,
@@ -316,61 +321,56 @@
final int maxRate,
final boolean browseOnly) throws MessagingException
{
+ return internalCreateConsumer(queueName, filterString, direct, windowSize, maxRate, browseOnly, null);
+ }
+
+ public ClientConsumer createFileConsumer(final File directory, final SimpleString queueName) throws MessagingException
+ {
checkClosed();
- SessionCreateConsumerMessage request = new SessionCreateConsumerMessage(queueName,
- filterString,
- windowSize,
- maxRate,
- browseOnly);
+ return createFileConsumer(directory, queueName, null, false);
+ }
- SessionCreateConsumerResponseMessage response = (SessionCreateConsumerResponseMessage)channel.sendBlocking(request);
+ public ClientConsumer createFileConsumer(final File directory,
+ final SimpleString queueName,
+ final SimpleString filterString,
+ final boolean direct) 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
- int actualWindowSize = response.getWindowSize();
+ return createFileConsumer(directory,
+ queueName,
+ filterString,
+ direct,
+ connectionFactory.getConsumerWindowSize(),
+ connectionFactory.getConsumerMaxRate(),
+ false);
+ }
- int clientWindowSize;
- if (actualWindowSize == -1)
- {
- // No flow control - buffer can increase without bound! Only use with
- // caution for very fast consumers
- clientWindowSize = 0;
- }
- else if (actualWindowSize == 1)
- {
- // Slow consumer - no buffering
- clientWindowSize = 1;
- }
- else if (actualWindowSize > 1)
- {
- // Client window size is half server window size
- clientWindowSize = actualWindowSize >> 1;
- }
- else
- {
- throw new IllegalArgumentException("Invalid window size " + actualWindowSize);
- }
+ public ClientConsumer createFileConsumer(final File directory,
+ final SimpleString queueName,
+ final SimpleString filterString,
+ final boolean direct,
+ final boolean browseOnly) throws MessagingException
+ {
+ return createFileConsumer(directory,
+ queueName,
+ filterString,
+ direct,
+ connectionFactory.getConsumerWindowSize(),
+ connectionFactory.getConsumerMaxRate(),
+ browseOnly);
+ }
- long consumerID = idGenerator.generateID();
-
- ClientConsumerInternal consumer = new ClientConsumerImpl(this,
- consumerID,
- clientWindowSize,
- direct,
- 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, response.getWindowSize()));
-
- return consumer;
+ public ClientConsumer createFileConsumer(File directory,
+ SimpleString queueName,
+ SimpleString filterString,
+ boolean direct,
+ int windowSize,
+ int maxRate,
+ boolean browseOnly) throws MessagingException
+ {
+ return internalCreateConsumer(queueName, filterString, direct, windowSize, maxRate, browseOnly, directory);
}
public ClientProducer createProducer(final SimpleString address) throws MessagingException
@@ -423,6 +423,7 @@
autoCommitSends && blockOnNonPersistentSend,
autoCommitSends && blockOnPersistentSend,
response.getAutoGroupId(),
+ sessionFactory.getMinLargeMessageSize(),
channel);
}
@@ -498,6 +499,11 @@
return new ClientMessageImpl(durable, body);
}
+ public FileClientMessage createFileMessage(final boolean durable)
+ {
+ return new FileClientMessageImpl(durable);
+ }
+
public boolean isClosed()
{
return closed;
@@ -642,6 +648,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)
@@ -1033,7 +1050,82 @@
// Private
// ----------------------------------------------------------------------------
+ /**
+ * @param queueName
+ * @param filterString
+ * @param direct
+ * @param windowSize
+ * @param maxRate
+ * @param browseOnly
+ * @return
+ * @throws MessagingException
+ */
+ private ClientConsumer internalCreateConsumer(final SimpleString queueName,
+ final SimpleString filterString,
+ final boolean direct,
+ final int windowSize,
+ final int maxRate,
+ final boolean browseOnly,
+ final File directory) throws MessagingException
+ {
+ checkClosed();
+ SessionCreateConsumerMessage request = new SessionCreateConsumerMessage(queueName,
+ filterString,
+ windowSize,
+ maxRate,
+ browseOnly);
+
+ SessionCreateConsumerResponseMessage response = (SessionCreateConsumerResponseMessage)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 actualWindowSize = response.getWindowSize();
+
+ int clientWindowSize;
+ if (actualWindowSize == -1)
+ {
+ // No flow control - buffer can increase without bound! Only use with
+ // caution for very fast consumers
+ clientWindowSize = 0;
+ }
+ else if (actualWindowSize == 1)
+ {
+ // Slow consumer - no buffering
+ clientWindowSize = 1;
+ }
+ else if (actualWindowSize > 1)
+ {
+ // Client window size is half server window size
+ clientWindowSize = actualWindowSize >> 1;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Invalid window size " + actualWindowSize);
+ }
+
+ long consumerID = idGenerator.generateID();
+
+ ClientConsumerInternal consumer = new ClientConsumerImpl(this,
+ consumerID,
+ clientWindowSize,
+ direct,
+ 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, response.getWindowSize()));
+
+ return consumer;
+ }
+
private void checkXA() throws XAException
{
if (!xa)
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionInternal.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionInternal.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionInternal.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -19,6 +19,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;
import org.jboss.messaging.util.SimpleString;
/**
@@ -47,6 +48,8 @@
Map<SimpleString, ClientProducerInternal> getProducerCache();
void handleReceiveMessage(long consumerID, ClientMessage message) throws Exception;
+
+ void handleReceiveChunk(long consumerID, SessionSendChunkMessage chunk) throws Exception;
void handleFailover();
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionPacketHandler.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionPacketHandler.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionPacketHandler.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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;
@@ -30,6 +31,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;
/**
*
@@ -45,18 +47,25 @@
private final ClientSessionInternal clientSession;
public ClientSessionPacketHandler(final ClientSessionInternal clientSesssion)
- {
+ {
this.clientSession = clientSesssion;
}
-
+
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;
Added: branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/FileClientMessageImpl.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/FileClientMessageImpl.java (rev 0)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/client/impl/FileClientMessageImpl.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -0,0 +1,254 @@
+/*
+ * 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.FileClientMessage;
+import org.jboss.messaging.core.exception.MessagingException;
+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);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param type
+ * @param durable
+ * @param body
+ */
+ public FileClientMessageImpl(final byte type, final boolean durable, final MessagingBuffer body)
+ {
+ super(type, durable, body);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @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()
+ {
+ 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: branches/Branch_Chunk/src/main/org/jboss/messaging/core/config/Configuration.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/config/Configuration.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/config/Configuration.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -37,8 +37,7 @@
*/
public interface Configuration extends Serializable
{
- // General attributes
- // -------------------------------------------------------------------
+ // General attributes -------------------------------------------------------------------
boolean isClustered();
@@ -88,9 +87,10 @@
void setBackupConnectorConfiguration(TransportConfiguration config);
- // Journal related attributes
- // ------------------------------------------------------------
+ boolean isWildcardRoutingEnabled();
+ // Journal related attributes ------------------------------------------------------------
+
String getBindingsDirectory();
void setBindingsDirectory(String dir);
@@ -99,10 +99,6 @@
void setJournalDirectory(String dir);
- String getPagingDirectory();
-
- void setPagingDirectory(String dir);
-
JournalType getJournalType();
void setJournalType(JournalType type);
@@ -139,9 +135,24 @@
void setCreateJournalDir(boolean create);
+
+ // Paging Properties --------------------------------------------------------------------
+
+ String getPagingDirectory();
+
+ void setPagingDirectory(String dir);
+
long getPagingMaxGlobalSizeBytes();
void setPagingMaxGlobalSizeBytes(long maxGlobalSize);
-
- boolean isWildcardRoutingEnabled();
+
+ long getPagingDefaultSize();
+
+ void setPagingDefaultSize(long pageSize);
+
+ // Large Messages Properties ------------------------------------------------------------
+
+ String getLargeMessagesDirectory();
+
+ void setLargeMessagesDirectory(String directory);
}
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -56,6 +56,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;
@@ -101,14 +105,21 @@
protected TransportConfiguration backupConnectorConfig;
- // Paging related attributes
+ protected boolean wildcardRoutingEnabled = DEFAULT_WILDCARD_ROUTING_ENABLED;
+ // 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;
@@ -131,8 +142,6 @@
protected int journalBufferReuseSize = DEFAULT_JOURNAL_REUSE_BUFFER_SIZE;
- protected boolean wildcardRoutingEnabled = DEFAULT_WILDCARD_ROUTING_ENABLED;
-
public boolean isClustered()
{
return clustered;
@@ -387,7 +396,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;
+ }
+
+
@Override
public boolean equals(final Object other)
{
@@ -410,6 +447,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() &&
@@ -417,7 +455,11 @@
cother.getJournalMinFiles() == getJournalMinFiles() &&
cother.getJournalType() == getJournalType() &&
cother.getScheduledThreadPoolMaxSize() == getScheduledThreadPoolMaxSize() &&
- cother.getSecurityInvalidationInterval() == getSecurityInvalidationInterval();
+ cother.getSecurityInvalidationInterval() == getSecurityInvalidationInterval() &&
+ cother.getPagingDefaultSize() == getPagingDefaultSize();
}
+
+
+
}
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -304,6 +304,8 @@
// Persistence config
+ largeMessagesDirectory = getString(e, "large-messages-directory", largeMessagesDirectory);
+
bindingsDirectory = getString(e, "bindings-directory", bindingsDirectory);
createBindingsDir = getBoolean(e, "create-bindings-dir", createBindingsDir);
@@ -313,6 +315,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: branches/Branch_Chunk/src/main/org/jboss/messaging/core/exception/MessagingException.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/exception/MessagingException.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/exception/MessagingException.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/SequentialFile.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/SequentialFile.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/SequentialFile.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/SequentialFileFactory.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/SequentialFileFactory.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/SequentialFileFactory.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/impl/AIOSequentialFile.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/impl/AIOSequentialFile.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/impl/AIOSequentialFile.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/impl/AIOSequentialFileFactory.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/impl/AIOSequentialFileFactory.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/impl/AIOSequentialFileFactory.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/impl/JournalFile.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/impl/JournalFile.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/impl/JournalFile.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/impl/JournalFileImpl.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/impl/JournalFileImpl.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/impl/JournalFileImpl.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFile.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFile.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFile.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFileFactory.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFileFactory.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFileFactory.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/src/main/org/jboss/messaging/core/message/Message.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/message/Message.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/message/Message.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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;
@@ -65,7 +65,7 @@
// Attributes ----------------------------------------------------
protected long messageID;
-
+
private SimpleString destination;
private byte type;
@@ -87,7 +87,7 @@
protected MessageImpl()
{
- this.properties = new TypedProperties();
+ properties = new TypedProperties();
}
/**
@@ -99,8 +99,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;
@@ -117,17 +121,17 @@
protected MessageImpl(final MessageImpl other)
{
this();
- this.messageID = other.messageID;
- this.destination = other.destination;
- this.type = other.type;
- this.durable = other.durable;
- this.expiration = other.expiration;
- this.timestamp = other.timestamp;
- this.priority = other.priority;
- this.properties = new TypedProperties(other.properties);
- this.body = other.body;
+ messageID = other.messageID;
+ destination = other.destination;
+ type = other.type;
+ durable = other.durable;
+ expiration = other.expiration;
+ timestamp = other.timestamp;
+ priority = other.priority;
+ properties = new TypedProperties(other.properties);
+ body = other.body;
}
-
+
protected MessageImpl(final long messageID)
{
this();
@@ -136,34 +140,70 @@
// 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();
@@ -171,32 +211,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);
+
}
-
+
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;
@@ -206,7 +251,7 @@
{
return durable;
}
-
+
public void setDurable(final boolean durable)
{
this.durable = durable;
@@ -226,12 +271,12 @@
{
return timestamp;
}
-
+
public void setTimestamp(final long timestamp)
{
this.timestamp = timestamp;
}
-
+
public byte getPriority()
{
return priority;
@@ -241,105 +286,105 @@
{
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 -----------------------------------------------------
// Private -------------------------------------------------------
- // Inner classes -------------------------------------------------
+ // Inner classes -------------------------------------------------
}
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/paging/PageMessage.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/paging/PageMessage.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/paging/PageMessage.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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;
import org.jboss.messaging.util.TypedProperties;
@@ -36,7 +37,7 @@
*/
public interface PageMessage extends EncodingSupport
{
- ServerMessage getMessage();
+ ServerMessage getMessage(StorageManager storageManager);
long getTransactionID();
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/paging/PagingManager.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/paging/PagingManager.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/paging/PagingManager.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -140,4 +140,9 @@
* */
void clearLastPageRecord(LastPageRecord lastRecord) throws Exception;
+ /**
+ * @return
+ */
+ long getDefaultPageSize();
+
}
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/paging/impl/PageMessageImpl.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/paging/impl/PageMessageImpl.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/paging/impl/PageMessageImpl.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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;
@@ -50,7 +55,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;
@@ -87,8 +95,15 @@
this.properties = properties;
}
- 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;
}
@@ -107,20 +122,49 @@
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
+ {
+ message = new ServerMessageImpl();
+ message.decode(buffer);
+ }
+
properties.decode(buffer);
}
public void encode(final MessagingBuffer buffer)
{
buffer.putLong(transactionID);
- message.encode(buffer);
+ buffer.putBoolean(message instanceof ServerLargeMessage);
+ if (message instanceof ServerLargeMessage)
+ {
+ buffer.putInt(message.getEncodeSize());
+ message.encode(buffer);
+ }
+ else
+ {
+ message.encode(buffer);
+ }
properties.encode(buffer);
}
public int getEncodeSize()
{
- return DataConstants.SIZE_LONG + message.getEncodeSize() + properties.getEncodeSize();
+ return DataConstants.SIZE_LONG + DataConstants.SIZE_BYTE +
+ (message instanceof ServerLargeMessage ? DataConstants.SIZE_INT : 0) +
+ message.getEncodeSize() +
+ properties.getEncodeSize();
}
// Package protected ---------------------------------------------
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/paging/impl/PagingManagerImpl.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/paging/impl/PagingManagerImpl.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/paging/impl/PagingManagerImpl.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -59,7 +59,6 @@
{
// Constants -----------------------------------------------------
- private static final long WATERMARK_GLOBAL_PAGE = QueueSettings.DEFAULT_PAGE_SIZE_BYTES;
// Attributes ----------------------------------------------------
@@ -81,6 +80,8 @@
private final StorageManager storageManager;
+ private final long defaultPageSize;
+
private PostOffice postOffice;
private final ConcurrentMap</*TransactionID*/Long, PageTransactionInfo> transactions = new ConcurrentHashMap<Long, PageTransactionInfo>();
@@ -110,11 +111,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;
}
@@ -208,6 +211,10 @@
for (PageMessage msg : data)
{
+ ServerMessage pagedMessage = null;
+
+ pagedMessage = (ServerMessage)msg.getMessage(storageManager);
+
final long transactionIdDuringPaging = msg.getTransactionID();
if (transactionIdDuringPaging >= 0)
{
@@ -220,7 +227,7 @@
{
if (isTrace)
{
- trace("Transaction " + msg.getTransactionID() + " not found, ignoring message " + msg.getMessage());
+ trace("Transaction " + msg.getTransactionID() + " not found, ignoring message " + pagedMessage);
}
continue;
}
@@ -229,40 +236,40 @@
// 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);
}
}
- Long scheduledDeliveryTime = (Long) msg.getProperties().getProperty(SCHEDULED_DELIVERY_PROP);
- //if this is a scheduled message we add it to the queue as just that
- if(scheduledDeliveryTime == null)
+ Long scheduledDeliveryTime = (Long)msg.getProperties().getProperty(SCHEDULED_DELIVERY_PROP);
+ // if this is a scheduled message we add it to the queue as just that
+ if (scheduledDeliveryTime == null)
{
- refsToAdd.addAll(postOffice.route(msg.getMessage()));
+ refsToAdd.addAll(postOffice.route(pagedMessage));
}
else
{
- List<MessageReference> refs = postOffice.route(msg.getMessage());
+ List<MessageReference> refs = postOffice.route(pagedMessage);
for (MessageReference ref : refs)
{
ref.setScheduledDeliveryTime(scheduledDeliveryTime);
if(ref.getQueue().isDurable())
{
- storageManager.storeMessageReferenceScheduledTransactional(depageTransactionID, ref.getQueue().getPersistenceID(), msg.getMessage().getMessageID(), scheduledDeliveryTime);
+ storageManager.storeMessageReferenceScheduledTransactional(depageTransactionID, ref.getQueue().getPersistenceID(), pagedMessage.getMessageID(), scheduledDeliveryTime);
}
}
scheduledRefsToAdd.addAll(refs);
}
- if (msg.getMessage().getDurableRefCount() != 0)
+ if (pagedMessage.getDurableRefCount() != 0)
{
- storageManager.storeMessageTransactional(depageTransactionID, msg.getMessage());
+ storageManager.storeMessageTransactional(depageTransactionID, pagedMessage);
}
}
@@ -294,7 +301,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
@@ -306,6 +314,11 @@
}
+ public long getDefaultPageSize()
+ {
+ return defaultPageSize;
+ }
+
public void setLastPage(final LastPageRecord lastPage) throws Exception
{
trace("LastPage loaded was " + lastPage.getLastId() + " recordID = " + lastPage.getRecordId());
@@ -460,8 +473,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: branches/Branch_Chunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -31,6 +31,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;
@@ -72,7 +73,7 @@
private final boolean dropMessagesOnSize;
private boolean droppedMessages;
-
+
private final PagingManager pagingManager;
private final Executor executor;
@@ -113,7 +114,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: branches/Branch_Chunk/src/main/org/jboss/messaging/core/persistence/StorageManager.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/persistence/StorageManager.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/persistence/StorageManager.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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;
@@ -68,6 +69,9 @@
void storeMessageReferenceScheduledTransactional(final long txID, final long queueID, final long messageID, final long scheduledDeliveryTime) 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();
/** Used to delete non-messaging data (such as PageTransaction and LasPage) */
void storeDeleteTransactional(long txID, long recordID) throws Exception;
Added: branches/Branch_Chunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalServerLargeMessageImpl.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalServerLargeMessageImpl.java (rev 0)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalServerLargeMessageImpl.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -0,0 +1,257 @@
+/*
+ * 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 JournalServerLargeMessageImpl extends ServerMessageImpl implements ServerLargeMessage
+{
+
+ // Constants -----------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(JournalServerLargeMessageImpl.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 JournalServerLargeMessageImpl(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)
+ {
+ new Exception ("Encode body");
+ 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
+ {
+
+ if (file == null)
+ {
+ new Exception ("ainda nulo?").printStackTrace();
+ }
+
+ 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 -------------------------------------------------
+
+}
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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 java.io.File;
import java.nio.ByteBuffer;
import java.util.ArrayList;
@@ -29,17 +33,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;
@@ -61,12 +70,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;
@@ -83,12 +94,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;
@@ -100,6 +105,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;
@@ -112,7 +119,7 @@
public static final byte SET_SCHEDULED_DELIVERY_TIME = 44;
- //This will produce a unique id **for this node only**
+ // This will produce a unique id **for this node only**
private final IDGenerator idGenerator = new TimeAndCounterIDGenerator();
private final AtomicLong bindingIDSequence = new AtomicLong(0);
@@ -121,12 +128,19 @@
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");
@@ -152,7 +166,7 @@
throw new NullPointerException("journal-dir is null");
}
- checkAndCreateDir(journalDir, config.isCreateBindingsDir());
+ checkAndCreateDir(journalDir, config.isCreateJournalDir());
SequentialFileFactory journalFF = null;
@@ -191,13 +205,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 +229,31 @@
return idGenerator.generateID();
}
+ /** Create an area that will get LargeMessage bytes on the server size*/
+ public ServerLargeMessage createLargeMessageStorage()
+ {
+ return new JournalServerLargeMessageImpl(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
@@ -232,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
@@ -333,6 +393,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);
@@ -436,17 +513,14 @@
Queue queue = queues.get(encoding.queueID);
- if (queue == null)
- {
- 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);
+ if (queue == null)
+ {
+ throw new IllegalStateException("Cannot find queue with id " + encoding.queueID);
+ }
- removed.setScheduledDeliveryTime(encoding.scheduledDeliveryTime);
+ //remove the reference and then add it back in with the scheduled time set.
+ queue.rescheduleDelivery(messageID, encoding.scheduledDeliveryTime);
- queue.addLast(removed);
-
break;
}
default:
@@ -604,6 +678,8 @@
{
return;
}
+
+ cleanupIncompleteFiles();
bindingsJournal.start();
@@ -618,11 +694,15 @@
{
return;
}
+
+ executor.shutdown();
bindingsJournal.stop();
messageJournal.stop();
+ executor.awaitTermination(60, TimeUnit.SECONDS);
+
started = false;
}
@@ -631,8 +711,7 @@
return started;
}
- // Public
- // -----------------------------------------------------------------------------------
+ // Public -----------------------------------------------------------------------------------
public Journal getMessageJournal()
{
@@ -644,9 +723,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,
@@ -832,6 +948,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);
+ System.out.println("cleaning up file " + file);
+ file.delete();
+ }
+ }
+ }
+
// Inner Classes
// ----------------------------------------------------------------------------
@@ -902,7 +1035,7 @@
public int getEncodeSize()
{
return SimpleString.sizeofString(queueName) + SimpleString.sizeofString(address) + 1 + // HasFilter?
- ((filter != null) ? SimpleString.sizeofString(filter) : 0);
+ (filter != null ? SimpleString.sizeofString(filter) : 0);
}
}
@@ -936,6 +1069,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;
@@ -1028,8 +1197,10 @@
super(queueID);
}
}
+
private static class ScheduledDeliveryEncoding extends QueueEncoding
{
+
long scheduledDeliveryTime;
private ScheduledDeliveryEncoding(long scheduledDeliveryTime, long queueID)
@@ -1060,4 +1231,5 @@
scheduledDeliveryTime = buffer.getLong();
}
}
+
}
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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;
@@ -144,7 +145,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 NullStorageServerLargeMessageImpl();
+ }
+
public long generateUniqueID()
{
//FIXME - this needs to use Howard's ID generator from JBM 1.4
Added: branches/Branch_Chunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageServerLargeMessageImpl.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageServerLargeMessageImpl.java (rev 0)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageServerLargeMessageImpl.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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 NullStorageServerLargeMessageImpl
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ * Created 30-Sep-08 1:51:42 PM
+ *
+ *
+ */
+public class NullStorageServerLargeMessageImpl extends ServerMessageImpl implements ServerLargeMessage
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public NullStorageServerLargeMessageImpl()
+ {
+ 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 -------------------------------------------------
+
+}
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/Packet.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/Packet.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/Packet.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -45,9 +45,12 @@
void decode(MessagingBuffer buffer);
+ int getPacketSize();
+
+ int getRequiredBufferSize();
+
+
boolean isRequiresConfirmations();
boolean isWriteAlways();
-
- int getPacketSize();
}
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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;
@@ -125,6 +126,7 @@
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.SessionScheduledSendMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendChunkMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendManagementMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXACommitMessage;
@@ -784,6 +786,11 @@
packet = new SessionSendManagementMessage();
break;
}
+ case SESS_CHUNK_SEND:
+ {
+ packet = new SessionSendChunkMessage();
+ break;
+ }
case SESS_REPLICATE_DELIVERY:
{
packet = new SessionReplicateDeliveryMessage();
@@ -937,7 +944,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);
@@ -1002,7 +1009,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);
@@ -1306,7 +1313,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: branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateSessionMessage.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateSessionMessage.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateSessionMessage.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -28,7 +28,9 @@
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;
+
+ protected static final int BASIC_PACKET_SIZE = DataConstants.SIZE_INT + DataConstants.SIZE_BYTE + DataConstants.SIZE_LONG;
private long channelID;
@@ -152,6 +154,8 @@
public static final byte SESS_REPLICATE_DELIVERY = 82;
+ public static final byte SESS_CHUNK_SEND = 95;
+
// Static --------------------------------------------------------
public PacketImpl(final byte type)
@@ -161,6 +165,7 @@
// Public --------------------------------------------------------
+
public byte getType()
{
return type;
@@ -206,10 +211,15 @@
size = buffer.position();
}
- public int getPacketSize()
+ public final int getPacketSize()
{
return size;
}
+
+ public int getRequiredBufferSize()
+ {
+ return DEFAULT_PACKET_SIZE;
+ }
public boolean isResponse()
{
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ReplicateCreateSessionMessage.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ReplicateCreateSessionMessage.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ReplicateCreateSessionMessage.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionReceiveMessage.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionReceiveMessage.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionReceiveMessage.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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);
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionScheduledSendMessage.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionScheduledSendMessage.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionScheduledSendMessage.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -23,6 +23,7 @@
import org.jboss.messaging.core.client.ClientMessage;
import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+import org.jboss.messaging.util.DataConstants;
/**
* @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
@@ -48,6 +49,13 @@
buffer.putLong(scheduledDeliveryTime);
}
+ @Override
+ public int getRequiredBufferSize()
+ {
+ return super.getRequiredBufferSize() + DataConstants.LONG;
+ }
+
+
public void decodeBody(final MessagingBuffer buffer)
{
super.decodeBody(buffer);
@@ -58,4 +66,6 @@
{
return scheduledDeliveryTime;
}
+
+
}
Added: branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionSendChunkMessage.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionSendChunkMessage.java (rev 0)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionSendChunkMessage.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -0,0 +1,239 @@
+/*
+ * 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;
+
+ private long scheduledDeliveryTime;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public SessionSendChunkMessage(final long targetID,
+ final byte[] header,
+ final byte[] body,
+ final boolean continues,
+ final boolean requiresResponse,
+ final long scheduledDelivery)
+ {
+ super(SESS_CHUNK_SEND);
+ this.targetID = targetID;
+ this.header = header;
+ this.body = body;
+ this.continues = continues;
+ this.requiresResponse = requiresResponse;
+ this.scheduledDeliveryTime = scheduledDelivery;
+ }
+
+ 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;
+ this.scheduledDeliveryTime = 0;
+ }
+
+ 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;
+ }
+
+ /**
+ * @return the scheduledDeliveryTime
+ */
+ public long getScheduledDeliveryTime()
+ {
+ return scheduledDeliveryTime;
+ }
+
+ 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) +
+ DataConstants.SIZE_BOOLEAN /* has scheduled delivery time */+
+ (scheduledDeliveryTime > 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);
+ }
+
+ buffer.putBoolean(scheduledDeliveryTime > 0);
+
+ if (scheduledDeliveryTime > 0)
+ {
+ buffer.putLong(scheduledDeliveryTime);
+ }
+ }
+
+ @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();
+ }
+
+ final boolean hasScheduledDelivery = buffer.getBoolean();
+
+ if (hasScheduledDelivery)
+ {
+ scheduledDeliveryTime = buffer.getLong();
+ }
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionSendMessage.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionSendMessage.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionSendMessage.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -18,15 +18,17 @@
* 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.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>
@@ -39,15 +41,13 @@
// Constants -----------------------------------------------------
private static final Logger log = Logger.getLogger(SessionSendMessage.class);
-
+
// Attributes ----------------------------------------------------
private long producerID;
-
- private ClientMessage clientMessage;
-
- private ServerMessage serverMessage;
-
+
+ private Message message;
+
private boolean requiresResponse;
// Static --------------------------------------------------------
@@ -59,29 +59,32 @@
super(SESS_SEND);
this.producerID = producerID;
-
- this.clientMessage = message;
-
+
+ this.message = message;
+
this.requiresResponse = requiresResponse;
}
-
+
public SessionSendMessage()
{
super(SESS_SEND);
}
- protected SessionSendMessage(final byte type, final long producerID, final ClientMessage message, final boolean requiresResponse)
+ protected SessionSendMessage(final byte type,
+ final long producerID,
+ final ClientMessage message,
+ final boolean requiresResponse)
{
super(type);
this.producerID = producerID;
- this.clientMessage = message;
+ this.message = message;
this.requiresResponse = requiresResponse;
}
- protected SessionSendMessage(byte type)
+ protected SessionSendMessage(final byte type)
{
super(type);
}
@@ -92,55 +95,54 @@
{
return producerID;
}
-
+
public ClientMessage getClientMessage()
{
- return clientMessage;
+ return (ClientMessage)message;
}
-
+
public ServerMessage getServerMessage()
{
- return serverMessage;
+ return (ServerMessage)message;
}
-
+
public boolean isRequiresResponse()
{
return requiresResponse;
}
-
+
+ @Override
+ public int getRequiredBufferSize()
+ {
+ return BASIC_PACKET_SIZE + DataConstants.SIZE_LONG + message.getEncodeSize() + DataConstants.BOOLEAN;
+ }
+
+ @Override
public void encodeBody(final MessagingBuffer buffer)
{
- buffer.putLong(producerID);
-
- if (clientMessage != null)
- {
- clientMessage.encode(buffer);
- }
- else
- {
- //If we're replicating a buffer to a backup node then we encode the serverMessage not the clientMessage
- serverMessage.encode(buffer);
- }
-
+ buffer.putLong(producerID);
+
+ message.encode(buffer);
+
buffer.putBoolean(requiresResponse);
}
-
+
+ @Override
public void decodeBody(final MessagingBuffer buffer)
{
- //TODO can be optimised
-
+ // TODO can be optimised
+
producerID = buffer.getLong();
-
- serverMessage = new ServerMessageImpl();
-
- serverMessage.decode(buffer);
-
- serverMessage.getBody().flip();
-
+
+ message = new ServerMessageImpl();
+
+ message.decode(buffer);
+
+ message.getBody().flip();
+
requiresResponse = buffer.getBoolean();
}
-
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/MessagingServer.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/MessagingServer.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/MessagingServer.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -67,6 +67,7 @@
long channelID,
String username,
String password,
+ int minLargeMessageSize,
int incrementingVersion,
RemotingConnection remotingConnection,
boolean autoCommitSends,
@@ -78,6 +79,7 @@
long channelID,
String username,
String password,
+ int minLargeMessageSize,
int incrementingVersion,
RemotingConnection remotingConnection,
boolean autoCommitSends,
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/Queue.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/Queue.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/Queue.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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;
Added: branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/ServerLargeMessage.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/ServerLargeMessage.java (rev 0)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/ServerLargeMessage.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/ServerMessage.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/ServerMessage.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/ServerMessage.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -41,12 +41,12 @@
int decrementDurableRefCount();
- int incrementReference(boolean durable);
-
int getDurableRefCount();
int decrementRefCount();
+ int incrementDurableRefCount();
+
int getRefCount();
ServerMessage copy();
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/ServerProducer.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/ServerProducer.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/ServerProducer.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -18,11 +18,10 @@
* 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 ServerProducer
@@ -39,5 +38,11 @@
void send(ServerMessage msg) throws Exception;
+ /** Current LargeMessage being sent in chunks */
+ ServerLargeMessage getCurrentChunk();
+
+ /** Current LargeMessage being sent in chunks */
+ void setCurrentChunk(ServerLargeMessage message);
+
void sendScheduled(ServerMessage message, long scheduledDeliveryTime) throws Exception;
}
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/ServerSession.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/ServerSession.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/ServerSession.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -40,6 +40,7 @@
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.SessionScheduledSendMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendChunkMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendManagementMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXACommitMessage;
@@ -67,6 +68,8 @@
String getUsername();
String getPassword();
+
+ int getMinLargeMessageSize();
void removeConsumer(ServerConsumer consumer) throws Exception;
@@ -136,6 +139,8 @@
void handleReceiveConsumerCredits(SessionConsumerFlowCreditMessage packet);
+ public void handleSendChunkMessage(SessionSendChunkMessage packet);
+
void handleSendProducerMessage(SessionSendMessage packet);
void handleSendScheduledProducerMessage(SessionScheduledSendMessage packet);
@@ -154,5 +159,4 @@
//Should this really be here??
void sendResponse(final DelayedResult result, final Packet response);
-
}
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -212,7 +212,8 @@
pagingManager = new PagingManagerImpl(storeFactory,
storageManager,
queueSettingsRepository,
- configuration.getPagingMaxGlobalSizeBytes());
+ configuration.getPagingMaxGlobalSizeBytes(),
+ configuration.getPagingDefaultSize());
storeFactory.setPagingManager(pagingManager);
@@ -255,6 +256,7 @@
"\"",
e);
}
+
Map<String, Object> backupConnectorParams = backupConnector.getParams();
// TODO don't hardcode ping interval and code timeout
@@ -475,20 +477,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,
@@ -501,6 +505,7 @@
final long channelID,
final String username,
final String password,
+ final int minLargeMessageSize,
final int incrementingVersion,
final RemotingConnection connection,
final boolean autoCommitSends,
@@ -514,6 +519,7 @@
channelID,
username,
password,
+ minLargeMessageSize,
incrementingVersion,
connection,
autoCommitSends,
@@ -580,6 +586,7 @@
final long channelID,
final String username,
final String password,
+ final int minLargeMessageSize,
final int incrementingVersion,
final RemotingConnection connection,
final boolean autoCommitSends,
@@ -621,6 +628,7 @@
channelID,
username,
password,
+ minLargeMessageSize,
autoCommitSends,
autoCommitAcks,
xa,
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/MessagingServiceImpl.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/MessagingServiceImpl.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/MessagingServiceImpl.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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;
}
}
@@ -261,6 +282,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();
@@ -315,9 +360,9 @@
public void referenceAcknowledged(MessageReference ref) throws Exception
{
- deliveringCount.decrementAndGet();
- sizeBytes.addAndGet(-ref.getMessage().getEncodeSize());
+ referenceRemoved(ref);
+
}
public void referenceCancelled()
@@ -739,6 +784,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: branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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;
@@ -37,14 +38,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;
@@ -55,7 +60,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
@@ -79,6 +85,8 @@
private final Filter filter;
+ private final int minLargeMessageSize;
+
private final ServerSession session;
private final Lock lock = new ReentrantLock();
@@ -99,6 +107,17 @@
private final PostOffice postOffice;
private final java.util.Queue<MessageReference> deliveringRefs = new ConcurrentLinkedQueue<MessageReference>();
+
+ /** The current message being processed */
+ private volatile ServerLargeMessage pendingLargeMessage;
+
+ /** The current position on the message being processed */
+ private volatile long positionLargeMessage;
+
+ private volatile long sizeLargeMessage;
+
+ private SessionSendChunkMessage readAheadChunk = null;
+
private final Channel channel;
@@ -150,6 +169,8 @@
this.channel = channel;
messageQueue.addConsumer(this);
+
+ this.minLargeMessageSize = session.getMinLargeMessageSize();
}
// ServerConsumer implementation
@@ -397,7 +418,18 @@
private void promptDelivery()
{
- session.promptDelivery(messageQueue);
+ if (pendingLargeMessage != null)
+ {
+ if (sendLargeMessage())
+ {
+ // prompt Delivery only if chunk was finished
+ session.promptDelivery(messageQueue);
+ }
+ }
+ else
+ {
+ session.promptDelivery(messageQueue);
+ }
}
private HandleStatus doHandle(final MessageReference ref) throws Exception
@@ -420,7 +452,15 @@
lock.lock();
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 (pendingLargeMessage != 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.
@@ -434,46 +474,185 @@
return HandleStatus.NO_MATCH;
}
- if (availableCredits != null)
+ if (!browseOnly)
{
- availableCredits.addAndGet(-message.getEncodeSize());
+ deliveringRefs.add(ref);
}
- final SessionReceiveMessage packet = new SessionReceiveMessage(id, message, ref.getDeliveryCount() + 1);
+ if (message instanceof ServerLargeMessage)
+ {
+ // TODO: How to inform the backup node about the LargeMessage being sent?
+ pendingLargeMessage = (ServerLargeMessage)message;
+ positionLargeMessage = 0;
+ // it is better to cache this, as this usually means an operation on the file system
+ sizeLargeMessage = pendingLargeMessage.getBodySize();
+ sendLargeMessage();
+ }
+ else
+ {
+ sendRegularMessage(ref, message);
+ }
- DelayedResult result =
- channel.replicatePacket(new SessionReplicateDeliveryMessage(id, message.getMessageID()));
+ return HandleStatus.HANDLED;
+ }
+ finally
+ {
+ lock.unlock();
+ }
+ }
- if (!browseOnly)
+ /**
+ * @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()
{
- deliveringRefs.add(ref);
+ public void run()
+ {
+ channel.send(packet);
+ }
+ });
+ }
+ }
+
+
+ private boolean sendLargeMessage()
+ {
+
+ lock.lock();
+
+ try
+ {
+
+ if (pendingLargeMessage == null)
+ {
+ return true;
}
- if (result == null)
+ if (availableCredits != null && availableCredits.get() <= 0)
{
- // Not replicated - just send now
- channel.send(packet);
+ return false;
}
- else
+
+ if (readAheadChunk != null)
{
- // Send when replicate delivery response comes back
- result.setResultRunner(new Runnable()
+ int chunkLen = readAheadChunk.getBody().length;
+ positionLargeMessage += chunkLen;
+ channel.send(readAheadChunk);
+ readAheadChunk = null;
+ if (availableCredits != null)
{
- public void run()
+ availableCredits.addAndGet(-chunkLen);
+ }
+ }
+
+ while (positionLargeMessage < sizeLargeMessage)
+ {
+
+ if (availableCredits != null && availableCredits.get() <= 0)
+ {
+ if (readAheadChunk == null)
{
- channel.send(packet);
+ readAheadChunk = createChunkSend();
}
- });
+ return false;
+ }
+
+ SessionSendChunkMessage chunk = createChunkSend();
+
+ int chunkLen = chunk.getBody().length;
+
+ if (availableCredits != null)
+ {
+ availableCredits.addAndGet(-chunkLen);
+ }
+
+ channel.send(chunk);
+
+ positionLargeMessage += chunkLen;
}
-
- return HandleStatus.HANDLED;
+
+ pendingLargeMessage.releaseResources();
+ this.pendingLargeMessage = null;
+ this.positionLargeMessage = -1;
+
+
+ return true;
}
finally
{
lock.unlock();
}
+
+
}
+
+
+ private SessionSendChunkMessage createChunkSend()
+ {
+ SessionSendChunkMessage chunk;
+
+ int localChunkLen = 0;
+
+ if (positionLargeMessage == 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 < sizeLargeMessage,
+ false);
+ }
+ else
+ {
+ localChunkLen = (int)Math.min(sizeLargeMessage - positionLargeMessage, minLargeMessageSize);
+
+ MessagingBuffer bodyBuffer = new ByteBufferWrapper(ByteBuffer.allocate((int)localChunkLen));
+
+ pendingLargeMessage.encodeBody(bodyBuffer, positionLargeMessage, localChunkLen);
+
+ chunk = new SessionSendChunkMessage(id,
+ null,
+ bodyBuffer.array(),
+ positionLargeMessage + localChunkLen < sizeLargeMessage,
+ false);
+ }
+
+ return chunk;
+
+ }
+
+
// Inner classes
// ------------------------------------------------------------------------
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/ServerMessageImpl.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/ServerMessageImpl.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/ServerMessageImpl.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/ServerProducerImpl.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/ServerProducerImpl.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/ServerProducerImpl.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -18,11 +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.server.impl;
import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.remoting.Channel;
+import org.jboss.messaging.core.server.ServerLargeMessage;
import org.jboss.messaging.core.server.ServerMessage;
import org.jboss.messaging.core.server.ServerProducer;
import org.jboss.messaging.core.server.ServerSession;
@@ -32,45 +34,76 @@
* A ServerProducerImpl
*
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:clebert.suconic at jboss.com">Clebert Suconic</a>
* @author <a href="mailto:andy.taylor at jboss.org>Andy Taylor</a>
*
*/
public class ServerProducerImpl implements ServerProducer
{
- private static final Logger log = Logger.getLogger(ServerProducerImpl.class);
-
- private final long id;
-
- private final ServerSession session;
-
- // Constructors ----------------------------------------------------------------
-
+
+ // Static -----------------------------------------------------------------------
+ private static final Logger log = Logger.getLogger(ServerProducerImpl.class);
+
+ // Attributes--------------------------------------------------------------------
+
+ private final long id;
+
+ private final ServerSession session;
+
+ private ServerLargeMessage currentLargeMessage;
+
+ // Constructors ----------------------------------------------------------------
+
public ServerProducerImpl(final long id, final ServerSession session) throws Exception
{
this.id = id;
this.session = session;
}
-
- // ServerProducer implementation --------------------------------------------
-
- public long getID()
- {
- return id;
- }
-
- public void close() throws Exception
- {
- session.removeProducer(this);
- }
-
- public void send(final ServerMessage message) throws Exception
- {
- session.send(message);
- }
-
- public void sendScheduled(final ServerMessage message, final long scheduledDeliveryTime) throws Exception
+
+ // ServerProducer implementation --------------------------------------------
+
+ public long getID()
{
+ return id;
+ }
+
+ public void close() throws Exception
+ {
+ if (currentLargeMessage != null)
+ {
+ try
+ {
+ currentLargeMessage.deleteFile();
+ }
+ catch (Throwable error)
+ {
+ log.warn(error.toString(), error);
+
+ }
+ }
+
+ session.removeProducer(this);
+ }
+
+ public void send(final ServerMessage message) throws Exception
+ {
+ session.send(message);
+ }
+
+ public void sendScheduled(final ServerMessage message, final long scheduledDeliveryTime) throws Exception
+ {
session.sendScheduled(message, scheduledDeliveryTime);
}
+
+ public ServerLargeMessage getCurrentChunk()
+ {
+ return currentLargeMessage;
+ }
+
+ public void setCurrentChunk(final ServerLargeMessage message)
+ {
+ currentLargeMessage = message;
+ }
+
}
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -65,6 +65,7 @@
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.SessionScheduledSendMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendChunkMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendManagementMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXACommitMessage;
@@ -80,6 +81,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;
@@ -87,6 +89,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.ServerProducer;
import org.jboss.messaging.core.server.ServerSession;
@@ -127,6 +130,8 @@
private final String password;
+ private final int minLargeMessageSize;
+
private final boolean autoCommitSends;
private final boolean autoCommitAcks;
@@ -175,6 +180,7 @@
final long id,
final String username,
final String password,
+ final int minLargeMessageSize,
final boolean autoCommitSends,
final boolean autoCommitAcks,
final boolean xa,
@@ -195,6 +201,8 @@
this.username = username;
this.password = password;
+
+ this.minLargeMessageSize = minLargeMessageSize;
this.autoCommitSends = autoCommitSends;
@@ -243,6 +251,11 @@
{
return password;
}
+
+ public int getMinLargeMessageSize()
+ {
+ return minLargeMessageSize;
+ }
public long getID()
{
@@ -323,6 +336,78 @@
}
}
+ public void handleSendChunkMessage(final SessionSendChunkMessage packet)
+ {
+
+ if (packet.getMessageID() == 0)
+ {
+ packet.setMessageID(storageManager.generateUniqueID());
+ }
+
+ Packet response = null;
+
+ DelayedResult result = channel.replicatePacket(packet);
+
+ try
+ {
+ ServerLargeMessage largeMessage = null;
+
+ if (packet.getHeader() != null)
+ {
+ largeMessage = createLargeMessageStorage(packet.getTargetID(), packet.getMessageID(), packet.getHeader());
+ }
+ else
+ {
+ largeMessage = getCurrentLargeMessage(packet.getTargetID());
+ }
+
+
+ largeMessage.addBytes(packet.getBody());
+
+
+ if (!packet.isContinues())
+ {
+ largeMessage.complete();
+ clearCurrentLargeMessage(packet.getTargetID());
+ if (packet.getScheduledDeliveryTime() > 0)
+ {
+ producers.get(packet.getTargetID()).sendScheduled(largeMessage, packet.getScheduledDeliveryTime());
+ }
+ else
+ {
+ producers.get(packet.getTargetID()).send(largeMessage);
+ }
+ }
+
+ 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));
+ }
+ }
+ }
+
+ sendResponse(result, response);
+
+ }
+
+
+
public void sendScheduled(final ServerMessage msg, final long scheduledDeliveryTime) throws Exception
{
doSecurity(msg);
@@ -2536,6 +2621,38 @@
// 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);
+
+ ServerProducer producer = producers.get(producerID);
+
+ producer.setCurrentChunk(largeMessage);
+
+ return largeMessage;
+ }
+
+ private ServerLargeMessage getCurrentLargeMessage(long producerID)
+ {
+ ServerProducer producer = producers.get(producerID);
+
+ return producer.getCurrentChunk();
+ }
+
+ private void clearCurrentLargeMessage(long producerID)
+ {
+ ServerProducer producer = producers.get(producerID);
+
+ producer.setCurrentChunk(null);
+ }
+
private void doRollback(final Transaction theTx) throws Exception
{
boolean wasStarted = started;
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -16,6 +16,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;
@@ -64,6 +65,7 @@
import org.jboss.messaging.core.remoting.impl.wireformat.SessionProducerCloseMessage;
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.SessionScheduledSendMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendManagementMessage;
@@ -77,6 +79,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;
/**
@@ -293,6 +297,12 @@
session.handleSendProducerMessage(message);
break;
}
+ case SESS_CHUNK_SEND:
+ {
+ SessionSendChunkMessage message = (SessionSendChunkMessage)packet;
+ session.handleSendChunkMessage(message);
+ break;
+ }
case SESS_SCHEDULED_SEND:
{
SessionScheduledSendMessage message = (SessionScheduledSendMessage)packet;
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/settings/impl/QueueSettings.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/settings/impl/QueueSettings.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/settings/impl/QueueSettings.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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;
@@ -97,7 +95,7 @@
public Integer getPageSizeBytes()
{
- return pageSizeBytes != null ? pageSizeBytes : DEFAULT_PAGE_SIZE_BYTES;
+ return pageSizeBytes;
}
public Boolean isDropMessagesWhenFull()
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/core/transaction/impl/TransactionImpl.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/core/transaction/impl/TransactionImpl.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/core/transaction/impl/TransactionImpl.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -217,11 +217,6 @@
ServerMessage message = acknowledgement.getMessage();
- if (message.decrementRefCount() == 0 && pagingManager != null)
- {
- pagingManager.messageDone(message);
- }
-
if (message.isDurable())
{
Queue queue = acknowledgement.getQueue();
@@ -391,6 +386,15 @@
for (MessageReference ref : acknowledgements)
{
+ Queue queue = ref.getQueue();
+
+ ServerMessage message = ref.getMessage();
+
+ if (message.isDurable() && queue.isDurable())
+ {
+ message.incrementDurableRefCount();
+
+ }
toCancel.add(ref);
}
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossBytesMessage.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossBytesMessage.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossBytesMessage.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -104,7 +104,7 @@
checkRead();
try
{
- return body.getBoolean();
+ return getBody().getBoolean();
}
catch (BufferUnderflowException e)
{
@@ -117,7 +117,7 @@
checkRead();
try
{
- return body.getByte();
+ return getBody().getByte();
}
catch (BufferUnderflowException e)
{
@@ -130,7 +130,7 @@
checkRead();
try
{
- return body.getUnsignedByte();
+ return getBody().getUnsignedByte();
}
catch (BufferUnderflowException e)
{
@@ -143,7 +143,7 @@
checkRead();
try
{
- return body.getShort();
+ return getBody().getShort();
}
catch (BufferUnderflowException e)
{
@@ -156,7 +156,7 @@
checkRead();
try
{
- return body.getUnsignedShort();
+ return getBody().getUnsignedShort();
}
catch (BufferUnderflowException e)
{
@@ -169,7 +169,7 @@
checkRead();
try
{
- return body.getChar();
+ return getBody().getChar();
}
catch (BufferUnderflowException e)
{
@@ -182,7 +182,7 @@
checkRead();
try
{
- return body.getInt();
+ return getBody().getInt();
}
catch (BufferUnderflowException e)
{
@@ -195,7 +195,7 @@
checkRead();
try
{
- return body.getLong();
+ return getBody().getLong();
}
catch (BufferUnderflowException e)
{
@@ -208,7 +208,7 @@
checkRead();
try
{
- return body.getFloat();
+ return getBody().getFloat();
}
catch (BufferUnderflowException e)
{
@@ -221,7 +221,7 @@
checkRead();
try
{
- return body.getDouble();
+ return getBody().getDouble();
}
catch (BufferUnderflowException e)
{
@@ -234,7 +234,7 @@
checkRead();
try
{
- return body.getUTF();
+ return getBody().getUTF();
}
catch (BufferUnderflowException e)
{
@@ -258,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;
@@ -273,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
@@ -323,7 +323,7 @@
checkWrite();
try
{
- body.putUTF(value);
+ getBody().putUTF(value);
}
catch (Exception e)
{
@@ -336,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
@@ -402,11 +402,11 @@
{
readOnly = true;
- body.flip();
+ getBody().flip();
}
else
{
- body.rewind();
+ getBody().rewind();
}
}
@@ -416,21 +416,19 @@
{
super.clearBody();
- body = new IoBufferWrapper(1024);
+ message.setBody(new IoBufferWrapper(1024));
}
public long getBodyLength() throws JMSException
{
checkRead();
- return body.limit();
+ return getBody().limit();
}
public void doBeforeSend() throws Exception
{
reset();
-
- message.setBody(body);
}
// Public --------------------------------------------------------
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -71,7 +71,7 @@
private final int dupsOKBatchSize;
private final long pingPeriod;
-
+
private final long callTimeout;
private final int consumerWindowSize;
@@ -81,6 +81,8 @@
private final int sendWindowSize;
private final int producerMaxRate;
+
+ private final int minLargeMessageSize;
private final boolean blockOnAcknowledge;
@@ -104,6 +106,7 @@
final int consumerMaxRate,
final int sendWindowSize,
final int producerMaxRate,
+ final int minLargeMessageSize,
final boolean blockOnAcknowledge,
final boolean blockOnNonPersistentSend,
final boolean blockOnPersistentSend,
@@ -121,6 +124,7 @@
this.producerMaxRate = producerMaxRate;
this.sendWindowSize = sendWindowSize;
this.blockOnAcknowledge = blockOnAcknowledge;
+ this.minLargeMessageSize = minLargeMessageSize;
this.blockOnNonPersistentSend = blockOnNonPersistentSend;
this.blockOnPersistentSend = blockOnPersistentSend;
this.autoGroupId = autoGroupId;
@@ -220,7 +224,7 @@
{
return pingPeriod;
}
-
+
public long getCallTimeout()
{
return callTimeout;
@@ -296,6 +300,7 @@
consumerMaxRate,
sendWindowSize,
producerMaxRate,
+ minLargeMessageSize,
blockOnAcknowledge,
blockOnNonPersistentSend,
blockOnPersistentSend,
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossMapMessage.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossMapMessage.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossMapMessage.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossMessage.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossMessage.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossMessage.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -154,8 +154,6 @@
// The underlying message
protected ClientMessage message;
- protected MessagingBuffer body;
-
private ClientSession session;
// Read-only?
@@ -191,8 +189,6 @@
(byte)4,
new ByteBufferWrapper(ByteBuffer.allocate(1024)));
- // TODO - can we lazily create this?
- body = message.getBody();
}
public JBossMessage(byte type)
@@ -204,8 +200,6 @@
(byte)4,
new ByteBufferWrapper(ByteBuffer.allocate(1024)));
- // TODO - can we lazily create this?
- body = message.getBody();
}
/*
@@ -215,8 +209,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)
@@ -234,8 +226,6 @@
this.readOnly = true;
this.session = session;
-
- this.body = message.getBody();
}
/*
@@ -936,14 +926,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()
@@ -985,6 +977,11 @@
throw new MessageNotReadableException("Message is write-only");
}
}
+
+ protected MessagingBuffer getBody()
+ {
+ return message.getBody();
+ }
// Private ------------------------------------------------------------
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossObjectMessage.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossObjectMessage.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossObjectMessage.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossStreamMessage.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossStreamMessage.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossStreamMessage.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -119,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");
@@ -143,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");
@@ -166,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");
@@ -191,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");
}
@@ -211,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");
@@ -238,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");
@@ -267,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");
@@ -290,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);
@@ -315,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");
}
@@ -360,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)
{
@@ -385,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");
@@ -419,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
@@ -554,11 +554,11 @@
{
readOnly = true;
- body.flip();
+ getBody().flip();
}
else
{
- body.rewind();
+ getBody().rewind();
}
}
@@ -567,15 +567,13 @@
public void clearBody() throws JMSException
{
super.clearBody();
-
- body = new IoBufferWrapper(1024);
+
+ message.setBody(new IoBufferWrapper(1024));
}
public void doBeforeSend() throws Exception
{
reset();
-
- message.setBody(body);
}
// Package protected ---------------------------------------------
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossTextMessage.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossTextMessage.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/jms/client/JBossTextMessage.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -116,6 +116,7 @@
int consumerMaxRate,
int sendWindowSize,
int producerMaxRate,
+ int minLargeMessageSize,
boolean blockOnAcknowledge,
boolean blockOnNonPersistentSend,
boolean blockOnPersistentSend,
@@ -134,6 +135,7 @@
int consumerMaxRate,
int sendWindowSize,
int producerMaxRate,
+ int minLargeMessageSize,
boolean blockOnAcknowledge,
boolean blockOnNonPersistentSend,
boolean blockOnPersistentSend,
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerDeployer.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerDeployer.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerDeployer.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -43,7 +43,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";
@@ -55,7 +55,9 @@
private static final String PRODUCER_WINDOW_SIZE_ELEMENT = "producer-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();
@@ -402,6 +409,7 @@
consumerMaxRate,
sendWindowSize,
producerMaxRate,
+ minLargeMessageSize,
blockOnAcknowledge,
blockOnNonPersistentSend,
blockOnPersistentSend,
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -31,6 +31,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;
@@ -189,7 +190,7 @@
public boolean createConnectionFactory(String name,
TransportConfiguration connectorConfig,
TransportConfiguration backupConnectorConfig,
- long pingPeriod,
+ long pingPeriod,
long callTimeout,
String clientID,
int dupsOKBatchSize,
@@ -197,6 +198,7 @@
int consumerMaxRate,
int sendWindowSize,
int producerMaxRate,
+ int minLargeMessageSize,
boolean blockOnAcknowledge,
boolean blockOnNonPersistentSend,
boolean blockOnPersistentSend,
@@ -204,47 +206,33 @@
int maxConnections,
String jndiBinding) throws Exception
{
- JBossConnectionFactory cf = connectionFactories.get(name);
- if (cf == null)
- {
- cf = new JBossConnectionFactory(connectorConfig,
- backupConnectorConfig,
- pingPeriod,
- callTimeout,
- clientID,
- dupsOKBatchSize,
- consumerWindowSize,
- consumerMaxRate,
- sendWindowSize,
- producerMaxRate,
- blockOnAcknowledge,
- blockOnNonPersistentSend,
- blockOnPersistentSend,
- autoGroupId,
- 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,
+ consumerWindowSize,
+ consumerMaxRate,
+ sendWindowSize,
+ producerMaxRate,
+ minLargeMessageSize,
+ blockOnAcknowledge,
+ blockOnNonPersistentSend,
+ blockOnPersistentSend,
+ autoGroupId,
+ maxConnections,
+ bindings);
}
public boolean createConnectionFactory(String name,
TransportConfiguration connectorConfig,
TransportConfiguration backupConnectorConfig,
- long pingPeriod,
+ long pingPeriod,
long callTimeout,
String clientID,
int dupsOKBatchSize,
@@ -252,6 +240,7 @@
int consumerMaxRate,
int sendWindowSize,
int producerMaxRate,
+ int minLargeMessageSize,
boolean blockOnAcknowledge,
boolean blockOnNonPersistentSend,
boolean blockOnPersistentSend,
@@ -264,7 +253,7 @@
{
cf = new JBossConnectionFactory(connectorConfig,
backupConnectorConfig,
- pingPeriod,
+ pingPeriod,
callTimeout,
clientID,
dupsOKBatchSize,
@@ -272,6 +261,8 @@
consumerMaxRate,
sendWindowSize,
producerMaxRate,
+ minLargeMessageSize == -1 ? ClientSessionFactoryImpl.DEFAULT_BIG_MESSAGE_SIZE
+ : minLargeMessageSize,
blockOnAcknowledge,
blockOnNonPersistentSend,
blockOnPersistentSend,
Modified: branches/Branch_Chunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -85,6 +85,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: branches/Branch_Chunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java
===================================================================
--- branches/Branch_Chunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -87,6 +87,7 @@
int consumerMaxRate,
int producerWindowSize,
int producerMaxRate,
+ int minLargeMessageSize,
boolean blockOnAcknowledge,
boolean blockOnNonPersistentSend,
boolean blockOnPersistentSend,
@@ -108,6 +109,7 @@
consumerMaxRate,
producerWindowSize,
producerMaxRate,
+ minLargeMessageSize,
blockOnAcknowledge,
blockOnNonPersistentSend,
blockOnPersistentSend,
Modified: branches/Branch_Chunk/tests/jms-tests/src/org/jboss/test/messaging/jms/CTSMiscellaneousTest.java
===================================================================
--- branches/Branch_Chunk/tests/jms-tests/src/org/jboss/test/messaging/jms/CTSMiscellaneousTest.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/jms-tests/src/org/jboss/test/messaging/jms/CTSMiscellaneousTest.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -97,6 +97,7 @@
-1,
1024 * 1024,
-1,
+ -1,
true,
true,
true,
Modified: branches/Branch_Chunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTest.java
===================================================================
--- branches/Branch_Chunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTest.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTest.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -95,6 +95,8 @@
conn.start();
TextMessage rm = (TextMessage)cons.receive();
+
+ assertNotNull(rm);
assertEquals("message one", rm.getText());
}
Modified: branches/Branch_Chunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTestCase.java
===================================================================
--- branches/Branch_Chunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTestCase.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTestCase.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -47,6 +47,7 @@
-1,
1024 * 1024,
-1,
+ -1,
true,
true,
true,
Modified: branches/Branch_Chunk/tests/jms-tests/src/org/jboss/test/messaging/jms/String64KLimitTest.java
===================================================================
--- branches/Branch_Chunk/tests/jms-tests/src/org/jboss/test/messaging/jms/String64KLimitTest.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/jms-tests/src/org/jboss/test/messaging/jms/String64KLimitTest.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
===================================================================
--- branches/Branch_Chunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -545,6 +545,7 @@
-1,
1024 * 1024,
-1,
+ -1,
blockOnAcknowledge,
true,
true,
Modified: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/base/IntegrationTestBase.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/base/IntegrationTestBase.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/base/IntegrationTestBase.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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.core.remoting.impl.netty.NettyAcceptorFactory;
-import org.jboss.messaging.core.remoting.impl.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 -------------------------------------------------
-
-}
Added: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/ChunkTestBase.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/ChunkTestBase.java (rev 0)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/ChunkTestBase.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -0,0 +1,440 @@
+/*
+ * 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.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, false);
+
+ session.createQueue(ADDRESS, ADDRESS, null, true, false);
+
+ 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)
+ {
+ message.putLongProperty(new SimpleString("original-time"), System.currentTimeMillis());
+ producer.send(message, System.currentTimeMillis() + delayDelivery);
+ }
+ 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)
+ {
+ message.putLongProperty(new SimpleString("original-time"), System.currentTimeMillis());
+ producer.send(message, System.currentTimeMillis() + delayDelivery);
+ }
+ 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, false);
+
+ 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(10);
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ assertEquals(0, largeMessagesFileDir.listFiles().length);
+ }
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Added: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/MessageChunkTest.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/MessageChunkTest.java (rev 0)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/MessageChunkTest.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -0,0 +1,506 @@
+/*
+ * 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() == 10)
+ {
+ 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, true);
+
+ callback.session = session;
+
+ session.createQueue(ADDRESS, ADDRESS, null, true, false);
+
+ 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, false);
+
+ session.createQueue(ADDRESS, queue[0], null, true, false);
+ session.createQueue(ADDRESS, queue[1], null, true, false);
+
+ 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, false);
+
+ 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, false);
+
+ session.createQueue(ADDRESS, ADDRESS, null, true, false);
+
+ 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, false);
+
+ 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, false);
+
+ readMessage(session, ADDRESS, numberOfIntegersBigMessage);
+
+ // printBuffer("message received : ", message2.getBody());
+
+ session.close();
+ }
+ finally
+ {
+ try
+ {
+ messagingService.stop();
+ }
+ catch (Throwable ignored)
+ {
+ }
+ }
+
+ }
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Added: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/MockConnector.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/MockConnector.java (rev 0)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/MockConnector.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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);
+ }
+ }
+}
Added: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/MockConnectorFactory.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/MockConnectorFactory.java (rev 0)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/mock/MockConnectorFactory.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/clientcrash/ClientCrashTest.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/clientcrash/ClientCrashTest.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/clientcrash/ClientCrashTest.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -22,31 +22,17 @@
package org.jboss.messaging.tests.integration.clientcrash;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP_ID;
-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;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
-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;
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.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;
@@ -58,7 +44,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 -----------------------------------------------------
@@ -74,17 +60,10 @@
// Attributes ----------------------------------------------------
- private MessagingService messagingService;
-
private ClientSessionFactory sf;
// Constructors --------------------------------------------------
- public ClientCrashTest(String name)
- {
- super(name);
- }
-
// Public --------------------------------------------------------
public void testCrashClientWithOneConnection() throws Exception
@@ -152,26 +131,13 @@
{
super.setUp();
- ConfigurationImpl config = new ConfigurationImpl();
+
+ Configuration config = createDefaultConfig(true);
config.setSecurityEnabled(false);
- config.getAcceptorConfigurations()
- .add(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.netty.NettyAcceptorFactory"));
- messagingService = MessagingServiceImpl.newNullStorageMessagingServer(config);
+ messagingService = createService(false, config);
messagingService.start();
- sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.netty.NettyConnectorFactory"),
- null,
- 2000,
- DEFAULT_CALL_TIMEOUT,
- DEFAULT_CONSUMER_WINDOW_SIZE,
- DEFAULT_CONSUMER_MAX_RATE,
- DEFAULT_SEND_WINDOW_SIZE,
- DEFAULT_PRODUCER_MAX_RATE,
- DEFAULT_BLOCK_ON_ACKNOWLEDGE,
- DEFAULT_BLOCK_ON_PERSISTENT_SEND,
- DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
- DEFAULT_AUTO_GROUP_ID,
- DEFAULT_MAX_CONNECTIONS);
+ sf = createNettyFactory();
}
@Override
Modified: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/paging/PagingManagerIntegrationTest.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/paging/PagingManagerIntegrationTest.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/paging/PagingManagerIntegrationTest.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -69,7 +69,8 @@
PagingManagerImpl managerImpl = new PagingManagerImpl(new PagingManagerFactoryNIO(journalDir),
null,
queueSettings,
- -1);
+ -1,
+ 1024 * 1024);
managerImpl.start();
PagingStore store = managerImpl.getPageStore(new SimpleString("simple-test"));
@@ -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,7 +116,8 @@
PagingManagerImpl managerImpl = new PagingManagerImpl(new PagingManagerFactoryNIO(journalDir),
null,
queueSettings,
- -1);
+ -1,
+ 1024 * 1024);
managerImpl.start();
ServerMessage msg = createMessage(1l, new SimpleString("simple-test"), createRandomBuffer(100));
Modified: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/remoting/DestroyConsumerTest.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/remoting/DestroyConsumerTest.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/remoting/DestroyConsumerTest.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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.core.remoting.impl.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: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/scheduling/ScheduledMessageTest.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/scheduling/ScheduledMessageTest.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/scheduling/ScheduledMessageTest.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -27,65 +27,48 @@
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
+import java.util.Calendar;
+
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
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.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.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 +85,7 @@
// ignore
}
}
- new File(journalDir).delete();
- new File(bindingsDir).delete();
- new File(pageDir).delete();
+ deleteData();
}
public void testRecoveredMessageDeliveredCorrectly() throws Exception
@@ -160,14 +141,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, false);
session.createQueue(atestq, atestq, null, true, true);
ClientProducer producer = session.createProducer(atestq);
@@ -198,17 +173,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, false);
session.createQueue(atestq, atestq, null, true, true);
session.createQueue(atestq, atestq2, null, true, true);
@@ -253,17 +222,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, false);
session.createQueue(atestq, atestq, null, true, true);
session.createQueue(atestq, atestq2, null, true, true);
@@ -289,9 +252,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, false);
consumer = session.createConsumer(atestq);
consumer2 = session.createConsumer(atestq2);
@@ -317,13 +280,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, false);
session.createQueue(atestq, atestq, null, true, true);
ClientProducer producer = session.createProducer(atestq);
@@ -345,9 +303,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, false);
}
ClientConsumer consumer = session.createConsumer(atestq);
@@ -371,13 +329,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, false);
session.createQueue(atestq, atestq, null, true, true);
ClientProducer producer = session.createProducer(atestq);
@@ -404,10 +356,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, false);
}
@@ -452,13 +404,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, false);
session.createQueue(atestq, atestq, null, true, true);
ClientProducer producer = session.createProducer(atestq);
@@ -486,10 +432,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, false);
@@ -534,13 +480,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, false);
session.createQueue(atestq, atestq, null, true, true);
ClientProducer producer = session.createProducer(atestq);
@@ -566,10 +506,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, false);
}
@@ -610,13 +550,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, false);
session.createQueue(atestq, atestq, null, true, false);
session.start(xid, XAResource.TMNOFLAGS);
@@ -640,10 +576,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, false);
}
Modified: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/xa/BasicXaRecoveryTest.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/xa/BasicXaRecoveryTest.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/integration/xa/BasicXaRecoveryTest.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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.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, false);
- clientSession.createQueue(atestq, atestq, null, true, true);
- clientProducer = clientSession.createProducer(atestq);
- clientConsumer = clientSession.createConsumer(atestq);
+ createClients(true, false);
+
+
}
protected void tearDown() throws Exception
@@ -899,7 +879,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)
{
@@ -1193,10 +1173,8 @@
clientSession = null;
messagingService.stop();
messagingService = null;
- messagingService = MessagingServiceImpl.newNioStorageMessagingServer(configuration, journalDir, bindingsDir);
+ messagingService = createService(true, configuration, queueSettings);
- addSettings();
-
messagingService.start();
createClients();
}
@@ -1237,11 +1215,20 @@
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, false);
+ sessionFactory = createInVMFactory();
+ clientSession = sessionFactory.createSession(true, false, commitACKs, false);
+ if (createQueue)
+ {
+ clientSession.createQueue(atestq, atestq, null, true, true);
+ }
clientProducer = clientSession.createProducer(atestq);
clientConsumer = clientSession.createConsumer(atestq);
}
Added: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/soak/chunk/MessageChunkSoakTest.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/soak/chunk/MessageChunkSoakTest.java (rev 0)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/soak/chunk/MessageChunkSoakTest.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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 -------------------------------------------------
+
+}
Added: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/stress/chunk/MessageChunkStressTest.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/stress/chunk/MessageChunkStressTest.java (rev 0)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/stress/chunk/MessageChunkStressTest.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/stress/paging/MultipleDestinationPagingTest.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/stress/paging/MultipleDestinationPagingTest.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/stress/paging/MultipleDestinationPagingTest.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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 MultipleDestinationPagingTest extends IntegrationTestBase
+public class MultipleDestinationPagingTest extends ServiceTestBase
{
// Constants -----------------------------------------------------
@@ -77,7 +77,7 @@
settings.put("page-adr", setting);
}
- service = createService(true, false, config, settings);
+ service = createService(true, config, settings);
service.start();
ClientSessionFactory factory = createInVMFactory();
Modified: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/ReclaimerTest.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/ReclaimerTest.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/ReclaimerTest.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PageImplTestBase.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PageImplTestBase.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PageImplTestBase.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PageManagerImplTest.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PageManagerImplTest.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PageManagerImplTest.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -66,9 +66,6 @@
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
-
-
-
public void testOnDepage() throws Exception
{
long time = System.currentTimeMillis() + 10000;
@@ -82,7 +79,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);
@@ -115,7 +112,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);
Modified: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingStoreImplTest.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingStoreImplTest.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingStoreImplTest.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -201,8 +201,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());
}
}
@@ -264,8 +264,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());
}
}
@@ -307,9 +307,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: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingStoreTestBase.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingStoreTestBase.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingStoreTestBase.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/persistence/impl/journal/JournalStorageManagerTest.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/persistence/impl/journal/JournalStorageManagerTest.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/persistence/impl/journal/JournalStorageManagerTest.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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");
@@ -493,7 +494,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);
@@ -515,7 +516,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);
@@ -543,7 +544,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");
@@ -667,7 +668,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());
@@ -734,7 +735,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();
@@ -788,7 +789,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: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/MessageReferenceImplTest.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/MessageReferenceImplTest.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/MessageReferenceImplTest.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueImplTest.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueImplTest.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueImplTest.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/ServerMessageImplTest.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/ServerMessageImplTest.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/ServerMessageImplTest.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/settings/impl/QueueSettingsTest.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/settings/impl/QueueSettingsTest.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/settings/impl/QueueSettingsTest.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/transaction/impl/TransactionImplTest.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/transaction/impl/TransactionImplTest.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/core/transaction/impl/TransactionImplTest.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/jms/client/JBossMessageConsumerTest.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/jms/client/JBossMessageConsumerTest.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/jms/client/JBossMessageConsumerTest.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/jms/client/JBossMessageTest.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/jms/client/JBossMessageTest.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/unit/jms/client/JBossMessageTest.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -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,
Added: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/util/ServiceTestBase.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/util/ServiceTestBase.java (rev 0)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/util/ServiceTestBase.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -0,0 +1,244 @@
+/*
+ * 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.remoting.impl.netty.NettyAcceptorFactory;
+import org.jboss.messaging.core.remoting.impl.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.integration.chunkmessage.ChunkTestBase;
+
+/**
+ *
+ * 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));
+ }
+
+ 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: branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/util/UnitTestCase.java
===================================================================
--- branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/util/UnitTestCase.java 2008-11-04 22:40:06 UTC (rev 5269)
+++ branches/Branch_Chunk/tests/src/org/jboss/messaging/tests/util/UnitTestCase.java 2008-11-04 23:26:10 UTC (rev 5270)
@@ -87,6 +87,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