JBoss hornetq SVN: r8371 - branches/ClebertCallback/src/main/org/hornetq/core/journal/impl.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2009-11-22 22:30:52 -0500 (Sun, 22 Nov 2009)
New Revision: 8371
Modified:
branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/TimedBuffer.java
Log:
Improving flush time for NIO with callbacks
Modified: branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/TimedBuffer.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/TimedBuffer.java 2009-11-23 02:51:06 UTC (rev 8370)
+++ branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/TimedBuffer.java 2009-11-23 03:30:52 UTC (rev 8371)
@@ -259,36 +259,55 @@
}
}
- public synchronized void flush()
+ public void flush()
{
- if (buffer.writerIndex() > 0)
+ ByteBuffer bufferToFlush = null;
+
+ boolean useSync = false;
+
+ List<IOAsyncTask> callbacksToCall = null;
+
+ synchronized (this)
{
- latchTimer.up();
+ if (buffer.writerIndex() > 0)
+ {
+ latchTimer.up();
+
+ int pos = buffer.writerIndex();
+
+ if (logRates)
+ {
+ bytesFlushed += pos;
+ }
+
+ bufferToFlush = bufferObserver.newBuffer(bufferSize, pos);
+
+ // Putting a byteArray on a native buffer is much faster, since it will do in a single native call.
+ // Using bufferToFlush.put(buffer) would make several append calls for each byte
+
+ bufferToFlush.put(buffer.array(), 0, pos);
- int pos = buffer.writerIndex();
-
- if (logRates)
- {
- bytesFlushed += pos;
+ callbacksToCall = callbacks;
+
+ callbacks = new LinkedList<IOAsyncTask>();
+
+ useSync = pendingSync;
+
+ active = false;
+ pendingSync = false;
+
+ buffer.clear();
+ bufferLimit = 0;
}
+ }
+
+ // Execute the flush outside of the lock
+ // This is important for NIO performance while we are using NIO Callbacks
+ if (bufferToFlush != null)
+ {
+ bufferObserver.flushBuffer(bufferToFlush, useSync, callbacksToCall);
+ }
- ByteBuffer directBuffer = bufferObserver.newBuffer(bufferSize, pos);
-
- // Putting a byteArray on a native buffer is much faster, since it will do in a single native call.
- // Using directBuffer.put(buffer) would make several append calls for each byte
-
- directBuffer.put(buffer.array(), 0, pos);
-
- bufferObserver.flushBuffer(directBuffer, pendingSync, callbacks);
-
- callbacks = new LinkedList<IOAsyncTask>();
-
- active = false;
- pendingSync = false;
-
- buffer.clear();
- bufferLimit = 0;
- }
}
// Package protected ---------------------------------------------
15 years, 1 month
JBoss hornetq SVN: r8370 - in branches/ClebertCallback: tests/src/org/hornetq/tests/integration/largemessage and 1 other directory.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2009-11-22 21:51:06 -0500 (Sun, 22 Nov 2009)
New Revision: 8370
Modified:
branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/OperationContextImpl.java
branches/ClebertCallback/tests/src/org/hornetq/tests/integration/largemessage/ServerLargeMessageTest.java
Log:
tweaks
Modified: branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/OperationContextImpl.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/OperationContextImpl.java 2009-11-23 02:04:55 UTC (rev 8369)
+++ branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/OperationContextImpl.java 2009-11-23 02:51:06 UTC (rev 8370)
@@ -211,6 +211,8 @@
{
public void run()
{
+ // If any IO is done inside the callback, it needs to be done on a new context
+ clearContext();
task.done();
executorsPending.decrementAndGet();
}
Modified: branches/ClebertCallback/tests/src/org/hornetq/tests/integration/largemessage/ServerLargeMessageTest.java
===================================================================
--- branches/ClebertCallback/tests/src/org/hornetq/tests/integration/largemessage/ServerLargeMessageTest.java 2009-11-23 02:04:55 UTC (rev 8369)
+++ branches/ClebertCallback/tests/src/org/hornetq/tests/integration/largemessage/ServerLargeMessageTest.java 2009-11-23 02:51:06 UTC (rev 8370)
@@ -50,7 +50,7 @@
// Public --------------------------------------------------------
- protected void setup() throws Exception
+ protected void setUp() throws Exception
{
super.setUp();
15 years, 1 month
JBoss hornetq SVN: r8369 - in branches/ClebertCallback: src/main/org/hornetq/core/management/impl and 17 other directories.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2009-11-22 21:04:55 -0500 (Sun, 22 Nov 2009)
New Revision: 8369
Modified:
branches/ClebertCallback/src/main/org/hornetq/core/management/ManagementService.java
branches/ClebertCallback/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java
branches/ClebertCallback/src/main/org/hornetq/core/persistence/OperationContext.java
branches/ClebertCallback/src/main/org/hornetq/core/persistence/StorageManager.java
branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/OperationContextImpl.java
branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/nullpm/NullStorageManager.java
branches/ClebertCallback/src/main/org/hornetq/core/postoffice/impl/DuplicateIDCacheImpl.java
branches/ClebertCallback/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicationEndpointImpl.java
branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicationManagerImpl.java
branches/ClebertCallback/src/main/org/hornetq/core/server/Queue.java
branches/ClebertCallback/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
branches/ClebertCallback/src/main/org/hornetq/core/server/impl/LastValueQueue.java
branches/ClebertCallback/src/main/org/hornetq/core/server/impl/QueueFactoryImpl.java
branches/ClebertCallback/src/main/org/hornetq/core/server/impl/QueueImpl.java
branches/ClebertCallback/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
branches/ClebertCallback/src/main/org/hornetq/core/server/impl/ServerSessionPacketHandler.java
branches/ClebertCallback/tests/src/org/hornetq/tests/integration/largemessage/ServerLargeMessageTest.java
branches/ClebertCallback/tests/src/org/hornetq/tests/integration/persistence/RestartSMTest.java
branches/ClebertCallback/tests/src/org/hornetq/tests/integration/replication/ReplicationTest.java
branches/ClebertCallback/tests/src/org/hornetq/tests/performance/persistence/StorageManagerTimingTest.java
branches/ClebertCallback/tests/src/org/hornetq/tests/timing/core/server/impl/QueueImplTest.java
branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java
branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/postoffice/impl/DuplicateDetectionUnitTest.java
branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/server/impl/QueueImplTest.java
branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/server/impl/fakes/FakeQueueFactory.java
branches/ClebertCallback/tests/src/org/hornetq/tests/util/UnitTestCase.java
Log:
Reverting unecessary executors..
Modified: branches/ClebertCallback/src/main/org/hornetq/core/management/ManagementService.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/management/ManagementService.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/src/main/org/hornetq/core/management/ManagementService.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -71,6 +71,8 @@
ObjectNameBuilder getObjectNameBuilder();
// Resource Registration
+
+ void setStorageManager(StorageManager storageManager);
HornetQServerControlImpl registerServer(PostOffice postOffice,
StorageManager storageManager,
Modified: branches/ClebertCallback/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -59,7 +59,6 @@
import org.hornetq.core.messagecounter.impl.MessageCounterManagerImpl;
import org.hornetq.core.paging.PagingManager;
import org.hornetq.core.persistence.StorageManager;
-import org.hornetq.core.persistence.impl.journal.OperationContextImpl;
import org.hornetq.core.postoffice.PostOffice;
import org.hornetq.core.remoting.server.RemotingService;
import org.hornetq.core.remoting.spi.Acceptor;
@@ -181,6 +180,11 @@
{
return messageCounterManager;
}
+
+ public void setStorageManager(StorageManager storageManager)
+ {
+ this.storageManager = storageManager;
+ }
public HornetQServerControlImpl registerServer(final PostOffice postOffice,
final StorageManager storageManager,
@@ -741,28 +745,17 @@
}
}
- // TODO: Talk to Andy and Jeff about a better way to sync this...
- System.out.println("Waiting");
- final CountDownLatch latch = new CountDownLatch(1);
- OperationContextImpl.getInstance().executeOnCompletion(new IOAsyncTask()
+ if (storageManager != null)
{
-
- public void done()
- {
- System.out.println("Done on management");
- latch.countDown();
- }
-
- public void onError(int errorCode, String errorMessage)
- {
- }
-
- });
-
- OperationContextImpl.getInstance().complete();
-
- latch.await(5, TimeUnit.SECONDS);
- System.out.println("Done");
+ System.out.println("Waiting on management...");
+ storageManager.waitOnOperations(managementRequestTimeout);
+ storageManager.clearContext();
+ System.out.println("Done");
+ }
+ else
+ {
+ new Exception("storagemanager is null, can't wait on operations").printStackTrace();
+ }
}
public void enableNotifications(boolean enabled)
Modified: branches/ClebertCallback/src/main/org/hornetq/core/persistence/OperationContext.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/persistence/OperationContext.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/src/main/org/hornetq/core/persistence/OperationContext.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -30,11 +30,6 @@
public interface OperationContext extends IOCompletion
{
- boolean hasReplication();
-
- /** Reattach the context to the current thread */
- void reinstall();
-
/** The executor used on responses.
* If this is not set, it will use the current thread. */
void setExecutor(Executor executor);
@@ -49,8 +44,5 @@
/** To be called when there are no more operations pending */
void complete();
-
- /** Is this a special operation to sync replication. */
- boolean isSync();
}
Modified: branches/ClebertCallback/src/main/org/hornetq/core/persistence/StorageManager.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/persistence/StorageManager.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/src/main/org/hornetq/core/persistence/StorageManager.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -52,9 +52,12 @@
/** Get the context associated with the thread for later reuse */
OperationContext getContext();
- /** It just creates an OperationContext without associating it to any threads */
+ /** It just creates an OperationContext without associating it */
OperationContext newContext(Executor executor);
+ /** Set the context back to the thread */
+ void setContext(OperationContext context);
+
// Message related operations
void pageClosed(SimpleString storeName, int pageNumber);
@@ -77,6 +80,8 @@
/** To close the OperationsContext */
void completeOperations();
+
+ void clearContext();
UUID getPersistentID();
Modified: branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -78,6 +78,7 @@
import org.hornetq.core.transaction.Transaction.State;
import org.hornetq.core.transaction.impl.TransactionImpl;
import org.hornetq.utils.DataConstants;
+import org.hornetq.utils.ExecutorFactory;
import org.hornetq.utils.Pair;
import org.hornetq.utils.SimpleString;
import org.hornetq.utils.UUID;
@@ -93,6 +94,7 @@
*/
public class JournalStorageManager implements StorageManager
{
+
private static final Logger log = Logger.getLogger(JournalStorageManager.class);
private static final long CHECKPOINT_BATCH_SIZE = Integer.MAX_VALUE;
@@ -144,6 +146,9 @@
private final SequentialFileFactory largeMessagesFactory;
private volatile boolean started;
+
+ /** Used to create Operation Contexts */
+ private final ExecutorFactory executorFactory;
private final Executor executor;
@@ -163,15 +168,17 @@
private final String largeMessagesDirectory;
- public JournalStorageManager(final Configuration config, final Executor executor)
+ public JournalStorageManager(final Configuration config, final ExecutorFactory executorFactory)
{
- this(config, executor, null);
+ this(config, executorFactory, null);
}
- public JournalStorageManager(final Configuration config, final Executor executor, final ReplicationManager replicator)
+ public JournalStorageManager(final Configuration config, final ExecutorFactory executorFactory, final ReplicationManager replicator)
{
- this.executor = executor;
+ this.executorFactory = executorFactory;
+ this.executor = executorFactory.getExecutor();
+
this.replicator = replicator;
if (config.getJournalType() != JournalType.NIO && config.getJournalType() != JournalType.ASYNCIO)
@@ -295,8 +302,13 @@
*/
public void completeOperations()
{
- OperationContextImpl.getInstance().complete();
+ getContext().complete();
}
+
+ public void clearContext()
+ {
+ OperationContextImpl.clearContext();
+ }
public boolean isReplicated()
{
@@ -373,8 +385,13 @@
*/
public OperationContext getContext()
{
- return OperationContextImpl.getInstance();
+ return OperationContextImpl.getContext(executorFactory);
}
+
+ public void setContext(OperationContext context)
+ {
+ OperationContextImpl.setContext(context);
+ }
/* (non-Javadoc)
* @see org.hornetq.core.persistence.StorageManager#newContext()
@@ -386,7 +403,7 @@
public void afterCompleteOperations(IOAsyncTask run)
{
- OperationContextImpl.getInstance().executeOnCompletion(run);
+ getContext().executeOnCompletion(run);
}
public UUID getPersistentID()
@@ -469,27 +486,27 @@
messageJournal.appendAddRecord(message.getMessageID(),
ADD_LARGE_MESSAGE,
new LargeMessageEncoding((LargeServerMessage)message),
- false, getIOContext());
+ false, getContext());
}
else
{
- messageJournal.appendAddRecord(message.getMessageID(), ADD_MESSAGE, message, false, getIOContext());
+ messageJournal.appendAddRecord(message.getMessageID(), ADD_MESSAGE, message, false, getContext());
}
}
public void storeReference(final long queueID, final long messageID) throws Exception
{
- messageJournal.appendUpdateRecord(messageID, ADD_REF, new RefEncoding(queueID), syncNonTransactional, getIOContext());
+ messageJournal.appendUpdateRecord(messageID, ADD_REF, new RefEncoding(queueID), syncNonTransactional, getContext());
}
public void storeAcknowledge(final long queueID, final long messageID) throws Exception
{
- messageJournal.appendUpdateRecord(messageID, ACKNOWLEDGE_REF, new RefEncoding(queueID), syncNonTransactional, getIOContext());
+ messageJournal.appendUpdateRecord(messageID, ACKNOWLEDGE_REF, new RefEncoding(queueID), syncNonTransactional, getContext());
}
public void deleteMessage(final long messageID) throws Exception
{
- messageJournal.appendDeleteRecord(messageID, syncNonTransactional, getIOContext());
+ messageJournal.appendDeleteRecord(messageID, syncNonTransactional, getContext());
}
public void updateScheduledDeliveryTime(final MessageReference ref) throws Exception
@@ -500,19 +517,19 @@
messageJournal.appendUpdateRecord(ref.getMessage().getMessageID(),
SET_SCHEDULED_DELIVERY_TIME,
encoding,
- syncNonTransactional, getIOContext());
+ syncNonTransactional, getContext());
}
public void storeDuplicateID(final SimpleString address, final byte[] duplID, final long recordID) throws Exception
{
DuplicateIDEncoding encoding = new DuplicateIDEncoding(address, duplID);
- messageJournal.appendAddRecord(recordID, DUPLICATE_ID, encoding, syncNonTransactional, getIOContext());
+ messageJournal.appendAddRecord(recordID, DUPLICATE_ID, encoding, syncNonTransactional, getContext());
}
public void deleteDuplicateID(long recordID) throws Exception
{
- messageJournal.appendDeleteRecord(recordID, syncNonTransactional, getIOContext());
+ messageJournal.appendDeleteRecord(recordID, syncNonTransactional, getContext());
}
// Transactional operations
@@ -568,13 +585,13 @@
public long storeHeuristicCompletion(Xid xid, boolean isCommit) throws Exception
{
long id = generateUniqueID();
- messageJournal.appendAddRecord(id, HEURISTIC_COMPLETION, new HeuristicCompletionEncoding(xid, isCommit), true, getIOContext());
+ messageJournal.appendAddRecord(id, HEURISTIC_COMPLETION, new HeuristicCompletionEncoding(xid, isCommit), true, getContext());
return id;
}
public void deleteHeuristicCompletion(long id) throws Exception
{
- messageJournal.appendDeleteRecord(id, true, getIOContext());
+ messageJournal.appendDeleteRecord(id, true, getContext());
}
public void deletePageTransactional(final long txID, final long recordID) throws Exception
@@ -600,17 +617,17 @@
public void prepare(final long txID, final Xid xid) throws Exception
{
- messageJournal.appendPrepareRecord(txID, new XidEncoding(xid), syncTransactional, getIOContext());
+ messageJournal.appendPrepareRecord(txID, new XidEncoding(xid), syncTransactional, getContext());
}
public void commit(final long txID) throws Exception
{
- messageJournal.appendCommitRecord(txID, syncTransactional, getIOContext());
+ messageJournal.appendCommitRecord(txID, syncTransactional, getContext());
}
public void rollback(final long txID) throws Exception
{
- messageJournal.appendRollbackRecord(txID, syncTransactional, getIOContext());
+ messageJournal.appendRollbackRecord(txID, syncTransactional, getContext());
}
public void storeDuplicateIDTransactional(final long txID,
@@ -648,7 +665,7 @@
messageJournal.appendUpdateRecord(ref.getMessage().getMessageID(),
UPDATE_DELIVERY_COUNT,
updateInfo,
- syncNonTransactional, getIOContext());
+ syncNonTransactional, getContext());
}
private static final class AddMessageRecord
@@ -1394,11 +1411,6 @@
// Private ----------------------------------------------------------------------------------
- private IOCompletion getIOContext()
- {
- return OperationContextImpl.getInstance();
- }
-
private void checkAndCreateDir(final String dir, final boolean create)
{
File f = new File(dir);
Modified: branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/OperationContextImpl.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/OperationContextImpl.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/OperationContextImpl.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -21,9 +21,8 @@
import org.hornetq.core.journal.IOAsyncTask;
import org.hornetq.core.persistence.OperationContext;
+import org.hornetq.utils.ExecutorFactory;
-import sun.security.util.PendingException;
-
/**
*
* This class will hold operations when there are IO operations...
@@ -33,24 +32,31 @@
*/
public class OperationContextImpl implements OperationContext
{
- private static final ThreadLocal<OperationContext> tlContext = new ThreadLocal<OperationContext>();
+
+ private static final ThreadLocal<OperationContext> threadLocalContext = new ThreadLocal<OperationContext>();
- public static void setInstance(OperationContext context)
+ public static void clearContext()
{
- tlContext.set(context);
+ threadLocalContext.set(null);
}
- public static OperationContext getInstance()
+ public static OperationContext getContext(final ExecutorFactory executorFactory)
{
- OperationContext token = tlContext.get();
+ OperationContext token = threadLocalContext.get();
if (token == null)
{
- token = new OperationContextImpl();
- tlContext.set(token);
+ token = new OperationContextImpl(executorFactory.getExecutor());
+ threadLocalContext.set(token);
}
return token;
}
-
+
+ public static void setContext(OperationContext context)
+ {
+ threadLocalContext.set(context);
+ }
+
+
private List<TaskHolder> tasks;
private volatile int storeLineUp = 0;
@@ -64,38 +70,21 @@
private int stored = 0;
private int replicated = 0;
-
+
private int errorCode = -1;
-
+
private String errorMessage = null;
-
+
private Executor executor;
-
+
private final AtomicInteger executorsPending = new AtomicInteger(0);
- /**
- * @param executor
- */
- public OperationContextImpl()
- {
- super();
- }
-
public OperationContextImpl(final Executor executor)
{
super();
this.executor = executor;
}
-
- /*
- * @see org.hornetq.core.persistence.OperationContext#reinstall()
- */
- public void reinstall()
- {
- setInstance(this);
- }
-
/** To be called by the replication manager, when new replication is added to the queue */
public void lineUp()
{
@@ -106,7 +95,7 @@
{
replicationLineUp++;
}
-
+
/** this method needs to be called before the executor became operational */
public void setExecutor(Executor executor)
{
@@ -119,50 +108,56 @@
checkTasks();
}
- public boolean hasReplication()
- {
- return replicationLineUp > 0;
- }
-
/** You may have several actions to be done after a replication operation is completed. */
- public synchronized void executeOnCompletion(final IOAsyncTask completion)
+ public void executeOnCompletion(final IOAsyncTask completion)
{
- if (tasks == null)
- {
- tasks = new LinkedList<TaskHolder>();
- minimalReplicated = replicationLineUp;
- minimalStore = storeLineUp;
- }
+ boolean executeNow = false;
- // On this case, we can just execute the context directly
- if (replicationLineUp == replicated && storeLineUp == stored)
+ synchronized (this)
{
- if (executor != null)
+ if (tasks == null)
{
- // We want to avoid the executor if everything is complete...
- // However, we can't execute the context if there are executions pending
- // We need to use the executor on this case
- if (executorsPending.get() == 0)
+ tasks = new LinkedList<TaskHolder>();
+ minimalReplicated = replicationLineUp;
+ minimalStore = storeLineUp;
+ }
+
+ // On this case, we can just execute the context directly
+ if (replicationLineUp == replicated && storeLineUp == stored)
+ {
+ if (executor != null)
{
- // No need to use an executor here or a context switch
- // there are no actions pending.. hence we can just execute the task directly on the same thread
- completion.done();
+ // We want to avoid the executor if everything is complete...
+ // However, we can't execute the context if there are executions pending
+ // We need to use the executor on this case
+ if (executorsPending.get() == 0)
+ {
+ // No need to use an executor here or a context switch
+ // there are no actions pending.. hence we can just execute the task directly on the same thread
+ executeNow = true;
+ }
+ else
+ {
+ execute(completion);
+ }
}
else
{
- execute(completion);
+ executeNow = true;
}
}
else
{
- // Execute without an executor
- completion.done();
+ tasks.add(new TaskHolder(completion));
}
}
- else
+
+ if (executeNow)
{
- tasks.add(new TaskHolder(completion));
+ // Executing outside of any locks
+ completion.done();
}
+
}
/** To be called by the storage manager, when data is confirmed on the channel */
@@ -183,7 +178,7 @@
if (!holder.executed && stored >= holder.storeLined && replicated >= holder.replicationLined)
{
holder.executed = true;
-
+
if (executor != null)
{
// If set, we use an executor to avoid the server being single threaded
@@ -193,7 +188,7 @@
{
holder.task.done();
}
-
+
iter.remove();
}
else
@@ -227,8 +222,6 @@
*/
public void complete()
{
- tlContext.set(null);
-
// TODO: test and fix exceptions on the Context
if (tasks != null && errorMessage != null)
{
@@ -237,16 +230,11 @@
run.task.onError(errorCode, errorMessage);
}
}
-
+
// We hold errors until the complete is set, or the callbacks will never get informed
errorCode = -1;
errorMessage = null;
}
-
- public boolean isSync()
- {
- return false;
- }
/* (non-Javadoc)
* @see org.hornetq.core.asyncio.AIOCallback#onError(int, java.lang.String)
@@ -275,5 +263,4 @@
}
}
-
}
Modified: branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/nullpm/NullStorageManager.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/nullpm/NullStorageManager.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/nullpm/NullStorageManager.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -374,4 +374,18 @@
return null;
}
+ /* (non-Javadoc)
+ * @see org.hornetq.core.persistence.StorageManager#setContext(org.hornetq.core.persistence.OperationContext)
+ */
+ public void setContext(OperationContext context)
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.hornetq.core.persistence.StorageManager#clearContext()
+ */
+ public void clearContext()
+ {
+ }
+
}
Modified: branches/ClebertCallback/src/main/org/hornetq/core/postoffice/impl/DuplicateIDCacheImpl.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/postoffice/impl/DuplicateIDCacheImpl.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/src/main/org/hornetq/core/postoffice/impl/DuplicateIDCacheImpl.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -18,7 +18,6 @@
import java.util.Collections;
import java.util.List;
import java.util.Set;
-import java.util.concurrent.Executor;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.persistence.StorageManager;
@@ -59,14 +58,11 @@
private final StorageManager storageManager;
private final boolean persist;
-
- private final Executor executor;
public DuplicateIDCacheImpl(final SimpleString address,
final int size,
final StorageManager storageManager,
- final boolean persist,
- final Executor executor)
+ final boolean persist)
{
this.address = address;
@@ -77,8 +73,6 @@
this.storageManager = storageManager;
this.persist = persist;
-
- this.executor = executor;
}
public void load(final List<Pair<byte[], Long>> theIds) throws Exception
@@ -144,7 +138,7 @@
storageManager.storeDuplicateID(address, duplID, recordID);
}
- addToCacheInMemory(duplID, recordID, null);
+ addToCacheInMemory(duplID, recordID);
}
else
{
@@ -161,12 +155,11 @@
}
}
-
- private synchronized void addToCacheInMemory(final byte[] duplID, final long recordID, final Executor journalExecutor) throws Exception
+ private synchronized void addToCacheInMemory(final byte[] duplID, final long recordID)
{
cache.add(new ByteArrayHolder(duplID));
- final Pair<ByteArrayHolder, Long> id;
+ Pair<ByteArrayHolder, Long> id;
if (pos < ids.size())
{
@@ -180,27 +173,13 @@
// reclaimed
id.a = new ByteArrayHolder(duplID);
- if (journalExecutor != null)
+ try
{
- // We can't execute any IO inside the Journal callback, so taking it outside
- journalExecutor.execute(new Runnable()
- {
- public void run()
- {
- try
- {
- storageManager.deleteDuplicateID(id.b);
- }
- catch (Exception e)
- {
- log.warn("Error on deleting duplicate cache");
- }
- }
- });
+ storageManager.deleteDuplicateID(id.b);
}
- else
+ catch (Exception e)
{
- storageManager.deleteDuplicateID(id.b);
+ log.warn("Error on deleting duplicate cache", e);
}
id.b = recordID;
@@ -237,14 +216,8 @@
{
if (!done)
{
- try
- {
- addToCacheInMemory(duplID, recordID, executor);
- }
- catch (Exception shouldNotHappen)
- {
- // if you pass an executor to addtoCache, an exception will never happen here
- }
+ addToCacheInMemory(duplID, recordID);
+
done = true;
}
}
Modified: branches/ClebertCallback/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -743,9 +743,7 @@
if (cache == null)
{
- // TODO: What's the right executor?
- // Is there another way
- cache = new DuplicateIDCacheImpl(address, idCacheSize, storageManager, persistIDCache, redistributorExecutorFactory.getExecutor());
+ cache = new DuplicateIDCacheImpl(address, idCacheSize, storageManager, persistIDCache);
DuplicateIDCache oldCache = duplicateIDCaches.putIfAbsent(address, cache);
Modified: branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicationEndpointImpl.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicationEndpointImpl.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicationEndpointImpl.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -190,8 +190,10 @@
{
Configuration config = server.getConfiguration();
- storage = new JournalStorageManager(config, server.getExecutorFactory().getExecutor());
+ storage = new JournalStorageManager(config, server.getExecutorFactory());
storage.start();
+
+ server.getManagementService().setStorageManager(storage);
bindingsJournal = storage.getBindingsJournal();
messagingJournal = storage.getMessageJournal();
Modified: branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicationManagerImpl.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicationManagerImpl.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicationManagerImpl.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -14,8 +14,6 @@
package org.hornetq.core.replication.impl;
import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
@@ -28,6 +26,7 @@
import org.hornetq.core.logging.Logger;
import org.hornetq.core.paging.PagedMessage;
import org.hornetq.core.persistence.OperationContext;
+import org.hornetq.core.persistence.StorageManager;
import org.hornetq.core.persistence.impl.journal.OperationContextImpl;
import org.hornetq.core.remoting.Channel;
import org.hornetq.core.remoting.ChannelHandler;
@@ -49,6 +48,7 @@
import org.hornetq.core.remoting.impl.wireformat.ReplicationPrepareMessage;
import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.replication.ReplicationManager;
+import org.hornetq.utils.ExecutorFactory;
import org.hornetq.utils.SimpleString;
/**
@@ -83,6 +83,8 @@
private final Object replicationLock = new Object();
private final Queue<OperationContext> pendingTokens = new ConcurrentLinkedQueue<OperationContext>();
+
+ private final ExecutorFactory executorFactory;
// Static --------------------------------------------------------
@@ -91,11 +93,12 @@
/**
* @param replicationConnectionManager
*/
- public ReplicationManagerImpl(final FailoverManager failoverManager, final int backupWindowSize)
+ public ReplicationManagerImpl(final FailoverManager failoverManager, final ExecutorFactory executorFactory, final int backupWindowSize)
{
super();
this.failoverManager = failoverManager;
this.backupWindowSize = backupWindowSize;
+ this.executorFactory = executorFactory;
}
// Public --------------------------------------------------------
@@ -430,7 +433,7 @@
{
boolean runItNow = false;
- OperationContext repliToken = getContext();
+ OperationContext repliToken = OperationContextImpl.getContext(executorFactory);
repliToken.replicationLineUp();
synchronized (replicationLock)
@@ -459,67 +462,16 @@
private void replicated()
{
- List<OperationContext> tokensToExecute = getTokens();
+ OperationContext ctx = pendingTokens.poll();
- for (OperationContext ctx : tokensToExecute)
+ if (ctx == null)
{
- ctx.replicationDone();
+ throw new IllegalStateException("Missing replication token on the queue.");
}
- }
- public OperationContext getContext()
- {
- return OperationContextImpl.getInstance();
+ ctx.replicationDone();
}
- /**
- * This method will first get all the sync tokens (that won't go to the backup node)
- * Then it will get the round trip tokens.
- * At last, if the list is empty, it will verify if there are any future tokens that are sync tokens, to avoid a case where no more replication is done due to inactivity.
- * @return
- */
- private List<OperationContext> getTokens()
- {
- List<OperationContext> retList = new LinkedList<OperationContext>();
-
- OperationContext tokenPolled = null;
-
- // First will get all the non replicated tokens up to the first one that is not replicated
- do
- {
- tokenPolled = pendingTokens.poll();
-
- if (tokenPolled == null)
- {
- throw new IllegalStateException("Missing replication token on the queue.");
- }
-
- retList.add(tokenPolled);
-
- }
- while (tokenPolled.isSync());
-
- // This is to avoid a situation where we won't have more replicated packets
- // We need to make sure we process any pending sync packet up to the next non empty packet
- synchronized (replicationLock)
- {
- while (!pendingTokens.isEmpty() && pendingTokens.peek().isSync())
- {
- tokenPolled = pendingTokens.poll();
- if (!tokenPolled.isSync())
- {
- throw new IllegalStateException("Replicatoin context is not a roundtrip token as expected");
- }
-
- retList.add(tokenPolled);
-
- }
- }
-
- return retList;
- }
-
-
// Inner classes -------------------------------------------------
protected class ResponseHandler implements ChannelHandler
Modified: branches/ClebertCallback/src/main/org/hornetq/core/server/Queue.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/server/Queue.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/src/main/org/hornetq/core/server/Queue.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -125,10 +125,6 @@
Collection<Consumer> getConsumers();
- /** We can't execute IO operation when inside the IOCallback / TransactionCallback.
- * This method will will perform IO operations in a second thread */
- boolean checkDLQ(MessageReference ref, Executor ioExecutor) throws Exception;
-
boolean checkDLQ(MessageReference ref) throws Exception;
void lockDelivery();
Modified: branches/ClebertCallback/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -651,7 +651,7 @@
Executor sessionExecutor = executorFactory.getExecutor();
- OperationContext sessionContext = storageManager.newContext(sessionExecutor);
+ storageManager.newContext(sessionExecutor);
final ServerSessionImpl session = new ServerSessionImpl(name,
username,
@@ -667,7 +667,6 @@
postOffice,
resourceManager,
securityStore,
- sessionContext,
sessionExecutor,
channel,
managementService,
@@ -677,7 +676,8 @@
sessions.put(name, session);
- ServerSessionPacketHandler handler = new ServerSessionPacketHandler(session, sessionContext);
+ // The executor on the OperationContext here has to be the same as the session, or we would have ordering issues on messages
+ ServerSessionPacketHandler handler = new ServerSessionPacketHandler(session, storageManager.newContext(sessionExecutor), storageManager);
session.setHandler(handler);
@@ -906,7 +906,7 @@
{
if (configuration.isPersistenceEnabled())
{
- return new JournalStorageManager(configuration, threadPool, replicationManager);
+ return new JournalStorageManager(configuration, this.executorFactory, replicationManager);
}
else
{
@@ -935,6 +935,7 @@
replicationFailoverManager = createBackupConnection(backupConnector, threadPool, scheduledPool);
replicationManager = new ReplicationManagerImpl(replicationFailoverManager,
+ executorFactory,
configuration.getBackupWindowSize());
replicationManager.start();
}
Modified: branches/ClebertCallback/src/main/org/hornetq/core/server/impl/LastValueQueue.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/server/impl/LastValueQueue.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/src/main/org/hornetq/core/server/impl/LastValueQueue.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -51,7 +51,6 @@
final Filter filter,
final boolean durable,
final boolean temporary,
- final Executor executor,
final ScheduledExecutorService scheduledExecutor,
final PostOffice postOffice,
final StorageManager storageManager,
@@ -63,7 +62,6 @@
filter,
durable,
temporary,
- executor,
scheduledExecutor,
postOffice,
storageManager,
Modified: branches/ClebertCallback/src/main/org/hornetq/core/server/impl/QueueFactoryImpl.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/server/impl/QueueFactoryImpl.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/src/main/org/hornetq/core/server/impl/QueueFactoryImpl.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -83,7 +83,6 @@
filter,
durable,
temporary,
- executorFactory.getExecutor(),
scheduledExecutor,
postOffice,
storageManager,
@@ -97,7 +96,6 @@
filter,
durable,
temporary,
- executorFactory.getExecutor(),
scheduledExecutor,
postOffice,
storageManager,
Modified: branches/ClebertCallback/src/main/org/hornetq/core/server/impl/QueueImpl.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/server/impl/QueueImpl.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/src/main/org/hornetq/core/server/impl/QueueImpl.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -115,9 +115,6 @@
private final ScheduledExecutorService scheduledExecutor;
- /** We can't perform any operation on the journal while inside the Transactional operations. */
- private final Executor journalExecutor;
-
private final SimpleString address;
private Redistributor redistributor;
@@ -142,7 +139,6 @@
final Filter filter,
final boolean durable,
final boolean temporary,
- final Executor executor,
final ScheduledExecutorService scheduledExecutor,
final PostOffice postOffice,
final StorageManager storageManager,
@@ -167,8 +163,6 @@
this.addressSettingsRepository = addressSettingsRepository;
this.scheduledExecutor = scheduledExecutor;
-
- this.journalExecutor = executor;
direct = true;
@@ -939,37 +933,12 @@
public boolean checkDLQ(final MessageReference reference) throws Exception
{
- return checkDLQ(reference, null);
- }
-
- public boolean checkDLQ(final MessageReference reference, Executor ioExecutor) throws Exception
- {
ServerMessage message = reference.getMessage();
if (message.isDurable() && durable)
{
- if (ioExecutor != null)
- {
- ioExecutor.execute(new Runnable()
- {
- public void run()
- {
- try
- {
- storageManager.updateDeliveryCount(reference);
- storageManager.completeOperations();
- }
- catch (Exception e)
- {
- log.warn("Can't update delivery count on checkDLQ", e);
- }
- }
- });
- }
- else
- {
- storageManager.updateDeliveryCount(reference);
- }
+ storageManager.updateDeliveryCount(reference);
+ storageManager.waitOnOperations();
}
AddressSettings addressSettings = addressSettingsRepository.getMatch(address.toString());
@@ -978,28 +947,8 @@
if (maxDeliveries > 0 && reference.getDeliveryCount() >= maxDeliveries)
{
- if (ioExecutor != null)
- {
- ioExecutor.execute(new Runnable()
- {
- public void run()
- {
- try
- {
- sendToDeadLetterAddress(reference);
- storageManager.completeOperations();
- }
- catch (Exception e)
- {
- log.warn("Error on DLQ send", e);
- }
- }
- });
- }
- else
- {
- sendToDeadLetterAddress(reference);
- }
+ sendToDeadLetterAddress(reference);
+ storageManager.waitOnOperations();
return false;
}
@@ -1011,28 +960,7 @@
{
reference.setScheduledDeliveryTime(System.currentTimeMillis() + redeliveryDelay);
- if (ioExecutor != null)
- {
- ioExecutor.execute(new Runnable()
- {
- public void run()
- {
- try
- {
- storageManager.updateScheduledDeliveryTime(reference);
- storageManager.completeOperations();
- }
- catch (Exception e)
- {
- log.warn("Error on DLQ send", e);
- }
- }
- });
- }
- else
- {
- storageManager.updateScheduledDeliveryTime(reference);
- }
+ storageManager.updateScheduledDeliveryTime(reference);
}
deliveringCount.decrementAndGet();
@@ -1495,23 +1423,14 @@
// also note then when this happens as part of a trasaction its the tx commt of the ack that is important
// not this
-
- // and this has to happen in a different thread
-
- journalExecutor.execute(new Runnable()
+ try
{
- public void run()
- {
- try
- {
- storageManager.deleteMessage(message.getMessageID());
- }
- catch (Exception e)
- {
- log.warn("Unable to remove message id = " + message.getMessageID() + " please remove manually");
- }
- }
- });
+ storageManager.deleteMessage(message.getMessageID());
+ }
+ catch (Exception e)
+ {
+ log.warn("Unable to remove message id = " + message.getMessageID() + " please remove manually");
+ }
}
}
@@ -1584,7 +1503,7 @@
{
try
{
- if (ref.getQueue().checkDLQ(ref, journalExecutor))
+ if (ref.getQueue().checkDLQ(ref))
{
LinkedList<MessageReference> toCancel = queueMap.get(ref.getQueue());
@@ -1600,8 +1519,6 @@
}
catch (Exception e)
{
- // checkDLQ here will be using an executor, this shouldn't happen
- // don't you just hate checked exceptions in java?
log.warn("Error on checkDLQ", e);
}
}
Modified: branches/ClebertCallback/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -39,9 +39,7 @@
import org.hornetq.core.management.ManagementService;
import org.hornetq.core.management.Notification;
import org.hornetq.core.paging.PagingStore;
-import org.hornetq.core.persistence.OperationContext;
import org.hornetq.core.persistence.StorageManager;
-import org.hornetq.core.persistence.impl.journal.OperationContextImpl;
import org.hornetq.core.postoffice.Binding;
import org.hornetq.core.postoffice.BindingType;
import org.hornetq.core.postoffice.Bindings;
@@ -189,10 +187,6 @@
private final SimpleString managementAddress;
- /** We always use the same operation context for the session.
- * With that we can perform extra checks */
- private final OperationContext sessionOperationContext;
-
// The current currentLargeMessage being processed
private volatile LargeServerMessage currentLargeMessage;
@@ -218,7 +212,6 @@
final PostOffice postOffice,
final ResourceManager resourceManager,
final SecurityStore securityStore,
- final OperationContext sessionOperationContext,
final Executor executor,
final Channel channel,
final ManagementService managementService,
@@ -249,8 +242,6 @@
this.securityStore = securityStore;
- this.sessionOperationContext = sessionOperationContext;
-
this.executor = executor;
if (!xa)
Modified: branches/ClebertCallback/src/main/org/hornetq/core/server/impl/ServerSessionPacketHandler.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/server/impl/ServerSessionPacketHandler.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/src/main/org/hornetq/core/server/impl/ServerSessionPacketHandler.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -46,6 +46,7 @@
import org.hornetq.core.logging.Logger;
import org.hornetq.core.persistence.OperationContext;
+import org.hornetq.core.persistence.StorageManager;
import org.hornetq.core.remoting.ChannelHandler;
import org.hornetq.core.remoting.Packet;
import org.hornetq.core.remoting.impl.wireformat.CreateQueueMessage;
@@ -90,10 +91,16 @@
private final ServerSession session;
private final OperationContext sessionContext;
+
+ // Storagemanager here is used to set the Context
+ private final StorageManager storageManager;
- public ServerSessionPacketHandler(final ServerSession session, OperationContext sessionContext)
+ public ServerSessionPacketHandler(final ServerSession session, OperationContext sessionContext, StorageManager storageManager)
{
this.session = session;
+
+ this.storageManager = storageManager;
+
this.sessionContext = sessionContext;
}
@@ -108,7 +115,7 @@
if (sessionContext != null)
{
- sessionContext.reinstall();
+ storageManager.setContext(sessionContext);
}
try
@@ -303,7 +310,7 @@
{
if (sessionContext != null)
{
- sessionContext.complete();
+ storageManager.completeOperations();
}
}
}
Modified: branches/ClebertCallback/tests/src/org/hornetq/tests/integration/largemessage/ServerLargeMessageTest.java
===================================================================
--- branches/ClebertCallback/tests/src/org/hornetq/tests/integration/largemessage/ServerLargeMessageTest.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/tests/src/org/hornetq/tests/integration/largemessage/ServerLargeMessageTest.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -13,6 +13,8 @@
package org.hornetq.tests.integration.largemessage;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.hornetq.core.config.Configuration;
@@ -21,6 +23,8 @@
import org.hornetq.core.server.LargeServerMessage;
import org.hornetq.core.server.ServerMessage;
import org.hornetq.tests.util.ServiceTestBase;
+import org.hornetq.utils.ExecutorFactory;
+import org.hornetq.utils.OrderedExecutorFactory;
/**
* A ServerLargeMessageTest
@@ -36,12 +40,32 @@
// Attributes ----------------------------------------------------
+ ExecutorService executor;
+
+ ExecutorFactory execFactory;
+
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
+ protected void setup() throws Exception
+ {
+ super.setUp();
+
+ executor = Executors.newCachedThreadPool();
+
+ execFactory = new OrderedExecutorFactory(executor);
+ }
+
+ protected void tearDown() throws Exception
+ {
+ executor.shutdown();
+
+ super.tearDown();
+ }
+
public void testLargeMessageCopy() throws Exception
{
clearData();
@@ -52,7 +76,7 @@
configuration.setJournalType(JournalType.ASYNCIO);
- final JournalStorageManager journal = new JournalStorageManager(configuration, Executors.newCachedThreadPool());
+ final JournalStorageManager journal = new JournalStorageManager(configuration, execFactory);
journal.start();
LargeServerMessage msg = journal.createLargeMessage();
Modified: branches/ClebertCallback/tests/src/org/hornetq/tests/integration/persistence/RestartSMTest.java
===================================================================
--- branches/ClebertCallback/tests/src/org/hornetq/tests/integration/persistence/RestartSMTest.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/tests/src/org/hornetq/tests/integration/persistence/RestartSMTest.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -18,6 +18,8 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.hornetq.core.config.Configuration;
@@ -30,6 +32,8 @@
import org.hornetq.core.server.Queue;
import org.hornetq.tests.unit.core.server.impl.fakes.FakePostOffice;
import org.hornetq.tests.util.ServiceTestBase;
+import org.hornetq.utils.ExecutorFactory;
+import org.hornetq.utils.OrderedExecutorFactory;
/**
* A DeleteMessagesRestartTest
@@ -48,11 +52,32 @@
// Attributes ----------------------------------------------------
+ ExecutorService executor;
+
+ ExecutorFactory execFactory;
+
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ executor = Executors.newCachedThreadPool();
+
+ this.execFactory = new OrderedExecutorFactory(executor);
+ }
+
+ protected void tearDown() throws Exception
+ {
+ executor.shutdown();
+
+ super.tearDown();
+ }
+
public void testRestartStorageManager() throws Exception
{
@@ -67,7 +92,8 @@
PostOffice postOffice = new FakePostOffice();
- final JournalStorageManager journal = new JournalStorageManager(configuration, Executors.newCachedThreadPool());
+ final JournalStorageManager journal = new JournalStorageManager(configuration, execFactory);
+
try
{
Modified: branches/ClebertCallback/tests/src/org/hornetq/tests/integration/replication/ReplicationTest.java
===================================================================
--- branches/ClebertCallback/tests/src/org/hornetq/tests/integration/replication/ReplicationTest.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/tests/src/org/hornetq/tests/integration/replication/ReplicationTest.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -53,7 +53,7 @@
import org.hornetq.core.paging.impl.PagingStoreFactoryNIO;
import org.hornetq.core.persistence.OperationContext;
import org.hornetq.core.persistence.StorageManager;
-import org.hornetq.core.persistence.impl.journal.OperationContextImpl;
+import org.hornetq.core.persistence.impl.journal.JournalStorageManager;
import org.hornetq.core.remoting.Interceptor;
import org.hornetq.core.remoting.Packet;
import org.hornetq.core.remoting.RemotingConnection;
@@ -70,6 +70,7 @@
import org.hornetq.tests.util.ServiceTestBase;
import org.hornetq.utils.ExecutorFactory;
import org.hornetq.utils.HornetQThreadFactory;
+import org.hornetq.utils.OrderedExecutorFactory;
import org.hornetq.utils.SimpleString;
/**
@@ -89,6 +90,8 @@
private ThreadFactory tFactory;
private ExecutorService executor;
+
+ private ExecutorFactory factory;
private ScheduledExecutorService scheduledExecutor;
@@ -114,6 +117,7 @@
try
{
ReplicationManagerImpl manager = new ReplicationManagerImpl(failoverManager,
+ this.factory,
ConfigurationImpl.DEFAULT_BACKUP_WINDOW_SIZE);
manager.start();
manager.stop();
@@ -140,6 +144,7 @@
try
{
ReplicationManagerImpl manager = new ReplicationManagerImpl(failoverManager,
+ this.factory,
ConfigurationImpl.DEFAULT_BACKUP_WINDOW_SIZE);
manager.start();
try
@@ -182,6 +187,7 @@
try
{
ReplicationManagerImpl manager = new ReplicationManagerImpl(failoverManager,
+ this.factory,
ConfigurationImpl.DEFAULT_BACKUP_WINDOW_SIZE);
manager.start();
@@ -189,6 +195,7 @@
try
{
ReplicationManagerImpl manager2 = new ReplicationManagerImpl(failoverManager,
+ this.factory,
ConfigurationImpl.DEFAULT_BACKUP_WINDOW_SIZE);
manager2.start();
@@ -223,6 +230,7 @@
try
{
ReplicationManagerImpl manager = new ReplicationManagerImpl(failoverManager,
+ this.factory,
ConfigurationImpl.DEFAULT_BACKUP_WINDOW_SIZE);
try
@@ -241,7 +249,7 @@
server.stop();
}
}
-
+
public void testSendPackets() throws Exception
{
@@ -257,7 +265,10 @@
try
{
+ StorageManager storage = getStorage();
+
ReplicationManagerImpl manager = new ReplicationManagerImpl(failoverManager,
+ this.factory,
ConfigurationImpl.DEFAULT_BACKUP_WINDOW_SIZE);
manager.start();
@@ -276,7 +287,7 @@
replicatedJournal.appendPrepareRecord(3, new FakeData(), false);
replicatedJournal.appendRollbackRecord(3, false);
- blockOnReplication(manager);
+ blockOnReplication(storage, manager);
assertEquals(0, manager.getActiveTokens().size());
@@ -294,7 +305,7 @@
manager.pageWrite(pgmsg, 3);
manager.pageWrite(pgmsg, 4);
- blockOnReplication(manager);
+ blockOnReplication(storage, manager);
PagingManager pagingManager = createPageManager(server.getStorageManager(),
server.getConfiguration(),
@@ -313,7 +324,7 @@
manager.pageDeleted(dummy, 5);
manager.pageDeleted(dummy, 6);
- blockOnReplication(manager);
+ blockOnReplication(storage, manager);
ServerMessageImpl serverMsg = new ServerMessageImpl();
serverMsg.setMessageID(500);
@@ -328,7 +339,7 @@
manager.largeMessageDelete(500);
- blockOnReplication(manager);
+ blockOnReplication(storage, manager);
store.start();
@@ -363,7 +374,9 @@
try
{
+ StorageManager storage = getStorage();
ReplicationManagerImpl manager = new ReplicationManagerImpl(failoverManager,
+ this.factory,
ConfigurationImpl.DEFAULT_BACKUP_WINDOW_SIZE);
manager.start();
@@ -377,7 +390,7 @@
}
final CountDownLatch latch = new CountDownLatch(1);
- OperationContextImpl.getInstance().executeOnCompletion(new IOAsyncTask()
+ storage.afterCompleteOperations(new IOAsyncTask()
{
public void onError(int errorCode, String errorMessage)
@@ -401,13 +414,21 @@
}
/**
+ * @return
+ */
+ private JournalStorageManager getStorage()
+ {
+ return new JournalStorageManager(createDefaultConfig(), factory);
+ }
+
+ /**
* @param manager
* @return
*/
- private void blockOnReplication(ReplicationManagerImpl manager) throws Exception
+ private void blockOnReplication(StorageManager storage, ReplicationManagerImpl manager) throws Exception
{
final CountDownLatch latch = new CountDownLatch(1);
- OperationContextImpl.getInstance().executeOnCompletion(new IOAsyncTask()
+ storage.afterCompleteOperations(new IOAsyncTask()
{
public void onError(int errorCode, String errorMessage)
@@ -430,6 +451,7 @@
try
{
ReplicationManagerImpl manager = new ReplicationManagerImpl(failoverManager,
+ this.factory,
ConfigurationImpl.DEFAULT_BACKUP_WINDOW_SIZE);
manager.start();
fail("Exception expected");
@@ -455,7 +477,9 @@
try
{
+ StorageManager storage = getStorage();
ReplicationManagerImpl manager = new ReplicationManagerImpl(failoverManager,
+ this.factory,
ConfigurationImpl.DEFAULT_BACKUP_WINDOW_SIZE);
manager.start();
@@ -464,7 +488,7 @@
replicatedJournal.appendPrepareRecord(1, new FakeData(), false);
final CountDownLatch latch = new CountDownLatch(1);
- OperationContextImpl.getInstance().executeOnCompletion(new IOAsyncTask()
+ storage.afterCompleteOperations(new IOAsyncTask()
{
public void onError(int errorCode, String errorMessage)
@@ -505,7 +529,9 @@
try
{
+ StorageManager storage = getStorage();
ReplicationManagerImpl manager = new ReplicationManagerImpl(failoverManager,
+ this.factory,
ConfigurationImpl.DEFAULT_BACKUP_WINDOW_SIZE);
manager.start();
@@ -515,7 +541,7 @@
final CountDownLatch latch = new CountDownLatch(numberOfAdds);
- OperationContext ctx = OperationContextImpl.getInstance();
+ OperationContext ctx = storage.getContext();
for (int i = 0; i < numberOfAdds; i++)
{
@@ -593,9 +619,26 @@
executor = Executors.newCachedThreadPool(tFactory);
scheduledExecutor = new ScheduledThreadPoolExecutor(10, tFactory);
+
+ factory = new OrderedExecutorFactory(executor);
+ }
+ protected void tearDown() throws Exception
+ {
+
+ executor.shutdown();
+
+ scheduledExecutor.shutdown();
+
+ tFactory = null;
+
+ scheduledExecutor = null;
+
+ super.tearDown();
+
}
+
private FailoverManagerImpl createFailoverManager()
{
return createFailoverManager(null);
@@ -622,22 +665,6 @@
scheduledExecutor,
interceptors);
}
-
- protected void tearDown() throws Exception
- {
-
- executor.shutdown();
-
- scheduledExecutor.shutdown();
-
- tFactory = null;
-
- scheduledExecutor = null;
-
- super.tearDown();
-
- }
-
protected PagingManager createPageManager(StorageManager storageManager,
Configuration configuration,
ExecutorFactory executorFactory,
Modified: branches/ClebertCallback/tests/src/org/hornetq/tests/performance/persistence/StorageManagerTimingTest.java
===================================================================
--- branches/ClebertCallback/tests/src/org/hornetq/tests/performance/persistence/StorageManagerTimingTest.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/tests/src/org/hornetq/tests/performance/persistence/StorageManagerTimingTest.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -15,6 +15,8 @@
import java.io.File;
import java.util.HashMap;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicLong;
@@ -29,6 +31,7 @@
import org.hornetq.core.server.impl.ServerMessageImpl;
import org.hornetq.tests.unit.core.server.impl.fakes.FakePostOffice;
import org.hornetq.tests.util.UnitTestCase;
+import org.hornetq.utils.ExecutorFactory;
import org.hornetq.utils.SimpleString;
/**
@@ -110,6 +113,17 @@
final int transInterval,
final int numberOfThreads) throws Exception
{
+
+ final ExecutorService executor = Executors.newCachedThreadPool();
+
+ ExecutorFactory factory = new ExecutorFactory()
+ {
+ public Executor getExecutor()
+ {
+ return executor;
+ }
+ };
+
FileConfiguration configuration = new FileConfiguration();
configuration.start();
@@ -122,7 +136,7 @@
PostOffice postOffice = new FakePostOffice();
final JournalStorageManager journal = new JournalStorageManager(configuration,
- Executors.newCachedThreadPool());
+ factory);
journal.start();
HashMap<Long, Queue> queues = new HashMap<Long, Queue>();
@@ -187,6 +201,7 @@
if (transInterval > 0 && i % transInterval == 0)
{
journal.commit(trans);
+ journal.waitOnOperations();
commits++;
trans = transactionGenerator.incrementAndGet();
commitPending = false;
@@ -194,7 +209,10 @@
}
if (commitPending)
+ {
journal.commit(trans);
+ journal.waitOnOperations();
+ }
long end = System.currentTimeMillis();
Modified: branches/ClebertCallback/tests/src/org/hornetq/tests/timing/core/server/impl/QueueImplTest.java
===================================================================
--- branches/ClebertCallback/tests/src/org/hornetq/tests/timing/core/server/impl/QueueImplTest.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/tests/src/org/hornetq/tests/timing/core/server/impl/QueueImplTest.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -15,8 +15,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@@ -44,22 +42,18 @@
private ScheduledExecutorService scheduledExecutor;
- private ExecutorService executor;
+ //private ExecutorService executor;
public void setUp() throws Exception
{
super.setUp();
scheduledExecutor = new ScheduledThreadPoolExecutor(1);
-
- executor = Executors.newSingleThreadExecutor();
}
public void tearDown() throws Exception
{
scheduledExecutor.shutdownNow();
-
- executor.shutdown();
super.tearDown();
}
@@ -78,7 +72,7 @@
public void testScheduledNoConsumer() throws Exception
{
- Queue queue = new QueueImpl(1, new SimpleString("address1"), new SimpleString("queue1"), null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, new SimpleString("address1"), new SimpleString("queue1"), null, false, true, scheduledExecutor, null, null, null);
//Send one scheduled
@@ -144,7 +138,7 @@
private void testScheduled(boolean direct) throws Exception
{
- Queue queue = new QueueImpl(1,new SimpleString("address1"), new SimpleString("queue1"), null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1,new SimpleString("address1"), new SimpleString("queue1"), null, false, true, scheduledExecutor, null, null, null);
FakeConsumer consumer = null;
@@ -251,7 +245,7 @@
return HandleStatus.HANDLED;
}
};
- Queue queue = new QueueImpl(1, new SimpleString("address1"), queue1, null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, new SimpleString("address1"), queue1, null, false, true, scheduledExecutor, null, null, null);
MessageReference messageReference = generateReference(queue, 1);
queue.addConsumer(consumer);
messageReference.setScheduledDeliveryTime(System.currentTimeMillis() + 2000);
Modified: branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java
===================================================================
--- branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -1264,6 +1264,20 @@
return null;
}
+ /* (non-Javadoc)
+ * @see org.hornetq.core.persistence.StorageManager#clearContext()
+ */
+ public void clearContext()
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.hornetq.core.persistence.StorageManager#setContext(org.hornetq.core.persistence.OperationContext)
+ */
+ public void setContext(OperationContext context)
+ {
+ }
+
}
class FakeStoreFactory implements PagingStoreFactory
Modified: branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/postoffice/impl/DuplicateDetectionUnitTest.java
===================================================================
--- branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/postoffice/impl/DuplicateDetectionUnitTest.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/postoffice/impl/DuplicateDetectionUnitTest.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -17,6 +17,7 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
+import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@@ -38,6 +39,8 @@
import org.hornetq.tests.unit.core.server.impl.fakes.FakePostOffice;
import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.ServiceTestBase;
+import org.hornetq.utils.ExecutorFactory;
+import org.hornetq.utils.OrderedExecutorFactory;
import org.hornetq.utils.Pair;
import org.hornetq.utils.SimpleString;
@@ -60,6 +63,8 @@
ExecutorService executor;
+ ExecutorFactory factory;
+
@Override
protected void tearDown() throws Exception
{
@@ -71,6 +76,7 @@
{
super.setUp();
executor = Executors.newSingleThreadExecutor();
+ factory = new OrderedExecutorFactory(executor);
}
// Public --------------------------------------------------------
@@ -96,7 +102,7 @@
ScheduledExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(ConfigurationImpl.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE);
- journal = new JournalStorageManager(configuration, Executors.newCachedThreadPool());
+ journal = new JournalStorageManager(configuration, factory);
journal.start();
journal.loadBindingJournal(new ArrayList<QueueBindingInfo>(), new ArrayList<GroupingInfo>());
@@ -111,7 +117,7 @@
assertEquals(0, mapDups.size());
- DuplicateIDCacheImpl cacheID = new DuplicateIDCacheImpl(ADDRESS, 10, journal, true, executor);
+ DuplicateIDCacheImpl cacheID = new DuplicateIDCacheImpl(ADDRESS, 10, journal, true);
for (int i = 0; i < 100; i++)
{
@@ -120,7 +126,7 @@
journal.stop();
- journal = new JournalStorageManager(configuration, Executors.newCachedThreadPool());
+ journal = new JournalStorageManager(configuration, factory);
journal.start();
journal.loadBindingJournal(new ArrayList<QueueBindingInfo>(), new ArrayList<GroupingInfo>());
@@ -136,7 +142,7 @@
assertEquals(10, values.size());
- cacheID = new DuplicateIDCacheImpl(ADDRESS, 10, journal, true, executor);
+ cacheID = new DuplicateIDCacheImpl(ADDRESS, 10, journal, true);
cacheID.load(values);
for (int i = 0; i < 100; i++)
@@ -148,7 +154,7 @@
mapDups.clear();
- journal = new JournalStorageManager(configuration, Executors.newCachedThreadPool());
+ journal = new JournalStorageManager(configuration, factory);
journal.start();
journal.loadBindingJournal(new ArrayList<QueueBindingInfo>(), new ArrayList<GroupingInfo>());
Modified: branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/server/impl/QueueImplTest.java
===================================================================
--- branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/server/impl/QueueImplTest.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/server/impl/QueueImplTest.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -17,7 +17,6 @@
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@@ -46,19 +45,15 @@
private ScheduledExecutorService scheduledExecutor;
- private ExecutorService executor;
-
protected void setUp() throws Exception
{
super.setUp();
scheduledExecutor = Executors.newSingleThreadScheduledExecutor();
- executor = Executors.newSingleThreadExecutor();
}
protected void tearDown() throws Exception
{
scheduledExecutor.shutdown();
- executor.shutdown();
super.tearDown();
}
@@ -70,18 +65,18 @@
{
final SimpleString name = new SimpleString("oobblle");
- Queue queue = new QueueImpl(1, address1, name, null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, address1, name, null, false, true, scheduledExecutor, null, null, null);
assertEquals(name, queue.getName());
}
public void testDurable()
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, false, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, address1, queue1, null, false, false, scheduledExecutor, null, null, null);
assertFalse(queue.isDurable());
- queue = new QueueImpl(1, address1, queue1, null, true, false, executor, scheduledExecutor, null, null, null);
+ queue = new QueueImpl(1, address1, queue1, null, true, false, scheduledExecutor, null, null, null);
assertTrue(queue.isDurable());
}
@@ -94,7 +89,7 @@
Consumer cons3 = new FakeConsumer();
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
assertEquals(0, queue.getConsumerCount());
@@ -135,7 +130,7 @@
public void testGetFilter()
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
assertNull(queue.getFilter());
@@ -152,7 +147,7 @@
}
};
- queue = new QueueImpl(1, address1, queue1, filter, false, true, executor, scheduledExecutor, null, null, null);
+ queue = new QueueImpl(1, address1, queue1, filter, false, true, scheduledExecutor, null, null, null);
assertEquals(filter, queue.getFilter());
@@ -160,7 +155,7 @@
public void testSimpleadd()
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
final int numMessages = 10;
@@ -179,7 +174,7 @@
public void testSimpleDirectDelivery() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
FakeConsumer consumer = new FakeConsumer();
@@ -207,7 +202,7 @@
public void testSimpleNonDirectDelivery() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
final int numMessages = 10;
@@ -245,7 +240,7 @@
public void testBusyConsumer() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
FakeConsumer consumer = new FakeConsumer();
@@ -289,7 +284,7 @@
public void testBusyConsumerThenAddMoreMessages() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
FakeConsumer consumer = new FakeConsumer();
@@ -356,7 +351,7 @@
public void testAddFirstadd() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
final int numMessages = 10;
@@ -416,7 +411,7 @@
null,
false,
true,
- executor, scheduledExecutor,
+ scheduledExecutor,
new FakePostOffice(),
null,
null);
@@ -573,7 +568,7 @@
public void testConsumerReturningNull() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
class NullConsumer implements Consumer
{
@@ -606,7 +601,7 @@
public void testRoundRobinWithQueueing() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
final int numMessages = 10;
@@ -649,7 +644,7 @@
public void testRoundRobinDirect() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
final int numMessages = 10;
@@ -690,7 +685,7 @@
public void testWithPriorities() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
final int numMessages = 10;
@@ -757,7 +752,7 @@
public void testConsumerWithFilterAddAndRemove()
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
Filter filter = new FakeFilter("fruit", "orange");
@@ -766,7 +761,7 @@
public void testList()
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
final int numMessages = 20;
@@ -790,7 +785,7 @@
public void testListWithFilter()
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
final int numMessages = 20;
@@ -832,7 +827,7 @@
null,
false,
true,
- executor, scheduledExecutor,
+ scheduledExecutor,
new FakePostOffice(),
null,
null);
@@ -904,7 +899,7 @@
public void testBusyConsumerWithFilterFirstCallBusy() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
FakeConsumer consumer = new FakeConsumer(FilterImpl.createFilter("color = 'green'"));
@@ -945,7 +940,7 @@
public void testBusyConsumerWithFilterThenAddMoreMessages() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
FakeConsumer consumer = new FakeConsumer(FilterImpl.createFilter("color = 'green'"));
@@ -1019,7 +1014,7 @@
public void testConsumerWithFilterThenAddMoreMessages() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
final int numMessages = 10;
List<MessageReference> refs = new ArrayList<MessageReference>();
@@ -1089,7 +1084,7 @@
null,
false,
true,
- executor, scheduledExecutor,
+ scheduledExecutor,
new FakePostOffice(),
null,
null);
@@ -1181,7 +1176,7 @@
public void testMessageOrder() throws Exception
{
FakeConsumer consumer = new FakeConsumer();
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
MessageReference messageReference = generateReference(queue, 1);
MessageReference messageReference2 = generateReference(queue, 2);
MessageReference messageReference3 = generateReference(queue, 3);
@@ -1201,7 +1196,7 @@
public void testMessagesAdded() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
MessageReference messageReference = generateReference(queue, 1);
MessageReference messageReference2 = generateReference(queue, 2);
MessageReference messageReference3 = generateReference(queue, 3);
@@ -1213,7 +1208,7 @@
public void testGetReference() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
MessageReference messageReference = generateReference(queue, 1);
MessageReference messageReference2 = generateReference(queue, 2);
MessageReference messageReference3 = generateReference(queue, 3);
@@ -1226,7 +1221,7 @@
public void testGetNonExistentReference() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
MessageReference messageReference = generateReference(queue, 1);
MessageReference messageReference2 = generateReference(queue, 2);
MessageReference messageReference3 = generateReference(queue, 3);
@@ -1243,7 +1238,7 @@
*/
public void testPauseAndResumeWithAsync() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
// pauses the queue
queue.pause();
@@ -1298,7 +1293,7 @@
public void testPauseAndResumeWithDirect() throws Exception
{
- Queue queue = new QueueImpl(1, address1, queue1, null, false, true, executor, scheduledExecutor, null, null, null);
+ Queue queue = new QueueImpl(1, address1, queue1, null, false, true, scheduledExecutor, null, null, null);
// Now add a consumer
FakeConsumer consumer = new FakeConsumer();
Modified: branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/server/impl/fakes/FakeQueueFactory.java
===================================================================
--- branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/server/impl/fakes/FakeQueueFactory.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/server/impl/fakes/FakeQueueFactory.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -35,14 +35,12 @@
{
private final ScheduledExecutorService scheduledExecutor = Executors.newSingleThreadScheduledExecutor();
- private final ExecutorService executor = Executors.newSingleThreadExecutor();
-
private PostOffice postOffice;
public Queue createQueue(long persistenceID, final SimpleString address, SimpleString name, Filter filter,
boolean durable, boolean temporary)
{
- return new QueueImpl(persistenceID, address, name, filter, durable, temporary, executor, scheduledExecutor, postOffice, null, null);
+ return new QueueImpl(persistenceID, address, name, filter, durable, temporary, scheduledExecutor, postOffice, null, null);
}
public void setPostOffice(PostOffice postOffice)
@@ -54,8 +52,6 @@
public void stop() throws Exception
{
scheduledExecutor.shutdown();
-
- executor.shutdown();
}
}
Modified: branches/ClebertCallback/tests/src/org/hornetq/tests/util/UnitTestCase.java
===================================================================
--- branches/ClebertCallback/tests/src/org/hornetq/tests/util/UnitTestCase.java 2009-11-22 18:49:03 UTC (rev 8368)
+++ branches/ClebertCallback/tests/src/org/hornetq/tests/util/UnitTestCase.java 2009-11-23 02:04:55 UTC (rev 8369)
@@ -50,6 +50,8 @@
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.journal.impl.AIOSequentialFileFactory;
import org.hornetq.core.logging.Logger;
+import org.hornetq.core.persistence.impl.journal.JournalStorageManager;
+import org.hornetq.core.persistence.impl.journal.OperationContextImpl;
import org.hornetq.core.postoffice.Binding;
import org.hornetq.core.postoffice.Bindings;
import org.hornetq.core.postoffice.PostOffice;
@@ -647,6 +649,8 @@
@Override
protected void tearDown() throws Exception
{
+ OperationContextImpl.clearContext();
+
deleteDirectory(new File(getTestDir()));
assertEquals(0, InVMRegistry.instance.size());
15 years, 1 month
JBoss hornetq SVN: r8368 - in branches/20-optimisation: tests/src/org/hornetq/tests/integration/client and 1 other directory.
by do-not-reply@jboss.org
Author: timfox
Date: 2009-11-22 13:49:03 -0500 (Sun, 22 Nov 2009)
New Revision: 8368
Added:
branches/20-optimisation/src/main/org/hornetq/core/buffers/ResetLimitWrappedHornetQBuffer.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/InVMNonPersistentMessageBufferTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/InVMPersistentMessageBufferTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/NettyNonPersistentMessageBufferTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/NettyPersistentMessageBufferTest.java
Log:
optimisation
Added: branches/20-optimisation/src/main/org/hornetq/core/buffers/ResetLimitWrappedHornetQBuffer.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/buffers/ResetLimitWrappedHornetQBuffer.java (rev 0)
+++ branches/20-optimisation/src/main/org/hornetq/core/buffers/ResetLimitWrappedHornetQBuffer.java 2009-11-22 18:49:03 UTC (rev 8368)
@@ -0,0 +1,327 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.core.buffers;
+
+import org.hornetq.core.logging.Logger;
+import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.utils.SimpleString;
+
+/**
+ * A ResetLimitWrappedHornetQBuffer
+ *
+ * @author Tim Fox
+ *
+ */
+public class ResetLimitWrappedHornetQBuffer implements HornetQBuffer
+{
+ private static final Logger log = Logger.getLogger(ResetLimitWrappedHornetQBuffer.class);
+
+ private final int limit;
+
+ private HornetQBuffer buffer;
+
+ public ResetLimitWrappedHornetQBuffer(final int limit, final HornetQBuffer buffer)
+ {
+ this.limit = limit;
+
+ this.buffer = buffer;
+
+ this.resetReaderIndex();
+ }
+
+ public void setBuffer(HornetQBuffer buffer)
+ {
+ this.buffer = buffer;
+ }
+
+ public byte[] array()
+ {
+ return buffer.array();
+ }
+
+ public int capacity()
+ {
+ return buffer.capacity();
+ }
+
+ public void clear()
+ {
+ buffer.clear();
+
+ buffer.setIndex(limit, limit);
+ }
+
+ public HornetQBuffer copy()
+ {
+ return buffer.copy();
+ }
+
+ public Object getUnderlyingBuffer()
+ {
+ return buffer.getUnderlyingBuffer();
+ }
+
+ public boolean readable()
+ {
+ return buffer.readable();
+ }
+
+ public int readableBytes()
+ {
+ return buffer.readableBytes();
+ }
+
+ public boolean readBoolean()
+ {
+ return buffer.readBoolean();
+ }
+
+ public byte readByte()
+ {
+ return buffer.readByte();
+ }
+
+ public void readBytes(byte[] bytes, int offset, int length)
+ {
+ buffer.readBytes(bytes, offset, length);
+ }
+
+ public void readBytes(byte[] bytes)
+ {
+ buffer.readBytes(bytes);
+ }
+
+ public char readChar()
+ {
+ return buffer.readChar();
+ }
+
+ public double readDouble()
+ {
+ return buffer.readDouble();
+ }
+
+ public int readerIndex()
+ {
+ return buffer.readerIndex();
+ }
+
+ public void readerIndex(int readerIndex)
+ {
+ if (readerIndex < limit)
+ {
+ readerIndex = limit;
+ }
+
+ buffer.readerIndex(readerIndex);
+ }
+
+ public float readFloat()
+ {
+ return buffer.readFloat();
+ }
+
+ public int readInt()
+ {
+ return buffer.readInt();
+ }
+
+ public int readInt(int pos)
+ {
+ return buffer.readInt(pos);
+ }
+
+ public long readLong()
+ {
+ return buffer.readLong();
+ }
+
+ public SimpleString readNullableSimpleString()
+ {
+ return buffer.readNullableSimpleString();
+ }
+
+ public String readNullableString()
+ {
+ return buffer.readNullableString();
+ }
+
+ public short readShort()
+ {
+ return buffer.readShort();
+ }
+
+ public SimpleString readSimpleString()
+ {
+ return buffer.readSimpleString();
+ }
+
+ public String readString()
+ {
+ return buffer.readString();
+ }
+
+ public short readUnsignedByte()
+ {
+ return buffer.readUnsignedByte();
+ }
+
+ public int readUnsignedShort()
+ {
+ return buffer.readUnsignedShort();
+ }
+
+ public String readUTF() throws Exception
+ {
+ return buffer.readUTF();
+ }
+
+ public void resetReaderIndex()
+ {
+ buffer.readerIndex(limit);
+ }
+
+ public void resetWriterIndex()
+ {
+ buffer.writerIndex(limit);
+ }
+
+ public void setIndex(int readerIndex, int writerIndex)
+ {
+ if (readerIndex < limit)
+ {
+ readerIndex = limit;
+ }
+ if (writerIndex < limit)
+ {
+ writerIndex = limit;
+ }
+ buffer.setIndex(readerIndex, writerIndex);
+ }
+
+ public void setInt(int pos, int val)
+ {
+ buffer.setInt(pos, val);
+ }
+
+ public HornetQBuffer slice(int index, int length)
+ {
+ return buffer.slice(index, length);
+ }
+
+ public boolean writable()
+ {
+ return buffer.writable();
+ }
+
+ public int writableBytes()
+ {
+ return buffer.writableBytes();
+ }
+
+ public void writeBoolean(boolean val)
+ {
+ buffer.writeBoolean(val);
+ }
+
+ public void writeByte(byte val)
+ {
+ buffer.writeByte(val);
+ }
+
+ public void writeBytes(byte[] bytes, int offset, int length)
+ {
+ buffer.writeBytes(bytes, offset, length);
+ }
+
+ public void writeBytes(byte[] bytes)
+ {
+ buffer.writeBytes(bytes);
+ }
+
+ public void writeBytes(HornetQBuffer src, int srcIndex, int length)
+ {
+ buffer.writeBytes(src, srcIndex, length);
+ }
+
+ public void writeChar(char val)
+ {
+ buffer.writeChar(val);
+ }
+
+ public void writeDouble(double val)
+ {
+ buffer.writeDouble(val);
+ }
+
+ public void writeFloat(float val)
+ {
+ buffer.writeFloat(val);
+ }
+
+ public void writeInt(int val)
+ {
+ buffer.writeInt(val);
+ }
+
+ public void writeLong(long val)
+ {
+ buffer.writeLong(val);
+ }
+
+ public void writeNullableSimpleString(SimpleString val)
+ {
+ buffer.writeNullableSimpleString(val);
+ }
+
+ public void writeNullableString(String val)
+ {
+ buffer.writeNullableString(val);
+ }
+
+ public int writerIndex()
+ {
+ return buffer.writerIndex();
+ }
+
+ public void writerIndex(int writerIndex)
+ {
+ if (writerIndex < limit)
+ {
+ writerIndex = limit;
+ }
+ buffer.writerIndex(writerIndex);
+ }
+
+ public void writeShort(short val)
+ {
+ buffer.writeShort(val);
+ }
+
+ public void writeSimpleString(SimpleString val)
+ {
+ buffer.writeSimpleString(val);
+ }
+
+ public void writeString(String val)
+ {
+ buffer.writeString(val);
+ }
+
+ public void writeUTF(String utf) throws Exception
+ {
+ buffer.writeUTF(utf);
+ }
+
+}
Added: branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/InVMNonPersistentMessageBufferTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/InVMNonPersistentMessageBufferTest.java (rev 0)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/InVMNonPersistentMessageBufferTest.java 2009-11-22 18:49:03 UTC (rev 8368)
@@ -0,0 +1,256 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.hornetq.tests.integration.client;
+
+import org.hornetq.core.client.ClientConsumer;
+import org.hornetq.core.client.ClientMessage;
+import org.hornetq.core.client.ClientProducer;
+import org.hornetq.core.client.ClientSession;
+import org.hornetq.core.client.ClientSessionFactory;
+import org.hornetq.core.logging.Logger;
+import org.hornetq.core.remoting.impl.wireformat.PacketImpl;
+import org.hornetq.core.server.HornetQServer;
+import org.hornetq.tests.util.RandomUtil;
+import org.hornetq.tests.util.ServiceTestBase;
+import org.hornetq.utils.DataConstants;
+
+public class InVMNonPersistentMessageBufferTest extends ServiceTestBase
+{
+ private static final Logger log = Logger.getLogger(InVMNonPersistentMessageBufferTest.class);
+
+ public static final String address = "testaddress";
+
+ public static final String queueName = "testqueue";
+
+ private HornetQServer server;
+
+ private ClientSession session;
+
+ private ClientProducer producer;
+
+ private ClientConsumer consumer;
+
+ /*
+ * Test message can be read after being sent
+ * Message can be sent multiple times
+ * After sending, local message can be read
+ * After sending, local message body can be added to and sent
+ * When reset message body it should only reset to after packet headers
+ * Should not be able to read past end of body into encoded message
+ */
+
+ public void testSimpleSendReceive() throws Exception
+ {
+ ClientMessage message = session.createClientMessage(false);
+
+ final String body = RandomUtil.randomString();
+
+ message.getBodyBuffer().writeString(body);
+
+ ClientMessage received = sendAndReceive(message);
+
+ assertNotNull(received);
+
+ assertEquals(body, received.getBodyBuffer().readString());
+ }
+
+ public void testSendSameMessageMultipleTimes() throws Exception
+ {
+ ClientMessage message = session.createClientMessage(false);
+
+ final String body = RandomUtil.randomString();
+
+ message.getBodyBuffer().writeString(body);
+
+ int bodySize = message.getBodySize();
+
+ for (int i = 0; i < 10; i++)
+ {
+ ClientMessage received = sendAndReceive(message);
+
+ assertNotNull(received);
+
+ assertEquals(bodySize, received.getBodySize());
+
+ assertEquals(body, received.getBodyBuffer().readString());
+
+ assertFalse(received.getBodyBuffer().readable());
+ }
+ }
+
+ public void testSendMessageResetSendAgainDifferentBody() throws Exception
+ {
+ ClientMessage message = session.createClientMessage(false);
+
+ for (int i = 0; i < 10; i++)
+ {
+ final String body = RandomUtil.randomString();
+
+ message.getBodyBuffer().writeString(body);
+
+ int bodySize = message.getBodySize();
+
+ ClientMessage received = sendAndReceive(message);
+
+ assertNotNull(received);
+
+ assertEquals(bodySize, received.getBodySize());
+
+ assertEquals(body, received.getBodyBuffer().readString());
+
+ assertFalse(received.getBodyBuffer().readable());
+
+ message.getBodyBuffer().clear();
+
+ assertEquals(PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT, message.getBodyBuffer().writerIndex());
+
+ assertEquals(PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT, message.getBodyBuffer().readerIndex());
+ }
+ }
+
+ public void testCannotReadPastEndOfMessageBody() throws Exception
+ {
+ ClientMessage message = session.createClientMessage(false);
+
+ final String body = RandomUtil.randomString();
+
+ message.getBodyBuffer().writeString(body);
+
+ ClientMessage received = sendAndReceive(message);
+
+ assertNotNull(received);
+
+ assertEquals(body, received.getBodyBuffer().readString());
+
+ try
+ {
+ received.getBodyBuffer().readByte();
+
+ fail("Should throw exception");
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ // OK
+ }
+ }
+
+ public void testCanReReadBodyAfterReaderReset() throws Exception
+ {
+ ClientMessage message = session.createClientMessage(false);
+
+ final String body = RandomUtil.randomString();
+
+ message.getBodyBuffer().writeString(body);
+
+ assertEquals(PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT, message.getBodyBuffer().readerIndex());
+
+ String body2 = message.getBodyBuffer().readString();
+
+ assertEquals(body, body2);
+
+ message.getBodyBuffer().resetReaderIndex();
+
+ assertEquals(PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT, message.getBodyBuffer().readerIndex());
+
+ String body3 = message.getBodyBuffer().readString();
+
+ assertEquals(body, body3);
+
+ ClientMessage received = sendAndReceive(message);
+
+ assertNotNull(received);
+
+ assertEquals(body, received.getBodyBuffer().readString());
+
+ received.getBodyBuffer().resetReaderIndex();
+
+ assertEquals(PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT, received.getBodyBuffer().readerIndex());
+
+ String body4 = received.getBodyBuffer().readString();
+
+ assertEquals(body, body4);
+
+ }
+
+ protected ClientSessionFactory createFactory()
+ {
+ if (isNetty())
+ {
+ return this.createNettyFactory();
+ }
+ else
+ {
+ return this.createInVMFactory();
+ }
+ }
+
+ protected boolean isNetty()
+ {
+ return false;
+ }
+
+ protected boolean isPersistent()
+ {
+ return false;
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ server = createServer(isPersistent(), isNetty());
+
+ server.start();
+
+ ClientSessionFactory cf = createFactory();
+
+ session = cf.createSession();
+
+ session.createQueue(address, queueName);
+
+ producer = session.createProducer(address);
+
+ consumer = session.createConsumer(queueName);
+
+ session.start();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ if (session != null)
+ {
+ consumer.close();
+
+ session.deleteQueue(queueName);
+
+ session.close();
+ }
+
+ if (server.isStarted())
+ {
+ server.stop();
+ }
+
+ super.tearDown();
+ }
+
+ private ClientMessage sendAndReceive(final ClientMessage message) throws Exception
+ {
+ producer.send(message);
+
+ ClientMessage received = consumer.receive(10000);
+
+ return received;
+ }
+
+}
Added: branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/InVMPersistentMessageBufferTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/InVMPersistentMessageBufferTest.java (rev 0)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/InVMPersistentMessageBufferTest.java 2009-11-22 18:49:03 UTC (rev 8368)
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.tests.integration.client;
+
+/**
+ * A InVMPersistentMessageBufferTest
+ *
+ * @author tim
+ *
+ *
+ */
+public class InVMPersistentMessageBufferTest extends InVMNonPersistentMessageBufferTest
+{
+ public boolean isPersistent()
+ {
+ return true;
+ }
+
+ public boolean isNetty()
+ {
+ return false;
+ }
+}
Added: branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/NettyNonPersistentMessageBufferTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/NettyNonPersistentMessageBufferTest.java (rev 0)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/NettyNonPersistentMessageBufferTest.java 2009-11-22 18:49:03 UTC (rev 8368)
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.tests.integration.client;
+
+/**
+ * A NettyNonPersistentMessageBufferTest
+ *
+ * @author tim
+ *
+ *
+ */
+public class NettyNonPersistentMessageBufferTest extends InVMNonPersistentMessageBufferTest
+{
+ public boolean isPersistent()
+ {
+ return false;
+ }
+
+ public boolean isNetty()
+ {
+ return true;
+ }
+}
Added: branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/NettyPersistentMessageBufferTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/NettyPersistentMessageBufferTest.java (rev 0)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/NettyPersistentMessageBufferTest.java 2009-11-22 18:49:03 UTC (rev 8368)
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.tests.integration.client;
+
+/**
+ * A NettyPersistentMessageBufferTest
+ *
+ * @author tim
+ *
+ *
+ */
+public class NettyPersistentMessageBufferTest extends InVMNonPersistentMessageBufferTest
+{
+ public boolean isPersistent()
+ {
+ return true;
+ }
+
+ public boolean isNetty()
+ {
+ return true;
+ }
+}
15 years, 1 month
JBoss hornetq SVN: r8367 - in branches/20-optimisation: src/main/org/hornetq/core/buffers and 41 other directories.
by do-not-reply@jboss.org
Author: timfox
Date: 2009-11-22 13:47:45 -0500 (Sun, 22 Nov 2009)
New Revision: 8367
Added:
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/LargeServerMessageImpl.java
Removed:
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/FileLargeServerMessage.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/EncodeSizeTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/persistence/JournalStorageManagerIntegrationTest.java
Modified:
branches/20-optimisation/examples/core/perf/src/org/hornetq/core/example/PerfBase.java
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQAbstractChannelBuffer.java
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQByteBufferBackedChannelBuffer.java
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQDynamicChannelBuffer.java
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQHeapChannelBuffer.java
branches/20-optimisation/src/main/org/hornetq/core/client/ClientMessage.java
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientMessageImpl.java
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientProducerCreditsImpl.java
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientProducerImpl.java
branches/20-optimisation/src/main/org/hornetq/core/client/impl/LargeMessageBufferImpl.java
branches/20-optimisation/src/main/org/hornetq/core/client/management/impl/ManagementHelper.java
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/JournalImpl.java
branches/20-optimisation/src/main/org/hornetq/core/message/Message.java
branches/20-optimisation/src/main/org/hornetq/core/message/impl/MessageImpl.java
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PageImpl.java
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PagedMessageImpl.java
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/invm/InVMConnection.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionReceiveMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionSendMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/spi/HornetQBuffer.java
branches/20-optimisation/src/main/org/hornetq/core/server/ServerMessage.java
branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerMessageImpl.java
branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/ChannelBufferWrapper.java
branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/NettyConnection.java
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQBytesMessage.java
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMapMessage.java
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMessage.java
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMessageProducer.java
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQObjectMessage.java
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQStreamMessage.java
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQTextMessage.java
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/MessageConsumerTest.java
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/JMSExpirationHeaderTest.java
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/JMSMessageIDHeaderTest.java
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageBodyTest.java
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageHeaderTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/String64KLimitTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/AddressSettingsTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ConsumerRoundRobinTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ConsumerTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ConsumerWindowSizeTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/CoreClientTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/DeadLetterAddressTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/DeliveryOrderTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ExpiryAddressTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/HeuristicXATest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/JournalCrashTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/LargeMessageTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/MessageCounterTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/MessageGroupingTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/MessagePriorityTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/NewDeadLetterAddressTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/PagingTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ProducerFlowControlTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ProducerTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/QueueBrowserTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ReceiveImmediateTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/SelfExpandingBufferTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/SessionCreateProducerTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/WildCardRoutingTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/ClientCrashTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/ClientExitTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/CrashClient.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/GracefulClient.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/bridge/SimpleTransformer.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/AsynchronousFailoverTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/LargeMessageFailoverTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/reattach/MultiThreadRandomReattachTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/reattach/ReattachTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/http/CoreClientOverHttpTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/largemessage/LargeMessageTestBase.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/largemessage/ServerLargeMessageTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/management/AddressControlTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/management/ManagementHelperTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/paging/PageCrashTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/scheduling/DelayedMessageTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/scheduling/ScheduledMessageTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/security/SimpleClient.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/server/ExpiryRunnerTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/server/LVQRecoveryTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/server/LVQTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSL.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/xa/BasicXaRecoveryTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/xa/BasicXaTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/xa/XaTimeoutTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/performance/paging/MeasurePagingMultiThreadTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/performance/persistence/StorageManagerTimingTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/CompactingStressTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/NIOMultiThreadCompactorStressTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/client/impl/LargeMessageBufferTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/message/impl/MessageImplTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PageImplTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingManagerImplTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingsImplTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/util/ServiceTestBase.java
branches/20-optimisation/tests/src/org/hornetq/tests/util/UnitTestCase.java
Log:
optimisation
Modified: branches/20-optimisation/examples/core/perf/src/org/hornetq/core/example/PerfBase.java
===================================================================
--- branches/20-optimisation/examples/core/perf/src/org/hornetq/core/example/PerfBase.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/examples/core/perf/src/org/hornetq/core/example/PerfBase.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -355,7 +355,7 @@
byte[] payload = randomByteArray(messageSize);
- message.getBuffer().writeBytes(payload);
+ message.getBodyBuffer().writeBytes(payload);
final int modulo = 2000;
Modified: branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQAbstractChannelBuffer.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQAbstractChannelBuffer.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQAbstractChannelBuffer.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -454,7 +454,23 @@
public void writeBytes(final HornetQBuffer src, final int srcIndex, final int length)
{
- writeBytes((HornetQChannelBuffer)src, srcIndex, length);
+ if (src instanceof HornetQChannelBuffer)
+ {
+ writeBytes((HornetQChannelBuffer)src, srcIndex, length);
+ }
+ else
+ {
+ //There is a bug in Netty readBytes() which doesn't let us to do this, so we workaround it
+// byte[] bytes = new byte[length];
+//
+// src.readBytes(bytes, srcIndex, length);
+//
+// writeBytes(bytes);
+
+ byte[] bytes = src.array();
+
+ writeBytes(bytes, srcIndex, length);
+ }
}
public void writeBytes(final ByteBuffer src)
@@ -784,5 +800,5 @@
{
UTF8Util.saveUTF(this, utf);
}
-
+
}
Modified: branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQByteBufferBackedChannelBuffer.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQByteBufferBackedChannelBuffer.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQByteBufferBackedChannelBuffer.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -378,7 +378,23 @@
{
ByteBuffer newBuffer = ByteBuffer.allocate(buffer.remaining());
newBuffer.put(buffer);
- newBuffer.flip();
+ newBuffer.flip();
return new HornetQByteBufferBackedChannelBuffer(newBuffer);
}
+
+ public HornetQBuffer slice(int index, int length)
+ {
+ int currentPos = buffer.position();
+ int currentLimit = buffer.limit();
+
+ buffer.position(index);
+ buffer.limit(length);
+
+ ByteBuffer sliced = buffer.slice();
+
+ buffer.position(currentPos);
+ buffer.limit(currentLimit);
+
+ return new HornetQByteBufferBackedChannelBuffer(sliced);
+ }
}
Modified: branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQDynamicChannelBuffer.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQDynamicChannelBuffer.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQDynamicChannelBuffer.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -20,6 +20,7 @@
import java.nio.channels.GatheringByteChannel;
import java.nio.channels.ScatteringByteChannel;
+import org.hornetq.core.logging.Logger;
import org.hornetq.core.remoting.spi.HornetQBuffer;
/**
@@ -35,6 +36,8 @@
*/
public class HornetQDynamicChannelBuffer extends HornetQAbstractChannelBuffer
{
+ private static final Logger log = Logger.getLogger(HornetQDynamicChannelBuffer.class);
+
private final int initialCapacity;
private HornetQChannelBuffer buffer = HornetQChannelBuffers.EMPTY_BUFFER;
@@ -199,7 +202,7 @@
@Override
public void writeBytes(final byte[] src, final int srcIndex, final int length)
- {
+ {
ensureWritableBytes(length);
super.writeBytes(src, srcIndex, length);
}
@@ -217,7 +220,7 @@
ensureWritableBytes(src.remaining());
super.writeBytes(src);
}
-
+
@Override
public void writeZero(final int length)
{
@@ -278,5 +281,10 @@
{
return new HornetQDynamicChannelBuffer(buffer.copy().array());
}
+
+ public HornetQBuffer slice(int index, int length)
+ {
+ return buffer.slice(index, length);
+ }
}
Modified: branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQHeapChannelBuffer.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQHeapChannelBuffer.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQHeapChannelBuffer.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -313,5 +313,19 @@
{
return new HornetQHeapChannelBuffer(array.clone());
}
+
+ public HornetQBuffer slice(int index, int length)
+ {
+ //FIXME - this is currently very inefficient since we just copy the underlying array
+ //We should really get rid of these versions of the Netty classes and just use the real
+ //Netty classes, since these don't have all the functionality and fixes.
+ //However this will introduce a dependency on Netty on core
+
+ byte[] copied = new byte[length];
+
+ System.arraycopy(array, index, copied, 0, length);
+
+ return new HornetQHeapChannelBuffer(copied);
+ }
}
Modified: branches/20-optimisation/src/main/org/hornetq/core/client/ClientMessage.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/client/ClientMessage.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/core/client/ClientMessage.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -18,7 +18,6 @@
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.message.Message;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
/**
*
@@ -34,9 +33,7 @@
void setDeliveryCount(int deliveryCount);
- void acknowledge() throws HornetQException;
-
- void resetBuffer();
+ void acknowledge() throws HornetQException;
//FIXME - the following are only used for large messages - they should be put somewhere else:
@@ -56,4 +53,6 @@
boolean waitOutputStreamCompletion(long timeMilliseconds) throws HornetQException;
void setBodyInputStream(InputStream bodyInputStream);
+
+ int getBodySize();
}
Modified: branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientMessageImpl.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientMessageImpl.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientMessageImpl.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -17,16 +17,15 @@
import java.io.InputStream;
import java.io.OutputStream;
+import org.hornetq.core.buffers.ResetLimitWrappedHornetQBuffer;
import org.hornetq.core.client.LargeMessageBuffer;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.message.impl.MessageImpl;
import org.hornetq.core.remoting.impl.wireformat.PacketImpl;
import org.hornetq.core.remoting.spi.HornetQBuffer;
-import org.hornetq.integration.transports.netty.ChannelBufferWrapper;
import org.hornetq.utils.DataConstants;
import org.hornetq.utils.SimpleString;
-import org.jboss.netty.buffer.ChannelBuffer;
/**
*
@@ -64,15 +63,15 @@
/*
* Construct messages before sending
*/
- ClientMessageImpl(final byte type,
- final boolean durable,
- final long expiration,
- final long timestamp,
- final byte priority,
- final HornetQBuffer buffer)
+ public ClientMessageImpl(final byte type,
+ final boolean durable,
+ final long expiration,
+ final long timestamp,
+ final byte priority,
+ final HornetQBuffer buffer)
{
- super(type, durable, expiration, timestamp, priority, buffer);
-
+ super(type, durable, expiration, timestamp, priority, buffer);
+
this.resetBuffer();
}
@@ -129,11 +128,11 @@
this.largeMessage = largeMessage;
}
- @Override
- public void afterSend()
+ public int getBodySize()
{
+ return buffer.writerIndex() - buffer.readerIndex();
}
-
+
@Override
public String toString()
{
@@ -154,7 +153,7 @@
{
if (largeMessage)
{
- return ((LargeMessageBuffer)getBuffer()).getSize();
+ return ((LargeMessageBuffer)getWholeBuffer()).getSize();
}
else
{
@@ -169,13 +168,13 @@
{
if (largeMessage)
{
- ((LargeMessageBufferImpl)this.getBuffer()).saveBuffer(out);
+ ((LargeMessageBufferImpl)this.getWholeBuffer()).saveBuffer(out);
}
else
{
try
{
- out.write(this.getBuffer().array());
+ out.write(this.getWholeBuffer().array());
}
catch (IOException e)
{
@@ -192,7 +191,7 @@
{
if (largeMessage)
{
- ((LargeMessageBufferImpl)this.getBuffer()).setOutputStream(out);
+ ((LargeMessageBufferImpl)this.getWholeBuffer()).setOutputStream(out);
}
else
{
@@ -208,7 +207,7 @@
{
if (largeMessage)
{
- return ((LargeMessageBufferImpl)this.getBuffer()).waitCompletion(timeMilliseconds);
+ return ((LargeMessageBufferImpl)this.getWholeBuffer()).waitCompletion(timeMilliseconds);
}
else
{
@@ -223,15 +222,10 @@
{
if (largeMessage)
{
- ((LargeMessageBuffer)getBuffer()).discardUnusedPackets();
+ ((LargeMessageBuffer)getWholeBuffer()).discardUnusedPackets();
}
}
- public void setBuffer(final HornetQBuffer buffer)
- {
- this.buffer = buffer;
- }
-
/**
* @return the bodyInputStream
*/
Modified: branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientProducerCreditsImpl.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientProducerCreditsImpl.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientProducerCreditsImpl.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -63,14 +63,18 @@
public void acquireCredits(int credits) throws InterruptedException
{
// credits += offset;
-
+
+ // log.info("trying to acquire " + credits);
+
checkCredits(credits);
-
+
semaphore.acquire(credits);
}
public void receiveCredits(final int credits, final int offset)
{
+ // log.info("receiving credits " + credits);
+
synchronized (this)
{
arriving -= credits;
@@ -117,6 +121,7 @@
if (toRequest != -1)
{
+ //log.info("sending request for credits " + toRequest);
requestCredits(toRequest);
}
}
Modified: branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientProducerImpl.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientProducerImpl.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientProducerImpl.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -32,7 +32,6 @@
import org.hornetq.utils.SimpleString;
import org.hornetq.utils.TokenBucketLimiter;
import org.hornetq.utils.UUIDGenerator;
-import org.jboss.netty.buffer.ChannelBuffers;
/**
* The client-side Producer connectionFactory class.
@@ -304,9 +303,9 @@
}
// msg.getBody() could be Null on LargeServerMessage
- if (msg.getBodyInputStream() == null && msg.getBuffer() != null)
+ if (msg.getBodyInputStream() == null && msg.getWholeBuffer() != null)
{
- msg.getBuffer().readerIndex(0);
+ msg.getWholeBuffer().readerIndex(0);
}
HornetQBuffer headerBuffer = HornetQChannelBuffers.buffer(headerSize);
Modified: branches/20-optimisation/src/main/org/hornetq/core/client/impl/LargeMessageBufferImpl.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/client/impl/LargeMessageBufferImpl.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/core/client/impl/LargeMessageBufferImpl.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -27,7 +27,6 @@
import java.util.concurrent.TimeUnit;
import org.hornetq.core.buffers.HornetQChannelBuffer;
-import org.hornetq.core.buffers.HornetQDynamicChannelBuffer;
import org.hornetq.core.client.LargeMessageBuffer;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.logging.Logger;
@@ -1200,6 +1199,11 @@
{
throw new UnsupportedOperationException();
}
+
+ public HornetQBuffer slice(int index, int length)
+ {
+ throw new UnsupportedOperationException();
+ }
// Package protected ---------------------------------------------
Modified: branches/20-optimisation/src/main/org/hornetq/core/client/management/impl/ManagementHelper.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/client/management/impl/ManagementHelper.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/core/client/management/impl/ManagementHelper.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -118,7 +118,7 @@
paramString = null;
}
- message.getBuffer().writeNullableString(paramString);
+ message.getBodyBuffer().writeNullableString(paramString);
}
private static JSONArray toJSONArray(final Object[] array) throws Exception
@@ -273,7 +273,7 @@
public static Object[] retrieveOperationParameters(final Message message) throws Exception
{
- String jsonString = message.getBuffer().readNullableString();
+ String jsonString = message.getBodyBuffer().readNullableString();
if (jsonString != null)
{
@@ -314,12 +314,12 @@
resultString = null;
}
- message.getBuffer().writeNullableString(resultString);
+ message.getBodyBuffer().writeNullableString(resultString);
}
public static Object[] getResults(final Message message) throws Exception
{
- String jsonString = message.getBuffer().readNullableString();
+ String jsonString = message.getBodyBuffer().readNullableString();
if (jsonString != null)
{
Modified: branches/20-optimisation/src/main/org/hornetq/core/journal/impl/JournalImpl.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/journal/impl/JournalImpl.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/core/journal/impl/JournalImpl.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -416,14 +416,14 @@
final EncodingSupport record,
final int size,
final HornetQChannelBuffer bb)
- {
+ {
bb.writeByte(ADD_RECORD);
bb.writeInt(fileId);
bb.writeLong(id);
bb.writeInt(record.getEncodeSize());
bb.writeByte(recordType);
- record.encode(bb);
- bb.writeInt(size);
+ record.encode(bb);
+ bb.writeInt(size);
}
/**
@@ -511,12 +511,10 @@
final JournalFile file,
final JournalReaderCallback reader) throws Exception
{
-
file.getFile().open(1);
ByteBuffer wholeFileBuffer = null;
try
{
-
final int filesize = (int)file.getFile().size();
wholeFileBuffer = fileFactory.newBuffer((int)filesize);
@@ -736,13 +734,13 @@
switch (recordType)
{
case ADD_RECORD:
- {
+ {
reader.onReadAddRecord(new RecordInfo(recordID, userRecordType, record, false));
break;
}
case UPDATE_RECORD:
- {
+ {
reader.onReadUpdateRecord(new RecordInfo(recordID, userRecordType, record, true));
break;
}
@@ -857,7 +855,7 @@
compactingLock.readLock().lock();
try
- {
+ {
int size = SIZE_ADD_RECORD + record.getEncodeSize();
HornetQChannelBuffer bb = newBuffer(size);
@@ -1706,7 +1704,6 @@
int lastDataPos = SIZE_HEADER;
final AtomicLong maxID = new AtomicLong(-1);
- // long maxID = -1;
for (final JournalFile file : orderedFiles)
{
Modified: branches/20-optimisation/src/main/org/hornetq/core/message/Message.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/message/Message.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/core/message/Message.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -64,6 +64,9 @@
int getEncodeSize();
boolean isLargeMessage();
+
+ HornetQBuffer getBodyBuffer();
+
// Properties
// ------------------------------------------------------------------
@@ -173,7 +176,7 @@
int getHeadersAndPropertiesEncodeSize();
- HornetQBuffer getBuffer();
+ HornetQBuffer getWholeBuffer();
void setBuffer(HornetQBuffer buffer);
@@ -188,11 +191,7 @@
// Sending stuff
-
- void afterSend();
-
- boolean isBufferWritten();
-
+
boolean isEncodedToBuffer();
void decodeFromWire(HornetQBuffer buffer);
Modified: branches/20-optimisation/src/main/org/hornetq/core/message/impl/MessageImpl.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/message/impl/MessageImpl.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/core/message/impl/MessageImpl.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -13,7 +13,6 @@
package org.hornetq.core.message.impl;
-import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.PACKET_HEADERS_SIZE;
import static org.hornetq.utils.DataConstants.SIZE_BOOLEAN;
import static org.hornetq.utils.DataConstants.SIZE_BYTE;
import static org.hornetq.utils.DataConstants.SIZE_LONG;
@@ -24,6 +23,8 @@
import java.util.Set;
import org.hornetq.core.buffers.HornetQChannelBuffers;
+import org.hornetq.core.buffers.ResetLimitWrappedHornetQBuffer;
+import org.hornetq.core.client.LargeMessageBuffer;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.message.BodyEncoder;
@@ -139,36 +140,11 @@
// Message implementation ----------------------------------------
- public void afterSend()
- {
- }
-
- public boolean isBufferWritten()
- {
- return false;
- }
-
- public void resetBuffer()
- {
- //There is a bug in Netty which requires us to initially write a byte
- if (buffer.capacity() == 0)
- {
- buffer.writeByte((byte)0);
- }
-
- buffer.setIndex(0, PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT);
- }
-
public int getEncodeSize()
{
return encodeSize;
}
- public int getBodySize()
- {
- return buffer.writerIndex();
- }
-
public void encodeHeadersAndProperties(final HornetQBuffer buffer)
{
buffer.writeLong(messageID);
@@ -179,7 +155,7 @@
buffer.writeLong(timestamp);
buffer.writeByte(priority);
properties.encode(buffer);
- encodeSize = buffer.writerIndex();
+ encodeSize = buffer.writerIndex() - PacketImpl.PACKET_HEADERS_SIZE;
}
public void decodeFromWire(final HornetQBuffer buffer)
@@ -197,16 +173,16 @@
}
public void decodeHeadersAndProperties(final HornetQBuffer buffer)
- {
- messageID = buffer.readLong();
- destination = buffer.readSimpleString();
+ {
+ messageID = buffer.readLong();
+ destination = buffer.readSimpleString();
type = buffer.readByte();
durable = buffer.readBoolean();
expiration = buffer.readLong();
timestamp = buffer.readLong();
priority = buffer.readByte();
properties.decode(buffer);
- encodeSize = buffer.readerIndex();
+ encodeSize = buffer.readerIndex() - PacketImpl.PACKET_HEADERS_SIZE;
}
public long getMessageID()
@@ -278,9 +254,7 @@
return System.currentTimeMillis() - expiration >= 0;
}
-
-
public Map<String, Object> toMap()
{
Map<String, Object> map = new HashMap<String, Object>();
@@ -597,27 +571,62 @@
return properties;
}
- public HornetQBuffer getBuffer()
+ public HornetQBuffer getWholeBuffer()
{
return buffer;
}
public void setBuffer(HornetQBuffer buffer)
{
- this.buffer = buffer;
+ this.buffer = buffer;
+
+ if (bodyBuffer != null)
+ {
+ bodyBuffer.setBuffer(buffer);
+ }
}
public BodyEncoder getBodyEncoder()
{
return new DecodingContext();
}
+
+ private ResetLimitWrappedHornetQBuffer bodyBuffer;
+ public HornetQBuffer getBodyBuffer()
+ {
+ if (bodyBuffer == null)
+ {
+ if (buffer instanceof LargeMessageBuffer == false)
+ {
+ bodyBuffer = new ResetLimitWrappedHornetQBuffer(PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT, buffer);
+ }
+ else
+ {
+ return buffer;
+ }
+ }
+
+ return bodyBuffer;
+ }
+
// Public --------------------------------------------------------
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
+
+ protected void resetBuffer()
+ {
+ // There is a bug in Netty which requires us to initially write a byte
+ if (buffer.capacity() == 0)
+ {
+ buffer.writeByte((byte)0);
+ }
+ buffer.setIndex(0, PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT);
+ }
+
// Private -------------------------------------------------------
// Inner classes -------------------------------------------------
@@ -646,7 +655,7 @@
public int encode(HornetQBuffer bufferOut, int size)
{
- bufferOut.writeBytes(getBuffer(), lastPos, size);
+ bufferOut.writeBytes(getWholeBuffer(), lastPos, size);
lastPos += size;
return size;
}
Modified: branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PageImpl.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PageImpl.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PageImpl.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -117,11 +117,12 @@
{
PagedMessage msg = new PagedMessageImpl();
msg.decode(fileBuffer);
- if (fileBuffer.readByte() != END_BYTE)
+ byte b = fileBuffer.readByte();
+ if (b != END_BYTE)
{
// Sanity Check: This would only happen if there is a bug on decode or any internal code, as this
// constraint was already checked
- throw new IllegalStateException("Internal error, it wasn't possible to locate END_BYTE");
+ throw new IllegalStateException("Internal error, it wasn't possible to locate END_BYTE " + b);
}
messages.add(msg);
}
@@ -151,10 +152,13 @@
HornetQChannelBuffer wrap = HornetQChannelBuffers.wrappedBuffer(buffer);
wrap.writeByte(START_BYTE);
- wrap.writeInt(message.getEncodeSize());
+ wrap.writeInt(0);
+ int startIndex = wrap.writerIndex();
message.encode(wrap);
+ int endIndex = wrap.writerIndex();
+ wrap.setInt(1, endIndex - startIndex); // The encoded length
wrap.writeByte(END_BYTE);
-
+
buffer.rewind();
file.writeDirect(buffer, false);
Modified: branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PagedMessageImpl.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PagedMessageImpl.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PagedMessageImpl.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -18,6 +18,7 @@
import static org.hornetq.utils.DataConstants.SIZE_LONG;
import org.hornetq.core.buffers.HornetQChannelBuffers;
+import org.hornetq.core.logging.Logger;
import org.hornetq.core.paging.PagedMessage;
import org.hornetq.core.persistence.StorageManager;
import org.hornetq.core.remoting.spi.HornetQBuffer;
@@ -37,6 +38,9 @@
{
// Constants -----------------------------------------------------
+ private static final Logger log = Logger.getLogger(PagedMessageImpl.class);
+
+
// Attributes ----------------------------------------------------
// Static --------------------------------------------------------
@@ -107,7 +111,7 @@
message = new ServerMessageImpl();
- message.decodeHeadersAndProperties(buffer);
+ message.decode(buffer);
}
}
@@ -119,7 +123,7 @@
buffer.writeBoolean(message instanceof LargeServerMessage);
buffer.writeInt(message.getEncodeSize());
-
+
message.encode(buffer);
}
Modified: branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -280,9 +280,11 @@
}
public void addSize(final ServerMessage message, final boolean add) throws Exception
- {
+ {
long size = message.getMemoryEstimate();
+ //log.info((add ? "adding" : "subtracting") + " message size " + size);
+
if (add)
{
checkReleaseProducerFlowControlCredits(size);
@@ -300,6 +302,8 @@
public void addSize(final MessageReference reference, final boolean add) throws Exception
{
long size = MessageReferenceImpl.getMemoryEstimate();
+
+ //log.info((add ? "adding" : "subtracting") + " reference size " + size);
if (add)
{
Deleted: branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/FileLargeServerMessage.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/FileLargeServerMessage.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/FileLargeServerMessage.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -1,432 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.core.persistence.impl.journal;
-
-import static org.hornetq.utils.DataConstants.SIZE_INT;
-
-import java.nio.ByteBuffer;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.hornetq.core.exception.HornetQException;
-import org.hornetq.core.journal.SequentialFile;
-import org.hornetq.core.logging.Logger;
-import org.hornetq.core.message.BodyEncoder;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
-import org.hornetq.core.server.LargeServerMessage;
-import org.hornetq.core.server.MessageReference;
-import org.hornetq.core.server.ServerMessage;
-import org.hornetq.core.server.impl.ServerMessageImpl;
-
-/**
- * A JournalLargeServerMessage
- *
- * @author <a href="mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
- *
- * Created 30-Sep-08 12:02:45 PM
- *
- *
- */
-public class FileLargeServerMessage extends ServerMessageImpl implements LargeServerMessage
-{
- // Constants -----------------------------------------------------
-
- private static final Logger log = Logger.getLogger(FileLargeServerMessage.class);
-
- private static boolean isTrace = log.isTraceEnabled();
-
- // Attributes ----------------------------------------------------
-
- private final JournalStorageManager storageManager;
-
- private LargeServerMessage linkMessage;
-
- // We should only use the NIO implementation on the Journal
- private SequentialFile file;
-
- private long bodySize = -1;
-
- private final AtomicInteger delayDeletionCount = new AtomicInteger(0);
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- public FileLargeServerMessage(final JournalStorageManager storageManager)
- {
- this.storageManager = storageManager;
- }
-
- /**
- * Copy constructor
- * @param copy
- * @param fileCopy
- */
- private FileLargeServerMessage(final FileLargeServerMessage copy, final SequentialFile fileCopy, final long newID)
- {
- super(copy);
- this.linkMessage = copy;
- storageManager = copy.storageManager;
- file = fileCopy;
- bodySize = copy.bodySize;
- setMessageID(newID);
- }
-
- // Public --------------------------------------------------------
-
- /* (non-Javadoc)
- * @see org.hornetq.core.server.LargeServerMessage#addBytes(byte[])
- */
- public synchronized void addBytes(final byte[] bytes) throws Exception
- {
- validateFile();
-
- if (!file.isOpen())
- {
- file.open();
- }
-
- storageManager.addBytesToLargeMessage(file, this.getMessageID(), bytes);
-
- bodySize += bytes.length;
- }
-
- public void encodeBody(final HornetQBuffer bufferOut, BodyEncoder context, int size)
- {
- try
- {
- // This could maybe be optimized (maybe reading directly into bufferOut)
- ByteBuffer bufferRead = ByteBuffer.allocate(size);
-
- int bytesRead = context.encode(bufferRead);
-
- bufferRead.flip();
-
- if (bytesRead > 0)
- {
- bufferOut.writeBytes(bufferRead.array(), 0, bytesRead);
- }
-
- }
- catch (Exception e)
- {
- throw new RuntimeException(e.getMessage(), e);
- }
- }
-
- @Override
- public synchronized int getBodySize()
- {
- try
- {
- validateFile();
- }
- catch (Exception e)
- {
- throw new RuntimeException(e.getMessage(), e);
- }
- return (int)Math.min(bodySize, Integer.MAX_VALUE);
- }
-
- @Override
- public synchronized long getLargeBodySize()
- {
- try
- {
- validateFile();
- }
- catch (Exception e)
- {
- throw new RuntimeException(e.getMessage(), e);
- }
- return bodySize;
- }
-
- @Override
- public synchronized int getEncodeSize()
- {
- return getHeadersAndPropertiesEncodeSize();
- }
-
-// @Override
-// public void encode(final HornetQBuffer buffer)
-// {
-// encodeHeadersAndProperties(buffer);
-// }
-
- @Override
- public void decodeHeadersAndProperties(final HornetQBuffer buffer)
- {
- file = null;
- decodeHeadersAndProperties(buffer);
- }
-
- public synchronized void incrementDelayDeletionCount()
- {
- this.delayDeletionCount.incrementAndGet();
- }
-
- public synchronized void decrementDelayDeletionCount() throws Exception
- {
- int count = this.delayDeletionCount.decrementAndGet();
-
- if (count == 0)
- {
- checkDelete();
- }
- }
-
- @Override
- public BodyEncoder getBodyEncoder()
- {
- return new DecodingContext();
- }
-
- private void checkDelete() throws Exception
- {
- if (getRefCount() <= 0)
- {
- if (linkMessage != null)
- {
- // This file is linked to another message, deleting the reference where it belongs on this case
- linkMessage.decrementDelayDeletionCount();
- }
- else
- {
- if (isTrace)
- {
- log.trace("Deleting file " + file + " as the usage was complete");
- }
-
- try
- {
- deleteFile();
- }
- catch (Exception e)
- {
- log.error(e.getMessage(), e);
- }
- }
- }
- }
-
- @Override
- public synchronized int decrementRefCount(MessageReference reference) throws Exception
- {
- int currentRefCount = super.decrementRefCount(reference);
-
- // We use <= as this could be used by load.
- // because of a failure, no references were loaded, so we have 0... and we still need to delete the associated
- // files
- if (delayDeletionCount.get() <= 0)
- {
- checkDelete();
- }
-
- return currentRefCount;
- }
-
- @Override
- public boolean isLargeMessage()
- {
- return true;
- }
-
- public synchronized void deleteFile() throws Exception
- {
- validateFile();
- releaseResources();
- storageManager.deleteFile(file);
- }
-
- public boolean isFileExists() throws Exception
- {
- SequentialFile localfile = storageManager.createFileForLargeMessage(getMessageID(), durable);
- return localfile.exists();
- }
-
- // We cache this
- private volatile int memoryEstimate = -1;
-
- @Override
- public synchronized int getMemoryEstimate()
- {
- if (memoryEstimate == -1)
- {
- // The body won't be on memory (aways on-file), so we don't consider this for paging
- memoryEstimate = getHeadersAndPropertiesEncodeSize() + SIZE_INT + getEncodeSize() + (16 + 4) * 2 + 1;
- }
-
- return memoryEstimate;
- }
-
- public synchronized void releaseResources()
- {
- if (file != null && file.isOpen())
- {
- try
- {
- file.close();
- }
- catch (Exception e)
- {
- log.error(e.getMessage(), e);
- }
- }
- }
-
- @Override
- public synchronized ServerMessage copy(final long newID) throws Exception
- {
- incrementDelayDeletionCount();
-
- long idToUse = messageID;
-
- if (linkMessage != null)
- {
- idToUse = linkMessage.getMessageID();
- }
-
- SequentialFile newfile = storageManager.createFileForLargeMessage(idToUse, durable);
-
- ServerMessage newMessage = new FileLargeServerMessage(linkMessage == null ? this
- : (FileLargeServerMessage)linkMessage,
- newfile,
- newID);
-
- return newMessage;
- }
-
- public SequentialFile getFile()
- {
- return file;
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- @Override
- protected void finalize() throws Throwable
- {
- releaseResources();
- super.finalize();
- }
-
- // Private -------------------------------------------------------
-
- private synchronized void validateFile() throws Exception
- {
- if (file == null)
- {
- if (messageID <= 0)
- {
- throw new RuntimeException("MessageID not set on LargeMessage");
- }
-
- file = storageManager.createFileForLargeMessage(getMessageID(), durable);
-
- file.open();
-
- bodySize = file.size();
-
- }
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.server.LargeServerMessage#setLinkedMessage(org.hornetq.core.server.LargeServerMessage)
- */
- public void setLinkedMessage(LargeServerMessage message)
- {
- if (file != null)
- {
- // Sanity check.. it shouldn't happen
- throw new IllegalStateException("LargeMessage file was already set");
- }
-
- this.linkMessage = message;
-
- file = storageManager.createFileForLargeMessage(message.getMessageID(), durable);
- try
- {
- file.open();
- this.bodySize = file.size();
- file.close();
- }
- catch (Exception e)
- {
- throw new RuntimeException("could not setup linked file", e);
- }
- }
-
- // Inner classes -------------------------------------------------
-
- class DecodingContext implements BodyEncoder
- {
- private SequentialFile cFile;
-
- public void open() throws HornetQException
- {
- try
- {
- cFile = file.copy();
- cFile.open();
- }
- catch (Exception e)
- {
- throw new HornetQException(HornetQException.INTERNAL_ERROR, e.getMessage(), e);
- }
- }
-
- public void close() throws HornetQException
- {
- try
- {
- cFile.close();
- }
- catch (Exception e)
- {
- throw new HornetQException(HornetQException.INTERNAL_ERROR, e.getMessage(), e);
- }
- }
-
- public int encode(ByteBuffer bufferRead) throws HornetQException
- {
- try
- {
- return cFile.read(bufferRead);
- }
- catch (Exception e)
- {
- throw new HornetQException(HornetQException.INTERNAL_ERROR, e.getMessage(), e);
- }
- }
-
- public int encode(HornetQBuffer bufferOut, int size) throws HornetQException
- {
- // This could maybe be optimized (maybe reading directly into bufferOut)
- ByteBuffer bufferRead = ByteBuffer.allocate(size);
-
- int bytesRead = encode(bufferRead);
-
- bufferRead.flip();
-
- if (bytesRead > 0)
- {
- bufferOut.writeBytes(bufferRead.array(), 0, bytesRead);
- }
-
- return bytesRead;
- }
- }
-}
Modified: branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -408,7 +408,7 @@
public LargeServerMessage createLargeMessage()
{
- return new FileLargeServerMessage(this);
+ return new LargeServerMessageImpl(this);
}
public void addBytesToLargeMessage(SequentialFile file, long messageId, final byte[] bytes) throws Exception
@@ -430,7 +430,7 @@
replicator.largeMessageBegin(id);
}
- FileLargeServerMessage largeMessage = (FileLargeServerMessage)createLargeMessage();
+ LargeServerMessageImpl largeMessage = (LargeServerMessageImpl)createLargeMessage();
HornetQBuffer headerBuffer = HornetQChannelBuffers.wrappedBuffer(header);
@@ -451,8 +451,6 @@
throw new HornetQException(HornetQException.ILLEGAL_STATE, "MessageId was not assigned to Message");
}
- log.info("storing message");
-
// Note that we don't sync, the add reference that comes immediately after will sync if appropriate
if (message.isLargeMessage())
@@ -740,7 +738,7 @@
break;
}
case ADD_MESSAGE:
- {
+ {
ServerMessage message = new ServerMessageImpl(record.id);
message.decode(buff);
Copied: branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/LargeServerMessageImpl.java (from rev 8349, branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/FileLargeServerMessage.java)
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/LargeServerMessageImpl.java (rev 0)
+++ branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/LargeServerMessageImpl.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -0,0 +1,420 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.core.persistence.impl.journal;
+
+import static org.hornetq.utils.DataConstants.SIZE_INT;
+
+import java.nio.ByteBuffer;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.hornetq.core.exception.HornetQException;
+import org.hornetq.core.journal.SequentialFile;
+import org.hornetq.core.logging.Logger;
+import org.hornetq.core.message.BodyEncoder;
+import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.server.LargeServerMessage;
+import org.hornetq.core.server.MessageReference;
+import org.hornetq.core.server.ServerMessage;
+import org.hornetq.core.server.impl.ServerMessageImpl;
+
+/**
+ * A LargeServerMessageImpl
+ *
+ * @author <a href="mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
+ *
+ * Created 30-Sep-08 12:02:45 PM
+ *
+ *
+ */
+public class LargeServerMessageImpl extends ServerMessageImpl implements LargeServerMessage
+{
+ // Constants -----------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(LargeServerMessageImpl.class);
+
+ private static boolean isTrace = log.isTraceEnabled();
+
+ // Attributes ----------------------------------------------------
+
+ private final JournalStorageManager storageManager;
+
+ private LargeServerMessage linkMessage;
+
+ // We should only use the NIO implementation on the Journal
+ private SequentialFile file;
+
+ private long bodySize = -1;
+
+ private final AtomicInteger delayDeletionCount = new AtomicInteger(0);
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public LargeServerMessageImpl(final JournalStorageManager storageManager)
+ {
+ this.storageManager = storageManager;
+ }
+
+ /**
+ * Copy constructor
+ * @param copy
+ * @param fileCopy
+ */
+ private LargeServerMessageImpl(final LargeServerMessageImpl copy, final SequentialFile fileCopy, final long newID)
+ {
+ super(copy);
+ this.linkMessage = copy;
+ storageManager = copy.storageManager;
+ file = fileCopy;
+ bodySize = copy.bodySize;
+ setMessageID(newID);
+ }
+
+ // Public --------------------------------------------------------
+
+ /* (non-Javadoc)
+ * @see org.hornetq.core.server.LargeServerMessage#addBytes(byte[])
+ */
+ public synchronized void addBytes(final byte[] bytes) throws Exception
+ {
+ validateFile();
+
+ if (!file.isOpen())
+ {
+ file.open();
+ }
+
+ storageManager.addBytesToLargeMessage(file, this.getMessageID(), bytes);
+
+ bodySize += bytes.length;
+ }
+
+ public void encodeBody(final HornetQBuffer bufferOut, BodyEncoder context, int size)
+ {
+ log.info("large server message, encodebody");
+ try
+ {
+ // This could maybe be optimized (maybe reading directly into bufferOut)
+ ByteBuffer bufferRead = ByteBuffer.allocate(size);
+
+ int bytesRead = context.encode(bufferRead);
+
+ bufferRead.flip();
+
+ if (bytesRead > 0)
+ {
+ bufferOut.writeBytes(bufferRead.array(), 0, bytesRead);
+ }
+
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public synchronized long getLargeBodySize()
+ {
+ try
+ {
+ validateFile();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ return bodySize;
+ }
+
+ @Override
+ public synchronized int getEncodeSize()
+ {
+ return getHeadersAndPropertiesEncodeSize();
+ }
+
+ @Override
+ public void encode(final HornetQBuffer buffer)
+ {
+ super.encodeHeadersAndProperties(buffer);
+ }
+
+ @Override
+ public void decode(final HornetQBuffer buffer)
+ {
+ file = null;
+
+ super.decodeHeadersAndProperties(buffer);
+ }
+
+ public synchronized void incrementDelayDeletionCount()
+ {
+ this.delayDeletionCount.incrementAndGet();
+ }
+
+ public synchronized void decrementDelayDeletionCount() throws Exception
+ {
+ int count = this.delayDeletionCount.decrementAndGet();
+
+ if (count == 0)
+ {
+ checkDelete();
+ }
+ }
+
+ @Override
+ public BodyEncoder getBodyEncoder()
+ {
+ return new DecodingContext();
+ }
+
+ private void checkDelete() throws Exception
+ {
+ if (getRefCount() <= 0)
+ {
+ if (linkMessage != null)
+ {
+ // This file is linked to another message, deleting the reference where it belongs on this case
+ linkMessage.decrementDelayDeletionCount();
+ }
+ else
+ {
+ if (isTrace)
+ {
+ log.trace("Deleting file " + file + " as the usage was complete");
+ }
+
+ try
+ {
+ deleteFile();
+ }
+ catch (Exception e)
+ {
+ log.error(e.getMessage(), e);
+ }
+ }
+ }
+ }
+
+ @Override
+ public synchronized int decrementRefCount(MessageReference reference) throws Exception
+ {
+ int currentRefCount = super.decrementRefCount(reference);
+
+ // We use <= as this could be used by load.
+ // because of a failure, no references were loaded, so we have 0... and we still need to delete the associated
+ // files
+ if (delayDeletionCount.get() <= 0)
+ {
+ checkDelete();
+ }
+
+ return currentRefCount;
+ }
+
+ @Override
+ public boolean isLargeMessage()
+ {
+ return true;
+ }
+
+ public synchronized void deleteFile() throws Exception
+ {
+ validateFile();
+ releaseResources();
+ storageManager.deleteFile(file);
+ }
+
+ public boolean isFileExists() throws Exception
+ {
+ SequentialFile localfile = storageManager.createFileForLargeMessage(getMessageID(), durable);
+ return localfile.exists();
+ }
+
+ // We cache this
+ private volatile int memoryEstimate = -1;
+
+ @Override
+ public synchronized int getMemoryEstimate()
+ {
+ if (memoryEstimate == -1)
+ {
+ // The body won't be on memory (aways on-file), so we don't consider this for paging
+ memoryEstimate = getHeadersAndPropertiesEncodeSize() + SIZE_INT + getEncodeSize() + (16 + 4) * 2 + 1;
+ }
+
+ return memoryEstimate;
+ }
+
+ public synchronized void releaseResources()
+ {
+ if (file != null && file.isOpen())
+ {
+ try
+ {
+ file.close();
+ }
+ catch (Exception e)
+ {
+ log.error(e.getMessage(), e);
+ }
+ }
+ }
+
+ @Override
+ public synchronized ServerMessage copy(final long newID) throws Exception
+ {
+ incrementDelayDeletionCount();
+
+ long idToUse = messageID;
+
+ if (linkMessage != null)
+ {
+ idToUse = linkMessage.getMessageID();
+ }
+
+ SequentialFile newfile = storageManager.createFileForLargeMessage(idToUse, durable);
+
+ ServerMessage newMessage = new LargeServerMessageImpl(linkMessage == null ? this
+ : (LargeServerMessageImpl)linkMessage,
+ newfile,
+ newID);
+
+ return newMessage;
+ }
+
+ public SequentialFile getFile()
+ {
+ return file;
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ @Override
+ protected void finalize() throws Throwable
+ {
+ releaseResources();
+ super.finalize();
+ }
+
+ // Private -------------------------------------------------------
+
+ private synchronized void validateFile() throws Exception
+ {
+ if (file == null)
+ {
+ if (messageID <= 0)
+ {
+ throw new RuntimeException("MessageID not set on LargeMessage");
+ }
+
+ file = storageManager.createFileForLargeMessage(getMessageID(), durable);
+
+ file.open();
+
+ bodySize = file.size();
+
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.hornetq.core.server.LargeServerMessage#setLinkedMessage(org.hornetq.core.server.LargeServerMessage)
+ */
+ public void setLinkedMessage(LargeServerMessage message)
+ {
+ if (file != null)
+ {
+ // Sanity check.. it shouldn't happen
+ throw new IllegalStateException("LargeMessage file was already set");
+ }
+
+ this.linkMessage = message;
+
+ file = storageManager.createFileForLargeMessage(message.getMessageID(), durable);
+ try
+ {
+ file.open();
+ this.bodySize = file.size();
+ file.close();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("could not setup linked file", e);
+ }
+ }
+
+ // Inner classes -------------------------------------------------
+
+ class DecodingContext implements BodyEncoder
+ {
+ private SequentialFile cFile;
+
+ public void open() throws HornetQException
+ {
+ try
+ {
+ cFile = file.copy();
+ cFile.open();
+ }
+ catch (Exception e)
+ {
+ throw new HornetQException(HornetQException.INTERNAL_ERROR, e.getMessage(), e);
+ }
+ }
+
+ public void close() throws HornetQException
+ {
+ try
+ {
+ cFile.close();
+ }
+ catch (Exception e)
+ {
+ throw new HornetQException(HornetQException.INTERNAL_ERROR, e.getMessage(), e);
+ }
+ }
+
+ public int encode(ByteBuffer bufferRead) throws HornetQException
+ {
+ try
+ {
+ return cFile.read(bufferRead);
+ }
+ catch (Exception e)
+ {
+ throw new HornetQException(HornetQException.INTERNAL_ERROR, e.getMessage(), e);
+ }
+ }
+
+ public int encode(HornetQBuffer bufferOut, int size) throws HornetQException
+ {
+ // This could maybe be optimized (maybe reading directly into bufferOut)
+ ByteBuffer bufferRead = ByteBuffer.allocate(size);
+
+ int bytesRead = encode(bufferRead);
+
+ bufferRead.flip();
+
+ if (bytesRead > 0)
+ {
+ bufferOut.writeBytes(bufferRead.array(), 0, bytesRead);
+ }
+
+ return bytesRead;
+ }
+ }
+}
Modified: branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/invm/InVMConnection.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/invm/InVMConnection.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/invm/InVMConnection.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -97,7 +97,7 @@
public HornetQBuffer createBuffer(final int size)
{
- return HornetQChannelBuffers.buffer(size);
+ return HornetQChannelBuffers.dynamicBuffer(size);
}
public Object getID()
Modified: branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionReceiveMessage.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionReceiveMessage.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionReceiveMessage.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -89,7 +89,16 @@
{
//We re-use the same packet buffer - but we need to change the extra data
- HornetQBuffer buffer = serverMessage.getBuffer();
+ //Since many consumers could be delivering the same message concurrently, we must copy the buffer before sending
+ //since otherwise they will all write different consumer ids and delivering counts on the same buffer concurrently
+ //and indexes will get screwed up
+
+ //TODO - optimise this
+ HornetQBuffer origBuffer = serverMessage.getWholeBuffer();
+
+ HornetQBuffer buffer = origBuffer.copy();
+
+ buffer.setIndex(origBuffer.readerIndex(), origBuffer.writerIndex());
if (serverMessage.isEncodedToBuffer())
{
@@ -104,11 +113,18 @@
//Message hasn't been encoded yet - probably it's something like a notification message generated on the server
+ //End of message position
+ buffer.writeInt(0);
+
// We now write the message headers and properties
serverMessage.encodeHeadersAndProperties(buffer);
- serverMessage.setEndMessagePosition(buffer.writerIndex());
+ int endMessage = buffer.writerIndex();
+ buffer.setInt(afterBody, endMessage);
+
+ serverMessage.setEndMessagePosition(endMessage);
+
//Now we need to fill in the afterBody
buffer.setInt(PacketImpl.PACKET_HEADERS_SIZE, afterBody);
}
@@ -128,13 +144,7 @@
buffer.writeByte(type);
buffer.writeLong(channelID);
- //And fill in the message id, since this was set on the server side so won't already be in the buffer
-
- buffer.writerIndex(buffer.readInt(PacketImpl.PACKET_HEADERS_SIZE));
- buffer.writeLong(serverMessage.getMessageID());
-
- //Set the reader and writer position to be read fully by remoting
- buffer.setIndex(0, size);
+ buffer.writerIndex(size);
return buffer;
}
@@ -151,10 +161,12 @@
//At this point standard headers have been decoded and we are positioned at the beginning of the body
int bodyStart = buffer.readerIndex();
-
+
// We now read message headers/properties
buffer.readerIndex(afterBody);
+
+ int endMessage = buffer.readInt();
clientMessage.decodeFromWire(buffer);
@@ -169,9 +181,9 @@
size = buffer.readerIndex();
// Set reader index back to beginning of body
+
+ buffer.setIndex(bodyStart, afterBody);
- buffer.readerIndex(bodyStart);
-
clientMessage.setBuffer(buffer);
}
Modified: branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionSendMessage.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionSendMessage.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionSendMessage.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -19,9 +19,7 @@
import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.server.ServerMessage;
import org.hornetq.core.server.impl.ServerMessageImpl;
-import org.hornetq.integration.transports.netty.ChannelBufferWrapper;
import org.hornetq.utils.DataConstants;
-import org.jboss.netty.buffer.ChannelBuffer;
/**
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
@@ -43,7 +41,7 @@
private ServerMessage receivedMessage;
private boolean requiresResponse;
-
+
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
@@ -93,13 +91,15 @@
*
* Then the message body:
*
- * bodySize:int
+ * position of end of body: int
* body:byte[]
*
* {Note we store the message body before the message headers/properties since this allows the user to
* construct a message, add stuff to the body buffer, and send it without us having to copy the body into a new
* buffer before sending it, this minmises buffer copying}
*
+ * position of end of encoded message headers/properties: int
+ *
* Then followed by the message headers and properties:
*
* messageID:long
@@ -115,15 +115,24 @@
*
*/
- HornetQBuffer buffer = sentMessage.getBuffer();
+ HornetQBuffer buffer = sentMessage.getWholeBuffer();
// The body will already be written (if any) at this point, so we take note of the position of the end of the
// body
int afterBody = buffer.writerIndex();
+
+ //The next int is the position of after the encoded message headers/properties, so we skip this for now
+ buffer.writeInt(0);
// We now write the message headers and properties
sentMessage.encodeHeadersAndProperties(buffer);
+
+ //Write the position of the end of the message
+
+ int endMessage = buffer.writerIndex();
+
+ buffer.setInt(afterBody, endMessage);
// We now write the extra data for the packet
buffer.writeBoolean(requiresResponse);
@@ -133,7 +142,7 @@
// We now set the standard packet headers at the beginning of the buffer
- buffer.writerIndex(0);
+ buffer.clear();
int len = size - DataConstants.SIZE_INT;
buffer.writeInt(len);
@@ -145,14 +154,14 @@
// And we set the indexes back for reading and writing
buffer.setIndex(0, size);
-
+
//We must make a copy of the buffer, since the message might get sent again, and the body might get read or written
//this might occur while the same send is in operatio since netty send is asynch
//this could cause incorrect data to be send and/or reader/writer positions to become corrupted
HornetQBuffer newBuffer = buffer.copy();
- newBuffer.setIndex(0, afterBody);
+ newBuffer.setIndex(PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT, afterBody);
this.sentMessage.setBuffer(newBuffer);
@@ -169,18 +178,22 @@
// At this point, the standard packet headers will already have been read
// We read the position of the end of the body - this is where the message headers and properties are stored
- int afterBody = buffer.readInt();
-
+ int afterBody = buffer.readInt();
+
+ buffer.setIndex(afterBody, buffer.writerIndex());
+
+ int endMessage = buffer.readInt();
+
+ receivedMessage.setEndMessagePosition(endMessage);
+
// We now read message headers/properties
-
- buffer.setIndex(afterBody, buffer.writerIndex());
-
+
receivedMessage.decodeFromWire(buffer);
//We store the position of the end of the encoded message, where the extra data starts - this
//will be needed if we re-deliver this packet, since we need to reset to there to rewrite the extra data
//for the different packet
- receivedMessage.setEndMessagePosition(buffer.readerIndex());
+ //receivedMessage.setEndMessagePosition(endMessage);
// And we read extra data in the packet
Modified: branches/20-optimisation/src/main/org/hornetq/core/remoting/spi/HornetQBuffer.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/remoting/spi/HornetQBuffer.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/core/remoting/spi/HornetQBuffer.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -13,8 +13,6 @@
package org.hornetq.core.remoting.spi;
-import java.nio.ByteBuffer;
-
import org.hornetq.utils.SimpleString;
/**
@@ -127,4 +125,6 @@
byte[] array();
HornetQBuffer copy();
+
+ HornetQBuffer slice(int index, int length);
}
Modified: branches/20-optimisation/src/main/org/hornetq/core/server/ServerMessage.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/server/ServerMessage.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/core/server/ServerMessage.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -67,4 +67,6 @@
void setEndMessagePosition(int pos);
int getEndMessagePosition();
+
+ void encodeMessageIDToBuffer();;
}
Modified: branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerMessageImpl.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerMessageImpl.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerMessageImpl.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -64,25 +64,23 @@
* Construct a MessageImpl from storage
*/
public ServerMessageImpl(final long messageID)
- {
- super(messageID);
-
- log.info("creating server message from storage, with id " + messageID);
+ {
+ super(messageID);
}
-
+
/*
* Constructor when creating a ServerMessage for sending - e.g. notification
*/
public ServerMessageImpl(final long messageID, final HornetQBuffer buffer)
{
super(messageID);
-
+
this.buffer = buffer;
-
- //Must align the body after the packet headers
+
+ // Must align the body after the packet headers
resetBuffer();
}
-
+
/*
* Copy constructor
*/
@@ -97,22 +95,9 @@
timestamp = other.getTimestamp();
priority = other.getPriority();
properties = new TypedProperties(other.getProperties());
- buffer = other.getBuffer();
+ buffer = other.getWholeBuffer();
}
-// /**
-// * Only used in testing
-// */
-// public ServerMessageImpl(final byte type,
-// final boolean durable,
-// final long expiration,
-// final long timestamp,
-// final byte priority,
-// final HornetQBuffer buffer)
-// {
-// super(type, durable, expiration, timestamp, priority, buffer);
-// }
-
public void setMessageID(final long id)
{
messageID = id;
@@ -186,7 +171,7 @@
public long getLargeBodySize()
{
- return getBodySize();
+ return -1;
}
public int getMemoryEstimate()
@@ -260,7 +245,7 @@
putLongProperty(HDR_ACTUAL_EXPIRY_TIME, actualExpiryTime);
}
-
+
setNeedsEncoding();
}
@@ -313,9 +298,7 @@
return false;
}
}
-
-
@Override
public String toString()
{
@@ -326,91 +309,111 @@
getDestination() +
"]";
}
-
- //FIXME - this is stuff that is only used in large messages
-
- //This is only valid on the client side - why is it here?
+
+ // FIXME - this is stuff that is only used in large messages
+
+ // This is only valid on the client side - why is it here?
public InputStream getBodyInputStream()
{
return null;
}
-
-
-
+
// Encoding stuff
-
-
+
public void setNeedsEncoding()
{
- //This wil force the message to be re-encoded if it gets sent to a client
- //Typically this is called after properties or headers are changed on the server side
+ // This wil force the message to be re-encoded if it gets sent to a client
+ // Typically this is called after properties or headers are changed on the server side
this.encodedToBuffer = false;
}
-
+
private int endMessagePosition;
-
+
public void setEndMessagePosition(int pos)
{
this.endMessagePosition = pos;
}
-
+
public int getEndMessagePosition()
{
return this.endMessagePosition;
}
-
+
+ public void encodeToWire()
+ {
+ }
+
// EncodingSupport implementation
-
+
// Used when storing to/from journal
-
+
public void encode(final HornetQBuffer buffer)
{
- //Encode the message to a buffer for storage in the journal
-
+ // Encode the message to a buffer for storage in the journal
+
if (this.encodedToBuffer)
{
- //The body starts after the standard packet headers
+ // The body starts after the standard packet headers
int bodyStart = PacketImpl.PACKET_HEADERS_SIZE;
-
+
int end = this.endMessagePosition;
- buffer.writeBytes(this.buffer, bodyStart, end);
+ buffer.writeBytes(this.buffer, bodyStart, end - bodyStart);
}
else
{
- //encodeToBuffer();
-
+ // encodeToBuffer();
+
throw new IllegalStateException("Not encoded to buffer and storing to journal");
- }
+ }
}
-
+
public void decode(final HornetQBuffer buffer)
{
- //TODO optimise
+ // TODO optimise
+
+ int start = buffer.readerIndex();
+
+ int bodyEndPos = buffer.readInt();
- log.info("decoding server message");
+ this.endMessagePosition = buffer.readInt(bodyEndPos - PacketImpl.PACKET_HEADERS_SIZE + start);
+ int endPos = endMessagePosition + start -
+ PacketImpl.PACKET_HEADERS_SIZE;
+
this.buffer = HornetQChannelBuffers.dynamicBuffer(1500);
-
- //work around Netty bug
+
+ // work around Netty bug
this.buffer.writeByte((byte)0);
-
+
this.buffer.setIndex(0, PacketImpl.PACKET_HEADERS_SIZE);
+
+ this.buffer.writeBytes(buffer, start, endPos - start);
- this.buffer.writeBytes(buffer, 0, buffer.readableBytes());
-
-
+ // Position to beginning of encoded message headers/properties
+
+ this.buffer.readerIndex(0);
+
//Position to beginning of encoded message headers/properties
- int msgHeadersPos = this.buffer.readInt(PacketImpl.PACKET_HEADERS_SIZE);
-
- this.buffer.readerIndex(msgHeadersPos);
-
+ this.buffer.readerIndex(bodyEndPos + DataConstants.SIZE_INT);
+
this.decodeHeadersAndProperties(this.buffer);
- log.info("priority is now " + this.getPriority());
+ buffer.setIndex(endPos, buffer.capacity());
-
+ this.encodedToBuffer = true;
}
+ public void encodeMessageIDToBuffer()
+ {
+ // We first set the message id - this needs to be set on the buffer since this buffer will be re-used
+
+ buffer.readerIndex(0);
+
+ buffer.writerIndex(buffer.readInt(PacketImpl.PACKET_HEADERS_SIZE) + DataConstants.SIZE_INT);
+
+ buffer.writeLong(messageID);
+ }
+
}
Modified: branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -1435,6 +1435,8 @@
public void handleSendLargeMessage(final SessionSendLargeMessage packet)
{
+ log.info("Got large message on server");
+
// need to create the LargeMessage before continue
long id = storageManager.generateUniqueID();
@@ -1464,6 +1466,7 @@
long id = storageManager.generateUniqueID();
message.setMessageID(id);
+ message.encodeMessageIDToBuffer();
if (message.getDestination().equals(managementAddress))
{
@@ -1573,7 +1576,7 @@
final CreditManagerHolder holder = this.getCreditManagerHolder(address);
int credits = packet.getCredits();
-
+
int gotCredits = holder.manager.acquireCredits(credits, new CreditsAvailableRunnable()
{
public boolean run(final int credits)
@@ -1593,6 +1596,8 @@
}
}
});
+
+ //log.info("session requesting " + credits + " got " + gotCredits);
if (gotCredits > 0)
{
@@ -1899,6 +1904,8 @@
*/
private void releaseOutStanding(final ServerMessage message, final int credits) throws Exception
{
+ //log.info("releasing outstanding credits " + credits);
+
CreditManagerHolder holder = getCreditManagerHolder(message);
holder.outstandingCredits -= credits;
@@ -1941,6 +1948,8 @@
private void sendProducerCredits(final CreditManagerHolder holder, final int credits, final SimpleString address)
{
holder.outstandingCredits += credits;
+
+ // log.info("sending producer credits " + credits);
Packet packet = new SessionProducerCreditsMessage(credits, address, -1);
Modified: branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/ChannelBufferWrapper.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/ChannelBufferWrapper.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/ChannelBufferWrapper.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -33,7 +33,6 @@
{
private static final Logger log = Logger.getLogger(ChannelBufferWrapper.class);
-
private final ChannelBuffer buffer;
/**
@@ -94,7 +93,7 @@
{
return buffer.readInt();
}
-
+
public int readInt(final int pos)
{
return buffer.getInt(pos);
@@ -284,8 +283,8 @@
* @see org.hornetq.core.remoting.spi.HornetQBuffer#readString()
*/
public String readString()
- {
- int len = readInt();
+ {
+ int len = readInt();
char[] chars = new char[len];
for (int i = 0; i < len; i++)
{
@@ -382,12 +381,12 @@
* @see org.hornetq.core.remoting.spi.HornetQBuffer#writeString(java.lang.String)
*/
public void writeString(final String val)
- {
+ {
writeInt(val.length());
for (int i = 0; i < val.length(); i++)
{
writeShort((short)val.charAt(i));
- }
+ }
}
/* (non-Javadoc)
@@ -405,10 +404,15 @@
{
return buffer;
}
-
+
public HornetQBuffer copy()
{
return new ChannelBufferWrapper(buffer.copy(0, buffer.capacity()));
}
+ public HornetQBuffer slice(int index, int length)
+ {
+ return new ChannelBufferWrapper(buffer.slice(index, length));
+ }
+
}
Modified: branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/NettyConnection.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/NettyConnection.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/NettyConnection.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -13,12 +13,14 @@
package org.hornetq.integration.transports.netty;
+import org.hornetq.core.buffers.HornetQChannelBuffer;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.remoting.spi.Connection;
import org.hornetq.core.remoting.spi.ConnectionLifeCycleListener;
import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelFuture;
import org.jboss.netty.handler.ssl.SslHandler;
@@ -117,9 +119,26 @@
write(buffer, false);
}
- public void write(final HornetQBuffer buffer, final boolean flush)
+ public void write(HornetQBuffer buffer, final boolean flush)
{
- ChannelFuture future = channel.write(buffer.getUnderlyingBuffer());
+ Object underlying = buffer.getUnderlyingBuffer();
+
+ if (underlying instanceof ChannelBuffer == false)
+ {
+ //Need to copy it
+
+ //TODO we can avoid this if we use Netty buffers everywhere!!
+
+ HornetQBuffer hq = (HornetQBuffer)underlying;
+
+ ChannelBuffer cb = ChannelBuffers.copiedBuffer(hq.array());
+
+ cb.setIndex(hq.readerIndex(), hq.writerIndex());
+
+ underlying = cb;
+ }
+
+ ChannelFuture future = channel.write(underlying);
if (flush)
{
Modified: branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQBytesMessage.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQBytesMessage.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQBytesMessage.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -47,6 +47,8 @@
// Attributes ----------------------------------------------------
+ private int bodyLength;
+
// Constructor ---------------------------------------------------
/*
@@ -387,6 +389,8 @@
if (!readOnly)
{
readOnly = true;
+
+ bodyLength = message.getBodySize();
getBuffer().resetReaderIndex();
}
@@ -395,6 +399,13 @@
getBuffer().resetReaderIndex();
}
}
+
+ public void doBeforeReceive() throws Exception
+ {
+ bodyLength = message.getBodySize();
+
+ super.doBeforeReceive();
+ }
// HornetQRAMessage overrides ----------------------------------------
@@ -409,7 +420,7 @@
{
checkRead();
- return message.getLargeBodySize();
+ return bodyLength;
}
public void doBeforeSend() throws Exception
@@ -432,7 +443,7 @@
private HornetQBuffer getBuffer()
{
- return message.getBuffer();
+ return message.getBodyBuffer();
}
// Inner classes -------------------------------------------------
Modified: branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMapMessage.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMapMessage.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMapMessage.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -70,6 +70,10 @@
{
super(message, session);
}
+
+ public HornetQMapMessage()
+ {
+ }
/**
*
@@ -366,7 +370,7 @@
public void doBeforeSend() throws Exception
{
- map.encode(message.getBuffer());
+ map.encode(message.getBodyBuffer());
super.doBeforeSend();
}
@@ -375,7 +379,7 @@
{
super.doBeforeReceive();
- map.decode(message.getBuffer());
+ map.decode(message.getBodyBuffer());
}
// Package protected ---------------------------------------------
Modified: branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMessage.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMessage.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMessage.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -213,7 +213,7 @@
// Read-only?
protected boolean readOnly;
- // Read-only?
+ // Properties read-only?
protected boolean propertiesReadOnly;
// Cache it
@@ -268,6 +268,10 @@
{
this(foreign, HornetQMessage.TYPE, session);
}
+
+ public HornetQMessage()
+ {
+ }
protected HornetQMessage(final Message foreign, final byte type, final ClientSession session) throws JMSException
{
@@ -339,7 +343,7 @@
msgID = jmsMessageID;
}
-
+
public long getJMSTimestamp() throws JMSException
{
return message.getTimestamp();
@@ -850,6 +854,11 @@
// Public --------------------------------------------------------
+ public void resetMessageID(String msgID)
+ {
+ this.msgID = msgID;
+ }
+
public ClientMessage getCoreMessage()
{
return message;
@@ -857,12 +866,12 @@
public void doBeforeSend() throws Exception
{
- message.getBuffer().resetReaderIndex();
+ message.getBodyBuffer().resetReaderIndex();
}
public void doBeforeReceive() throws Exception
{
- HornetQBuffer body = message.getBuffer();
+ HornetQBuffer body = message.getBodyBuffer();
if (body != null)
{
@@ -965,11 +974,6 @@
}
}
-// protected HornetQBuffer getBody()
-// {
-// return message.getBody();
-// }
-
// Private ------------------------------------------------------------
private void checkStream() throws JMSException
Modified: branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMessageProducer.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMessageProducer.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMessageProducer.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -404,8 +404,12 @@
if (!disableMessageID)
{
// Generate an id
+
+ SimpleString msgID = generateMessageID();
- msg.getCoreMessage().putStringProperty(HornetQMessage.HORNETQ_MESSAGE_ID, generateOldMessageID());
+ msg.getCoreMessage().putStringProperty(HornetQMessage.HORNETQ_MESSAGE_ID, msgID);
+
+ msg.resetMessageID(msgID.toString());
}
if (foreign)
@@ -476,14 +480,14 @@
return new SimpleString(bytes);
}
- private SimpleString generateOldMessageID()
- {
- SimpleString ss = new SimpleString(messageIDPrefix.getData());
-
- ss.concat(String.valueOf(sequenceNumber++));
-
- return ss;
- }
+// private SimpleString generateOldMessageID()
+// {
+// SimpleString ss = new SimpleString(messageIDPrefix.getData());
+//
+// ss.concat(String.valueOf(sequenceNumber++));
+//
+// return ss;
+// }
private void checkClosed() throws JMSException
{
Modified: branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQObjectMessage.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQObjectMessage.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQObjectMessage.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -15,7 +15,6 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
@@ -25,15 +24,13 @@
import org.hornetq.core.client.ClientMessage;
import org.hornetq.core.client.ClientSession;
-import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
/**
* This class implements javax.jms.ObjectMessage
*
* Don't used ObjectMessage if you want good performance!
*
- * Java Serialization is slooooow!
+ * Serialization is slooooow!
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
* @author <a href="mailto:ovidiu@feodorov.com">Ovidiu Feodorov</a>
@@ -47,13 +44,12 @@
{
// Constants -----------------------------------------------------
- public static final Logger log = Logger.getLogger(HornetQObjectMessage.class);
-
public static final byte TYPE = 2;
// Attributes ----------------------------------------------------
- private Serializable object;
+ // keep a snapshot of the Serializable Object as a byte[] to provide Object isolation
+ private byte[] data;
// Static --------------------------------------------------------
@@ -88,22 +84,30 @@
public void doBeforeSend() throws Exception
{
+ message.getBodyBuffer().clear();
+ if (data != null)
+ {
+ message.getBodyBuffer().writeInt(data.length);
+ message.getBodyBuffer().writeBytes(data);
+ }
+
super.doBeforeSend();
}
public void doBeforeReceive() throws Exception
{
super.doBeforeReceive();
-
- HornetQBuffer buffer = message.getBuffer();
-
- byte[] bytes = new byte[buffer.writerIndex() - buffer.readerIndex()];
-
- buffer.readBytes(bytes);
+ try
+ {
+ int len = message.getBodyBuffer().readInt();
+ data = new byte[len];
+ message.getBodyBuffer().readBytes(data);
+ }
+ catch (Exception e)
+ {
+ data = null;
+ }
- ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes));
-
- object = (Serializable)ois.readObject();
}
// ObjectMessage implementation ----------------------------------
@@ -112,52 +116,57 @@
{
checkWrite();
- this.object = object;
-
-// This is actually slower than serializing into a byte[] first
-// try
-// {
-// ObjectOutputStream oos = new ObjectOutputStream(new BufferOutputStream(message.getBuffer()));
-//
-// oos.writeObject(object);
-//
-// oos.flush();
-// }
-// catch (IOException e)
-// {
-// log.error("Failed to serialise object", e);
-// }
-
- //It's actually faster to serialize into a ByteArrayOutputStream than direct into the buffer
- try
+ if (object != null)
{
- ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
-
- ObjectOutputStream oos = new ObjectOutputStream(baos);
+ try
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
- oos.writeObject(object);
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.flush();
-
- message.getBuffer().writeBytes(baos.toByteArray());
+ oos.writeObject(object);
+
+ oos.flush();
+
+ data = baos.toByteArray();
+ }
+ catch (Exception e)
+ {
+ JMSException je = new JMSException("Failed to serialize object");
+ je.setLinkedException(e);
+ throw je;
+ }
}
- catch (IOException e)
- {
- log.error("Failed to serialise object", e);
- }
}
// lazy deserialize the Object the first time the client requests it
public Serializable getObject() throws JMSException
{
- return object;
+ if (data == null || data.length == 0)
+ {
+ return null;
+ }
+
+ try
+ {
+ ByteArrayInputStream bais = new ByteArrayInputStream(data);
+ ObjectInputStream ois = new org.hornetq.utils.ObjectInputStreamWithClassLoader(bais);
+ Serializable object = (Serializable)ois.readObject();
+ return object;
+ }
+ catch (Exception e)
+ {
+ JMSException je = new JMSException(e.getMessage());
+ je.setStackTrace(e.getStackTrace());
+ throw je;
+ }
}
public void clearBody() throws JMSException
{
super.clearBody();
- object = null;
+ data = null;
}
// Package protected ---------------------------------------------
@@ -167,36 +176,4 @@
// Private -------------------------------------------------------
// Inner classes -------------------------------------------------
-
-// private static class BufferOutputStream extends OutputStream
-// {
-// private HornetQBuffer buffer;
-//
-// BufferOutputStream(final HornetQBuffer buffer)
-// {
-// this.buffer = buffer;
-// }
-//
-// @Override
-// public void write(final int b) throws IOException
-// {
-// buffer.writeByte((byte)b);
-// }
-// }
-//
-// private static class BufferInputStream extends InputStream
-// {
-// private HornetQBuffer buffer;
-//
-// BufferInputStream(final HornetQBuffer buffer)
-// {
-// this.buffer = buffer;
-// }
-//
-// @Override
-// public int read() throws IOException
-// {
-// return buffer.readByte();
-// }
-// }
}
Modified: branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQStreamMessage.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQStreamMessage.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQStreamMessage.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -84,6 +84,10 @@
// Ignore
}
}
+
+ public HornetQStreamMessage()
+ {
+ }
// Public --------------------------------------------------------
@@ -561,7 +565,7 @@
private HornetQBuffer getBuffer()
{
- return message.getBuffer();
+ return message.getBodyBuffer();
}
// Inner classes -------------------------------------------------
Modified: branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQTextMessage.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQTextMessage.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQTextMessage.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -73,7 +73,7 @@
{
super(foreign, HornetQTextMessage.TYPE, session);
- text = new SimpleString(foreign.getText());
+ setText(foreign.getText());
}
// Public --------------------------------------------------------
@@ -89,12 +89,20 @@
{
checkWrite();
- this.text = new SimpleString(text);
+ HornetQBuffer buff = message.getBodyBuffer();
- //Reset buffer to just after standard headers space
- message.resetBuffer();
+ buff.clear();
- message.getBuffer().writeNullableSimpleString(this.text);
+ if (text != null)
+ {
+ this.text = new SimpleString(text);
+
+ buff.writeNullableSimpleString(this.text);
+ }
+ else
+ {
+ this.text = null;
+ }
}
public String getText() throws JMSException
@@ -118,11 +126,16 @@
// HornetQRAMessage override -----------------------------------------
+ public void doBeforeSend() throws Exception
+ {
+ super.doBeforeSend();
+ }
+
public void doBeforeReceive() throws Exception
{
super.doBeforeReceive();
- text = message.getBuffer().readNullableSimpleString();
+ text = message.getBodyBuffer().readNullableSimpleString();
}
// Package protected ---------------------------------------------
Modified: branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/MessageConsumerTest.java
===================================================================
--- branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/MessageConsumerTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/MessageConsumerTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -806,7 +806,7 @@
TextMessage m = (TextMessage)queueConsumer.receive(1500);
assertEquals("One", m.getText());
-
+
queueConsumer.close();
consumerSession.commit();
@@ -818,9 +818,9 @@
m = (TextMessage)queueConsumer2.receive(1500);
assertNotNull(m);
+
+ assertEquals("Two", m.getText());
- assertEquals(m.getText(), "Two");
-
consumerSession.commit();
}
finally
@@ -835,6 +835,7 @@
}
}
}
+
public void testRedel0() throws Exception
{
Modified: branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/JMSExpirationHeaderTest.java
===================================================================
--- branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/JMSExpirationHeaderTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/JMSExpirationHeaderTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -14,6 +14,7 @@
package org.hornetq.jms.tests.message;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicBoolean;
import javax.jms.DeliveryMode;
import javax.jms.Message;
@@ -231,11 +232,9 @@
assertEquals(m.getJMSMessageID(), result.getJMSMessageID());
}
-
-
public void testExpirationOnReceive() throws Exception
{
- expectedMessage = new HornetQMessage();
+ final AtomicBoolean received = new AtomicBoolean(true);
queueProducer.send(queueProducerSession.createMessage(), DeliveryMode.NON_PERSISTENT, 4, 2000);
@@ -258,6 +257,11 @@
//NOTE on close, the receive() call will return with null
log.trace("Receive exited without exception:" + expectedMessage);
+
+ if (expectedMessage == null)
+ {
+ received.set(false);
+ }
}
catch(Exception e)
{
@@ -287,7 +291,7 @@
log.trace("Expected message:" + expectedMessage);
- assertNull(expectedMessage);
+ assertFalse(received.get());
}
/*
Modified: branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/JMSMessageIDHeaderTest.java
===================================================================
--- branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/JMSMessageIDHeaderTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/JMSMessageIDHeaderTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -48,9 +48,26 @@
m.setJMSMessageID("ID:something");
queueProducer.send(m);
-
+
assertFalse("ID:something".equals(m.getJMSMessageID()));
+ }
+ finally
+ {
+ removeAllMessages(queue1.getQueueName(), true);
+ }
+ }
+
+ public void testJMSMessageID() throws Exception
+ {
+ try
+ {
+ Message m = queueProducerSession.createMessage();;
+ assertNull(m.getJMSMessageID());
+ queueProducer.send(m);
+
+ assertNotNull(m.getJMSMessageID());
+ assertTrue(m.getJMSMessageID().startsWith("ID:"));
}
finally
{
Modified: branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageBodyTest.java
===================================================================
--- branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageBodyTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageBodyTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -45,1509 +45,1624 @@
*/
public class MessageBodyTest extends HornetQServerTestCase
{
- // Constants -----------------------------------------------------
+ // Constants -----------------------------------------------------
- // Static --------------------------------------------------------
+ // Static --------------------------------------------------------
- // Attributes ----------------------------------------------------
+ // Attributes ----------------------------------------------------
- protected Connection producerConnection, consumerConnection;
+ protected Connection producerConnection, consumerConnection;
- protected Session queueProducerSession, queueConsumerSession;
+ protected Session queueProducerSession, queueConsumerSession;
- protected MessageProducer queueProducer;
+ protected MessageProducer queueProducer;
- protected MessageConsumer queueConsumer;
+ protected MessageConsumer queueConsumer;
- // Constructors --------------------------------------------------
+ // Constructors --------------------------------------------------
- // Public --------------------------------------------------------
+ // Public --------------------------------------------------------
- public void setUp() throws Exception
- {
- super.setUp();
+ public void setUp() throws Exception
+ {
+ super.setUp();
- producerConnection = getConnectionFactory().createConnection();
- consumerConnection = getConnectionFactory().createConnection();
+ producerConnection = getConnectionFactory().createConnection();
+ consumerConnection = getConnectionFactory().createConnection();
- queueProducerSession = producerConnection.createSession(false,
- Session.AUTO_ACKNOWLEDGE);
- queueConsumerSession = consumerConnection.createSession(false,
- Session.AUTO_ACKNOWLEDGE);
+ queueProducerSession = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ queueConsumerSession = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- queueProducer = queueProducerSession.createProducer(queue1);
- queueConsumer = queueConsumerSession.createConsumer(queue1);
+ queueProducer = queueProducerSession.createProducer(queue1);
+ queueConsumer = queueConsumerSession.createConsumer(queue1);
- consumerConnection.start();
- }
+ consumerConnection.start();
+ }
- public void tearDown() throws Exception
- {
- producerConnection.close();
- consumerConnection.close();
+ public void tearDown() throws Exception
+ {
+ producerConnection.close();
+ consumerConnection.close();
- super.tearDown();
- }
+ super.tearDown();
+ }
- public void testSMBodyReadable() throws Exception
- {
- byte bValue = 123;
- StreamMessage sm = queueProducerSession.createStreamMessage();
- sm.writeByte(bValue);
- sm.setStringProperty("COM_SUN_JMS_TESTNAME",
- "xMessageEOFExceptionQTestforStreamMessage");
- queueProducer.send(sm);
+ public void testSMBodyReadable() throws Exception
+ {
+ byte bValue = 123;
+ StreamMessage sm = queueProducerSession.createStreamMessage();
+ sm.writeByte(bValue);
+ sm.setStringProperty("COM_SUN_JMS_TESTNAME", "xMessageEOFExceptionQTestforStreamMessage");
+ queueProducer.send(sm);
- StreamMessage received = (StreamMessage) queueConsumer.receive(3000);
- received.readByte();
- }
+ StreamMessage received = (StreamMessage)queueConsumer.receive(3000);
+ received.readByte();
+ }
- public void testBytesMessage() throws Exception
- {
- BytesMessage m = queueProducerSession.createBytesMessage();
+ public void testBytesMessage() throws Exception
+ {
+ BytesMessage m = queueProducerSession.createBytesMessage();
- // some arbitrary values
- boolean myBool = true;
- byte myByte = -111;
- short myShort = 15321;
- int myInt = 0x71ab6c80;
- long myLong = 0x20bf1e3fb6fa31dfL;
- float myFloat = Float.MAX_VALUE - 23465;
- double myDouble = Double.MAX_VALUE - 72387633;
- String myString = "abcdef&^*&!^ghijkl\uD5E2\uCAC7\uD2BB\uB7DD\uB7C7\uB3A3\uBCE4\uB5A5";
- log.trace("String is length:" + myString.length());
- char myChar = 'q';
- byte[] myBytes = new byte[] { -23, 114, -126, -12, 74, 87 };
+ // some arbitrary values
+ boolean myBool = true;
+ byte myByte = -111;
+ short myShort = 15321;
+ int myInt = 0x71ab6c80;
+ long myLong = 0x20bf1e3fb6fa31dfL;
+ float myFloat = Float.MAX_VALUE - 23465;
+ double myDouble = Double.MAX_VALUE - 72387633;
+ String myString = "abcdef&^*&!^ghijkl\uD5E2\uCAC7\uD2BB\uB7DD\uB7C7\uB3A3\uBCE4\uB5A5";
+ log.trace("String is length:" + myString.length());
+ char myChar = 'q';
+ byte[] myBytes = new byte[] { -23, 114, -126, -12, 74, 87 };
- m.writeBoolean(myBool);
- m.writeByte(myByte);
- m.writeShort(myShort);
- m.writeChar(myChar);
- m.writeInt(myInt);
- m.writeLong(myLong);
- m.writeFloat(myFloat);
- m.writeDouble(myDouble);
- m.writeUTF(myString);
- m.writeBytes(myBytes);
- m.writeBytes(myBytes, 2, 3);
+ m.writeBoolean(myBool);
+ m.writeByte(myByte);
+ m.writeShort(myShort);
+ m.writeChar(myChar);
+ m.writeInt(myInt);
+ m.writeLong(myLong);
+ m.writeFloat(myFloat);
+ m.writeDouble(myDouble);
+ m.writeUTF(myString);
+ m.writeBytes(myBytes);
+ m.writeBytes(myBytes, 2, 3);
- m.writeObject(new Boolean(myBool));
- m.writeObject(new Byte(myByte));
- m.writeObject(new Short(myShort));
- m.writeObject(new Integer(myInt));
- m.writeObject(new Long(myLong));
- m.writeObject(new Float(myFloat));
- m.writeObject(new Double(myDouble));
- m.writeObject(myString);
- m.writeObject(myBytes);
+ m.writeObject(new Boolean(myBool));
+ m.writeObject(new Byte(myByte));
+ m.writeObject(new Short(myShort));
+ m.writeObject(new Integer(myInt));
+ m.writeObject(new Long(myLong));
+ m.writeObject(new Float(myFloat));
+ m.writeObject(new Double(myDouble));
+ m.writeObject(myString);
+ m.writeObject(myBytes);
- try
- {
- m.writeObject(new Object());
- fail();
- } catch (MessageFormatException e)
- {
- // OK
- }
+ try
+ {
+ m.writeObject(new Object());
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ // OK
+ }
- // Reading should not be possible when message is read-write
- try
- {
- m.readBoolean();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- // OK
- }
- try
- {
- m.readShort();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- // OK
- }
- try
- {
- m.readChar();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- // OK
- }
- try
- {
- m.readInt();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- // OK
- }
- try
- {
- m.readLong();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- // OK
- }
- try
- {
- m.readFloat();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- // OK
- }
- try
- {
- m.readDouble();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- // OK
- }
- try
- {
- m.readUTF();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- // OK
- }
- try
- {
- m.readUnsignedByte();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- // OK
- }
- try
- {
- m.readUnsignedShort();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- // OK
- }
- try
- {
- byte[] bytes = new byte[333];
- m.readBytes(bytes);
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- // OK
- }
- try
- {
- byte[] bytes = new byte[333];
- m.readBytes(bytes, 111);
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- // OK
- }
- try
- {
- m.getBodyLength();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- // OK
- }
+ // Reading should not be possible when message is read-write
+ try
+ {
+ m.readBoolean();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m.readShort();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m.readChar();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m.readInt();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m.readLong();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m.readFloat();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m.readDouble();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m.readUTF();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m.readUnsignedByte();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m.readUnsignedShort();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ // OK
+ }
+ try
+ {
+ byte[] bytes = new byte[333];
+ m.readBytes(bytes);
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ // OK
+ }
+ try
+ {
+ byte[] bytes = new byte[333];
+ m.readBytes(bytes, 111);
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m.getBodyLength();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ // OK
+ }
- queueProducer.send(queue1, m);
+ queueProducer.send(queue1, m);
- BytesMessage m2 = (BytesMessage) queueConsumer.receive(2000);
+ BytesMessage m2 = (BytesMessage)queueConsumer.receive(2000);
- assertNotNull(m2);
+ assertNotNull(m2);
- assertEquals(myBool, m2.readBoolean());
- assertEquals(myByte, m2.readByte());
- assertEquals(myShort, m2.readShort());
- assertEquals(myChar, m2.readChar());
- assertEquals(myInt, m2.readInt());
- assertEquals(myLong, m2.readLong());
- assertEquals(myFloat, m2.readFloat(), 0);
- assertEquals(myDouble, m2.readDouble(), 0);
- assertEquals(myString, m2.readUTF());
+ assertEquals(myBool, m2.readBoolean());
+ assertEquals(myByte, m2.readByte());
+ assertEquals(myShort, m2.readShort());
+ assertEquals(myChar, m2.readChar());
+ assertEquals(myInt, m2.readInt());
+ assertEquals(myLong, m2.readLong());
+ assertEquals(myFloat, m2.readFloat(), 0);
+ assertEquals(myDouble, m2.readDouble(), 0);
+ assertEquals(myString, m2.readUTF());
- byte[] bytes = new byte[6];
- int ret = m2.readBytes(bytes);
- assertEquals(6, ret);
+ byte[] bytes = new byte[6];
+ int ret = m2.readBytes(bytes);
+ assertEquals(6, ret);
- assertByteArraysEqual(myBytes, bytes);
+ assertByteArraysEqual(myBytes, bytes);
- byte[] bytes2 = new byte[3];
- ret = m2.readBytes(bytes2);
+ byte[] bytes2 = new byte[3];
+ ret = m2.readBytes(bytes2);
- assertEquals(3, ret);
+ assertEquals(3, ret);
- assertEquals(myBytes[2], bytes2[0]);
- assertEquals(myBytes[3], bytes2[1]);
- assertEquals(myBytes[4], bytes2[2]);
+ assertEquals(myBytes[2], bytes2[0]);
+ assertEquals(myBytes[3], bytes2[1]);
+ assertEquals(myBytes[4], bytes2[2]);
- assertEquals(myBool, m2.readBoolean());
- assertEquals(myByte, m2.readByte());
- assertEquals(myShort, m2.readShort());
- assertEquals(myInt, m2.readInt());
- assertEquals(myLong, m2.readLong());
- assertEquals(myFloat, m2.readFloat(), 0);
- assertEquals(myDouble, m2.readDouble(), 0);
- assertEquals(myString, m2.readUTF());
+ assertEquals(myBool, m2.readBoolean());
+ assertEquals(myByte, m2.readByte());
+ assertEquals(myShort, m2.readShort());
+ assertEquals(myInt, m2.readInt());
+ assertEquals(myLong, m2.readLong());
+ assertEquals(myFloat, m2.readFloat(), 0);
+ assertEquals(myDouble, m2.readDouble(), 0);
+ assertEquals(myString, m2.readUTF());
- bytes = new byte[6];
- ret = m2.readBytes(bytes);
- assertEquals(6, ret);
- assertByteArraysEqual(myBytes, bytes);
+ bytes = new byte[6];
+ ret = m2.readBytes(bytes);
+ assertEquals(6, ret);
+ assertByteArraysEqual(myBytes, bytes);
- ret = m2.readBytes(bytes);
- assertEquals(-1, ret);
+ ret = m2.readBytes(bytes);
+ assertEquals(-1, ret);
- // Try and read past the end of the stream
- try
- {
- m2.readBoolean();
- fail();
- } catch (MessageEOFException e)
- {
- // OK
- }
+ // Try and read past the end of the stream
+ try
+ {
+ m2.readBoolean();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ // OK
+ }
- try
- {
- m2.readByte();
- fail();
- } catch (MessageEOFException e)
- {
- // OK
- }
+ try
+ {
+ m2.readByte();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ // OK
+ }
- try
- {
- m2.readChar();
- fail();
- } catch (MessageEOFException e)
- {
- // OK
- }
+ try
+ {
+ m2.readChar();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ // OK
+ }
- try
- {
- m2.readDouble();
- fail();
- } catch (MessageEOFException e)
- {
- // OK
- }
+ try
+ {
+ m2.readDouble();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ // OK
+ }
- try
- {
- m2.readFloat();
- fail();
- } catch (MessageEOFException e)
- {
- // OK
- }
+ try
+ {
+ m2.readFloat();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ // OK
+ }
- try
- {
- m2.readInt();
- fail();
- } catch (MessageEOFException e)
- {
- // OK
- }
+ try
+ {
+ m2.readInt();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ // OK
+ }
- try
- {
- m2.readLong();
- fail();
- } catch (MessageEOFException e)
- {
- // OK
- }
+ try
+ {
+ m2.readLong();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ // OK
+ }
- try
- {
- m2.readShort();
- fail();
- } catch (MessageEOFException e)
- {
- // OK
- }
+ try
+ {
+ m2.readShort();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ // OK
+ }
- try
- {
- m2.readUnsignedByte();
- fail();
- } catch (MessageEOFException e)
- {
- // OK
- }
+ try
+ {
+ m2.readUnsignedByte();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ // OK
+ }
- try
- {
- m2.readUnsignedShort();
- fail();
- } catch (MessageEOFException e)
- {
- // OK
- }
+ try
+ {
+ m2.readUnsignedShort();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ // OK
+ }
- try
- {
- m2.readUTF();
- fail();
- } catch (MessageEOFException e)
- {
- // OK
- }
+ try
+ {
+ m2.readUTF();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ // OK
+ }
- // Message should not be writable in read-only mode
- try
- {
- m2.writeBoolean(myBool);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- // OK
- }
- try
- {
- m2.writeByte(myByte);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- // OK
- }
- try
- {
- m2.writeShort(myShort);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- // OK
- }
- try
- {
- m2.writeChar(myChar);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- // OK
- }
+ // Message should not be writable in read-only mode
+ try
+ {
+ m2.writeBoolean(myBool);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m2.writeByte(myByte);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m2.writeShort(myShort);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m2.writeChar(myChar);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ // OK
+ }
- try
- {
- m2.writeInt(myInt);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- // OK
- }
- try
- {
- m2.writeLong(myLong);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- // OK
- }
- try
- {
- m2.writeFloat(myFloat);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- // OK
- }
- try
- {
- m2.writeDouble(myDouble);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- // OK
- }
- try
- {
- m2.writeUTF(myString);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- // OK
- }
+ try
+ {
+ m2.writeInt(myInt);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m2.writeLong(myLong);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m2.writeFloat(myFloat);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m2.writeDouble(myDouble);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m2.writeUTF(myString);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ // OK
+ }
- try
- {
- m2.writeBytes(myBytes);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- // OK
- }
+ try
+ {
+ m2.writeBytes(myBytes);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ // OK
+ }
- try
- {
- m2.writeObject(myString);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- // OK
- }
+ try
+ {
+ m2.writeObject(myString);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ // OK
+ }
- long bodyLength = m2.getBodyLength();
+ long bodyLength = m2.getBodyLength();
- assertEquals(161, bodyLength);
+ assertEquals(161, bodyLength);
- m2.reset();
+ m2.reset();
- // test the unsigned reads
+ // test the unsigned reads
- m2.readBoolean();
- int unsignedByte = m2.readUnsignedByte();
+ m2.readBoolean();
+ int unsignedByte = m2.readUnsignedByte();
- assertEquals((int) (myByte & 0xFF), unsignedByte);
+ assertEquals((int)(myByte & 0xFF), unsignedByte);
- int unsignedShort = m2.readUnsignedShort();
+ int unsignedShort = m2.readUnsignedShort();
- assertEquals((int) (myShort & 0xFFFF), unsignedShort);
+ assertEquals((int)(myShort & 0xFFFF), unsignedShort);
- m2.clearBody();
+ m2.clearBody();
- try
- {
- m2.getBodyLength();
- fail();
- } catch (MessageNotReadableException e)
- {
- // OK
- }
+ try
+ {
+ m2.getBodyLength();
+ fail();
+ }
+ catch (MessageNotReadableException e)
+ {
+ // OK
+ }
- m2.reset();
+ m2.reset();
- assertEquals(0, m2.getBodyLength());
+ assertEquals(0, m2.getBodyLength());
- // Test that changing the received message doesn't affect the sent message
- m.reset();
- assertEquals(161, m.getBodyLength());
+ // Test that changing the received message doesn't affect the sent message
+ m.reset();
+ assertEquals(161, m.getBodyLength());
- // Should be diffent object instances after sending *even* if in same JVM
- assertFalse(m == m2);
+ // Should be diffent object instances after sending *even* if in same JVM
+ assertFalse(m == m2);
- }
+ }
- public void testMapMessage() throws Exception
- {
- MapMessage m1 = queueProducerSession.createMapMessage();
+ public void testMapMessage() throws Exception
+ {
+ MapMessage m1 = queueProducerSession.createMapMessage();
- // Some arbitrary values
- boolean myBool = true;
- byte myByte = 13;
- short myShort = 15321;
- int myInt = 0x71ab6c80;
- long myLong = 0x20bf1e3fb6fa31dfL;
- float myFloat = Float.MAX_VALUE - 23465;
- double myDouble = Double.MAX_VALUE - 72387633;
- String myString = "abcdef&^*&!^ghijkl\uD5E2\uCAC7\uD2BB\uB7DD\uB7C7\uB3A3\uBCE4\uB5A5";
+ // Some arbitrary values
+ boolean myBool = true;
+ byte myByte = 13;
+ short myShort = 15321;
+ int myInt = 0x71ab6c80;
+ long myLong = 0x20bf1e3fb6fa31dfL;
+ float myFloat = Float.MAX_VALUE - 23465;
+ double myDouble = Double.MAX_VALUE - 72387633;
+ String myString = "abcdef&^*&!^ghijkl\uD5E2\uCAC7\uD2BB\uB7DD\uB7C7\uB3A3\uBCE4\uB5A5";
- m1.setBoolean("myBool", myBool);
- m1.setByte("myByte", myByte);
- m1.setShort("myShort", myShort);
- m1.setInt("myInt", myInt);
- m1.setLong("myLong", myLong);
- m1.setFloat("myFloat", myFloat);
- m1.setDouble("myDouble", myDouble);
- m1.setString("myString", myString);
+ m1.setBoolean("myBool", myBool);
+ m1.setByte("myByte", myByte);
+ m1.setShort("myShort", myShort);
+ m1.setInt("myInt", myInt);
+ m1.setLong("myLong", myLong);
+ m1.setFloat("myFloat", myFloat);
+ m1.setDouble("myDouble", myDouble);
+ m1.setString("myString", myString);
- m1.setObject("myBool", new Boolean(myBool));
- m1.setObject("myByte", new Byte(myByte));
- m1.setObject("myShort", new Short(myShort));
- m1.setObject("myInt", new Integer(myInt));
- m1.setObject("myLong", new Long(myLong));
- m1.setObject("myFloat", new Float(myFloat));
- m1.setObject("myDouble", new Double(myDouble));
- m1.setObject("myString", myString);
+ m1.setObject("myBool", new Boolean(myBool));
+ m1.setObject("myByte", new Byte(myByte));
+ m1.setObject("myShort", new Short(myShort));
+ m1.setObject("myInt", new Integer(myInt));
+ m1.setObject("myLong", new Long(myLong));
+ m1.setObject("myFloat", new Float(myFloat));
+ m1.setObject("myDouble", new Double(myDouble));
+ m1.setObject("myString", myString);
- try
- {
- m1.setObject("myIllegal", new Object());
- fail();
- } catch (javax.jms.MessageFormatException e)
- {
- }
+ try
+ {
+ m1.setObject("myIllegal", new Object());
+ fail();
+ }
+ catch (javax.jms.MessageFormatException e)
+ {
+ }
- queueProducer.send(queue1, m1);
+ queueProducer.send(queue1, m1);
- MapMessage m2 = (MapMessage) queueConsumer.receive(2000);
+ MapMessage m2 = (MapMessage)queueConsumer.receive(2000);
- assertNotNull(m2);
+ assertNotNull(m2);
- assertEquals(myBool, m2.getBoolean("myBool"));
- assertEquals(myByte, m2.getByte("myByte"));
- assertEquals(myShort, m2.getShort("myShort"));
- assertEquals(myInt, m2.getInt("myInt"));
- assertEquals(myLong, m2.getLong("myLong"));
- assertEquals(myFloat, m2.getFloat("myFloat"), 0);
- assertEquals(myDouble, m2.getDouble("myDouble"), 0);
- assertEquals(myString, m2.getString("myString"));
+ assertEquals(myBool, m2.getBoolean("myBool"));
+ assertEquals(myByte, m2.getByte("myByte"));
+ assertEquals(myShort, m2.getShort("myShort"));
+ assertEquals(myInt, m2.getInt("myInt"));
+ assertEquals(myLong, m2.getLong("myLong"));
+ assertEquals(myFloat, m2.getFloat("myFloat"), 0);
+ assertEquals(myDouble, m2.getDouble("myDouble"), 0);
+ assertEquals(myString, m2.getString("myString"));
- // Properties should now be read-only
- try
- {
- m2.setBoolean("myBool", myBool);
- fail();
- } catch (MessageNotWriteableException e)
- {
- }
+ // Properties should now be read-only
+ try
+ {
+ m2.setBoolean("myBool", myBool);
+ fail();
+ }
+ catch (MessageNotWriteableException e)
+ {
+ }
- try
- {
- m2.setByte("myByte", myByte);
- fail();
- } catch (MessageNotWriteableException e)
- {
- }
+ try
+ {
+ m2.setByte("myByte", myByte);
+ fail();
+ }
+ catch (MessageNotWriteableException e)
+ {
+ }
- try
- {
- m2.setShort("myShort", myShort);
- fail();
- } catch (MessageNotWriteableException e)
- {
- }
+ try
+ {
+ m2.setShort("myShort", myShort);
+ fail();
+ }
+ catch (MessageNotWriteableException e)
+ {
+ }
- try
- {
- m2.setInt("myInt", myInt);
- fail();
- } catch (MessageNotWriteableException e)
- {
- }
+ try
+ {
+ m2.setInt("myInt", myInt);
+ fail();
+ }
+ catch (MessageNotWriteableException e)
+ {
+ }
- try
- {
- m2.setLong("myLong", myLong);
- fail();
- } catch (MessageNotWriteableException e)
- {
- }
+ try
+ {
+ m2.setLong("myLong", myLong);
+ fail();
+ }
+ catch (MessageNotWriteableException e)
+ {
+ }
- try
- {
- m2.setFloat("myFloat", myFloat);
- fail();
- } catch (MessageNotWriteableException e)
- {
- }
+ try
+ {
+ m2.setFloat("myFloat", myFloat);
+ fail();
+ }
+ catch (MessageNotWriteableException e)
+ {
+ }
- try
- {
- m2.setDouble("myDouble", myDouble);
- fail();
- } catch (MessageNotWriteableException e)
- {
- }
+ try
+ {
+ m2.setDouble("myDouble", myDouble);
+ fail();
+ }
+ catch (MessageNotWriteableException e)
+ {
+ }
- try
- {
- m2.setString("myString", myString);
- fail();
- } catch (MessageNotWriteableException e)
- {
- }
+ try
+ {
+ m2.setString("myString", myString);
+ fail();
+ }
+ catch (MessageNotWriteableException e)
+ {
+ }
- assertTrue(m2.itemExists("myBool"));
- assertTrue(m2.itemExists("myByte"));
- assertTrue(m2.itemExists("myShort"));
- assertTrue(m2.itemExists("myInt"));
- assertTrue(m2.itemExists("myLong"));
- assertTrue(m2.itemExists("myFloat"));
- assertTrue(m2.itemExists("myDouble"));
- assertTrue(m2.itemExists("myString"));
+ assertTrue(m2.itemExists("myBool"));
+ assertTrue(m2.itemExists("myByte"));
+ assertTrue(m2.itemExists("myShort"));
+ assertTrue(m2.itemExists("myInt"));
+ assertTrue(m2.itemExists("myLong"));
+ assertTrue(m2.itemExists("myFloat"));
+ assertTrue(m2.itemExists("myDouble"));
+ assertTrue(m2.itemExists("myString"));
- assertFalse(m2.itemExists("sausages"));
+ assertFalse(m2.itemExists("sausages"));
- HashSet itemNames = new HashSet();
- Enumeration en = m2.getMapNames();
- while (en.hasMoreElements())
- {
- String propName = (String) en.nextElement();
- itemNames.add(propName);
- }
+ HashSet itemNames = new HashSet();
+ Enumeration en = m2.getMapNames();
+ while (en.hasMoreElements())
+ {
+ String propName = (String)en.nextElement();
+ itemNames.add(propName);
+ }
- assertEquals(8, itemNames.size());
+ assertEquals(8, itemNames.size());
- assertTrue(itemNames.contains("myBool"));
- assertTrue(itemNames.contains("myByte"));
- assertTrue(itemNames.contains("myShort"));
- assertTrue(itemNames.contains("myInt"));
- assertTrue(itemNames.contains("myLong"));
- assertTrue(itemNames.contains("myFloat"));
- assertTrue(itemNames.contains("myDouble"));
- assertTrue(itemNames.contains("myString"));
+ assertTrue(itemNames.contains("myBool"));
+ assertTrue(itemNames.contains("myByte"));
+ assertTrue(itemNames.contains("myShort"));
+ assertTrue(itemNames.contains("myInt"));
+ assertTrue(itemNames.contains("myLong"));
+ assertTrue(itemNames.contains("myFloat"));
+ assertTrue(itemNames.contains("myDouble"));
+ assertTrue(itemNames.contains("myString"));
- // Check property conversions
+ // Check property conversions
- // Boolean property can be read as String but not anything else
+ // Boolean property can be read as String but not anything else
- assertEquals(String.valueOf(myBool), m2.getString("myBool"));
+ assertEquals(String.valueOf(myBool), m2.getString("myBool"));
- try
- {
- m2.getByte("myBool");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getByte("myBool");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getShort("myBool");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getShort("myBool");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getInt("myBool");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getInt("myBool");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getLong("myBool");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getLong("myBool");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getFloat("myBool");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getFloat("myBool");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getDouble("myBool");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getDouble("myBool");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- // byte item can be read as short, int, long or String
+ // byte item can be read as short, int, long or String
- assertEquals((short) myByte, m2.getShort("myByte"));
- assertEquals((int) myByte, m2.getInt("myByte"));
- assertEquals((long) myByte, m2.getLong("myByte"));
- assertEquals(String.valueOf(myByte), m2.getString("myByte"));
+ assertEquals((short)myByte, m2.getShort("myByte"));
+ assertEquals((int)myByte, m2.getInt("myByte"));
+ assertEquals((long)myByte, m2.getLong("myByte"));
+ assertEquals(String.valueOf(myByte), m2.getString("myByte"));
- try
- {
- m2.getBoolean("myByte");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getBoolean("myByte");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getFloat("myByte");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getFloat("myByte");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getDouble("myByte");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getDouble("myByte");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- // short item can be read as int, long or String
+ // short item can be read as int, long or String
- assertEquals((int) myShort, m2.getInt("myShort"));
- assertEquals((long) myShort, m2.getLong("myShort"));
- assertEquals(String.valueOf(myShort), m2.getString("myShort"));
+ assertEquals((int)myShort, m2.getInt("myShort"));
+ assertEquals((long)myShort, m2.getLong("myShort"));
+ assertEquals(String.valueOf(myShort), m2.getString("myShort"));
- try
- {
- m2.getByte("myShort");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getByte("myShort");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getBoolean("myShort");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getBoolean("myShort");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getFloat("myShort");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getFloat("myShort");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getDouble("myShort");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getDouble("myShort");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- // int item can be read as long or String
+ // int item can be read as long or String
- assertEquals((long) myInt, m2.getLong("myInt"));
- assertEquals(String.valueOf(myInt), m2.getString("myInt"));
+ assertEquals((long)myInt, m2.getLong("myInt"));
+ assertEquals(String.valueOf(myInt), m2.getString("myInt"));
- try
- {
- m2.getShort("myInt");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getShort("myInt");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getByte("myInt");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getByte("myInt");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getBoolean("myInt");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getBoolean("myInt");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getFloat("myInt");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getFloat("myInt");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getDouble("myInt");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getDouble("myInt");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- // long item can be read as String
+ // long item can be read as String
- assertEquals(String.valueOf(myLong), m2.getString("myLong"));
+ assertEquals(String.valueOf(myLong), m2.getString("myLong"));
- try
- {
- m2.getInt("myLong");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getInt("myLong");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getShort("myLong");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getShort("myLong");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getByte("myLong");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getByte("myLong");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getBoolean("myLong");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getBoolean("myLong");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getFloat("myLong");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getFloat("myLong");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getDouble("myLong");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getDouble("myLong");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- // float can be read as double or String
+ // float can be read as double or String
- assertEquals(String.valueOf(myFloat), m2.getString("myFloat"));
- assertEquals((double) myFloat, m2.getDouble("myFloat"), 0);
+ assertEquals(String.valueOf(myFloat), m2.getString("myFloat"));
+ assertEquals((double)myFloat, m2.getDouble("myFloat"), 0);
- try
- {
- m2.getInt("myFloat");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getInt("myFloat");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getShort("myFloat");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getShort("myFloat");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getLong("myFloat");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getLong("myFloat");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getByte("myFloat");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getByte("myFloat");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getBoolean("myFloat");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getBoolean("myFloat");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- // double can be read as String
+ // double can be read as String
- assertEquals(String.valueOf(myDouble), m2.getString("myDouble"));
+ assertEquals(String.valueOf(myDouble), m2.getString("myDouble"));
- try
- {
- m2.getFloat("myDouble");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getFloat("myDouble");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getInt("myDouble");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getInt("myDouble");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getShort("myDouble");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getShort("myDouble");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getByte("myDouble");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getByte("myDouble");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getBoolean("myDouble");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getBoolean("myDouble");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getFloat("myDouble");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getFloat("myDouble");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- m2.clearBody();
+ m2.clearBody();
- assertFalse(m2.getMapNames().hasMoreElements());
+ assertFalse(m2.getMapNames().hasMoreElements());
- // Test String -> Numeric and bool conversions
- MapMessage m3 = (MapMessage) queueProducerSession.createMapMessage();
+ // Test String -> Numeric and bool conversions
+ MapMessage m3 = (MapMessage)queueProducerSession.createMapMessage();
- m3.setString("myBool", String.valueOf(myBool));
- m3.setString("myByte", String.valueOf(myByte));
- m3.setString("myShort", String.valueOf(myShort));
- m3.setString("myInt", String.valueOf(myInt));
- m3.setString("myLong", String.valueOf(myLong));
- m3.setString("myFloat", String.valueOf(myFloat));
- m3.setString("myDouble", String.valueOf(myDouble));
- m3.setString("myIllegal", "xyz123");
+ m3.setString("myBool", String.valueOf(myBool));
+ m3.setString("myByte", String.valueOf(myByte));
+ m3.setString("myShort", String.valueOf(myShort));
+ m3.setString("myInt", String.valueOf(myInt));
+ m3.setString("myLong", String.valueOf(myLong));
+ m3.setString("myFloat", String.valueOf(myFloat));
+ m3.setString("myDouble", String.valueOf(myDouble));
+ m3.setString("myIllegal", "xyz123");
- assertEquals(myBool, m3.getBoolean("myBool"));
- assertEquals(myByte, m3.getByte("myByte"));
- assertEquals(myShort, m3.getShort("myShort"));
- assertEquals(myInt, m3.getInt("myInt"));
- assertEquals(myLong, m3.getLong("myLong"));
- assertEquals(myFloat, m3.getFloat("myFloat"), 0);
- assertEquals(myDouble, m3.getDouble("myDouble"), 0);
+ assertEquals(myBool, m3.getBoolean("myBool"));
+ assertEquals(myByte, m3.getByte("myByte"));
+ assertEquals(myShort, m3.getShort("myShort"));
+ assertEquals(myInt, m3.getInt("myInt"));
+ assertEquals(myLong, m3.getLong("myLong"));
+ assertEquals(myFloat, m3.getFloat("myFloat"), 0);
+ assertEquals(myDouble, m3.getDouble("myDouble"), 0);
- m3.getBoolean("myIllegal");
+ m3.getBoolean("myIllegal");
- try
- {
- m3.getByte("myIllegal");
- fail();
- } catch (NumberFormatException e)
- {
- }
- try
- {
- m3.getShort("myIllegal");
- fail();
- } catch (NumberFormatException e)
- {
- }
- try
- {
- m3.getInt("myIllegal");
- fail();
- } catch (NumberFormatException e)
- {
- }
- try
- {
- m3.getLong("myIllegal");
- fail();
- } catch (NumberFormatException e)
- {
- }
- try
- {
- m3.getFloat("myIllegal");
- fail();
- } catch (NumberFormatException e)
- {
- }
- try
- {
- m3.getDouble("myIllegal");
- fail();
- } catch (NumberFormatException e)
- {
- }
+ try
+ {
+ m3.getByte("myIllegal");
+ fail();
+ }
+ catch (NumberFormatException e)
+ {
+ }
+ try
+ {
+ m3.getShort("myIllegal");
+ fail();
+ }
+ catch (NumberFormatException e)
+ {
+ }
+ try
+ {
+ m3.getInt("myIllegal");
+ fail();
+ }
+ catch (NumberFormatException e)
+ {
+ }
+ try
+ {
+ m3.getLong("myIllegal");
+ fail();
+ }
+ catch (NumberFormatException e)
+ {
+ }
+ try
+ {
+ m3.getFloat("myIllegal");
+ fail();
+ }
+ catch (NumberFormatException e)
+ {
+ }
+ try
+ {
+ m3.getDouble("myIllegal");
+ fail();
+ }
+ catch (NumberFormatException e)
+ {
+ }
- }
+ }
- static class TestSerializable implements Serializable
- {
- private static final long serialVersionUID = -8641359255228705573L;
+ static class TestSerializable implements Serializable
+ {
+ private static final long serialVersionUID = -8641359255228705573L;
- String str;
- }
+ String str;
+ }
- public void testObjectMessage() throws Exception
- {
- TestSerializable obj = new TestSerializable();
+ public void testObjectMessage() throws Exception
+ {
+ TestSerializable obj = new TestSerializable();
- obj.str = "abcdefg";
+ obj.str = "abcdefg";
- ObjectMessage m1 = queueProducerSession.createObjectMessage(obj);
+ ObjectMessage m1 = queueProducerSession.createObjectMessage(obj);
- queueProducer.send(queue1, m1);
+ queueProducer.send(queue1, m1);
- ObjectMessage m2 = (ObjectMessage) queueConsumer.receive(2000);
+ ObjectMessage m2 = (ObjectMessage)queueConsumer.receive(2000);
- assertNotNull(m2);
+ assertNotNull(m2);
- TestSerializable obj2 = (TestSerializable) m2.getObject();
+ TestSerializable obj2 = (TestSerializable)m2.getObject();
- assertEquals(obj.str, obj2.str);
+ assertEquals(obj.str, obj2.str);
- ObjectMessage m3 = queueProducerSession.createObjectMessage();
+ ObjectMessage m3 = queueProducerSession.createObjectMessage();
- m3.setObject(obj);
-
- queueProducer.send(queue1, m3);
-
- obj.str = "xyz123";
+ m3.setObject(obj);
- ObjectMessage m4 = (ObjectMessage) queueConsumer.receive(2000);
+ queueProducer.send(queue1, m3);
- assertNotNull(m4);
+ obj.str = "xyz123";
- TestSerializable obj3 = (TestSerializable) m4.getObject();
+ ObjectMessage m4 = (ObjectMessage)queueConsumer.receive(2000);
- assertEquals("abcdefg", obj3.str);
+ assertNotNull(m4);
- try
- {
- m4.setObject(obj);
- fail();
- } catch (MessageNotWriteableException e)
- {
- }
+ TestSerializable obj3 = (TestSerializable)m4.getObject();
- m4.clearBody();
+ assertEquals("abcdefg", obj3.str);
- m4.setObject(obj);
+ try
+ {
+ m4.setObject(obj);
+ fail();
+ }
+ catch (MessageNotWriteableException e)
+ {
+ }
- TestSerializable obj4 = (TestSerializable) m4.getObject();
+ m4.clearBody();
- assertNotNull(obj4);
+ m4.setObject(obj);
- }
+ TestSerializable obj4 = (TestSerializable)m4.getObject();
- public void testStreamMessage() throws Exception
- {
- StreamMessage m = queueProducerSession.createStreamMessage();
+ assertNotNull(obj4);
- // Some arbitrary values
- boolean myBool = true;
- byte myByte = -111;
- short myShort = 15321;
- int myInt = 0x71ab6c80;
- long myLong = 0x20bf1e3fb6fa31dfL;
- float myFloat = Float.MAX_VALUE - 23465;
- double myDouble = Double.MAX_VALUE - 72387633;
- String myString = "abcdef&^*&!^ghijkl\uD5E2\uCAC7\uD2BB\uB7DD\uB7C7\uB3A3\uBCE4\uB5A5";
- char myChar = 'q';
- byte[] myBytes = new byte[] { -23, 114, -126, -12, 74, 87 };
+ }
- m.writeBoolean(myBool);
- m.writeByte(myByte);
- m.writeShort(myShort);
- m.writeChar(myChar);
- m.writeInt(myInt);
- m.writeLong(myLong);
- m.writeFloat(myFloat);
- m.writeDouble(myDouble);
- m.writeString(myString);
- m.writeBytes(myBytes);
- m.writeBytes(myBytes, 2, 3);
+ public void testStreamMessage() throws Exception
+ {
+ StreamMessage m = queueProducerSession.createStreamMessage();
- m.writeObject(new Boolean(myBool));
- m.writeObject(new Byte(myByte));
- m.writeObject(new Short(myShort));
- m.writeObject(new Integer(myInt));
- m.writeObject(new Long(myLong));
- m.writeObject(new Float(myFloat));
- m.writeObject(new Double(myDouble));
- m.writeObject(myString);
- m.writeObject(myBytes);
+ // Some arbitrary values
+ boolean myBool = true;
+ byte myByte = -111;
+ short myShort = 15321;
+ int myInt = 0x71ab6c80;
+ long myLong = 0x20bf1e3fb6fa31dfL;
+ float myFloat = Float.MAX_VALUE - 23465;
+ double myDouble = Double.MAX_VALUE - 72387633;
+ String myString = "abcdef&^*&!^ghijkl\uD5E2\uCAC7\uD2BB\uB7DD\uB7C7\uB3A3\uBCE4\uB5A5";
+ char myChar = 'q';
+ byte[] myBytes = new byte[] { -23, 114, -126, -12, 74, 87 };
- try
- {
- m.writeObject(new Object());
- fail();
- } catch (MessageFormatException e)
- {
- }
+ m.writeBoolean(myBool);
+ m.writeByte(myByte);
+ m.writeShort(myShort);
+ m.writeChar(myChar);
+ m.writeInt(myInt);
+ m.writeLong(myLong);
+ m.writeFloat(myFloat);
+ m.writeDouble(myDouble);
+ m.writeString(myString);
+ m.writeBytes(myBytes);
+ m.writeBytes(myBytes, 2, 3);
- // Reading should not be possible when message is read-write
- try
- {
- m.readBoolean();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- }
- try
- {
- m.readShort();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- }
- try
- {
- m.readChar();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- }
- try
- {
- m.readInt();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- }
- try
- {
- m.readLong();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- }
- try
- {
- m.readFloat();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- }
- try
- {
- m.readDouble();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- }
- try
- {
- byte[] bytes = new byte[333];
- m.readBytes(bytes);
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- }
+ m.writeObject(new Boolean(myBool));
+ m.writeObject(new Byte(myByte));
+ m.writeObject(new Short(myShort));
+ m.writeObject(new Integer(myInt));
+ m.writeObject(new Long(myLong));
+ m.writeObject(new Float(myFloat));
+ m.writeObject(new Double(myDouble));
+ m.writeObject(myString);
+ m.writeObject(myBytes);
- queueProducer.send(queue1, m);
+ try
+ {
+ m.writeObject(new Object());
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- StreamMessage m2 = (StreamMessage) queueConsumer.receive(2000);
+ // Reading should not be possible when message is read-write
+ try
+ {
+ m.readBoolean();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ }
+ try
+ {
+ m.readShort();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ }
+ try
+ {
+ m.readChar();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ }
+ try
+ {
+ m.readInt();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ }
+ try
+ {
+ m.readLong();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ }
+ try
+ {
+ m.readFloat();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ }
+ try
+ {
+ m.readDouble();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ }
+ try
+ {
+ byte[] bytes = new byte[333];
+ m.readBytes(bytes);
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ }
- assertEquals(myBool, m2.readBoolean());
- assertEquals(myByte, m2.readByte());
- assertEquals(myShort, m2.readShort());
- assertEquals(myChar, m2.readChar());
- assertEquals(myInt, m2.readInt());
- assertEquals(myLong, m2.readLong());
- assertEquals(myFloat, m2.readFloat(), 0);
- assertEquals(myDouble, m2.readDouble(), 0);
- assertEquals(myString, m2.readString());
+ queueProducer.send(queue1, m);
- byte[] bytes = new byte[6];
- int ret = m2.readBytes(bytes);
- assertEquals(6, ret);
+ StreamMessage m2 = (StreamMessage)queueConsumer.receive(2000);
- assertByteArraysEqual(myBytes, bytes);
+ assertEquals(myBool, m2.readBoolean());
+ assertEquals(myByte, m2.readByte());
+ assertEquals(myShort, m2.readShort());
+ assertEquals(myChar, m2.readChar());
+ assertEquals(myInt, m2.readInt());
+ assertEquals(myLong, m2.readLong());
+ assertEquals(myFloat, m2.readFloat(), 0);
+ assertEquals(myDouble, m2.readDouble(), 0);
+ assertEquals(myString, m2.readString());
- ret = m2.readBytes(bytes);
- assertEquals(-1, ret);
+ byte[] bytes = new byte[6];
+ int ret = m2.readBytes(bytes);
+ assertEquals(6, ret);
- byte[] bytes2 = new byte[3];
- ret = m2.readBytes(bytes2);
+ assertByteArraysEqual(myBytes, bytes);
- assertEquals(3, ret);
+ ret = m2.readBytes(bytes);
+ assertEquals(-1, ret);
- assertEquals(myBytes[2], bytes2[0]);
- assertEquals(myBytes[3], bytes2[1]);
- assertEquals(myBytes[4], bytes2[2]);
+ byte[] bytes2 = new byte[3];
+ ret = m2.readBytes(bytes2);
- ret = m2.readBytes(bytes2);
- assertEquals(-1, ret);
+ assertEquals(3, ret);
- assertEquals(myBool, m2.readBoolean());
- assertEquals(myByte, m2.readByte());
- assertEquals(myShort, m2.readShort());
- assertEquals(myInt, m2.readInt());
- assertEquals(myLong, m2.readLong());
- assertEquals(myFloat, m2.readFloat(), 0);
- assertEquals(myDouble, m2.readDouble(), 0);
- assertEquals(myString, m2.readString());
+ assertEquals(myBytes[2], bytes2[0]);
+ assertEquals(myBytes[3], bytes2[1]);
+ assertEquals(myBytes[4], bytes2[2]);
- bytes = new byte[6];
- ret = m2.readBytes(bytes);
- assertEquals(6, ret);
- assertByteArraysEqual(myBytes, bytes);
+ ret = m2.readBytes(bytes2);
+ assertEquals(-1, ret);
- ret = m2.readBytes(bytes);
- assertEquals(-1, ret);
+ assertEquals(myBool, m2.readBoolean());
+ assertEquals(myByte, m2.readByte());
+ assertEquals(myShort, m2.readShort());
+ assertEquals(myInt, m2.readInt());
+ assertEquals(myLong, m2.readLong());
+ assertEquals(myFloat, m2.readFloat(), 0);
+ assertEquals(myDouble, m2.readDouble(), 0);
+ assertEquals(myString, m2.readString());
- // Try and read past the end of the stream
- try
- {
- m2.readBoolean();
- fail();
- } catch (MessageEOFException e)
- {
- }
+ bytes = new byte[6];
+ ret = m2.readBytes(bytes);
+ assertEquals(6, ret);
+ assertByteArraysEqual(myBytes, bytes);
- try
- {
- m2.readByte();
- fail();
- } catch (MessageEOFException e)
- {
- }
+ ret = m2.readBytes(bytes);
+ assertEquals(-1, ret);
- try
- {
- m2.readChar();
- fail();
- } catch (MessageEOFException e)
- {
- }
+ // Try and read past the end of the stream
+ try
+ {
+ m2.readBoolean();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ }
- try
- {
- m2.readDouble();
- fail();
- } catch (MessageEOFException e)
- {
- }
+ try
+ {
+ m2.readByte();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ }
- try
- {
- m2.readFloat();
- fail();
- } catch (MessageEOFException e)
- {
- }
+ try
+ {
+ m2.readChar();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ }
- try
- {
- m2.readInt();
- fail();
- } catch (MessageEOFException e)
- {
- }
+ try
+ {
+ m2.readDouble();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ }
- try
- {
- m2.readLong();
- fail();
- } catch (MessageEOFException e)
- {
- }
+ try
+ {
+ m2.readFloat();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ }
- try
- {
- m2.readShort();
- fail();
- } catch (MessageEOFException e)
- {
- }
+ try
+ {
+ m2.readInt();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ }
- // Message should not be writable in read-only mode
- try
- {
- m2.writeBoolean(myBool);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- }
- try
- {
- m2.writeByte(myByte);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- }
- try
- {
- m2.writeShort(myShort);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- }
- try
- {
- m2.writeChar(myChar);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- }
+ try
+ {
+ m2.readLong();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ }
- try
- {
- m2.writeInt(myInt);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- }
- try
- {
- m2.writeLong(myLong);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- }
- try
- {
- m2.writeFloat(myFloat);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- }
- try
- {
- m2.writeDouble(myDouble);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- }
+ try
+ {
+ m2.readShort();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ }
- try
- {
- m2.writeBytes(myBytes);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- }
+ // Message should not be writable in read-only mode
+ try
+ {
+ m2.writeBoolean(myBool);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ }
+ try
+ {
+ m2.writeByte(myByte);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ }
+ try
+ {
+ m2.writeShort(myShort);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ }
+ try
+ {
+ m2.writeChar(myChar);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ }
- try
- {
- m2.writeObject(myString);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- }
+ try
+ {
+ m2.writeInt(myInt);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ }
+ try
+ {
+ m2.writeLong(myLong);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ }
+ try
+ {
+ m2.writeFloat(myFloat);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ }
+ try
+ {
+ m2.writeDouble(myDouble);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ }
- m2.reset();
+ try
+ {
+ m2.writeBytes(myBytes);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ }
- // check we go back to the beginning
- assertEquals(myBool, m2.readBoolean());
- assertEquals(myByte, m2.readByte());
- assertEquals(myShort, m2.readShort());
- assertEquals(myChar, m2.readChar());
- assertEquals(myInt, m2.readInt());
- assertEquals(myLong, m2.readLong());
- assertEquals(myFloat, m2.readFloat(), 0);
- assertEquals(myDouble, m2.readDouble(), 0);
- assertEquals(myString, m2.readString());
+ try
+ {
+ m2.writeObject(myString);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ }
- m2.clearBody();
+ m2.reset();
- try
- {
- // Should now be write only
- m2.readBoolean();
- fail();
- } catch (MessageNotReadableException e)
- {
- }
+ // check we go back to the beginning
+ assertEquals(myBool, m2.readBoolean());
+ assertEquals(myByte, m2.readByte());
+ assertEquals(myShort, m2.readShort());
+ assertEquals(myChar, m2.readChar());
+ assertEquals(myInt, m2.readInt());
+ assertEquals(myLong, m2.readLong());
+ assertEquals(myFloat, m2.readFloat(), 0);
+ assertEquals(myDouble, m2.readDouble(), 0);
+ assertEquals(myString, m2.readString());
- m2.writeBoolean(myBool);
+ m2.clearBody();
- m2.reset();
+ try
+ {
+ // Should now be write only
+ m2.readBoolean();
+ fail();
+ }
+ catch (MessageNotReadableException e)
+ {
+ }
- assertEquals(myBool, m2.readBoolean());
- try
- {
- m2.readBoolean();
- fail();
- } catch (MessageEOFException e)
- {
- }
+ m2.writeBoolean(myBool);
- // Test that changing the received message doesn't affect the sent message
- m.reset();
- assertEquals(myBool, m.readBoolean());
- assertEquals(myByte, m.readByte());
- assertEquals(myShort, m.readShort());
- assertEquals(myChar, m.readChar());
- assertEquals(myInt, m.readInt());
- assertEquals(myLong, m.readLong());
- assertEquals(myFloat, m.readFloat(), 0);
- assertEquals(myDouble, m.readDouble(), 0);
- assertEquals(myString, m.readString());
+ m2.reset();
- // Should be diffent object instances after sending *even* if in same JVM
- assertFalse(m == m2);
- }
+ assertEquals(myBool, m2.readBoolean());
+ try
+ {
+ m2.readBoolean();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ }
- public void testTextMessage() throws Exception
- {
- TextMessage m = queueProducerSession.createTextMessage();
+ // Test that changing the received message doesn't affect the sent message
+ m.reset();
+ assertEquals(myBool, m.readBoolean());
+ assertEquals(myByte, m.readByte());
+ assertEquals(myShort, m.readShort());
+ assertEquals(myChar, m.readChar());
+ assertEquals(myInt, m.readInt());
+ assertEquals(myLong, m.readLong());
+ assertEquals(myFloat, m.readFloat(), 0);
+ assertEquals(myDouble, m.readDouble(), 0);
+ assertEquals(myString, m.readString());
- // Arbitrary string with some Chinese characters to make sure UTF encoding
- // is ok
- String myString = "wwiuhdiuwhdwuhdwuhduqwhdiuwhdiuhwed8u29837482787\uD5E2\uCAC7\uD2BB\uB7DD\uB7C7\uB3A3\uBCE4\uB5A5";
+ // Should be diffent object instances after sending *even* if in same JVM
+ assertFalse(m == m2);
+ }
- m.setText(myString);
+ public void testTextMessage() throws Exception
+ {
+ TextMessage m = queueProducerSession.createTextMessage();
- queueProducer.send(queue1, m);
+ // Arbitrary string with some Chinese characters to make sure UTF encoding
+ // is ok
+ String myString = "wwiuhdiuwhdwuhdwuhduqwhdiuwhdiuhwed8u29837482787\uD5E2\uCAC7\uD2BB\uB7DD\uB7C7\uB3A3\uBCE4\uB5A5";
- TextMessage m2 = (TextMessage) queueConsumer.receive(2000);
+ m.setText(myString);
- assertEquals(myString, m2.getText());
+ queueProducer.send(queue1, m);
- m = queueProducerSession.createTextMessage(myString);
- queueProducer.send(queue1, m);
+ TextMessage m2 = (TextMessage)queueConsumer.receive(2000);
- m2 = (TextMessage) queueConsumer.receive(2000);
+ assertEquals(myString, m2.getText());
- assertEquals(myString, m2.getText());
+ m = queueProducerSession.createTextMessage(myString);
+ queueProducer.send(queue1, m);
- try
- {
- m2.setText("Should be read-only");
- fail();
- } catch (MessageNotWriteableException e)
- {
- }
+ m2 = (TextMessage)queueConsumer.receive(2000);
- m2.clearBody();
- assertNull(m2.getText());
- m2.setText("Now it is read-write");
- }
+ assertEquals(myString, m2.getText());
- // Package protected ---------------------------------------------
+ try
+ {
+ m2.setText("Should be read-only");
+ fail();
+ }
+ catch (MessageNotWriteableException e)
+ {
+ }
- // Protected -----------------------------------------------------
+ m2.clearBody();
+ assertNull(m2.getText());
+ m2.setText("Now it is read-write");
+ }
- // Private -------------------------------------------------------
+ // Package protected ---------------------------------------------
- private void assertByteArraysEqual(byte[] bytes1, byte[] bytes2)
- {
- if (bytes1 == null | bytes2 == null)
- {
- fail();
- }
+ // Protected -----------------------------------------------------
- if (bytes1.length != bytes2.length)
- {
- fail();
- }
+ // Private -------------------------------------------------------
- for (int i = 0; i < bytes1.length; i++)
- {
- assertEquals(bytes1[i], bytes2[i]);
- }
+ private void assertByteArraysEqual(byte[] bytes1, byte[] bytes2)
+ {
+ if (bytes1 == null | bytes2 == null)
+ {
+ fail();
+ }
- }
+ if (bytes1.length != bytes2.length)
+ {
+ fail();
+ }
- // Inner classes -------------------------------------------------
+ for (int i = 0; i < bytes1.length; i++)
+ {
+ assertEquals(bytes1[i], bytes2[i]);
+ }
+ }
+
+ // Inner classes -------------------------------------------------
+
}
Modified: branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageHeaderTest.java
===================================================================
--- branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageHeaderTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageHeaderTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -675,7 +675,8 @@
HornetQBuffer body = HornetQChannelBuffers.buffer(1024);
ClientMessage clientMessage = new ClientMessageImpl(HornetQTextMessage.TYPE, true, 0, System.currentTimeMillis(), (byte)4, body);
ClientSession session = new FakeSession(clientMessage);
- HornetQMessage jbossMessage = new HornetQMessage();
+ HornetQMessage jbossMessage = HornetQMessage.createMessage(clientMessage, session);
+ jbossMessage.clearProperties();
configureMessage(jbossMessage);
Deleted: branches/20-optimisation/tests/src/org/hornetq/tests/integration/EncodeSizeTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/EncodeSizeTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/EncodeSizeTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -1,137 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.tests.integration;
-
-import org.hornetq.core.buffers.HornetQChannelBuffers;
-import org.hornetq.core.client.ClientMessage;
-import org.hornetq.core.client.impl.ClientMessageImpl;
-import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.impl.wireformat.SessionSendLargeMessage;
-import org.hornetq.core.remoting.impl.wireformat.SessionSendMessage;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
-import org.hornetq.core.server.ServerMessage;
-import org.hornetq.core.server.impl.ServerMessageImpl;
-import org.hornetq.tests.util.RandomUtil;
-import org.hornetq.tests.util.UnitTestCase;
-
-/**
- * A EncodeSizeTest
- *
- * For flow control, it's crucial that encode sizes on client and server are the same
- *
- * @author Tim Fox
- *
- *
- */
-public class EncodeSizeTest extends UnitTestCase
-{
- private static final Logger log = Logger.getLogger(EncodeSizeTest.class);
-
- public void testMessageEncodeSize() throws Exception
- {
- for (int i = 0; i < 10; i++)
- {
- ClientMessage clientMessage = new ClientMessageImpl(0);
-
- clientMessage.putIntProperty(RandomUtil.randomString(), RandomUtil.randomInt());
- clientMessage.putBooleanProperty(RandomUtil.randomString(), RandomUtil.randomBoolean());
- clientMessage.putByteProperty(RandomUtil.randomString(), RandomUtil.randomByte());
- clientMessage.putBytesProperty(RandomUtil.randomString(), RandomUtil.randomBytes(125));
- clientMessage.putDoubleProperty(RandomUtil.randomString(), RandomUtil.randomDouble());
- clientMessage.putFloatProperty(RandomUtil.randomString(), RandomUtil.randomFloat());
- clientMessage.putLongProperty(RandomUtil.randomString(), RandomUtil.randomLong());
- clientMessage.putShortProperty(RandomUtil.randomString(), RandomUtil.randomShort());
- clientMessage.putStringProperty(RandomUtil.randomString(), RandomUtil.randomString());
-
- clientMessage.setDestination(RandomUtil.randomSimpleString());
-
- byte[] bytes = RandomUtil.randomBytes(1000);
-
- HornetQBuffer body = HornetQChannelBuffers.dynamicBuffer(bytes);
-
- clientMessage.setBuffer(body);
-
- int clientEncodeSize = clientMessage.getEncodeSize();
-
- HornetQBuffer buffer = HornetQChannelBuffers.dynamicBuffer(clientEncodeSize);
-
- clientMessage.encode(buffer);
-
- int wireSize = buffer.writerIndex();
-
- assertEquals(clientEncodeSize, wireSize);
-
- ServerMessage serverMessage = new ServerMessageImpl();
-
- serverMessage.decodeHeadersAndProperties(buffer);
-
- int serverEncodeSize = serverMessage.getEncodeSize();
-
- assertEquals(wireSize, serverEncodeSize);
- }
- }
-
- public void testMessageEncodeSizeWithPacket() throws Exception
- {
- for (int i = 0; i < 10; i++)
- {
- ClientMessage clientMessage = new ClientMessageImpl(0);
-
- clientMessage.putIntProperty(RandomUtil.randomString(), RandomUtil.randomInt());
- clientMessage.putBooleanProperty(RandomUtil.randomString(), RandomUtil.randomBoolean());
- clientMessage.putByteProperty(RandomUtil.randomString(), RandomUtil.randomByte());
- clientMessage.putBytesProperty(RandomUtil.randomString(), RandomUtil.randomBytes(125));
- clientMessage.putDoubleProperty(RandomUtil.randomString(), RandomUtil.randomDouble());
- clientMessage.putFloatProperty(RandomUtil.randomString(), RandomUtil.randomFloat());
- clientMessage.putLongProperty(RandomUtil.randomString(), RandomUtil.randomLong());
- clientMessage.putShortProperty(RandomUtil.randomString(), RandomUtil.randomShort());
- clientMessage.putStringProperty(RandomUtil.randomString(), RandomUtil.randomString());
-
- clientMessage.setDestination(RandomUtil.randomSimpleString());
-
- byte[] bytes = RandomUtil.randomBytes(1000);
-
- HornetQBuffer body = HornetQChannelBuffers.dynamicBuffer(bytes);
-
- clientMessage.setBuffer(body);
-
- int clientEncodeSize = clientMessage.getEncodeSize();
-
- SessionSendMessage packet = new SessionSendMessage(clientMessage, false);
-
- HornetQBuffer buffer = HornetQChannelBuffers.dynamicBuffer(packet.getRequiredBufferSize());
-
- packet.encode(buffer);
-
- int wireSize = buffer.writerIndex();
-
- assertEquals(wireSize, packet.getRequiredBufferSize());
-
- SessionSendMessage received = new SessionSendMessage();
-
- //The length
- buffer.readInt();
- //The packet type byte
- buffer.readByte();
-
- received.decode(buffer);
-
- ServerMessage serverMessage = received.getServerMessage();
-
- int serverEncodeSize = serverMessage.getEncodeSize();
-
- assertEquals(clientEncodeSize, serverEncodeSize);
- }
- }
-}
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/String64KLimitTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/String64KLimitTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/String64KLimitTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -90,16 +90,16 @@
String s4 = genString(10 * 64 * 1024);
ClientMessage tm1 = session.createClientMessage(false);
- tm1.getBuffer().writeString(s1);
+ tm1.getBodyBuffer().writeString(s1);
ClientMessage tm2 = session.createClientMessage(false);
- tm2.getBuffer().writeString(s2);
+ tm2.getBodyBuffer().writeString(s2);
ClientMessage tm3 = session.createClientMessage(false);
- tm3.getBuffer().writeString(s3);
+ tm3.getBodyBuffer().writeString(s3);
ClientMessage tm4 = session.createClientMessage(false);
- tm4.getBuffer().writeString(s4);
+ tm4.getBodyBuffer().writeString(s4);
producer.send(tm1);
@@ -113,23 +113,23 @@
assertNotNull(rm1);
- assertEquals(s1, rm1.getBuffer().readString());
+ assertEquals(s1, rm1.getBodyBuffer().readString());
ClientMessage rm2 = consumer.receive(1000);
assertNotNull(rm2);
- assertEquals(s2, rm2.getBuffer().readString());
+ assertEquals(s2, rm2.getBodyBuffer().readString());
ClientMessage rm3 = consumer.receive(1000);
- assertEquals(s3, rm3.getBuffer().readString());
+ assertEquals(s3, rm3.getBodyBuffer().readString());
assertNotNull(rm3);
ClientMessage rm4 = consumer.receive(1000);
- assertEquals(s4, rm4.getBuffer().readString());
+ assertEquals(s4, rm4.getBodyBuffer().readString());
assertNotNull(rm4);
}
@@ -155,15 +155,15 @@
String s4 = genString(10 * 64 * 1024);
ClientMessage tm1 = session.createClientMessage(false);
- tm1.getBuffer().writeUTF(s1);
+ tm1.getBodyBuffer().writeUTF(s1);
ClientMessage tm2 = session.createClientMessage(false);
- tm2.getBuffer().writeUTF(s2);
+ tm2.getBodyBuffer().writeUTF(s2);
try
{
ClientMessage tm3 = session.createClientMessage(false);
- tm3.getBuffer().writeUTF(s3);
+ tm3.getBodyBuffer().writeUTF(s3);
fail("can not write UTF string bigger than 64K");
}
catch (Exception e)
@@ -173,7 +173,7 @@
try
{
ClientMessage tm4 = session.createClientMessage(false);
- tm4.getBuffer().writeUTF(s4);
+ tm4.getBodyBuffer().writeUTF(s4);
fail("can not write UTF string bigger than 64K");
}
catch (Exception e)
@@ -191,8 +191,8 @@
assertNotNull(rm2);
- assertEquals(s1, rm1.getBuffer().readUTF());
- assertEquals(s2, rm2.getBuffer().readUTF());
+ assertEquals(s1, rm1.getBodyBuffer().readUTF());
+ assertEquals(s2, rm2.getBodyBuffer().readUTF());
}
// Protected -----------------------------------------------------
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/AddressSettingsTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/AddressSettingsTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/AddressSettingsTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -78,9 +78,9 @@
session.createQueue(dlaB, dlqB, false);
ClientSession sendSession = sf.createSession(false, true, true);
ClientMessage cm = sendSession.createClientMessage(true);
- cm.getBuffer().writeString("A");
+ cm.getBodyBuffer().writeString("A");
ClientMessage cm2 = sendSession.createClientMessage(true);
- cm2.getBuffer().writeString("B");
+ cm2.getBodyBuffer().writeString("B");
ClientProducer cp1 = sendSession.createProducer(addressA);
ClientProducer cp2 = sendSession.createProducer(addressB);
cp1.send(cm);
@@ -102,10 +102,10 @@
cc2.close();
message = dlqARec.receive(5000);
assertNotNull(message);
- assertEquals("A", message.getBuffer().readString());
+ assertEquals("A", message.getBodyBuffer().readString());
message = dlqBrec.receive(5000);
assertNotNull(message);
- assertEquals("B", message.getBuffer().readString());
+ assertEquals("B", message.getBodyBuffer().readString());
sendSession.close();
session.close();
}
@@ -141,9 +141,9 @@
session.createQueue(dlaB, dlqB, false);
ClientSession sendSession = sf.createSession(false, true, true);
ClientMessage cm = sendSession.createClientMessage(true);
- cm.getBuffer().writeString("A");
+ cm.getBodyBuffer().writeString("A");
ClientMessage cm2 = sendSession.createClientMessage(true);
- cm2.getBuffer().writeString("B");
+ cm2.getBodyBuffer().writeString("B");
ClientProducer cp1 = sendSession.createProducer(addressA);
ClientProducer cp2 = sendSession.createProducer(addressB);
cp1.send(cm);
@@ -165,10 +165,10 @@
cc2.close();
message = dlqARec.receive(5000);
assertNotNull(message);
- assertEquals("A", message.getBuffer().readString());
+ assertEquals("A", message.getBodyBuffer().readString());
message = dlqBrec.receive(5000);
assertNotNull(message);
- assertEquals("B", message.getBuffer().readString());
+ assertEquals("B", message.getBodyBuffer().readString());
sendSession.close();
session.close();
}
@@ -204,9 +204,9 @@
session.createQueue(dlaB, dlqB, false);
ClientSession sendSession = sf.createSession(false, true, true);
ClientMessage cm = sendSession.createClientMessage(true);
- cm.getBuffer().writeString("A");
+ cm.getBodyBuffer().writeString("A");
ClientMessage cm2 = sendSession.createClientMessage(true);
- cm2.getBuffer().writeString("B");
+ cm2.getBodyBuffer().writeString("B");
ClientProducer cp1 = sendSession.createProducer(addressA);
ClientProducer cp2 = sendSession.createProducer(addressB);
cp1.send(cm);
@@ -228,10 +228,10 @@
cc2.close();
message = dlqARec.receive(5000);
assertNotNull(message);
- assertEquals("A", message.getBuffer().readString());
+ assertEquals("A", message.getBodyBuffer().readString());
message = dlqBrec.receive(5000);
assertNotNull(message);
- assertEquals("B", message.getBuffer().readString());
+ assertEquals("B", message.getBodyBuffer().readString());
sendSession.close();
session.close();
}
@@ -273,11 +273,11 @@
session.createQueue(dlaC, dlqC, false);
ClientSession sendSession = sf.createSession(false, true, true);
ClientMessage cm = sendSession.createClientMessage(true);
- cm.getBuffer().writeString("A");
+ cm.getBodyBuffer().writeString("A");
ClientMessage cm2 = sendSession.createClientMessage(true);
- cm2.getBuffer().writeString("B");
+ cm2.getBodyBuffer().writeString("B");
ClientMessage cm3 = sendSession.createClientMessage(true);
- cm3.getBuffer().writeString("C");
+ cm3.getBodyBuffer().writeString("C");
ClientProducer cp1 = sendSession.createProducer(addressA2);
ClientProducer cp2 = sendSession.createProducer(addressB2);
ClientProducer cp3 = sendSession.createProducer(addressC);
@@ -307,13 +307,13 @@
cc3.close();
message = dlqARec.receive(5000);
assertNotNull(message);
- assertEquals("A", message.getBuffer().readString());
+ assertEquals("A", message.getBodyBuffer().readString());
message = dlqBrec.receive(5000);
assertNotNull(message);
- assertEquals("B", message.getBuffer().readString());
+ assertEquals("B", message.getBodyBuffer().readString());
message = dlqCrec.receive(5000);
assertNotNull(message);
- assertEquals("C", message.getBuffer().readString());
+ assertEquals("C", message.getBodyBuffer().readString());
sendSession.close();
session.close();
}
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ConsumerRoundRobinTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ConsumerRoundRobinTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ConsumerRoundRobinTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -57,7 +57,7 @@
for (int i = 0; i < numMessage; i++)
{
ClientMessage cm = session.createClientMessage(false);
- cm.getBuffer().writeInt(i);
+ cm.getBodyBuffer().writeInt(i);
cp.send(cm);
}
int currMessage = 0;
@@ -67,7 +67,7 @@
{
ClientMessage cm = consumers[j].receive(5000);
assertNotNull(cm);
- assertEquals(currMessage++, cm.getBuffer().readInt());
+ assertEquals(currMessage++, cm.getBodyBuffer().readInt());
}
}
//sendSession.close();
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ConsumerTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ConsumerTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ConsumerTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -88,7 +88,7 @@
{
ClientMessage message2 = consumer.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
}
// assert that all the messages are there and none have been acked
assertEquals(0, ((Queue)server.getPostOffice().getBinding(QUEUE).getBindable()).getDeliveringCount());
@@ -122,7 +122,7 @@
{
ClientMessage message2 = consumer.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
}
// assert that all the messages are there and none have been acked
assertEquals(0, ((Queue)server.getPostOffice().getBinding(QUEUE).getBindable()).getDeliveringCount());
@@ -156,7 +156,7 @@
{
ClientMessage message2 = consumer.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
if (i < 50)
{
message2.acknowledge();
@@ -194,7 +194,7 @@
{
ClientMessage message2 = consumer.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
if (i < 50)
{
message2.acknowledge();
@@ -347,7 +347,7 @@
{
ClientMessage message = session.createClientMessage(false);
- message.getBuffer().writeBytes(bytes);
+ message.getBodyBuffer().writeBytes(bytes);
message.putIntProperty("count", i);
@@ -407,7 +407,7 @@
{
ClientMessage message = session.createClientMessage(false);
- message.getBuffer().writeBytes(bytes);
+ message.getBodyBuffer().writeBytes(bytes);
message.putIntProperty("count", i);
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ConsumerWindowSizeTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ConsumerWindowSizeTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ConsumerWindowSizeTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -264,7 +264,7 @@
ClientMessage msg = createTextMessage(session, "This one will expire");
if (largeMessages)
{
- msg.getBuffer().writeBytes(new byte[600]);
+ msg.getBodyBuffer().writeBytes(new byte[600]);
}
msg.setExpiration(System.currentTimeMillis() + 100);
@@ -291,7 +291,7 @@
if (largeMessages)
{
- msg.getBuffer().writeBytes(new byte[600]);
+ msg.getBodyBuffer().writeBytes(new byte[600]);
}
prod.send(msg);
@@ -395,7 +395,7 @@
ClientMessage msg = createTextMessage(session1, "Msg" + i);
if (largeMessages)
{
- msg.getBuffer().writeBytes(new byte[600]);
+ msg.getBodyBuffer().writeBytes(new byte[600]);
}
prod.send(msg);
}
@@ -421,7 +421,7 @@
assertNotNull("expected message at i = " + i, msg);
- assertEquals("Msg" + i, msg.getBuffer().readString());
+ assertEquals("Msg" + i, msg.getBodyBuffer().readString());
msg.acknowledge();
@@ -456,7 +456,7 @@
ClientMessage msg = createTextMessage(session1, "Msg" + i);
if (largeMessages)
{
- msg.getBuffer().writeBytes(new byte[600]);
+ msg.getBodyBuffer().writeBytes(new byte[600]);
}
prod.send(msg);
}
@@ -470,7 +470,7 @@
ClientMessage msg = cons2.receive(1000);
assertNotNull("expected message at i = " + i, msg);
- assertEquals("Msg" + i, msg.getBuffer().readString());
+ assertEquals("Msg" + i, msg.getBodyBuffer().readString());
msg.acknowledge();
@@ -484,7 +484,7 @@
assertNotNull("expected message at i = " + i, msg);
- assertEquals("Msg" + i, msg.getBuffer().readString());
+ assertEquals("Msg" + i, msg.getBodyBuffer().readString());
msg.acknowledge();
@@ -607,7 +607,7 @@
if (largeMessages)
{
- message.getBuffer().readBytes(new byte[600]);
+ message.getBodyBuffer().readBytes(new byte[600]);
}
latchRead.countDown();
@@ -632,7 +632,7 @@
ClientMessage msg = createTextMessage(session, "Msg" + i);
if (largeMessages)
{
- msg.getBuffer().writeBytes(new byte[600]);
+ msg.getBodyBuffer().writeBytes(new byte[600]);
}
prod.send(msg);
}
@@ -790,7 +790,7 @@
ClientMessage msg = createTextMessage(session, "Msg" + i);
if (largeMessage)
{
- msg.getBuffer().writeBytes(new byte[600]);
+ msg.getBodyBuffer().writeBytes(new byte[600]);
}
prod.send(msg);
}
@@ -934,7 +934,7 @@
ClientMessage msg = createTextMessage(sessionA, "Msg" + i);
if (largeMessages)
{
- msg.getBuffer().writeBytes(new byte[600]);
+ msg.getBodyBuffer().writeBytes(new byte[600]);
}
prod.send(msg);
}
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/CoreClientTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/CoreClientTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/CoreClientTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -97,7 +97,7 @@
message.setDestination(QUEUE);
- message.getBuffer().writeString("testINVMCoreClient");
+ message.getBodyBuffer().writeString("testINVMCoreClient");
producer.send(message);
}
@@ -112,7 +112,7 @@
{
ClientMessage message2 = consumer.receive();
- HornetQBuffer buffer = message2.getBuffer();
+ HornetQBuffer buffer = message2.getBodyBuffer();
assertEquals("testINVMCoreClient", buffer.readString());
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/DeadLetterAddressTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/DeadLetterAddressTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/DeadLetterAddressTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -61,7 +61,7 @@
ClientMessage m = clientConsumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
// force a cancel
clientSession.rollback();
m = clientConsumer.receiveImmediate();
@@ -70,7 +70,7 @@
clientConsumer = clientSession.createConsumer(dlq);
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
}
public void testBasicSendToMultipleQueues() throws Exception
@@ -93,7 +93,7 @@
ClientMessage m = clientConsumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
// force a cancel
clientSession.rollback();
m = clientConsumer.receiveImmediate();
@@ -103,13 +103,13 @@
m = clientConsumer.receive(500);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
clientConsumer.close();
clientConsumer = clientSession.createConsumer(dlq2);
m = clientConsumer.receive(500);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
clientConsumer.close();
}
@@ -127,7 +127,7 @@
ClientMessage m = clientConsumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
// force a cancel
clientSession.rollback();
m = clientConsumer.receiveImmediate();
@@ -174,7 +174,7 @@
{
origIds.put("Message:" + j, tm.getMessageID());
}
- assertEquals("Message:" + j, tm.getBuffer().readString());
+ assertEquals("Message:" + j, tm.getBodyBuffer().readString());
}
clientSession.rollback();
}
@@ -192,7 +192,7 @@
assertNotNull(tm);
- String text = tm.getBuffer().readString();
+ String text = tm.getBodyBuffer().readString();
assertEquals("Message:" + i, text);
// Check the headers
@@ -248,7 +248,7 @@
clientConsumer = clientSession.createConsumer(deadLetterQueue);
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
}
public void testDeadlLetterAddressWithWildcardAddressSettings() throws Exception
@@ -288,7 +288,7 @@
clientConsumer = clientSession.createConsumer(deadLetterQueue);
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
}
public void testDeadLetterAddressWithOverridenSublevelAddressSettings() throws Exception
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/DeliveryOrderTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/DeliveryOrderTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/DeliveryOrderTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -56,7 +56,7 @@
for (int i = 0; i < numMessages; i++)
{
ClientMessage cm = sendSession.createClientMessage(false);
- cm.getBuffer().writeInt(i);
+ cm.getBodyBuffer().writeInt(i);
cp.send(cm);
if (i % 10 == 0)
{
@@ -70,7 +70,7 @@
{
ClientMessage cm = c.receive(5000);
assertNotNull(cm);
- assertEquals(i, cm.getBuffer().readInt());
+ assertEquals(i, cm.getBodyBuffer().readInt());
}
sendSession.close();
}
@@ -97,7 +97,7 @@
for (int i = 0; i < numMessages; i++)
{
ClientMessage cm = sendSession.createClientMessage(false);
- cm.getBuffer().writeInt(i);
+ cm.getBodyBuffer().writeInt(i);
cp.send(cm);
}
ClientConsumer c = sendSession.createConsumer(queueA);
@@ -107,7 +107,7 @@
ClientMessage cm = c.receive(5000);
assertNotNull(cm);
cm.acknowledge();
- assertEquals(i, cm.getBuffer().readInt());
+ assertEquals(i, cm.getBodyBuffer().readInt());
}
sendSession.rollback();
for (int i = 0; i < numMessages; i++)
@@ -115,7 +115,7 @@
ClientMessage cm = c.receive(5000);
assertNotNull(cm);
cm.acknowledge();
- assertEquals(i, cm.getBuffer().readInt());
+ assertEquals(i, cm.getBodyBuffer().readInt());
}
sendSession.close();
}
@@ -155,7 +155,7 @@
for (int i = 0; i < numMessage; i++)
{
ClientMessage cm = sendSession.createClientMessage(false);
- cm.getBuffer().writeInt(count.getAndIncrement());
+ cm.getBodyBuffer().writeInt(count.getAndIncrement());
clientProducer.send(cm);
}
assertTrue(latch.await(10, TimeUnit.SECONDS));
@@ -194,7 +194,7 @@
public void onMessage(ClientMessage message)
{
- int i = message.getBuffer().readInt();
+ int i = message.getBodyBuffer().readInt();
try
{
message.acknowledge();
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ExpiryAddressTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ExpiryAddressTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ExpiryAddressTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -69,7 +69,7 @@
clientConsumer = clientSession.createConsumer(eq);
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
m.acknowledge();
// PageSize should be the same as when it started
@@ -117,7 +117,7 @@
log.info("acking");
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
clientConsumer.close();
@@ -130,7 +130,7 @@
log.info("acking");
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
clientConsumer.close();
@@ -197,7 +197,7 @@
assertNotNull(tm);
- String text = tm.getBuffer().readString();
+ String text = tm.getBodyBuffer().readString();
assertEquals("Message:" + i, text);
// Check the headers
@@ -234,7 +234,7 @@
clientConsumer = clientSession.createConsumer(eq);
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
m.acknowledge();
}
@@ -264,7 +264,7 @@
clientConsumer = clientSession.createConsumer(eq);
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
m.acknowledge();
}
@@ -307,7 +307,7 @@
clientConsumer = clientSession.createConsumer(specificExpiryQueue);
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
m.acknowledge();
}
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/HeuristicXATest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/HeuristicXATest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/HeuristicXATest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -51,7 +51,9 @@
final SimpleString ADDRESS = new SimpleString("ADDRESS");
-
+
+ final String body = "this is the body";
+
// Attributes ----------------------------------------------------
private MBeanServer mbeanServer;
@@ -120,7 +122,7 @@
ClientMessage msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[123]);
+ msg.getBodyBuffer().writeString(body);
producer.send(msg);
@@ -173,7 +175,7 @@
msg = consumer.receive(1000);
assertNotNull(msg);
msg.acknowledge();
- assertEquals(123, msg.getBodySize());
+ assertEquals(body, msg.getBodyBuffer().readString());
session.commit();
session.close();
@@ -227,7 +229,7 @@
ClientMessage msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[123]);
+ msg.getBodyBuffer().writeString(body);
producer.send(msg);
@@ -267,8 +269,8 @@
msg = consumer.receive(1000);
assertNotNull(msg);
msg.acknowledge();
- assertEquals(123, msg.getBodySize());
-
+ assertEquals(body, msg.getBodyBuffer().readString());
+
session.commit();
session.close();
}
@@ -334,7 +336,7 @@
ClientMessage msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[123]);
+ msg.getBodyBuffer().writeString(body);
producer.send(msg);
@@ -374,7 +376,7 @@
msg = consumer.receive(1000);
assertNotNull(msg);
msg.acknowledge();
- assertEquals(123, msg.getBodySize());
+ assertEquals(body, msg.getBodyBuffer().readString());
session.commit();
session.close();
@@ -449,7 +451,7 @@
ClientMessage msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[123]);
+ msg.getBodyBuffer().writeBytes(new byte[123]);
producer.send(msg);
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/JournalCrashTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/JournalCrashTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/JournalCrashTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -178,7 +178,7 @@
{
ClientMessage msg = session.createClientMessage(true);
msg.getProperties().putIntProperty(new SimpleString("key"), i);
- msg.getBuffer().writeUTF("message " + i);
+ msg.getBodyBuffer().writeUTF("message " + i);
prod.send(msg);
}
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/LargeMessageTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/LargeMessageTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/LargeMessageTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -31,7 +31,7 @@
import org.hornetq.core.config.Configuration;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.message.Message;
-import org.hornetq.core.persistence.impl.journal.FileLargeServerMessage;
+import org.hornetq.core.persistence.impl.journal.LargeServerMessageImpl;
import org.hornetq.core.persistence.impl.journal.JournalStorageManager;
import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.server.HornetQServer;
@@ -53,7 +53,6 @@
*/
public class LargeMessageTest extends LargeMessageTestBase
{
-
// Constants -----------------------------------------------------
final static int RECEIVE_WAIT_TIME = 60000;
@@ -114,7 +113,7 @@
try
{
- msg1.getBuffer().readByte();
+ msg1.getBodyBuffer().readByte();
fail("Exception was expected");
}
catch (Throwable ignored)
@@ -200,7 +199,7 @@
for (int i = 0; i < messageSize; i++)
{
- assertEquals(getSamplebyte(i), msg1.getBuffer().readByte());
+ assertEquals(getSamplebyte(i), msg1.getBodyBuffer().readByte());
}
session.close();
@@ -224,7 +223,7 @@
for (int i = 0; i < messageSize; i++)
{
- assertEquals(getSamplebyte(i), msg1.getBuffer().readByte());
+ assertEquals(getSamplebyte(i), msg1.getBodyBuffer().readByte());
}
msg1.acknowledge();
@@ -241,7 +240,7 @@
for (int i = 0; i < messageSize; i++)
{
- assertEquals(getSamplebyte(i), msg1.getBuffer().readByte());
+ assertEquals(getSamplebyte(i), msg1.getBodyBuffer().readByte());
}
msg1.acknowledge();
@@ -305,9 +304,12 @@
assertNotNull(msg);
msg.acknowledge();
assertEquals(1, msg.getDeliveryCount());
+
+ log.info("body buffer is " + msg.getBodyBuffer());
+
for (int i = 0; i < messageSize; i++)
{
- assertEquals(getSamplebyte(i), msg.getBuffer().readByte());
+ assertEquals(getSamplebyte(i), msg.getBodyBuffer().readByte());
}
session.rollback();
@@ -322,7 +324,7 @@
msg.acknowledge();
for (int i = 0; i < messageSize; i++)
{
- assertEquals(getSamplebyte(i), msg.getBuffer().readByte());
+ assertEquals(getSamplebyte(i), msg.getBodyBuffer().readByte());
}
assertEquals(2, msg.getDeliveryCount());
msg.acknowledge();
@@ -410,7 +412,7 @@
for (int j = 0; j < messageSize; j++)
{
- assertEquals(getSamplebyte(j), msg1.getBuffer().readByte());
+ assertEquals(getSamplebyte(j), msg1.getBodyBuffer().readByte());
}
consumerExpiry.close();
@@ -428,7 +430,7 @@
for (int j = 0; j < messageSize; j++)
{
- assertEquals(getSamplebyte(j), msg1.getBuffer().readByte());
+ assertEquals(getSamplebyte(j), msg1.getBodyBuffer().readByte());
}
consumerExpiry.close();
@@ -450,7 +452,7 @@
for (int i = 0; i < messageSize; i++)
{
- assertEquals(getSamplebyte(i), msg1.getBuffer().readByte());
+ assertEquals(getSamplebyte(i), msg1.getBodyBuffer().readByte());
}
session.commit();
@@ -545,7 +547,7 @@
for (int j = 0; j < messageSize; j++)
{
- assertEquals(getSamplebyte(j), msg1.getBuffer().readByte());
+ assertEquals(getSamplebyte(j), msg1.getBodyBuffer().readByte());
}
consumerExpiry.close();
@@ -562,7 +564,7 @@
for (int j = 0; j < messageSize; j++)
{
- assertEquals(getSamplebyte(j), msg1.getBuffer().readByte());
+ assertEquals(getSamplebyte(j), msg1.getBodyBuffer().readByte());
}
consumerExpiry.close();
@@ -589,7 +591,7 @@
for (int i = 0; i < messageSize; i++)
{
- assertEquals(getSamplebyte(i), msg1.getBuffer().readByte());
+ assertEquals(getSamplebyte(i), msg1.getBodyBuffer().readByte());
}
session.commit();
@@ -674,7 +676,7 @@
for (int i = 0; i < messageSize; i++)
{
- assertEquals(getSamplebyte(i), msg1.getBuffer().readByte());
+ assertEquals(getSamplebyte(i), msg1.getBodyBuffer().readByte());
}
session.close();
@@ -698,7 +700,7 @@
for (int i = 0; i < messageSize; i++)
{
- assertEquals(getSamplebyte(i), msg1.getBuffer().readByte());
+ assertEquals(getSamplebyte(i), msg1.getBodyBuffer().readByte());
}
msg1.acknowledge();
@@ -802,7 +804,7 @@
for (int i = 0; i < messageSize; i++)
{
- assertEquals(getSamplebyte(i), msg2.getBuffer().readByte());
+ assertEquals(getSamplebyte(i), msg2.getBodyBuffer().readByte());
}
session.close();
@@ -1668,7 +1670,7 @@
assertNotNull(clientMessage);
- assertEquals(numberOfBytes, clientMessage.getBuffer().writerIndex());
+ assertEquals(numberOfBytes, clientMessage.getBodyBuffer().writerIndex());
clientMessage.acknowledge();
@@ -1748,7 +1750,7 @@
for (int i = 0; i < NUMBER_OF_MESSAGES; i++)
{
- Message clientFile = session.createClientMessage(true);
+ ClientMessage clientFile = session.createClientMessage(true);
clientFile.setBodyInputStream(createFakeLargeStream(SIZE));
producer.send(clientFile);
@@ -1782,7 +1784,7 @@
{
for (int byteRead = 0; byteRead < SIZE; byteRead++)
{
- assertEquals(getSamplebyte(byteRead), msg.getBuffer().readByte());
+ assertEquals(getSamplebyte(byteRead), msg.getBodyBuffer().readByte());
}
}
@@ -1850,7 +1852,7 @@
for (int i = 0; i < NUMBER_OF_MESSAGES; i++)
{
- Message clientFile = session.createClientMessage(true);
+ ClientMessage clientFile = session.createClientMessage(true);
clientFile.setBodyInputStream(createFakeLargeStream(SIZE));
producer.send(clientFile);
@@ -1883,7 +1885,7 @@
{
for (int byteRead = 0; byteRead < SIZE; byteRead++)
{
- assertEquals(getSamplebyte(byteRead), msg.getBuffer().readByte());
+ assertEquals(getSamplebyte(byteRead), msg.getBodyBuffer().readByte());
}
}
@@ -1947,7 +1949,7 @@
session.createQueue(ADDRESS, ADDRESS, null, true);
- Message clientFile = session.createClientMessage(true);
+ ClientMessage clientFile = session.createClientMessage(true);
clientFile.setBodyInputStream(createFakeLargeStream(SIZE));
ClientProducer producer = session.createProducer(ADDRESS);
@@ -2024,7 +2026,7 @@
for (int i = 0; i < NUMBER_OF_MESSAGES; i++)
{
- Message msg = session.createClientMessage(true);
+ ClientMessage msg = session.createClientMessage(true);
msg.setBodyInputStream(createFakeLargeStream(SIZE));
msg.putIntProperty(new SimpleString("key"), i);
producer.send(msg);
@@ -2086,55 +2088,55 @@
public void testSendServerMessage() throws Exception
{
HornetQServer server = createServer(true);
-
+
server.start();
-
+
ClientSessionFactory sf = createFactory(false);
-
+
ClientSession session = sf.createSession(false, false);
-
+
try
{
- FileLargeServerMessage fileMessage = new FileLargeServerMessage((JournalStorageManager)server.getStorageManager());
-
+ LargeServerMessageImpl fileMessage = new LargeServerMessageImpl((JournalStorageManager)server.getStorageManager());
+
fileMessage.setMessageID(1005);
-
- for (int i = 0 ; i < LARGE_MESSAGE_SIZE; i++)
+
+ for (int i = 0; i < LARGE_MESSAGE_SIZE; i++)
{
- fileMessage.addBytes(new byte[]{getSamplebyte(i)});
+ fileMessage.addBytes(new byte[] { getSamplebyte(i) });
}
-
+
fileMessage.releaseResources();
-
+
session.createQueue(ADDRESS, ADDRESS, true);
-
+
ClientProducer prod = session.createProducer(ADDRESS);
-
+
prod.send(fileMessage);
-
+
fileMessage.deleteFile();
-
+
session.commit();
-
+
session.start();
-
+
ClientConsumer cons = session.createConsumer(ADDRESS);
-
+
ClientMessage msg = cons.receive(5000);
-
+
assertNotNull(msg);
-
+
assertEquals(msg.getBodySize(), LARGE_MESSAGE_SIZE);
-
- for (int i = 0 ; i < LARGE_MESSAGE_SIZE; i++)
+
+ for (int i = 0; i < LARGE_MESSAGE_SIZE; i++)
{
- assertEquals(getSamplebyte(i), msg.getBuffer().readByte());
+ assertEquals(getSamplebyte(i), msg.getBodyBuffer().readByte());
}
-
+
msg.acknowledge();
-
+
session.commit();
-
+
}
finally
{
@@ -2143,8 +2145,6 @@
}
}
-
-
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@@ -2262,12 +2262,12 @@
try
{
- assertEqualsByteArrays(body.writerIndex(), body.array(), message2.getBuffer().array());
+ assertEqualsByteArrays(body.writerIndex(), body.array(), message2.getBodyBuffer().array());
}
catch (AssertionFailedError e)
{
log.info("Expected buffer:" + dumbBytesHex(body.array(), 40));
- log.info("Arriving buffer:" + dumbBytesHex(message2.getBuffer().array(), 40));
+ log.info("Arriving buffer:" + dumbBytesHex(message2.getBodyBuffer().array(), 40));
throw e;
}
}
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/MessageCounterTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/MessageCounterTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/MessageCounterTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -91,7 +91,7 @@
session.commit();
- assertEquals("m" + i, message.getBuffer().readString());
+ assertEquals("m" + i, message.getBodyBuffer().readString());
}
session.close();
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/MessageGroupingTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/MessageGroupingTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/MessageGroupingTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -108,14 +108,14 @@
int i = 0;
for (ClientMessage message : dummyMessageHandler.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
assertEquals(50, dummyMessageHandler2.list.size());
i = 1;
for (ClientMessage message : dummyMessageHandler2.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
consumer.close();
@@ -155,14 +155,14 @@
int i = 0;
for (ClientMessage message : dummyMessageHandler.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
assertEquals(50, dummyMessageHandler2.list.size());
i = 1;
for (ClientMessage message : dummyMessageHandler2.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
consumer.close();
@@ -196,11 +196,11 @@
{
ClientMessage cm = consumer.receive(500);
assertNotNull(cm);
- assertEquals(cm.getBuffer().readString(), "m" + i);
+ assertEquals(cm.getBodyBuffer().readString(), "m" + i);
i++;
cm = consumer2.receive(500);
assertNotNull(cm);
- assertEquals(cm.getBuffer().readString(), "m" + i);
+ assertEquals(cm.getBodyBuffer().readString(), "m" + i);
}
log.info("closing consumers");
@@ -218,13 +218,13 @@
{
ClientMessage cm = consumer.receive(500);
assertNotNull(cm);
- assertEquals(cm.getBuffer().readString(), "m" + i);
+ assertEquals(cm.getBodyBuffer().readString(), "m" + i);
}
for (int i = 1; i < numMessages; i += 2)
{
ClientMessage cm = consumer.receive(500);
assertNotNull(cm);
- assertEquals(cm.getBuffer().readString(), "m" + i);
+ assertEquals(cm.getBodyBuffer().readString(), "m" + i);
}
consumer.close();
}
@@ -258,7 +258,7 @@
int i = 0;
for (ClientMessage message : dummyMessageHandler.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 1;
}
consumer.close();
@@ -300,14 +300,14 @@
int i = 0;
for (ClientMessage message : dummyMessageHandler.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
assertEquals(dummyMessageHandler2.list.size(), 50);
i = 1;
for (ClientMessage message : dummyMessageHandler2.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
consumer.close();
@@ -352,14 +352,14 @@
int i = 0;
for (ClientMessage message : dummyMessageHandler.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
assertEquals(dummyMessageHandler2.list.size(), 50);
i = 1;
for (ClientMessage message : dummyMessageHandler2.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
latch = new CountDownLatch(numMessages);
@@ -371,14 +371,14 @@
i = 0;
for (ClientMessage message : dummyMessageHandler.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
assertEquals(dummyMessageHandler2.list.size(), 50);
i = 1;
for (ClientMessage message : dummyMessageHandler2.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
consumer = this.clientSession.createConsumer(qName);
@@ -426,14 +426,14 @@
int i = 0;
for (ClientMessage message : dummyMessageHandler.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
assertEquals(dummyMessageHandler2.list.size(), 50);
i = 1;
for (ClientMessage message : dummyMessageHandler2.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
consumer.close();
@@ -482,14 +482,14 @@
int i = 0;
for (ClientMessage message : dummyMessageHandler.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
assertEquals(dummyMessageHandler2.list.size(), 50);
i = 1;
for (ClientMessage message : dummyMessageHandler2.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
latch = new CountDownLatch(numMessages);
@@ -505,14 +505,14 @@
i = 0;
for (ClientMessage message : dummyMessageHandler.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
assertEquals(dummyMessageHandler2.list.size(), 50);
i = 1;
for (ClientMessage message : dummyMessageHandler2.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
consumer = this.clientSession.createConsumer(qName);
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/MessagePriorityTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/MessagePriorityTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/MessagePriorityTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -64,18 +64,12 @@
ClientProducer producer = session.createProducer(address);
- ClientMessage[] messages = new ClientMessage[10];
for (int i = 0; i < 10; i++)
{
ClientMessage m = createTextMessage(Integer.toString(i), session);
- m.setPriority((byte)i);
- messages[i] = m;
+ m.setPriority((byte)i);
+ producer.send(m);
}
- // send message with lower priority first
- for (int i = 0; i < 10; i++)
- {
- producer.send(messages[i]);
- }
ClientConsumer consumer = session.createConsumer(queue);
@@ -86,8 +80,7 @@
{
ClientMessage m = consumer.receive(500);
assertNotNull(m);
- assertEquals(messages[i].getPriority(), m.getPriority());
- assertEquals(m.getBuffer().readString(), messages[i].getBuffer().readString());
+ assertEquals(i, m.getPriority());
}
consumer.close();
@@ -112,26 +105,19 @@
ClientConsumer consumer = session.createConsumer(queue);
- ClientMessage[] messages = new ClientMessage[10];
for (int i = 0; i < 10; i++)
{
ClientMessage m = createTextMessage(Integer.toString(i), session);
m.setPriority((byte)i);
- messages[i] = m;
+ producer.send(m);
}
- // send message with lower priority first
- for (int i = 0; i < 10; i++)
- {
- producer.send(messages[i]);
- }
// expect to consumer message with higher priority first
for (int i = 9; i >= 0; i--)
{
ClientMessage m = consumer.receive(500);
assertNotNull(m);
- assertEquals(messages[i].getPriority(), m.getPriority());
- assertEquals(m.getBuffer().readString(), messages[i].getBuffer().readString());
+ assertEquals(i, m.getPriority());
}
consumer.close();
@@ -252,7 +238,7 @@
ClientMessage m = consumer.receive(500);
assertNotNull(m);
assertEquals(expectedPriority, m.getPriority());
- assertEquals(expectedStringInBody, m.getBuffer().readString());
+ assertEquals(expectedStringInBody, m.getBodyBuffer().readString());
}
// Inner classes -------------------------------------------------
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/NewDeadLetterAddressTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/NewDeadLetterAddressTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/NewDeadLetterAddressTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -58,7 +58,7 @@
ClientMessage m = clientConsumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
}
@Override
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/PagingTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/PagingTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/PagingTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -13,6 +13,7 @@
package org.hornetq.tests.integration.client;
+import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
@@ -65,7 +66,7 @@
private static final int RECEIVE_TIMEOUT = 30000;
private static final int PAGE_MAX = 100 * 1024;
-
+
private static final int PAGE_SIZE = 10 * 1024;
// Attributes ----------------------------------------------------
@@ -108,24 +109,23 @@
ClientMessage message = null;
- byte[] body = null;
+ byte[] body = new byte[numberOfIntegers * 4];
+
+ ByteBuffer bb = ByteBuffer.wrap(body);
+
+ for (int j = 1; j <= numberOfIntegers; j++)
+ {
+ bb.putInt(j);
+ }
for (int i = 0; i < numberOfMessages; i++)
{
message = session.createClientMessage(true);
- HornetQBuffer bodyLocal = message.getBuffer();
+ HornetQBuffer bodyLocal = message.getBodyBuffer();
- for (int j = 1; j <= numberOfIntegers; j++)
- {
- bodyLocal.writeInt(j);
- }
-
- if (body == null)
- {
- body = bodyLocal.array();
- }
-
+ bodyLocal.writeBytes(body);
+
message.putIntProperty(new SimpleString("id"), i);
producer.send(message);
@@ -170,12 +170,12 @@
try
{
- assertEqualsByteArrays(body.length, body, message2.getBuffer().array());
+ this.assertBodiesEqual(body, message2.getBodyBuffer());
}
catch (AssertionFailedError e)
{
log.info("Expected buffer:" + dumbBytesHex(body, 40));
- log.info("Arriving buffer:" + dumbBytesHex(message2.getBuffer().array(), 40));
+ log.info("Arriving buffer:" + dumbBytesHex(message2.getBodyBuffer().array(), 40));
throw e;
}
}
@@ -199,6 +199,15 @@
}
}
+
+ private void assertBodiesEqual(byte[] body, HornetQBuffer buffer)
+ {
+ byte[] other = new byte[body.length];
+
+ buffer.readBytes(other);
+
+ assertEqualsByteArrays(body, other);
+ }
/**
* - Make a destination in page mode
@@ -234,7 +243,8 @@
ClientProducer producer = session.createProducer(ADDRESS);
- HornetQBuffer bodyLocal = HornetQChannelBuffers.buffer(DataConstants.SIZE_INT * numberOfIntegers);
+ byte[] body = new byte[DataConstants.SIZE_INT * numberOfIntegers];
+ //HornetQBuffer bodyLocal = HornetQChannelBuffers.buffer(DataConstants.SIZE_INT * numberOfIntegers);
ClientMessage message = null;
@@ -242,7 +252,7 @@
while (true)
{
message = session.createClientMessage(true);
- message.setBuffer(bodyLocal);
+ message.getBodyBuffer().writeBytes(body);
// Stop sending message as soon as we start paging
if (server.getPostOffice().getPagingManager().getPageStore(ADDRESS).isPaging())
@@ -265,7 +275,7 @@
for (int i = 0; i < 10; i++)
{
message = session.createClientMessage(true);
- message.setBuffer(bodyLocal);
+ message.getBodyBuffer().writeBytes(body);
message.putIntProperty(new SimpleString("id"), i);
// Consume messages to force an eventual out of order delivery
@@ -386,8 +396,8 @@
for (int i = 0; i < numberOfMessages; i++)
{
message = session.createClientMessage(true);
-
- message.setBuffer(HornetQChannelBuffers.wrappedBuffer(body));
+
+ message.getBodyBuffer().writeBytes(body);
message.putIntProperty(new SimpleString("id"), i);
TestSupportPageStore store = (TestSupportPageStore)server.getPostOffice()
@@ -439,13 +449,13 @@
}
try
- {
- assertEqualsByteArrays(body.length, body, message2.getBuffer().array());
+ {
+ this.assertBodiesEqual(body, message2.getBodyBuffer());
}
catch (AssertionFailedError e)
{
log.info("Expected buffer:" + dumbBytesHex(body, 40));
- log.info("Arriving buffer:" + dumbBytesHex(message2.getBuffer().array(), 40));
+ log.info("Arriving buffer:" + dumbBytesHex(message2.getBodyBuffer().array(), 40));
throw e;
}
}
@@ -506,7 +516,7 @@
{
message = session.createClientMessage(true);
- HornetQBuffer bodyLocal = message.getBuffer();
+ HornetQBuffer bodyLocal = message.getBodyBuffer();
for (int j = 1; j <= numberOfIntegers; j++)
{
@@ -579,7 +589,7 @@
{
message = session.createClientMessage(true);
- HornetQBuffer bodyLocal = message.getBuffer();
+ HornetQBuffer bodyLocal = message.getBodyBuffer();
for (int j = 1; j <= numberOfIntegers; j++)
{
@@ -669,10 +679,10 @@
for (int i = 0; i < numberOfMessages; i++)
{
- HornetQBuffer bodyLocal = HornetQChannelBuffers.wrappedBuffer(new byte[1024]);
+ byte[] body = new byte[1024];
message = session.createClientMessage(true);
- message.setBuffer(bodyLocal);
+ message.getBodyBuffer().writeBytes(body);
producer.send(message);
}
@@ -697,10 +707,10 @@
for (int i = 0; i < numberOfMessages; i++)
{
- HornetQBuffer bodyLocal = HornetQChannelBuffers.wrappedBuffer(new byte[1024]);
+ byte[] body = new byte[1024];
message = session.createClientMessage(true);
- message.setBuffer(bodyLocal);
+ message.getBodyBuffer().writeBytes(body);
producer.send(message);
}
@@ -724,10 +734,10 @@
for (int i = 0; i < numberOfMessages; i++)
{
- HornetQBuffer bodyLocal = HornetQChannelBuffers.wrappedBuffer(new byte[1024]);
+ byte[] body = new byte[1024];
message = session.createClientMessage(true);
- message.setBuffer(bodyLocal);
+ message.getBodyBuffer().writeBytes(body);
producer.send(message);
}
@@ -800,11 +810,11 @@
ClientProducer producer = session.createProducer(ADDRESS);
ClientMessage message = null;
+
+ byte[] body = new byte[1024];
- HornetQBuffer bodyLocal = HornetQChannelBuffers.wrappedBuffer(new byte[1024]);
-
message = session.createClientMessage(true);
- message.setBuffer(bodyLocal);
+ message.getBodyBuffer().writeBytes(body);
for (int i = 0; i < NUMBER_OF_MESSAGES; i++)
{
@@ -918,7 +928,7 @@
for (int i = 0; i < NUMBER_OF_MESSAGES; i++)
{
ClientMessage msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[512]);
+ msg.getBodyBuffer().writeBytes(new byte[512]);
producerPaged.send(msg);
producerNonPaged.send(msg);
@@ -1030,7 +1040,7 @@
for (int i = 0; i < NUMBER_MESSAGES_BEFORE_PAGING; i++)
{
ClientMessage msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[512]);
+ msg.getBodyBuffer().writeBytes(new byte[512]);
producerA.send(msg);
producerB.send(msg);
@@ -1044,7 +1054,7 @@
for (int i = 0; i < NUMBER_MESSAGES_BEFORE_PAGING; i++)
{
ClientMessage msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[512]);
+ msg.getBodyBuffer().writeBytes(new byte[512]);
producerA.send(msg);
producerB.send(msg);
@@ -1058,7 +1068,7 @@
for (int i = NUMBER_MESSAGES_BEFORE_PAGING * 2; i < NUMBER_OF_MESSAGES; i++)
{
ClientMessage msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[512]);
+ msg.getBodyBuffer().writeBytes(new byte[512]);
producerA.send(msg);
producerB.send(msg);
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ProducerFlowControlTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ProducerFlowControlTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ProducerFlowControlTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -21,7 +21,6 @@
import org.hornetq.core.client.ClientSession;
import org.hornetq.core.client.ClientSessionFactory;
import org.hornetq.core.client.MessageHandler;
-import org.hornetq.core.client.impl.ClientMessageImpl;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.paging.impl.TestSupportPageStore;
import org.hornetq.core.server.HornetQServer;
@@ -29,6 +28,7 @@
import org.hornetq.core.settings.HierarchicalRepository;
import org.hornetq.core.settings.impl.AddressFullMessagePolicy;
import org.hornetq.core.settings.impl.AddressSettings;
+import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.ServiceTestBase;
import org.hornetq.utils.SimpleString;
@@ -212,6 +212,8 @@
{
session.createQueue(address, new SimpleString(queueName + i), null, false);
}
+
+ final byte[] bytes = RandomUtil.randomBytes(messageSize);
class MyHandler implements MessageHandler
{
@@ -225,16 +227,12 @@
{
try
{
- // log.info("got message " + count);
+ byte[] bytesRead = new byte[messageSize];
- int availBytes = message.getBuffer().readableBytes();
+ message.getBodyBuffer().readBytes(bytesRead);
+
+ assertEqualsByteArrays(bytes, bytesRead);
- assertEquals(messageSize, availBytes);
-
- byte[] bytes = new byte[availBytes];
-
- message.getBuffer().readBytes(bytes);
-
message.acknowledge();
if (++count == numMessages * numProducers)
@@ -250,8 +248,10 @@
catch (Exception e)
{
log.error("Failed to handle message", e);
-
+
this.exception = e;
+
+ latch.countDown();
}
}
}
@@ -285,11 +285,13 @@
long start = System.currentTimeMillis();
- byte[] bytes = new byte[messageSize];
+
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = new ClientMessageImpl(false, bytes);
+ ClientMessage message = session.createClientMessage(false);
+
+ message.getBodyBuffer().writeBytes(bytes);
for (int j = 0; j < numProducers; j++)
{
@@ -386,7 +388,9 @@
byte[] bytes = new byte[0];
- ClientMessage message = new ClientMessageImpl(false, bytes);
+ ClientMessage message = session.createClientMessage(false);
+
+ message.getBodyBuffer().writeBytes(bytes);
producer.send(message);
@@ -416,7 +420,9 @@
t.start();
- ClientMessage message2 = new ClientMessageImpl(false, bytes);
+ ClientMessage message2 = session.createClientMessage(false);
+
+ message2.getBodyBuffer().writeBytes(bytes);
producer2.send(message2);
@@ -467,7 +473,9 @@
byte[] bytes = new byte[0];
- ClientMessage message = new ClientMessageImpl(false, bytes);
+ ClientMessage message = session.createClientMessage(false);
+
+ message.getBodyBuffer().writeBytes(bytes);
producer.send(message);
@@ -495,7 +503,9 @@
assertEquals(1, waiting);
- message = new ClientMessageImpl(false, bytes);
+ message = session.createClientMessage(false);
+
+ message.getBodyBuffer().writeBytes(bytes);
producer2.send(message);
@@ -541,7 +551,9 @@
byte[] bytes = new byte[0];
- ClientMessage message = new ClientMessageImpl(false, bytes);
+ ClientMessage message = session.createClientMessage(false);
+
+ message.getBodyBuffer().writeBytes(bytes);
producer.send(message);
@@ -587,7 +599,9 @@
session.close();
- message = new ClientMessageImpl(false, bytes);
+ message = session.createClientMessage(false);
+
+ message.getBodyBuffer().writeBytes(bytes);
producer3.send(message);
@@ -633,7 +647,9 @@
byte[] bytes = new byte[2000];
- ClientMessage message = new ClientMessageImpl(false, bytes);
+ ClientMessage message = session.createClientMessage(false);
+
+ message.getBodyBuffer().writeBytes(bytes);
final AtomicBoolean closed = new AtomicBoolean(false);
@@ -704,7 +720,9 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = new ClientMessageImpl(false, bytes);
+ ClientMessage message = session.createClientMessage(false);
+
+ message.getBodyBuffer().writeBytes(bytes);
producer.send(message);
}
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ProducerTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ProducerTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ProducerTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -80,7 +80,7 @@
ClientProducer producer = session.createProducer(QUEUE);
ClientMessage message = session.createClientMessage(true);
byte[] body = new byte[1000];
- message.getBuffer().writeBytes(body);
+ message.getBodyBuffer().writeBytes(body);
producer.send(message);
assertTrue(latch.await(5, TimeUnit.SECONDS));
session.close();
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/QueueBrowserTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/QueueBrowserTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/QueueBrowserTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -85,7 +85,7 @@
{
ClientMessage message2 = consumer.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
}
consumer.close();
@@ -96,7 +96,7 @@
{
ClientMessage message2 = consumer.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
}
consumer.close();
@@ -133,7 +133,7 @@
{
ClientMessage message2 = consumer.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
}
consumer.close();
@@ -144,7 +144,7 @@
{
ClientMessage message2 = consumer.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
}
consumer.close();
@@ -184,7 +184,7 @@
{
ClientMessage message2 = consumer.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
}
session.close();
@@ -219,11 +219,11 @@
for (int i = 0; i < numMessages; i++)
{
ClientMessage message2 = consumer.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
message2 = consumer2.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
message2 = consumer3.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
}
session.close();
@@ -258,17 +258,17 @@
for (int i = 0; i < 50; i++)
{
ClientMessage message2 = consumer.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
}
for (int i = 50; i < numMessages; i++)
{
ClientMessage message2 = consumer2.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
}
for (int i = 0; i < numMessages; i++)
{
ClientMessage message2 = consumer3.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
}
session.close();
@@ -312,7 +312,7 @@
{
ClientMessage message2 = consumer.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
}
// assert that all the messages are there and none have been acked
assertEquals(0, ((Queue)server.getPostOffice().getBinding(QUEUE).getBindable()).getDeliveringCount());
@@ -349,7 +349,7 @@
message2.acknowledge();
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
}
// assert that all the messages are there and none have been acked
assertEquals(0, ((Queue)server.getPostOffice().getBinding(QUEUE).getBindable()).getDeliveringCount());
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ReceiveImmediateTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ReceiveImmediateTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ReceiveImmediateTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -167,7 +167,7 @@
{
ClientMessage message2 = consumer.receiveImmediate();
assertNotNull("did not receive message " + i, message2);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
if (!browser)
{
message2.acknowledge();
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/SelfExpandingBufferTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/SelfExpandingBufferTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/SelfExpandingBufferTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -18,8 +18,10 @@
import org.hornetq.core.client.ClientProducer;
import org.hornetq.core.client.ClientSession;
import org.hornetq.core.client.ClientSessionFactory;
+import org.hornetq.core.logging.Logger;
import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.server.HornetQServer;
+import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.ServiceTestBase;
import org.hornetq.utils.SimpleString;
@@ -37,6 +39,9 @@
// Constants -----------------------------------------------------
+ private static final Logger log = Logger.getLogger(SelfExpandingBufferTest.class);
+
+
// Attributes ----------------------------------------------------
HornetQServer service;
@@ -49,20 +54,29 @@
// Public --------------------------------------------------------
- public void testSelfExpandingBufferNetty() throws Exception
+ public void testSelfExpandingBufferNettyPersistent() throws Exception
{
- testSelfExpandingBuffer(true);
+ testSelfExpandingBuffer(true, true);
}
- public void testSelfExpandingBufferInVM() throws Exception
+ public void testSelfExpandingBufferInVMPersistent() throws Exception
{
- testSelfExpandingBuffer(false);
+ testSelfExpandingBuffer(false, true);
}
+
+ public void testSelfExpandingBufferNettyNonPersistent() throws Exception
+ {
+ testSelfExpandingBuffer(true, false);
+ }
- public void testSelfExpandingBuffer(boolean netty) throws Exception
+ public void testSelfExpandingBufferInVMNonPersistent() throws Exception
{
+ testSelfExpandingBuffer(false, false);
+ }
- setUpService(netty);
+ private void testSelfExpandingBuffer(boolean netty, boolean persistent) throws Exception
+ {
+ setUpService(netty, persistent);
ClientSessionFactory factory;
@@ -83,29 +97,50 @@
session.createQueue(ADDRESS, ADDRESS, true);
ClientMessage msg = session.createClientMessage(true);
+
+ HornetQBuffer buffer = msg.getBodyBuffer();
+
+ log.info("buffer is " + buffer);
+
+ byte[] bytes = RandomUtil.randomBytes(10 * buffer.capacity());
- HornetQBuffer buffer = msg.getBuffer();
-
- for (int i = 0; i < 10; i++)
- {
- buffer.writeBytes(new byte[1024]);
- }
+ buffer.writeBytes(bytes);
ClientProducer prod = session.createProducer(ADDRESS);
prod.send(msg);
+ //Send same message again
+
+ prod.send(msg);
+
ClientConsumer cons = session.createConsumer(ADDRESS);
session.start();
ClientMessage msg2 = cons.receive(3000);
+
assertNotNull(msg2);
+
+ byte[] receivedBytes = new byte[bytes.length];
+// log.info("buffer start pos should be at " + PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT);
+//
+// log.info("buffer pos at " + msg2.getBodyBuffer().readerIndex());
+//
+// log.info("buffer length should be " + msg2.getBodyBuffer().readInt(PacketImpl.PACKET_HEADERS_SIZE));
- assertEquals(1024 * 10, msg2.getBodySize());
+ msg2.getBodyBuffer().readBytes(receivedBytes);
+ assertEqualsByteArrays(bytes, receivedBytes);
+ msg2 = cons.receive(3000);
+
+ assertNotNull(msg2);
+
+ msg2.getBodyBuffer().readBytes(receivedBytes);
+
+ assertEqualsByteArrays(bytes, receivedBytes);
}
finally
{
@@ -117,9 +152,9 @@
// Protected -----------------------------------------------------
- protected void setUpService(boolean netty) throws Exception
+ protected void setUpService(boolean netty, boolean persistent) throws Exception
{
- service = createServer(false, createDefaultConfig(netty));
+ service = createServer(persistent, createDefaultConfig(netty));
service.start();
}
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/SessionCreateProducerTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/SessionCreateProducerTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/SessionCreateProducerTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -34,12 +34,12 @@
cf.setProducerMaxRate(99);
cf.setBlockOnNonPersistentSend(true);
cf.setBlockOnNonPersistentSend(true);
- ClientSessionInternal clientSession = (ClientSessionInternal) cf.createSession(false, true, true);
+ ClientSessionInternal clientSession = (ClientSessionInternal)cf.createSession(false, true, true);
ClientProducer producer = clientSession.createProducer();
assertNull(producer.getAddress());
assertEquals(cf.getProducerMaxRate(), producer.getMaxRate());
- assertEquals(cf.isBlockOnNonPersistentSend(),producer.isBlockOnNonPersistentSend());
- assertEquals(cf.isBlockOnPersistentSend(),producer.isBlockOnPersistentSend());
+ assertEquals(cf.isBlockOnNonPersistentSend(), producer.isBlockOnNonPersistentSend());
+ assertEquals(cf.isBlockOnPersistentSend(), producer.isBlockOnPersistentSend());
assertFalse(producer.isClosed());
clientSession.close();
}
@@ -59,12 +59,12 @@
cf.setProducerMaxRate(99);
cf.setBlockOnNonPersistentSend(true);
cf.setBlockOnNonPersistentSend(true);
- ClientSessionInternal clientSession = (ClientSessionInternal) cf.createSession(false, true, true);
+ ClientSessionInternal clientSession = (ClientSessionInternal)cf.createSession(false, true, true);
ClientProducer producer = clientSession.createProducer("testAddress");
assertNotNull(producer.getAddress());
assertEquals(cf.getProducerMaxRate(), producer.getMaxRate());
- assertEquals(cf.isBlockOnNonPersistentSend(),producer.isBlockOnNonPersistentSend());
- assertEquals(cf.isBlockOnPersistentSend(),producer.isBlockOnPersistentSend());
+ assertEquals(cf.isBlockOnNonPersistentSend(), producer.isBlockOnNonPersistentSend());
+ assertEquals(cf.isBlockOnPersistentSend(), producer.isBlockOnPersistentSend());
assertFalse(producer.isClosed());
clientSession.close();
}
@@ -84,13 +84,13 @@
cf.setProducerMaxRate(99);
cf.setBlockOnNonPersistentSend(true);
cf.setBlockOnNonPersistentSend(true);
- ClientSessionInternal clientSession = (ClientSessionInternal) cf.createSession(false, true, true);
+ ClientSessionInternal clientSession = (ClientSessionInternal)cf.createSession(false, true, true);
int rate = 9876;
ClientProducer producer = clientSession.createProducer("testAddress", rate);
assertNotNull(producer.getAddress());
assertEquals(rate, producer.getMaxRate());
- assertEquals(cf.isBlockOnNonPersistentSend(),producer.isBlockOnNonPersistentSend());
- assertEquals(cf.isBlockOnPersistentSend(),producer.isBlockOnPersistentSend());
+ assertEquals(cf.isBlockOnNonPersistentSend(), producer.isBlockOnNonPersistentSend());
+ assertEquals(cf.isBlockOnPersistentSend(), producer.isBlockOnPersistentSend());
assertFalse(producer.isClosed());
clientSession.close();
}
@@ -100,7 +100,7 @@
}
}
- public void testCreateProducer3() throws Exception
+ public void testProducerOnClosedSession() throws Exception
{
HornetQServer service = createServer(false);
try
@@ -110,17 +110,17 @@
cf.setProducerMaxRate(99);
cf.setBlockOnNonPersistentSend(true);
cf.setBlockOnNonPersistentSend(true);
- ClientSessionInternal clientSession = (ClientSessionInternal) cf.createSession(false, true, true);
- int rate = 9876;
- boolean blockOnSend = false;
- boolean blockOnNonSend = false;
- ClientProducer producer = clientSession.createProducer("testAddress", 9876, blockOnSend, blockOnNonSend);
- assertNotNull(producer.getAddress());
- assertEquals(rate, producer.getMaxRate());
- assertEquals(blockOnSend, producer.isBlockOnNonPersistentSend());
- assertEquals(blockOnNonSend, producer.isBlockOnPersistentSend());
- assertFalse(producer.isClosed());
+ ClientSessionInternal clientSession = (ClientSessionInternal)cf.createSession(false, true, true);
clientSession.close();
+ try
+ {
+ clientSession.createProducer();
+ fail("should throw exception");
+ }
+ catch (HornetQException e)
+ {
+ assertEquals(e.getCode(), HornetQException.OBJECT_CLOSED);
+ }
}
finally
{
@@ -128,32 +128,4 @@
}
}
- public void testProducerOnClosedSession() throws Exception
- {
- HornetQServer service = createServer(false);
- try
- {
- service.start();
- ClientSessionFactory cf = createInVMFactory();
- cf.setProducerMaxRate(99);
- cf.setBlockOnNonPersistentSend(true);
- cf.setBlockOnNonPersistentSend(true);
- ClientSessionInternal clientSession = (ClientSessionInternal) cf.createSession(false, true, true);
- clientSession.close();
- try
- {
- clientSession.createProducer();
- fail("should throw exception");
- }
- catch (HornetQException e)
- {
- assertEquals(e.getCode(), HornetQException.OBJECT_CLOSED);
- }
- }
- finally
- {
- service.stop();
- }
- }
-
}
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/WildCardRoutingTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/WildCardRoutingTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/WildCardRoutingTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -54,11 +54,11 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -79,11 +79,11 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -112,11 +112,11 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -153,11 +153,11 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -182,11 +182,11 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -214,11 +214,11 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
clientConsumer.close();
clientSession.deleteQueue(queueName);
@@ -272,39 +272,39 @@
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m3", m.getBuffer().readString());
+ assertEquals("m3", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m4", m.getBuffer().readString());
+ assertEquals("m4", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m5", m.getBuffer().readString());
+ assertEquals("m5", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m6", m.getBuffer().readString());
+ assertEquals("m6", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m7", m.getBuffer().readString());
+ assertEquals("m7", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m8", m.getBuffer().readString());
+ assertEquals("m8", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m9", m.getBuffer().readString());
+ assertEquals("m9", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -369,39 +369,39 @@
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m3", m.getBuffer().readString());
+ assertEquals("m3", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m4", m.getBuffer().readString());
+ assertEquals("m4", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m5", m.getBuffer().readString());
+ assertEquals("m5", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m6", m.getBuffer().readString());
+ assertEquals("m6", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m7", m.getBuffer().readString());
+ assertEquals("m7", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m8", m.getBuffer().readString());
+ assertEquals("m8", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m9", m.getBuffer().readString());
+ assertEquals("m9", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -439,11 +439,11 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -468,11 +468,11 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -498,11 +498,11 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -527,11 +527,11 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -556,7 +556,7 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -581,11 +581,11 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
}
@@ -608,7 +608,7 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -633,7 +633,7 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -658,7 +658,7 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -683,7 +683,7 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -708,7 +708,7 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -736,11 +736,11 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/ClientCrashTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/ClientCrashTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/ClientCrashTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -78,7 +78,7 @@
// send the message to the queue
Message messageFromClient = consumer.receive(5000);
assertNotNull("no message received", messageFromClient);
- assertEquals(MESSAGE_TEXT_FROM_CLIENT, messageFromClient.getBuffer().readString());
+ assertEquals(MESSAGE_TEXT_FROM_CLIENT, messageFromClient.getBodyBuffer().readString());
assertActiveConnections(1 + 1); // One local and one from the other vm
assertActiveSession(1 + 1);
@@ -88,7 +88,7 @@
0,
System.currentTimeMillis(),
(byte)1);
- message.getBuffer().writeString(ClientCrashTest.MESSAGE_TEXT_FROM_SERVER);
+ message.getBodyBuffer().writeString(ClientCrashTest.MESSAGE_TEXT_FROM_SERVER);
producer.send(message);
log.debug("waiting for the client VM to crash ...");
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/ClientExitTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/ClientExitTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/ClientExitTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -70,7 +70,7 @@
Message message = consumer.receive(15000);
assertNotNull(message);
- assertEquals(MESSAGE_TEXT, message.getBuffer().readString());
+ assertEquals(MESSAGE_TEXT, message.getBodyBuffer().readString());
// the client VM should exit by itself. If it doesn't, that means we have a problem
// and the test will timeout
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/CrashClient.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/CrashClient.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/CrashClient.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -63,7 +63,7 @@
0,
System.currentTimeMillis(),
(byte)1);
- message.getBuffer().writeString(ClientCrashTest.MESSAGE_TEXT_FROM_CLIENT);
+ message.getBodyBuffer().writeString(ClientCrashTest.MESSAGE_TEXT_FROM_CLIENT);
producer.send(message);
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/GracefulClient.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/GracefulClient.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/GracefulClient.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -61,7 +61,7 @@
ClientMessage message = session.createClientMessage(HornetQTextMessage.TYPE, false, 0,
System.currentTimeMillis(), (byte) 1);
- message.getBuffer().writeString(messageText);
+ message.getBodyBuffer().writeString(messageText);
producer.send(message);
session.start();
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -184,7 +184,7 @@
message.putIntProperty(propKey, i);
- message.getBuffer().writeBytes(bytes);
+ message.getBodyBuffer().writeBytes(bytes);
producer0.send(message);
}
@@ -261,7 +261,7 @@
for (int j = 0; j < 1024; j++)
{
- message.getBuffer().readBytes(byteRead);
+ message.getBodyBuffer().readBytes(byteRead);
}
}
@@ -540,7 +540,7 @@
message.putStringProperty(propKey, new SimpleString("bing"));
- message.getBuffer().writeString("doo be doo be doo be doo");
+ message.getBodyBuffer().writeString("doo be doo be doo be doo");
producer0.send(message);
}
@@ -555,7 +555,7 @@
assertEquals(new SimpleString("bong"), val);
- String sval = message.getBuffer().readString();
+ String sval = message.getBodyBuffer().readString();
assertEquals("dee be dee be dee be dee", sval);
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/bridge/SimpleTransformer.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/bridge/SimpleTransformer.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/bridge/SimpleTransformer.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -46,7 +46,7 @@
message.putStringProperty(new SimpleString("wibble"), new SimpleString("bong"));
//Change the body
- HornetQBuffer buffer = message.getBuffer();
+ HornetQBuffer buffer = message.getBodyBuffer();
buffer.readerIndex(0);
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/AsynchronousFailoverTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/AsynchronousFailoverTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/AsynchronousFailoverTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -218,7 +218,7 @@
{
ClientMessage message = session.createClientMessage(true);
- message.getBuffer().writeString("message" + i);
+ message.getBodyBuffer().writeString("message" + i);
message.putIntProperty("counter", i);
@@ -313,7 +313,7 @@
{
ClientMessage message = session.createClientMessage(true);
- message.getBuffer().writeString("message" + i);
+ message.getBodyBuffer().writeString("message" + i);
message.putIntProperty("counter", i);
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -1706,7 +1706,7 @@
{
ClientMessage message = session.createClientMessage(true);
- message.getBuffer().writeString("message");
+ message.getBodyBuffer().writeString("message");
try
{
@@ -2082,7 +2082,7 @@
*/
protected void assertMessageBody(int i, ClientMessage message)
{
- assertEquals("message" + i, message.getBuffer().readString());
+ assertEquals("message" + i, message.getBodyBuffer().readString());
}
/**
@@ -2092,7 +2092,7 @@
*/
protected void setBody(int i, ClientMessage message) throws Exception
{
- message.getBuffer().writeString("message" + i);
+ message.getBodyBuffer().writeString("message" + i);
}
// Private -------------------------------------------------------
@@ -2115,7 +2115,7 @@
System.currentTimeMillis(),
(byte)1);
message.putIntProperty(new SimpleString("count"), i);
- message.getBuffer().writeString("aardvarks");
+ message.getBodyBuffer().writeString("aardvarks");
producer.send(message);
}
@@ -2127,7 +2127,7 @@
{
ClientMessage message2 = consumer.receive();
- assertEquals("aardvarks", message2.getBuffer().readString());
+ assertEquals("aardvarks", message2.getBodyBuffer().readString());
assertEquals(i, message2.getObjectProperty(new SimpleString("count")));
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/LargeMessageFailoverTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/LargeMessageFailoverTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/LargeMessageFailoverTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -95,7 +95,7 @@
*/
protected void assertMessageBody(int i, ClientMessage message)
{
- HornetQBuffer buffer = message.getBuffer();
+ HornetQBuffer buffer = message.getBodyBuffer();
for (int j = 0; j < ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE * 3; j++)
{
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/reattach/MultiThreadRandomReattachTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/reattach/MultiThreadRandomReattachTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/reattach/MultiThreadRandomReattachTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -55,7 +55,7 @@
@Override
protected boolean checkSize(final ClientMessage message)
{
- return 0 == message.getBuffer().writerIndex();
+ return 0 == message.getBodyBuffer().writerIndex();
}
}
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/reattach/ReattachTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/reattach/ReattachTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/reattach/ReattachTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -101,7 +101,7 @@
System.currentTimeMillis(),
(byte)1);
message.putIntProperty(new SimpleString("count"), i);
- message.getBuffer().writeString("aardvarks");
+ message.getBodyBuffer().writeString("aardvarks");
producer.send(message);
}
@@ -119,7 +119,7 @@
assertNotNull(message);
- assertEquals("aardvarks", message.getBuffer().readString());
+ assertEquals("aardvarks", message.getBodyBuffer().readString());
assertEquals(i, message.getObjectProperty(new SimpleString("count")));
@@ -175,7 +175,7 @@
System.currentTimeMillis(),
(byte)1);
message.putIntProperty(new SimpleString("count"), i);
- message.getBuffer().writeString("aardvarks");
+ message.getBodyBuffer().writeString("aardvarks");
producer.send(message);
}
@@ -213,7 +213,7 @@
assertNotNull(message);
- assertEquals("aardvarks", message.getBuffer().readString());
+ assertEquals("aardvarks", message.getBodyBuffer().readString());
assertEquals(i, message.getIntProperty("count").intValue());
@@ -285,7 +285,7 @@
System.currentTimeMillis(),
(byte)1);
message.putIntProperty(new SimpleString("count"), i);
- message.getBuffer().writeString("aardvarks");
+ message.getBodyBuffer().writeString("aardvarks");
producer.send(message);
}
@@ -328,7 +328,7 @@
assertNotNull(message);
- assertEquals("aardvarks", message.getBuffer().readString());
+ assertEquals("aardvarks", message.getBodyBuffer().readString());
assertEquals(i, message.getIntProperty("count").intValue());
@@ -379,7 +379,7 @@
System.currentTimeMillis(),
(byte)1);
message.putIntProperty(new SimpleString("count"), i);
- message.getBuffer().writeString("aardvarks");
+ message.getBodyBuffer().writeString("aardvarks");
producer.send(message);
}
@@ -462,7 +462,7 @@
System.currentTimeMillis(),
(byte)1);
message.putIntProperty(new SimpleString("count"), i);
- message.getBuffer().writeString("aardvarks");
+ message.getBodyBuffer().writeString("aardvarks");
producer.send(message);
}
@@ -483,7 +483,7 @@
assertNotNull(message);
- assertEquals("aardvarks", message.getBuffer().readString());
+ assertEquals("aardvarks", message.getBodyBuffer().readString());
assertEquals(i, message.getIntProperty("count").intValue());
@@ -530,7 +530,7 @@
System.currentTimeMillis(),
(byte)1);
message.putIntProperty(new SimpleString("count"), i);
- message.getBuffer().writeString("aardvarks");
+ message.getBodyBuffer().writeString("aardvarks");
producer.send(message);
}
@@ -569,7 +569,7 @@
assertNotNull(message);
- assertEquals("aardvarks", message.getBuffer().readString());
+ assertEquals("aardvarks", message.getBodyBuffer().readString());
assertEquals(i, message.getIntProperty("count").intValue());
@@ -622,7 +622,7 @@
System.currentTimeMillis(),
(byte)1);
message.putIntProperty(new SimpleString("count"), i);
- message.getBuffer().writeString("aardvarks");
+ message.getBodyBuffer().writeString("aardvarks");
producer.send(message);
}
@@ -645,7 +645,7 @@
assertNotNull(message);
- assertEquals("aardvarks", message.getBuffer().readString());
+ assertEquals("aardvarks", message.getBodyBuffer().readString());
assertEquals(i, message.getObjectProperty(new SimpleString("count")));
@@ -701,7 +701,7 @@
System.currentTimeMillis(),
(byte)1);
message.putIntProperty(new SimpleString("count"), i);
- message.getBuffer().writeString("aardvarks");
+ message.getBodyBuffer().writeString("aardvarks");
producer.send(message);
}
@@ -724,7 +724,7 @@
assertNotNull(message);
- assertEquals("aardvarks", message.getBuffer().readString());
+ assertEquals("aardvarks", message.getBodyBuffer().readString());
assertEquals(i, message.getIntProperty("count").intValue());
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/http/CoreClientOverHttpTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/http/CoreClientOverHttpTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/http/CoreClientOverHttpTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -65,7 +65,7 @@
{
ClientMessage message = session.createClientMessage(HornetQTextMessage.TYPE, false, 0,
System.currentTimeMillis(), (byte) 1);
- message.getBuffer().writeString("CoreClientOverHttpTest");
+ message.getBodyBuffer().writeString("CoreClientOverHttpTest");
producer.send(message);
}
@@ -77,7 +77,7 @@
{
ClientMessage message2 = consumer.receive();
- assertEquals("CoreClientOverHttpTest", message2.getBuffer().readString());
+ assertEquals("CoreClientOverHttpTest", message2.getBodyBuffer().readString());
message2.acknowledge();
}
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/largemessage/LargeMessageTestBase.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/largemessage/LargeMessageTestBase.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/largemessage/LargeMessageTestBase.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -182,7 +182,6 @@
if (isXA)
{
-
session.end(xid, XAResource.TMSUCCESS);
session.prepare(xid);
@@ -349,7 +348,7 @@
else
{
- HornetQBuffer buffer = message.getBuffer();
+ HornetQBuffer buffer = message.getBodyBuffer();
buffer.resetReaderIndex();
assertEquals(numberOfBytes, buffer.writerIndex());
for (long b = 0; b < numberOfBytes; b++)
@@ -422,7 +421,7 @@
assertEquals(i, ((Integer)message.getObjectProperty(new SimpleString("counter-message"))).intValue());
}
- HornetQBuffer buffer = message.getBuffer();
+ HornetQBuffer buffer = message.getBodyBuffer();
buffer.resetReaderIndex();
if (useStreamOnConsume)
@@ -571,7 +570,7 @@
{
bytes[j] = getSamplebyte(j);
}
- message.getBuffer().writeBytes(bytes);
+ message.getBodyBuffer().writeBytes(bytes);
}
message.putIntProperty(new SimpleString("counter-message"), i);
if (delayDelivery > 0)
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/largemessage/ServerLargeMessageTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/largemessage/ServerLargeMessageTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/largemessage/ServerLargeMessageTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -19,7 +19,7 @@
import org.hornetq.core.client.ClientSession;
import org.hornetq.core.client.ClientSessionFactory;
import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
-import org.hornetq.core.persistence.impl.journal.FileLargeServerMessage;
+import org.hornetq.core.persistence.impl.journal.LargeServerMessageImpl;
import org.hornetq.core.persistence.impl.journal.JournalStorageManager;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.ServiceTestBase;
@@ -57,7 +57,7 @@
try
{
- FileLargeServerMessage fileMessage = new FileLargeServerMessage((JournalStorageManager)server.getStorageManager());
+ LargeServerMessageImpl fileMessage = new LargeServerMessageImpl((JournalStorageManager)server.getStorageManager());
fileMessage.setMessageID(1005);
@@ -90,7 +90,7 @@
for (int i = 0 ; i < 2 * ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE; i++)
{
- assertEquals(getSamplebyte(i), msg.getBuffer().readByte());
+ assertEquals(getSamplebyte(i), msg.getBodyBuffer().readByte());
}
msg.acknowledge();
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/management/AddressControlTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/management/AddressControlTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/management/AddressControlTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -359,7 +359,7 @@
for (int i = 0; i < NUMBER_MESSAGES_BEFORE_PAGING; i++)
{
ClientMessage msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[512]);
+ msg.getBodyBuffer().writeBytes(new byte[512]);
producer.send(msg);
}
session.commit();
@@ -368,21 +368,21 @@
assertEquals(0, addressControl.getNumberOfPages());
ClientMessage msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[512]);
+ msg.getBodyBuffer().writeBytes(new byte[512]);
producer.send(msg);
session.commit();
assertEquals(1, addressControl.getNumberOfPages());
msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[512]);
+ msg.getBodyBuffer().writeBytes(new byte[512]);
producer.send(msg);
session.commit();
assertEquals(1, addressControl.getNumberOfPages());
msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[512]);
+ msg.getBodyBuffer().writeBytes(new byte[512]);
producer.send(msg);
session.commit();
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/management/ManagementHelperTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/management/ManagementHelperTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/management/ManagementHelperTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -25,7 +25,9 @@
import junit.framework.TestCase;
import org.hornetq.core.buffers.HornetQChannelBuffers;
+import org.hornetq.core.client.ClientMessage;
import org.hornetq.core.client.impl.ClientMessageImpl;
+import org.hornetq.core.client.impl.ClientSessionImpl;
import org.hornetq.core.client.management.impl.ManagementHelper;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.message.Message;
@@ -58,7 +60,7 @@
String operationName = randomString();
String param = randomString();
String[] params = new String[] { randomString(), randomString(), randomString() };
- Message msg = new ClientMessageImpl(false, HornetQChannelBuffers.dynamicBuffer(1024));
+ Message msg = new ClientMessageImpl();
ManagementHelper.putOperationInvocation(msg, resource, operationName, param, params);
Object[] parameters = ManagementHelper.retrieveOperationParameters(msg);
@@ -146,7 +148,8 @@
Object[] params = new Object[] { i, s, d, b, l, map, strArray, maps };
- Message msg = new ClientMessageImpl(false, HornetQChannelBuffers.dynamicBuffer(1024));
+ Message msg = new ClientMessageImpl();
+ msg.setBuffer(HornetQChannelBuffers.dynamicBuffer(1024));
ManagementHelper.putOperationInvocation(msg, resource, operationName, params);
Object[] parameters = ManagementHelper.retrieveOperationParameters(msg);
@@ -212,7 +215,8 @@
Object[] params = new Object[] { "hello", map };
- Message msg = new ClientMessageImpl(false, HornetQChannelBuffers.dynamicBuffer(1024));
+ Message msg = new ClientMessageImpl();
+ msg.setBuffer(HornetQChannelBuffers.dynamicBuffer(1024));
ManagementHelper.putOperationInvocation(msg, resource, operationName, params);
Object[] parameters = ManagementHelper.retrieveOperationParameters(msg);
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/paging/PageCrashTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/paging/PageCrashTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/paging/PageCrashTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -151,7 +151,7 @@
ClientMessage message = null;
message = session.createClientMessage(true);
- message.getBuffer().writeBytes(new byte[1024]);
+ message.getBodyBuffer().writeBytes(new byte[1024]);
PagingStore store = server.getPostOffice().getPagingManager().getPageStore(ADDRESS);
Deleted: branches/20-optimisation/tests/src/org/hornetq/tests/integration/persistence/JournalStorageManagerIntegrationTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/persistence/JournalStorageManagerIntegrationTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/persistence/JournalStorageManagerIntegrationTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -1,85 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.tests.integration.persistence;
-
-import java.util.concurrent.Executors;
-
-import org.hornetq.core.config.Configuration;
-import org.hornetq.core.persistence.impl.journal.JournalStorageManager;
-import org.hornetq.core.server.JournalType;
-import org.hornetq.core.server.LargeServerMessage;
-import org.hornetq.core.server.ServerMessage;
-import org.hornetq.tests.util.ServiceTestBase;
-
-/**
- * A JournalStorageManagerIntegrationTest
- *
- * @author <a href="mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
- *
- * Created Jan 24, 2009 11:14:13 PM
- *
- *
- */
-public class JournalStorageManagerIntegrationTest extends ServiceTestBase
-{
-
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public void testLargeMessageCopy() throws Exception
- {
- clearData();
-
- Configuration configuration = createDefaultConfig();
-
- configuration.start();
-
- configuration.setJournalType(JournalType.ASYNCIO);
-
- final JournalStorageManager journal = new JournalStorageManager(configuration, Executors.newCachedThreadPool());
- journal.start();
-
- LargeServerMessage msg = journal.createLargeMessage();
- msg.setMessageID(1);
-
- byte[] data = new byte[1024];
-
- for (int i = 0; i < 110; i++)
- {
- msg.addBytes(data);
- }
-
- ServerMessage msg2 = msg.copy(2);
-
- assertEquals(110 * 1024, msg.getBodySize());
- assertEquals(110 * 1024, msg2.getBodySize());
-
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/scheduling/DelayedMessageTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/scheduling/DelayedMessageTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/scheduling/DelayedMessageTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -112,7 +112,7 @@
assertNotNull(tm);
- assertEquals("message" + i, tm.getBuffer().readString());
+ assertEquals("message" + i, tm.getBodyBuffer().readString());
}
//Now close the session
@@ -176,7 +176,7 @@
{
ClientMessage tm = consumer2.receive(500);
assertNotNull(tm);
- assertEquals("message" + i, tm.getBuffer().readString());
+ assertEquals("message" + i, tm.getBodyBuffer().readString());
}
//Now rollback
@@ -231,7 +231,7 @@
{
ClientMessage tm = consumer2.receive(500);
assertNotNull(tm);
- assertEquals("message" + i, tm.getBuffer().readString());
+ assertEquals("message" + i, tm.getBodyBuffer().readString());
}
//Now rollback
@@ -265,7 +265,7 @@
0,
System.currentTimeMillis(),
(byte)1);
- message.getBuffer().writeString(body);
+ message.getBodyBuffer().writeString(body);
return message;
}
}
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/scheduling/ScheduledMessageTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/scheduling/ScheduledMessageTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/scheduling/ScheduledMessageTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -149,7 +149,7 @@
ClientMessage message2 = consumer.receive(10250);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m1", message2.getBuffer().readString());
+ assertEquals("m1", message2.getBodyBuffer().readString());
message2.acknowledge();
@@ -183,8 +183,8 @@
session.start();
ClientMessage message3 = consumer.receive(1000);
ClientMessage message2 = consumer2.receive(1000);
- assertEquals("m1", message3.getBuffer().readString());
- assertEquals("m1", message2.getBuffer().readString());
+ assertEquals("m1", message3.getBodyBuffer().readString());
+ assertEquals("m1", message2.getBodyBuffer().readString());
long time = System.currentTimeMillis();
// force redelivery
consumer.close();
@@ -195,8 +195,8 @@
message2 = consumer2.receive(1000);
time += 5000;
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m1", message3.getBuffer().readString());
- assertEquals("m1", message2.getBuffer().readString());
+ assertEquals("m1", message3.getBodyBuffer().readString());
+ assertEquals("m1", message2.getBodyBuffer().readString());
message2.acknowledge();
message3.acknowledge();
@@ -234,8 +234,8 @@
assertNotNull(message3);
ClientMessage message2 = consumer2.receive(1000);
assertNotNull(message2);
- assertEquals("m1", message3.getBuffer().readString());
- assertEquals("m1", message2.getBuffer().readString());
+ assertEquals("m1", message3.getBodyBuffer().readString());
+ assertEquals("m1", message2.getBodyBuffer().readString());
long time = System.currentTimeMillis();
// force redelivery
consumer.close();
@@ -257,8 +257,8 @@
assertNotNull(message2);
time += 5000;
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m1", message3.getBuffer().readString());
- assertEquals("m1", message2.getBuffer().readString());
+ assertEquals("m1", message3.getBodyBuffer().readString());
+ assertEquals("m1", message2.getBodyBuffer().readString());
message2.acknowledge();
message3.acknowledge();
@@ -284,7 +284,7 @@
0,
System.currentTimeMillis(),
(byte)1);
- message.getBuffer().writeString("testINVMCoreClient");
+ message.getBodyBuffer().writeString("testINVMCoreClient");
message.setDurable(true);
long time = System.currentTimeMillis();
time += 10000;
@@ -309,7 +309,7 @@
ClientMessage message2 = consumer.receive(11000);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("testINVMCoreClient", message2.getBuffer().readString());
+ assertEquals("testINVMCoreClient", message2.getBodyBuffer().readString());
message2.acknowledge();
@@ -370,27 +370,27 @@
ClientMessage message = consumer.receive(11000);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m1", message.getBuffer().readString());
+ assertEquals("m1", message.getBodyBuffer().readString());
message.acknowledge();
time += 1000;
message = consumer.receive(1250);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m2", message.getBuffer().readString());
+ assertEquals("m2", message.getBodyBuffer().readString());
message.acknowledge();
time += 1000;
message = consumer.receive(1250);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m3", message.getBuffer().readString());
+ assertEquals("m3", message.getBodyBuffer().readString());
message.acknowledge();
time += 1000;
message = consumer.receive(1250);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m4", message.getBuffer().readString());
+ assertEquals("m4", message.getBodyBuffer().readString());
message.acknowledge();
time += 1000;
message = consumer.receive(1250);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m5", message.getBuffer().readString());
+ assertEquals("m5", message.getBodyBuffer().readString());
message.acknowledge();
// Make sure no more messages
@@ -451,27 +451,27 @@
ClientMessage message = consumer.receive(10250);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m1", message.getBuffer().readString());
+ assertEquals("m1", message.getBodyBuffer().readString());
message.acknowledge();
time += 1000;
message = consumer.receive(1250);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m3", message.getBuffer().readString());
+ assertEquals("m3", message.getBodyBuffer().readString());
message.acknowledge();
time += 1000;
message = consumer.receive(1250);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m5", message.getBuffer().readString());
+ assertEquals("m5", message.getBodyBuffer().readString());
message.acknowledge();
time += 1000;
message = consumer.receive(1250);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m2", message.getBuffer().readString());
+ assertEquals("m2", message.getBodyBuffer().readString());
message.acknowledge();
time += 1000;
message = consumer.receive(1250);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m4", message.getBuffer().readString());
+ assertEquals("m4", message.getBodyBuffer().readString());
message.acknowledge();
// Make sure no more messages
@@ -526,24 +526,24 @@
session.start();
ClientMessage message = consumer.receive(1000);
- assertEquals("m2", message.getBuffer().readString());
+ assertEquals("m2", message.getBodyBuffer().readString());
message.acknowledge();
message = consumer.receive(1000);
- assertEquals("m4", message.getBuffer().readString());
+ assertEquals("m4", message.getBodyBuffer().readString());
message.acknowledge();
message = consumer.receive(10250);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m1", message.getBuffer().readString());
+ assertEquals("m1", message.getBodyBuffer().readString());
message.acknowledge();
time += 1000;
message = consumer.receive(1250);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m3", message.getBuffer().readString());
+ assertEquals("m3", message.getBodyBuffer().readString());
message.acknowledge();
time += 1000;
message = consumer.receive(1250);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m5", message.getBuffer().readString());
+ assertEquals("m5", message.getBodyBuffer().readString());
message.acknowledge();
// Make sure no more messages
@@ -593,7 +593,7 @@
System.out.println("elapsed time = " + (end - time));
assertTrue(end >= time);
assertNotNull(message2);
- assertEquals("testINVMCoreClient", message2.getBuffer().readString());
+ assertEquals("testINVMCoreClient", message2.getBodyBuffer().readString());
message2.acknowledge();
session.end(xid2, XAResource.TMSUCCESS);
@@ -698,25 +698,25 @@
ClientMessage rm1 = consumer.receive(250);
assertNotNull(rm1);
- assertEquals("testScheduled2", rm1.getBuffer().readString());
+ assertEquals("testScheduled2", rm1.getBodyBuffer().readString());
ClientMessage rm2 = consumer.receive(250);
assertNotNull(rm2);
- assertEquals("testScheduled3", rm2.getBuffer().readString());
+ assertEquals("testScheduled3", rm2.getBodyBuffer().readString());
ClientMessage rm3 = consumer.receive(250);
assertNotNull(rm3);
- assertEquals("testScheduled4", rm3.getBuffer().readString());
+ assertEquals("testScheduled4", rm3.getBodyBuffer().readString());
//Now the one with a scheduled with a -ve number
ClientMessage rm5 = consumer.receive(250);
assertNotNull(rm5);
- assertEquals("testScheduled9", rm5.getBuffer().readString());
+ assertEquals("testScheduled9", rm5.getBodyBuffer().readString());
//Now the scheduled
ClientMessage rm6 = consumer.receive(3250);
assertNotNull(rm6);
- assertEquals("testScheduled7", rm6.getBuffer().readString());
+ assertEquals("testScheduled7", rm6.getBodyBuffer().readString());
long now2 = System.currentTimeMillis();
@@ -724,7 +724,7 @@
ClientMessage rm7 = consumer.receive(1250);
assertNotNull(rm7);
- assertEquals("testScheduled6", rm7.getBuffer().readString());
+ assertEquals("testScheduled6", rm7.getBodyBuffer().readString());
now2 = System.currentTimeMillis();
@@ -732,7 +732,7 @@
ClientMessage rm8 = consumer.receive(1250);
assertNotNull(rm8);
- assertEquals("testScheduled5", rm8.getBuffer().readString());
+ assertEquals("testScheduled5", rm8.getBodyBuffer().readString());
now2 = System.currentTimeMillis();
@@ -740,7 +740,7 @@
ClientMessage rm9 = consumer.receive(1250);
assertNotNull(rm9);
- assertEquals("testScheduled8", rm9.getBuffer().readString());
+ assertEquals("testScheduled8", rm9.getBodyBuffer().readString());
now2 = System.currentTimeMillis();
@@ -748,7 +748,7 @@
ClientMessage rm10 = consumer.receive(1250);
assertNotNull(rm10);
- assertEquals("testScheduled1", rm10.getBuffer().readString());
+ assertEquals("testScheduled1", rm10.getBodyBuffer().readString());
now2 = System.currentTimeMillis();
@@ -772,7 +772,7 @@
0,
System.currentTimeMillis(),
(byte)1);
- message.getBuffer().writeString(body);
+ message.getBodyBuffer().writeString(body);
return message;
}
}
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/security/SimpleClient.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/security/SimpleClient.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/security/SimpleClient.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -65,7 +65,7 @@
0,
System.currentTimeMillis(),
(byte)1);
- message.getBuffer().writeString(messageText);
+ message.getBodyBuffer().writeString(messageText);
producer.send(message);
session.start();
@@ -76,7 +76,7 @@
throw new Exception("did not receive the message");
}
- String text = receivedMsg.getBuffer().readString();
+ String text = receivedMsg.getBodyBuffer().readString();
if (text == null || !text.equals(messageText))
{
throw new Exception("received " + text + ", was expecting " + messageText);
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/server/ExpiryRunnerTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/server/ExpiryRunnerTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/server/ExpiryRunnerTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -131,7 +131,7 @@
ClientMessage cm = consumer.receive(500);
assertNotNull("message not received " + i, cm);
cm.acknowledge();
- assertEquals("m" + i, cm.getBuffer().readString());
+ assertEquals("m" + i, cm.getBodyBuffer().readString());
}
consumer.close();
Thread.sleep(2100);
@@ -208,7 +208,7 @@
{
break;
}
- String text = cm.getBuffer().readString();
+ String text = cm.getBodyBuffer().readString();
cm.acknowledge();
assertFalse(dummyMessageHandler.payloads.contains(text));
dummyMessageHandler.payloads.add(text);
@@ -327,7 +327,7 @@
break;
}
message.acknowledge();
- payloads.add(message.getBuffer().readString());
+ payloads.add(message.getBodyBuffer().readString());
Thread.sleep(110);
}
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/server/LVQRecoveryTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/server/LVQRecoveryTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/server/LVQRecoveryTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -53,7 +53,7 @@
public void testMultipleMessagesAfterRecovery() throws Exception
{
Xid xid = new XidImpl("bq1".getBytes(), 4, "gtid1".getBytes());
- ClientProducer producer = clientSessionXa.createProducer(address, -1, true, true);
+ ClientProducer producer = clientSessionXa.createProducer(address);
SimpleString messageId1 = new SimpleString("SMID1");
SimpleString messageId2 = new SimpleString("SMID2");
clientSessionXa.start(xid, XAResource.TMNOFLAGS);
@@ -82,17 +82,17 @@
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
}
public void testManyMessagesReceivedWithRollback() throws Exception
{
Xid xid = new XidImpl("bq1".getBytes(), 4, "gtid1".getBytes());
- ClientProducer producer = clientSession.createProducer(address, -1, true, true);
+ ClientProducer producer = clientSession.createProducer(address);
ClientConsumer consumer = clientSessionXa.createConsumer(qName1);
SimpleString rh = new SimpleString("SMID1");
@@ -119,27 +119,27 @@
producer.send(m1);
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
producer.send(m2);
m = consumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
producer.send(m3);
m = consumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
producer.send(m4);
m = consumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
producer.send(m5);
m = consumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m5");
+ assertEquals(m.getBodyBuffer().readString(), "m5");
producer.send(m6);
m = consumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
clientSessionXa.end(xid, XAResource.TMSUCCESS);
clientSessionXa.prepare(xid);
@@ -153,7 +153,7 @@
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
m = consumer.receiveImmediate();
assertNull(m);
}
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/server/LVQTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/server/LVQTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/server/LVQTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -50,7 +50,7 @@
public void testSimple() throws Exception
{
- ClientProducer producer = clientSession.createProducer(address, -1, true, true);
+ ClientProducer producer = clientSession.createProducer(address);
ClientConsumer consumer = clientSession.createConsumer(qName1);
ClientMessage m1 = createTextMessage("m1", clientSession);
SimpleString rh = new SimpleString("SMID1");
@@ -63,12 +63,12 @@
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
}
public void testMultipleMessages() throws Exception
{
- ClientProducer producer = clientSession.createProducer(address, -1, true, true);
+ ClientProducer producer = clientSession.createProducer(address);
ClientConsumer consumer = clientSession.createConsumer(qName1);
SimpleString messageId1 = new SimpleString("SMID1");
SimpleString messageId2 = new SimpleString("SMID2");
@@ -88,16 +88,16 @@
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
}
public void testFirstMessageReceivedButAckedAfter() throws Exception
{
- ClientProducer producer = clientSession.createProducer(address, -1, true, true);
+ ClientProducer producer = clientSession.createProducer(address);
ClientConsumer consumer = clientSession.createConsumer(qName1);
ClientMessage m1 = createTextMessage("m1", clientSession);
SimpleString rh = new SimpleString("SMID1");
@@ -110,16 +110,16 @@
assertNotNull(m);
producer.send(m2);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
}
public void testFirstMessageReceivedAndCancelled() throws Exception
{
- ClientProducer producer = clientSession.createProducer(address, -1, true, true);
+ ClientProducer producer = clientSession.createProducer(address);
ClientConsumer consumer = clientSession.createConsumer(qName1);
ClientMessage m1 = createTextMessage("m1", clientSession);
SimpleString rh = new SimpleString("SMID1");
@@ -130,13 +130,13 @@
clientSession.start();
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
producer.send(m2);
consumer.close();
consumer = clientSession.createConsumer(qName1);
m = consumer.receive(1000);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = consumer.receiveImmediate();
assertNull(m);
@@ -144,7 +144,7 @@
public void testManyMessagesReceivedAndCancelled() throws Exception
{
- ClientProducer producer = clientSession.createProducer(address, -1, true, true);
+ ClientProducer producer = clientSession.createProducer(address);
ClientConsumer consumer = clientSession.createConsumer(qName1);
SimpleString rh = new SimpleString("SMID1");
@@ -164,33 +164,33 @@
producer.send(m1);
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
producer.send(m2);
m = consumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
producer.send(m3);
m = consumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
producer.send(m4);
m = consumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
producer.send(m5);
m = consumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m5");
+ assertEquals(m.getBodyBuffer().readString(), "m5");
producer.send(m6);
m = consumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
consumer.close();
consumer = clientSession.createConsumer(qName1);
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
m = consumer.receiveImmediate();
assertNull(m);
}
@@ -198,7 +198,7 @@
public void testSimpleInTx() throws Exception
{
- ClientProducer producer = clientSessionTxReceives.createProducer(address, -1, true, true);
+ ClientProducer producer = clientSessionTxReceives.createProducer(address);
ClientConsumer consumer = clientSessionTxReceives.createConsumer(qName1);
ClientMessage m1 = createTextMessage("m1", clientSession);
SimpleString rh = new SimpleString("SMID1");
@@ -211,12 +211,12 @@
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
}
public void testMultipleMessagesInTx() throws Exception
{
- ClientProducer producer = clientSessionTxReceives.createProducer(address, -1, true, true);
+ ClientProducer producer = clientSessionTxReceives.createProducer(address);
ClientConsumer consumer = clientSessionTxReceives.createConsumer(qName1);
SimpleString messageId1 = new SimpleString("SMID1");
SimpleString messageId2 = new SimpleString("SMID2");
@@ -236,11 +236,11 @@
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
clientSessionTxReceives.commit();
m = consumer.receiveImmediate();
assertNull(m);
@@ -248,7 +248,7 @@
public void testMultipleMessagesInTxRollback() throws Exception
{
- ClientProducer producer = clientSessionTxReceives.createProducer(address, -1, true, true);
+ ClientProducer producer = clientSessionTxReceives.createProducer(address);
ClientConsumer consumer = clientSessionTxReceives.createConsumer(qName1);
SimpleString messageId1 = new SimpleString("SMID1");
SimpleString messageId2 = new SimpleString("SMID2");
@@ -266,35 +266,35 @@
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
producer.send(m3);
producer.send(m4);
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
clientSessionTxReceives.rollback();
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
}
public void testMultipleMessagesInTxSend() throws Exception
{
- ClientProducer producer = clientSessionTxSends.createProducer(address, -1, true, true);
+ ClientProducer producer = clientSessionTxSends.createProducer(address);
ClientConsumer consumer = clientSessionTxSends.createConsumer(qName1);
SimpleString rh = new SimpleString("SMID1");
ClientMessage m1 = createTextMessage("m1", clientSession);
@@ -320,12 +320,12 @@
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
}
public void testMultipleMessagesPersistedCorrectly() throws Exception
{
- ClientProducer producer = clientSession.createProducer(address, -1, true, true);
+ ClientProducer producer = clientSession.createProducer(address);
ClientConsumer consumer = clientSession.createConsumer(qName1);
SimpleString rh = new SimpleString("SMID1");
ClientMessage m1 = createTextMessage("m1", clientSession);
@@ -356,14 +356,14 @@
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
m = consumer.receiveImmediate();
assertNull(m);
}
public void testMultipleMessagesPersistedCorrectlyInTx() throws Exception
{
- ClientProducer producer = clientSessionTxSends.createProducer(address, -1, true, true);
+ ClientProducer producer = clientSessionTxSends.createProducer(address);
ClientConsumer consumer = clientSessionTxSends.createConsumer(qName1);
SimpleString rh = new SimpleString("SMID1");
ClientMessage m1 = createTextMessage("m1", clientSession);
@@ -395,14 +395,14 @@
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
m = consumer.receiveImmediate();
assertNull(m);
}
public void testMultipleAcksPersistedCorrectly() throws Exception
{
- ClientProducer producer = clientSession.createProducer(address, -1, true, true);
+ ClientProducer producer = clientSession.createProducer(address);
ClientConsumer consumer = clientSession.createConsumer(qName1);
SimpleString rh = new SimpleString("SMID1");
ClientMessage m1 = createTextMessage("m1", clientSession);
@@ -428,37 +428,37 @@
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
producer.send(m2);
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
producer.send(m3);
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
producer.send(m4);
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
producer.send(m5);
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m5");
+ assertEquals(m.getBodyBuffer().readString(), "m5");
producer.send(m6);
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
}
public void testMultipleAcksPersistedCorrectlyInTx() throws Exception
{
- ClientProducer producer = clientSessionTxReceives.createProducer(address, -1, true, true);
+ ClientProducer producer = clientSessionTxReceives.createProducer(address);
ClientConsumer consumer = clientSessionTxReceives.createConsumer(qName1);
SimpleString rh = new SimpleString("SMID1");
ClientMessage m1 = createTextMessage("m1", clientSession);
@@ -484,32 +484,32 @@
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
producer.send(m2);
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
producer.send(m3);
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
producer.send(m4);
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
producer.send(m5);
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m5");
+ assertEquals(m.getBodyBuffer().readString(), "m5");
producer.send(m6);
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
clientSessionTxReceives.commit();
}
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSL.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSL.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSL.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -67,7 +67,7 @@
ClientMessage message = session.createClientMessage(HornetQTextMessage.TYPE, false, 0,
System.currentTimeMillis(), (byte) 1);
- message.getBuffer().writeString(CoreClientOverSSLTest.MESSAGE_TEXT_FROM_CLIENT);
+ message.getBodyBuffer().writeString(CoreClientOverSSLTest.MESSAGE_TEXT_FROM_CLIENT);
producer.send(message);
session.close();
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/xa/BasicXaRecoveryTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/xa/BasicXaRecoveryTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/xa/BasicXaRecoveryTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -508,16 +508,16 @@
clientSession.start();
ClientMessage m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
}
public void testBasicSendWithRollback(final boolean stopServer) throws Exception
@@ -611,16 +611,16 @@
clientSession.start();
ClientMessage m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m5");
+ assertEquals(m.getBodyBuffer().readString(), "m5");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m7");
+ assertEquals(m.getBodyBuffer().readString(), "m7");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m8");
+ assertEquals(m.getBodyBuffer().readString(), "m8");
}
public void testMultipleTxSendWithCommit(final boolean stopServer) throws Exception
@@ -673,28 +673,28 @@
clientSession.start();
ClientMessage m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m5");
+ assertEquals(m.getBodyBuffer().readString(), "m5");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m7");
+ assertEquals(m.getBodyBuffer().readString(), "m7");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m8");
+ assertEquals(m.getBodyBuffer().readString(), "m8");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
}
public void testMultipleTxSendWithRollback(final boolean stopServer) throws Exception
@@ -799,16 +799,16 @@
clientSession.start();
ClientMessage m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
m = clientConsumer.receiveImmediate();
assertNull(m);
}
@@ -862,28 +862,28 @@
clientSession.start();
ClientMessage m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m5");
+ assertEquals(m.getBodyBuffer().readString(), "m5");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m7");
+ assertEquals(m.getBodyBuffer().readString(), "m7");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m8");
+ assertEquals(m.getBodyBuffer().readString(), "m8");
}
public void testBasicReceiveWithCommit(final boolean stopServer) throws Exception
@@ -905,19 +905,19 @@
ClientMessage m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
clientSession.end(xid, XAResource.TMSUCCESS);
assertEquals("Expected XA_OK", XAResource.XA_OK, clientSession.prepare(xid));
@@ -963,19 +963,19 @@
ClientMessage m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
clientSession.end(xid, XAResource.TMSUCCESS);
clientSession.prepare(xid);
@@ -1004,16 +1004,16 @@
clientSession.start();
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
}
public void testMultipleTxReceiveWithCommit(final boolean stopServer) throws Exception
@@ -1049,19 +1049,19 @@
ClientMessage m = clientConsumer2.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m5");
+ assertEquals(m.getBodyBuffer().readString(), "m5");
m = clientConsumer2.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
m = clientConsumer2.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m7");
+ assertEquals(m.getBodyBuffer().readString(), "m7");
m = clientConsumer2.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m8");
+ assertEquals(m.getBodyBuffer().readString(), "m8");
clientSession2.end(xid2, XAResource.TMSUCCESS);
clientSession2.prepare(xid2);
clientSession2.close();
@@ -1071,19 +1071,19 @@
m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
clientSession.end(xid, XAResource.TMSUCCESS);
clientSession.prepare(xid);
@@ -1139,19 +1139,19 @@
ClientMessage m = clientConsumer2.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m5");
+ assertEquals(m.getBodyBuffer().readString(), "m5");
m = clientConsumer2.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
m = clientConsumer2.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m7");
+ assertEquals(m.getBodyBuffer().readString(), "m7");
m = clientConsumer2.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m8");
+ assertEquals(m.getBodyBuffer().readString(), "m8");
clientSession2.end(xid2, XAResource.TMSUCCESS);
clientSession2.prepare(xid2);
clientSession2.close();
@@ -1161,19 +1161,19 @@
m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
clientSession.end(xid, XAResource.TMSUCCESS);
clientSession.prepare(xid);
@@ -1195,19 +1195,19 @@
m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
}
protected void stopAndRestartServer() throws Exception
@@ -1250,7 +1250,7 @@
0,
System.currentTimeMillis(),
(byte)1);
- message.getBuffer().writeString(s);
+ message.getBodyBuffer().writeString(s);
return message;
}
@@ -1261,7 +1261,7 @@
0,
System.currentTimeMillis(),
(byte)1);
- message.getBuffer().writeBytes(b);
+ message.getBodyBuffer().writeBytes(b);
return message;
}
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/xa/BasicXaTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/xa/BasicXaTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/xa/BasicXaTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -163,16 +163,16 @@
ClientConsumer clientConsumer = clientSession.createConsumer(atestq);
ClientMessage m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
}
public void testReceivePrepareDoesntRollbackOnClose() throws Exception
@@ -196,19 +196,19 @@
ClientMessage m = clientConsumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
clientSession.end(xid, XAResource.TMSUCCESS);
clientSession.prepare(xid);
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/integration/xa/XaTimeoutTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/integration/xa/XaTimeoutTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/integration/xa/XaTimeoutTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -178,19 +178,19 @@
ClientMessage m = clientConsumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(500);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
clientSession.end(xid, XAResource.TMSUCCESS);
CountDownLatch latch = new CountDownLatch(1);
messagingService.getResourceManager().getTransaction(xid).addOperation(new RollbackCompleteOperation(latch));
@@ -211,19 +211,19 @@
m = consumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = consumer.receive(500);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = consumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = consumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
clientSession2.close();
}
@@ -256,19 +256,19 @@
ClientMessage m = clientConsumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(500);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
clientSession.end(xid, XAResource.TMSUCCESS);
CountDownLatch latch = new CountDownLatch(1);
messagingService.getResourceManager().getTransaction(xid).addOperation(new RollbackCompleteOperation(latch));
@@ -289,19 +289,19 @@
m = consumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = consumer.receive(500);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = consumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = consumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
m = consumer.receiveImmediate();
assertNull(m);
clientSession2.close();
@@ -336,19 +336,19 @@
ClientMessage m = clientConsumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(500);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
clientSession.end(xid, XAResource.TMSUCCESS);
clientSession.prepare(xid);
CountDownLatch latch = new CountDownLatch(1);
@@ -364,19 +364,19 @@
m = consumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m5");
+ assertEquals(m.getBodyBuffer().readString(), "m5");
m = consumer.receive(500);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
m = consumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m7");
+ assertEquals(m.getBodyBuffer().readString(), "m7");
m = consumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m8");
+ assertEquals(m.getBodyBuffer().readString(), "m8");
m = consumer.receiveImmediate();
assertNull(m);
clientSession2.close();
@@ -440,19 +440,19 @@
clientSession2.start();
ClientMessage m = consumer.receive(500);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = consumer.receive(500);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = consumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = consumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
clientSession2.close();
}
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/performance/paging/MeasurePagingMultiThreadTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/performance/paging/MeasurePagingMultiThreadTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/performance/paging/MeasurePagingMultiThreadTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -101,7 +101,7 @@
session = factory.createSession(false, true, true);
producer = session.createProducer(adr);
msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[SIZE_OF_MESSAGE]);
+ msg.getBodyBuffer().writeBytes(new byte[SIZE_OF_MESSAGE]);
}
// run is not going to close sessions or anything, as we don't want to measure that time
@@ -202,7 +202,7 @@
ClientProducer producer = session.createProducer(adr);
ClientMessage msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[messageSize]);
+ msg.getBodyBuffer().writeBytes(new byte[messageSize]);
sendMessages(nMessages, producer, msg);
}
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/performance/persistence/StorageManagerTimingTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/performance/persistence/StorageManagerTimingTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/performance/persistence/StorageManagerTimingTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -167,11 +167,7 @@
final SimpleString address = new SimpleString("Destination " + i);
- ServerMessageImpl implMsg = new ServerMessageImpl(/* type */(byte)1, /* durable */
- true, /* expiration */
- 0,
- /* timestamp */0, /* priority */
- (byte)0, HornetQChannelBuffers.wrappedBuffer(new byte[1024]));
+ ServerMessageImpl implMsg = new ServerMessageImpl();
implMsg.putStringProperty(new SimpleString("Key"), new SimpleString("This String is worthless!"));
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/CompactingStressTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/CompactingStressTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/CompactingStressTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -115,7 +115,7 @@
for (int j = 0; j < 1000; j++)
{
Message msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[1024]);
+ msg.getBodyBuffer().writeBytes(new byte[1024]);
prod.send(msg);
}
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/NIOMultiThreadCompactorStressTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/NIOMultiThreadCompactorStressTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/NIOMultiThreadCompactorStressTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -303,7 +303,7 @@
for (int i = 0; i < nmessages; i++)
{
ClientMessage msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[1024]);
+ msg.getBodyBuffer().writeBytes(new byte[1024]);
prod.send(msg);
}
session.commit();
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/client/impl/LargeMessageBufferTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/client/impl/LargeMessageBufferTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/client/impl/LargeMessageBufferTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -34,7 +34,7 @@
import org.hornetq.core.client.impl.LargeMessageBufferImpl;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.remoting.impl.wireformat.SessionReceiveContinuationMessage;
-import org.hornetq.core.remoting.impl.wireformat.SessionReceiveMessage;
+import org.hornetq.core.remoting.impl.wireformat.SessionReceiveLargeMessage;
import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.UnitTestCase;
import org.hornetq.utils.SimpleString;
@@ -552,232 +552,158 @@
static class FakeConsumerInternal implements ClientConsumerInternal
{
- public void clearAtFailover()
+
+ public void close() throws HornetQException
{
// TODO Auto-generated method stub
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.impl.ClientConsumerInternal#acknowledge(org.hornetq.core.client.ClientMessage)
- */
- public void acknowledge(ClientMessage message) throws HornetQException
+ public Exception getLastException()
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.impl.ClientConsumerInternal#cleanUp()
- */
- public void cleanUp() throws HornetQException
+ public MessageHandler getMessageHandler() throws HornetQException
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.impl.ClientConsumerInternal#clear()
- */
- public void clear()
+ public boolean isClosed()
{
-
+ // TODO Auto-generated method stub
+ return false;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.impl.ClientConsumerInternal#flowControl(int, boolean)
- */
- public void flowControl(int messageBytes, boolean isLargeMessage) throws HornetQException
+ public ClientMessage receive() throws HornetQException
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.impl.ClientConsumerInternal#flushAcks()
- */
- public void flushAcks() throws HornetQException
+ public ClientMessage receive(long timeout) throws HornetQException
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.impl.ClientConsumerInternal#getBufferSize()
- */
- public int getBufferSize()
+ public ClientMessage receiveImmediate() throws HornetQException
{
-
- return 0;
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.impl.ClientConsumerInternal#getClientWindowSize()
- */
- public int getClientWindowSize()
+ public void setMessageHandler(MessageHandler handler) throws HornetQException
{
-
- return 0;
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.impl.ClientConsumerInternal#getID()
- */
- public long getID()
+ public void acknowledge(ClientMessage message) throws HornetQException
{
-
- return 0;
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.impl.ClientConsumerInternal#handleLargeMessage(org.hornetq.core.remoting.impl.wireformat.SessionReceiveMessage)
- */
- public void handleLargeMessage(SessionReceiveMessage largeMessageHeader) throws Exception
+ public void cleanUp() throws HornetQException
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.impl.ClientConsumerInternal#handleLargeMessageContinuation(org.hornetq.core.remoting.impl.wireformat.SessionReceiveContinuationMessage)
- */
- public void handleLargeMessageContinuation(SessionReceiveContinuationMessage continuation) throws Exception
+ public void clear() throws HornetQException
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.impl.ClientConsumerInternal#handleMessage(org.hornetq.core.client.impl.ClientMessageInternal)
- */
- public void handleMessage(ClientMessageInternal message) throws Exception
+ public void clearAtFailover()
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.impl.ClientConsumerInternal#isFileConsumer()
- */
- public boolean isFileConsumer()
+ public void flowControl(int messageBytes, boolean discountSlowConsumer) throws HornetQException
{
-
- return false;
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.impl.ClientConsumerInternal#start()
- */
- public void start()
+ public void flushAcks() throws HornetQException
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.impl.ClientConsumerInternal#stop()
- */
- public void stop() throws HornetQException
+ public int getBufferSize()
{
-
+ // TODO Auto-generated method stub
+ return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.ClientConsumer#close()
- */
- public void close() throws HornetQException
+ public int getClientWindowSize()
{
-
+ // TODO Auto-generated method stub
+ return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.ClientConsumer#getLastException()
- */
- public Exception getLastException()
+ public SimpleString getFilterString()
{
-
+ // TODO Auto-generated method stub
return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.ClientConsumer#getMessageHandler()
- */
- public MessageHandler getMessageHandler() throws HornetQException
+ public long getID()
{
-
- return null;
+ // TODO Auto-generated method stub
+ return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.ClientConsumer#isClosed()
- */
- public boolean isClosed()
+ public SimpleString getQueueName()
{
-
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.client.ClientConsumer#receive()
- */
- public ClientMessage receive() throws HornetQException
- {
-
+ // TODO Auto-generated method stub
return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.ClientConsumer#receive(long)
- */
- public ClientMessage receive(long timeout) throws HornetQException
+ public void handleLargeMessage(SessionReceiveLargeMessage largeMessageHeader) throws Exception
{
-
- return null;
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.ClientConsumer#receiveImmediate()
- */
- public ClientMessage receiveImmediate() throws HornetQException
+ public void handleLargeMessageContinuation(SessionReceiveContinuationMessage continuation) throws Exception
{
-
- return null;
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.ClientConsumer#setMessageHandler(org.hornetq.core.client.MessageHandler)
- */
- public void setMessageHandler(MessageHandler handler) throws HornetQException
+ public void handleMessage(ClientMessageInternal message) throws Exception
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.ClientConsumer#getLargeMessageCacheDir()
- */
- public File getLargeMessageCacheDir()
+ public boolean isBrowseOnly()
{
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.client.ClientConsumer#setLargeMessageCacheDir(java.io.File)
- */
- public void setLargeMessageCacheDir(File largeMessageCacheDir)
- {
- }
-
- public SimpleString getFilterString()
- {
// TODO Auto-generated method stub
- return null;
+ return false;
}
- public SimpleString getQueueName()
+ public void start()
{
// TODO Auto-generated method stub
- return null;
+
}
- public boolean isBrowseOnly()
+ public void stop() throws HornetQException
{
// TODO Auto-generated method stub
- return false;
+
}
+
-
}
}
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/message/impl/MessageImplTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/message/impl/MessageImplTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/message/impl/MessageImplTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -43,31 +43,7 @@
public class MessageImplTest extends UnitTestCase
{
private static final Logger log = Logger.getLogger(MessageImplTest.class);
-
- public void testEncodeDecode()
- {
- for (int j = 0; j < 10; j++)
- {
- byte[] bytes = new byte[1000];
- for (int i = 0; i < bytes.length; i++)
- {
- bytes[i] = randomByte();
- }
- HornetQBuffer body = HornetQChannelBuffers.wrappedBuffer(bytes);
- Message message1 = new ClientMessageImpl(randomByte(), randomBoolean(), randomLong(), randomLong(), randomByte(), body);
- Message message = message1;
- message.setDestination(new SimpleString("oasoas"));
-
- message.putStringProperty(new SimpleString("prop1"), new SimpleString("blah1"));
- message.putStringProperty(new SimpleString("prop2"), new SimpleString("blah2"));
- HornetQBuffer buffer = HornetQChannelBuffers.buffer(message.getEncodeSize());
- message.encode(buffer);
- Message message2 = new ClientMessageImpl(false);
- message2.decodeHeadersAndProperties(buffer);
- assertMessagesEquivalent(message, message2);
- }
- }
-
+
public void getSetAttributes()
{
for (int j = 0; j < 10; j++)
@@ -116,13 +92,13 @@
assertEquals(priority2, message.getPriority());
message.setBuffer(body);
- assertTrue(body == message.getBuffer());
+ assertTrue(body == message.getBodyBuffer());
}
}
public void testExpired()
{
- Message message = new ClientMessageImpl(false);
+ Message message = new ClientMessageImpl();
assertEquals(0, message.getExpiration());
assertFalse(message.isExpired());
@@ -141,34 +117,12 @@
}
- public void testEncodingMessage() throws Exception
- {
-
- SimpleString address = new SimpleString("Simple Destination ");
-
- Message msg = new ClientMessageImpl(false);
-
- byte[] bytes = new byte[]{(byte)1, (byte)2, (byte)3};
- msg.setBuffer(HornetQChannelBuffers.wrappedBuffer(bytes));
-
- msg.setDestination(address);
- msg.putStringProperty(new SimpleString("Key"), new SimpleString("This String is worthless!"));
- msg.putStringProperty(new SimpleString("Key"), new SimpleString("This String is worthless and bigger!"));
- msg.putStringProperty(new SimpleString("Key2"), new SimpleString("This String is worthless and bigger and bigger!"));
- msg.removeProperty(new SimpleString("Key2"));
-
- checkSizes(msg, new ServerMessageImpl());
-
- msg.removeProperty(new SimpleString("Key"));
-
- checkSizes(msg, new ServerMessageImpl());
- }
public void testProperties()
{
for (int j = 0; j < 10; j++)
{
- Message msg = new ClientMessageImpl(false);
+ Message msg = new ClientMessageImpl();
SimpleString prop1 = new SimpleString("prop1");
boolean val1 = randomBoolean();
@@ -300,7 +254,7 @@
assertEquals(msg1.getType(), msg2.getType());
- assertEqualsByteArrays(msg1.getBuffer().array(), msg2.getBuffer().array());
+ assertEqualsByteArrays(msg1.getBodyBuffer().array(), msg2.getBodyBuffer().array());
assertEquals(msg1.getDestination(), msg2.getDestination());
@@ -321,23 +275,5 @@
}
// Private ----------------------------------------------------------------------------------
-
- private void checkSizes(final Message obj, final EncodingSupport newObject)
- {
- HornetQBuffer buffer = HornetQChannelBuffers.buffer(1024);
- obj.encode(buffer);
- assertEquals (buffer.writerIndex(), obj.getEncodeSize());
- int originalSize = buffer.writerIndex();
- buffer.resetReaderIndex();
- newObject.decode(buffer);
-
-
- HornetQBuffer newBuffer = HornetQChannelBuffers.buffer(1024);
-
- newObject.encode(newBuffer);
-
- assertEquals(newObject.getEncodeSize(), newBuffer.writerIndex());
- assertEquals(originalSize, newBuffer.writerIndex());
- }
}
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PageImplTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PageImplTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PageImplTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -109,7 +109,7 @@
assertEquals(simpleDestination, (msgs.get(i).getMessage(null)).getDestination());
- assertEqualsByteArrays(buffers.get(i).array(), (msgs.get(i).getMessage(null)).getBuffer().array());
+ assertEqualsByteArrays(buffers.get(i).array(), (msgs.get(i).getMessage(null)).getBodyBuffer().array());
}
impl.delete();
@@ -182,7 +182,7 @@
assertEquals(simpleDestination, (msgs.get(i).getMessage(null)).getDestination());
- assertEqualsByteArrays(buffers.get(i).array(), (msgs.get(i).getMessage(null)).getBuffer().array());
+ assertEqualsByteArrays(buffers.get(i).array(), (msgs.get(i).getMessage(null)).getBodyBuffer().array());
}
impl.delete();
@@ -218,12 +218,7 @@
buffers.add(buffer);
- ServerMessage msg = new ServerMessageImpl((byte)1,
- true,
- 0,
- System.currentTimeMillis(),
- (byte)0,
- buffer);
+ ServerMessage msg = new ServerMessageImpl();
msg.setMessageID(i);
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingManagerImplTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingManagerImplTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingManagerImplTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -90,7 +90,7 @@
assertEquals(1, msgs.size());
- assertEqualsByteArrays(msg.getBuffer().array(), (msgs.get(0).getMessage(null)).getBuffer().array());
+ assertEqualsByteArrays(msg.getBodyBuffer().array(), (msgs.get(0).getMessage(null)).getBodyBuffer().array());
assertTrue(store.isPaging());
@@ -112,12 +112,7 @@
protected ServerMessage createMessage(final long messageId, final SimpleString destination, final ByteBuffer buffer)
{
- ServerMessage msg = new ServerMessageImpl((byte)1,
- true,
- 0,
- System.currentTimeMillis(),
- (byte)0,
- HornetQChannelBuffers.wrappedBuffer(new byte[1024]));
+ ServerMessage msg = new ServerMessageImpl();
msg.setMessageID(messageId);
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -295,7 +295,7 @@
for (int i = 0; i < 10; i++)
{
assertEquals(0, msg.get(i).getMessage(null).getMessageID());
- assertEqualsByteArrays(buffers.get(i).array(), msg.get(i).getMessage(null).getBuffer().array());
+ assertEqualsByteArrays(buffers.get(i).array(), msg.get(i).getMessage(null).getBodyBuffer().array());
}
}
@@ -366,7 +366,7 @@
for (int i = 0; i < 5; i++)
{
assertEquals(0, msg.get(i).getMessage(null).getMessageID());
- assertEqualsByteArrays(buffers.get(pageNr * 5 + i).array(), msg.get(i).getMessage(null).getBuffer().array());
+ assertEqualsByteArrays(buffers.get(pageNr * 5 + i).array(), msg.get(i).getMessage(null).getBodyBuffer().array());
}
}
@@ -410,7 +410,7 @@
assertEquals(0l, msgs.get(0).getMessage(null).getMessageID());
- assertEqualsByteArrays(buffers.get(0).array(), msgs.get(0).getMessage(null).getBuffer().array());
+ assertEqualsByteArrays(buffers.get(0).array(), msgs.get(0).getMessage(null).getBodyBuffer().array());
assertEquals(1, storeImpl.getNumberOfPages());
@@ -589,14 +589,14 @@
for (PagedMessage msg : msgs)
{
- long id = msg.getMessage(null).getBuffer().readLong();
- msg.getMessage(null).getBuffer().resetReaderIndex();
+ long id = msg.getMessage(null).getBodyBuffer().readLong();
+ msg.getMessage(null).getBodyBuffer().resetReaderIndex();
ServerMessage msgWritten = buffers.remove(id);
buffers2.put(id, msg.getMessage(null));
assertNotNull(msgWritten);
assertEquals(msg.getMessage(null).getDestination(), msgWritten.getDestination());
- assertEqualsByteArrays(msgWritten.getBuffer().array(), msg.getMessage(null).getBuffer().array());
+ assertEqualsByteArrays(msgWritten.getBodyBuffer().array(), msg.getMessage(null).getBodyBuffer().array());
}
}
@@ -662,11 +662,11 @@
for (PagedMessage msg : msgs)
{
- long id = msg.getMessage(null).getBuffer().readLong();
+ long id = msg.getMessage(null).getBodyBuffer().readLong();
ServerMessage msgWritten = buffers2.remove(id);
assertNotNull(msgWritten);
assertEquals(msg.getMessage(null).getDestination(), msgWritten.getDestination());
- assertEqualsByteArrays(msgWritten.getBuffer().array(), msg.getMessage(null).getBuffer().array());
+ assertEqualsByteArrays(msgWritten.getBodyBuffer().array(), msg.getMessage(null).getBodyBuffer().array());
}
}
@@ -675,9 +675,9 @@
lastPage.close();
assertEquals(1, lastMessages.size());
- lastMessages.get(0).getMessage(null).getBuffer().resetReaderIndex();
- assertEquals(lastMessages.get(0).getMessage(null).getBuffer().readLong(), lastMessageId);
- assertEqualsByteArrays(lastMessages.get(0).getMessage(null).getBuffer().array(), lastMsg.getBuffer().array());
+ lastMessages.get(0).getMessage(null).getBodyBuffer().resetReaderIndex();
+ assertEquals(lastMessages.get(0).getMessage(null).getBodyBuffer().readLong(), lastMessageId);
+ assertEqualsByteArrays(lastMessages.get(0).getMessage(null).getBodyBuffer().array(), lastMsg.getBodyBuffer().array());
assertEquals(0, buffers2.size());
@@ -706,7 +706,7 @@
final SimpleString destination,
final HornetQBuffer buffer)
{
- ServerMessage msg = new ServerMessageImpl((byte)1, true, 0, System.currentTimeMillis(), (byte)0, buffer);
+ ServerMessage msg = new ServerMessageImpl();
msg.setDestination(destination);
@@ -1232,6 +1232,12 @@
{
}
+ public void storeReference(long queueID, long messageID, boolean last) throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
}
class FakeStoreFactory implements PagingStoreFactory
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingsImplTest.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingsImplTest.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingsImplTest.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -285,864 +285,613 @@
class FakeMessage implements ServerMessage
{
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#makeCopyForExpiryOrDLA(long, boolean)
- */
- public ServerMessage makeCopyForExpiryOrDLA(long newID, boolean expiry) throws Exception
+ public ServerMessage copy() throws Exception
{
// TODO Auto-generated method stub
return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#setOriginalHeaders(org.hornetq.core.server.ServerMessage, boolean)
- */
- public void setOriginalHeaders(ServerMessage other, boolean expiry)
+ public ServerMessage copy(long newID) throws Exception
{
// TODO Auto-generated method stub
-
+ return null;
}
- public Map<String, Object> toMap()
+ public MessageReference createReference(Queue queue)
{
+ // TODO Auto-generated method stub
return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#copy(long)
- */
- public ServerMessage copy(final long newID) throws Exception
+ public int decrementDurableRefCount()
{
-
- return null;
+ // TODO Auto-generated method stub
+ return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#copy()
- */
- public ServerMessage copy() throws Exception
+ public int decrementRefCount(MessageReference reference) throws Exception
{
-
- return null;
+ // TODO Auto-generated method stub
+ return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#createReference(org.hornetq.core.server.Queue)
- */
- public MessageReference createReference(final Queue queue)
+ public void encodeMessageIDToBuffer()
{
-
- return null;
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#decrementDurableRefCount()
- */
- public int decrementDurableRefCount()
+ public int getEndMessagePosition()
{
-
+ // TODO Auto-generated method stub
return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#decrementRefCount()
- */
- public int decrementRefCount()
+ public int getMemoryEstimate()
{
-
+ // TODO Auto-generated method stub
return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#getMemoryEstimate()
- */
- public int getMemoryEstimate()
+ public PagingStore getPagingStore()
{
-
- return 0;
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#getRefCount()
- */
public int getRefCount()
{
-
+ // TODO Auto-generated method stub
return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#incrementDurableRefCount()
- */
public int incrementDurableRefCount()
{
-
+ // TODO Auto-generated method stub
return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#incrementRefCount()
- */
- public int incrementRefCount()
+ public int incrementRefCount(MessageReference reference) throws Exception
{
-
+ // TODO Auto-generated method stub
return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#isLargeMessage()
- */
- public boolean isLargeMessage()
+ public ServerMessage makeCopyForExpiryOrDLA(long newID, boolean expiry) throws Exception
{
+ // TODO Auto-generated method stub
+ return null;
+ }
+ public boolean page(boolean duplicateDetection) throws Exception
+ {
+ // TODO Auto-generated method stub
return false;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#isStored()
- */
- public boolean isStored()
+ public boolean page(long transactionID, boolean duplicateDetection) throws Exception
{
-
+ // TODO Auto-generated method stub
return false;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#setMessageID(long)
- */
- public void setMessageID(final long id)
+ public void setEndMessagePosition(int pos)
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#setStored()
- */
- public void setStored()
+ public void setMessageID(long id)
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#containsProperty(org.hornetq.utils.SimpleString)
- */
- public boolean containsProperty(final SimpleString key)
+ public void setNeedsEncoding()
{
-
- return false;
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#decode(org.hornetq.core.remoting.spi.HornetQBuffer)
- */
- public void decode(final HornetQBuffer buffer)
+ public void setOriginalHeaders(ServerMessage other, boolean expiry)
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#decodeBody(org.hornetq.core.remoting.spi.HornetQBuffer)
- */
- public void decodeBody(final HornetQBuffer buffer)
+ public void setPagingStore(PagingStore store)
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#decodeProperties(org.hornetq.core.remoting.spi.HornetQBuffer)
- */
- public void decodeHeadersAndProperties(final HornetQBuffer buffer)
+ public boolean storeIsPaging()
{
-
+ // TODO Auto-generated method stub
+ return false;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#encode(org.hornetq.core.remoting.spi.HornetQBuffer)
- */
- public void encode(final HornetQBuffer buffer)
+ public void afterSend()
{
-
+ // TODO Auto-generated method stub
+
}
- public void encodeBody(HornetQBuffer bufferOut, BodyEncoder context, int size)
+ public boolean containsProperty(SimpleString key)
{
- // To change body of implemented methods use File | Settings | File Templates.
+ // TODO Auto-generated method stub
+ return false;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#encodeBody(org.hornetq.core.remoting.spi.HornetQBuffer)
- */
- public void encodeBody(final HornetQBuffer buffer)
+ public boolean containsProperty(String key)
{
-
+ // TODO Auto-generated method stub
+ return false;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#encodeProperties(org.hornetq.core.remoting.spi.HornetQBuffer)
- */
- public void encodeHeadersAndProperties(final HornetQBuffer buffer)
+ public void decodeFromWire(HornetQBuffer buffer)
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getBody()
- */
- public HornetQBuffer getBuffer()
+ public void decodeHeadersAndProperties(HornetQBuffer buffer)
{
-
- return null;
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getBodySize()
- */
- public int getBodySize()
+ public void encodeHeadersAndProperties(HornetQBuffer buffer)
{
-
- return 0;
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getDestination()
- */
- public SimpleString getDestination()
+ public HornetQBuffer getBodyBuffer()
{
-
+ // TODO Auto-generated method stub
return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getEncodeSize()
- */
- public int getEncodeSize()
+ public BodyEncoder getBodyEncoder()
{
-
- return 0;
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getExpiration()
- */
- public long getExpiration()
+ public InputStream getBodyInputStream()
{
-
- return 0;
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getMessageID()
- */
- public long getMessageID()
+ public Boolean getBooleanProperty(SimpleString key) throws PropertyConversionException
{
-
- return 0;
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getPriority()
- */
- public byte getPriority()
+ public Boolean getBooleanProperty(String key) throws PropertyConversionException
{
-
- return 0;
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getProperties()
- */
- public TypedProperties getProperties()
+ public Byte getByteProperty(SimpleString key) throws PropertyConversionException
{
-
+ // TODO Auto-generated method stub
return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getPropertiesEncodeSize()
- */
- public int getHeadersAndPropertiesEncodeSize()
+ public Byte getByteProperty(String key) throws PropertyConversionException
{
-
- return 0;
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getPropertyNames()
- */
- public Set<SimpleString> getPropertyNames()
+ public byte[] getBytesProperty(SimpleString key) throws PropertyConversionException
{
-
+ // TODO Auto-generated method stub
return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getTimestamp()
- */
- public long getTimestamp()
+ public byte[] getBytesProperty(String key) throws PropertyConversionException
{
-
- return 0;
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getType()
- */
- public byte getType()
+ public SimpleString getDestination()
{
-
- return 0;
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#isDurable()
- */
- public boolean isDurable()
+ public Double getDoubleProperty(SimpleString key) throws PropertyConversionException
{
-
- return false;
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#isExpired()
- */
- public boolean isExpired()
+ public Double getDoubleProperty(String key) throws PropertyConversionException
{
-
- return false;
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putBooleanProperty(org.hornetq.utils.SimpleString, boolean)
- */
- public void putBooleanProperty(final SimpleString key, final boolean value)
+ public int getEncodeSize()
{
-
+ // TODO Auto-generated method stub
+ return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putByteProperty(org.hornetq.utils.SimpleString, byte)
- */
- public void putByteProperty(final SimpleString key, final byte value)
+ public long getExpiration()
{
-
+ // TODO Auto-generated method stub
+ return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putBytesProperty(org.hornetq.utils.SimpleString, byte[])
- */
- public void putBytesProperty(final SimpleString key, final byte[] value)
+ public Float getFloatProperty(SimpleString key) throws PropertyConversionException
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putDoubleProperty(org.hornetq.utils.SimpleString, double)
- */
- public void putDoubleProperty(final SimpleString key, final double value)
+ public Float getFloatProperty(String key) throws PropertyConversionException
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putFloatProperty(org.hornetq.utils.SimpleString, float)
- */
- public void putFloatProperty(final SimpleString key, final float value)
+ public int getHeadersAndPropertiesEncodeSize()
{
-
+ // TODO Auto-generated method stub
+ return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putIntProperty(org.hornetq.utils.SimpleString, int)
- */
- public void putIntProperty(final SimpleString key, final int value)
+ public Integer getIntProperty(SimpleString key) throws PropertyConversionException
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putLongProperty(org.hornetq.utils.SimpleString, long)
- */
- public void putLongProperty(final SimpleString key, final long value)
+ public Integer getIntProperty(String key) throws PropertyConversionException
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putShortProperty(org.hornetq.utils.SimpleString, short)
- */
- public void putShortProperty(final SimpleString key, final short value)
+ public long getLargeBodySize()
{
-
+ // TODO Auto-generated method stub
+ return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putStringProperty(org.hornetq.utils.SimpleString, org.hornetq.utils.SimpleString)
- */
- public void putStringProperty(final SimpleString key, final SimpleString value)
+ public Long getLongProperty(SimpleString key) throws PropertyConversionException
{
-
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getSimpleStringProperty(org.hornetq.utils.SimpleString)
- */
- public SimpleString getSimpleStringProperty(SimpleString key) throws PropertyConversionException
- {
// TODO Auto-generated method stub
return null;
}
-
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getSimpleStringProperty(java.lang.String)
- */
- public SimpleString getSimpleStringProperty(String key) throws PropertyConversionException
+ public Long getLongProperty(String key) throws PropertyConversionException
{
// TODO Auto-generated method stub
return null;
}
-
- public void putObjectProperty(SimpleString key, Object value)
+
+ public long getMessageID()
{
// TODO Auto-generated method stub
-
+ return 0;
}
-
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putObjectProperty(java.lang.String, java.lang.Object)
- */
- public void putObjectProperty(String key, Object value)
+
+ public Object getObjectProperty(SimpleString key)
{
// TODO Auto-generated method stub
-
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putTypedProperties(org.hornetq.utils.TypedProperties)
- */
- public void putTypedProperties(final TypedProperties properties)
+ public Object getObjectProperty(String key)
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#removeProperty(org.hornetq.utils.SimpleString)
- */
- public Object removeProperty(final SimpleString key)
+ public byte getPriority()
{
-
- return null;
+ // TODO Auto-generated method stub
+ return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#setBody(org.hornetq.core.remoting.spi.HornetQBuffer)
- */
- public void setBuffer(final HornetQBuffer body)
+ public TypedProperties getProperties()
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#setDestination(org.hornetq.utils.SimpleString)
- */
- public void setDestination(final SimpleString destination)
+ public Set<SimpleString> getPropertyNames()
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#setDurable(boolean)
- */
- public void setDurable(final boolean durable)
+ public Short getShortProperty(SimpleString key) throws PropertyConversionException
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#setExpiration(long)
- */
- public void setExpiration(final long expiration)
+ public Short getShortProperty(String key) throws PropertyConversionException
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#setPriority(byte)
- */
- public void setPriority(final byte priority)
+ public SimpleString getSimpleStringProperty(SimpleString key) throws PropertyConversionException
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#setTimestamp(long)
- */
- public void setTimestamp(final long timestamp)
+ public SimpleString getSimpleStringProperty(String key) throws PropertyConversionException
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getBodyInputStream()
- */
- public InputStream getBodyInputStream()
+ public String getStringProperty(SimpleString key) throws PropertyConversionException
{
+ // TODO Auto-generated method stub
return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#setBodyInputStream(java.io.InputStream)
- */
- public void setBodyInputStream(InputStream stream)
+ public String getStringProperty(String key) throws PropertyConversionException
{
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getLargeBodySize()
- */
- public long getLargeBodySize()
+ public long getTimestamp()
{
+ // TODO Auto-generated method stub
return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#containsProperty(java.lang.String)
- */
- public boolean containsProperty(String key)
+ public byte getType()
{
-
- return false;
+ // TODO Auto-generated method stub
+ return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getProperty(java.lang.String)
- */
- public Object getObjectProperty(String key)
+ public HornetQBuffer getWholeBuffer()
{
-
+ // TODO Auto-generated method stub
return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putBooleanProperty(java.lang.String, boolean)
- */
- public void putBooleanProperty(String key, boolean value)
+ public boolean isBufferWritten()
{
-
+ // TODO Auto-generated method stub
+ return false;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putByteProperty(java.lang.String, byte)
- */
- public void putByteProperty(String key, byte value)
+ public boolean isDurable()
{
-
+ // TODO Auto-generated method stub
+ return false;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putBytesProperty(java.lang.String, byte[])
- */
- public void putBytesProperty(String key, byte[] value)
+ public boolean isEncodedToBuffer()
{
-
+ // TODO Auto-generated method stub
+ return false;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putDoubleProperty(java.lang.String, double)
- */
- public void putDoubleProperty(String key, double value)
+ public boolean isExpired()
{
-
+ // TODO Auto-generated method stub
+ return false;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putFloatProperty(java.lang.String, float)
- */
- public void putFloatProperty(String key, float value)
+ public boolean isLargeMessage()
{
-
+ // TODO Auto-generated method stub
+ return false;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putIntProperty(java.lang.String, int)
- */
- public void putIntProperty(String key, int value)
+ public void putBooleanProperty(SimpleString key, boolean value)
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putLongProperty(java.lang.String, long)
- */
- public void putLongProperty(String key, long value)
+ public void putBooleanProperty(String key, boolean value)
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putShortProperty(java.lang.String, short)
- */
- public void putShortProperty(String key, short value)
+ public void putByteProperty(SimpleString key, byte value)
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putStringProperty(java.lang.String, java.lang.String)
- */
- public void putStringProperty(String key, String value)
+ public void putByteProperty(String key, byte value)
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#removeProperty(java.lang.String)
- */
- public Object removeProperty(String key)
+ public void putBytesProperty(SimpleString key, byte[] value)
{
-
- return null;
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getStringProperty(org.hornetq.utils.SimpleString)
- */
- public String getStringProperty(SimpleString key)
+ public void putBytesProperty(String key, byte[] value)
{
// TODO Auto-generated method stub
- return null;
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getBooleanProperty(org.hornetq.utils.SimpleString)
- */
- public Boolean getBooleanProperty(SimpleString key)
+ public void putDoubleProperty(SimpleString key, double value)
{
// TODO Auto-generated method stub
- return false;
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getByteProperty(org.hornetq.utils.SimpleString)
- */
- public Byte getByteProperty(SimpleString key)
+ public void putDoubleProperty(String key, double value)
{
// TODO Auto-generated method stub
- return 0;
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getBytesProperty(org.hornetq.utils.SimpleString)
- */
- public byte[] getBytesProperty(SimpleString key) throws PropertyConversionException
+ public void putFloatProperty(SimpleString key, float value)
{
// TODO Auto-generated method stub
- return null;
+
}
-
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getDoubleProperty(org.hornetq.utils.SimpleString)
- */
- public Double getDoubleProperty(SimpleString key)
+
+ public void putFloatProperty(String key, float value)
{
// TODO Auto-generated method stub
- return 0.0;
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getFloatProperty(org.hornetq.utils.SimpleString)
- */
- public Float getFloatProperty(SimpleString key)
+ public void putIntProperty(SimpleString key, int value)
{
// TODO Auto-generated method stub
- return 0f;
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getIntProperty(org.hornetq.utils.SimpleString)
- */
- public Integer getIntProperty(SimpleString key)
+ public void putIntProperty(String key, int value)
{
// TODO Auto-generated method stub
- return 0;
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getLongProperty(org.hornetq.utils.SimpleString)
- */
- public Long getLongProperty(SimpleString key)
+ public void putLongProperty(SimpleString key, long value)
{
// TODO Auto-generated method stub
- return 0L;
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getObjectProperty(org.hornetq.utils.SimpleString)
- */
- public Object getObjectProperty(SimpleString key)
+ public void putLongProperty(String key, long value)
{
// TODO Auto-generated method stub
- return null;
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getShortProperty(org.hornetq.utils.SimpleString)
- */
- public Short getShortProperty(SimpleString key)
+ public void putObjectProperty(SimpleString key, Object value) throws PropertyConversionException
{
// TODO Auto-generated method stub
- return 0;
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getBooleanProperty(java.lang.String)
- */
- public Boolean getBooleanProperty(String key) throws PropertyConversionException
+
+ public void putObjectProperty(String key, Object value) throws PropertyConversionException
{
// TODO Auto-generated method stub
- return null;
+
}
-
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getByteProperty(java.lang.String)
- */
- public Byte getByteProperty(String key) throws PropertyConversionException
+
+ public void putShortProperty(SimpleString key, short value)
{
// TODO Auto-generated method stub
- return null;
+
}
-
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getBytesProperty(java.lang.String)
- */
- public byte[] getBytesProperty(String key) throws PropertyConversionException
+
+ public void putShortProperty(String key, short value)
{
// TODO Auto-generated method stub
- return null;
+
}
-
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getDoubleProperty(java.lang.String)
- */
- public Double getDoubleProperty(String key) throws PropertyConversionException
+
+ public void putStringProperty(SimpleString key, SimpleString value)
{
// TODO Auto-generated method stub
- return null;
+
}
-
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getFloatProperty(java.lang.String)
- */
- public Float getFloatProperty(String key) throws PropertyConversionException
+
+ public void putStringProperty(String key, String value)
{
// TODO Auto-generated method stub
- return null;
+
}
-
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getIntProperty(java.lang.String)
- */
- public Integer getIntProperty(String key) throws PropertyConversionException
+
+ public void putTypedProperties(TypedProperties properties)
{
// TODO Auto-generated method stub
- return null;
+
}
-
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getLongProperty(java.lang.String)
- */
- public Long getLongProperty(String key) throws PropertyConversionException
+
+ public Object removeProperty(SimpleString key)
{
// TODO Auto-generated method stub
return null;
}
-
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getShortProperty(java.lang.String)
- */
- public Short getShortProperty(String key) throws PropertyConversionException
+
+ public Object removeProperty(String key)
{
// TODO Auto-generated method stub
return null;
}
-
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getStringProperty(java.lang.String)
- */
- public String getStringProperty(String key) throws PropertyConversionException
- {
- // TODO Auto-generated method stub
- return null;
- }
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#decrementRefCount(org.hornetq.core.paging.PagingStore, org.hornetq.core.server.MessageReference)
- */
- public int decrementRefCount(PagingStore pagingStore, MessageReference reference) throws Exception
+ public void setBuffer(HornetQBuffer buffer)
{
// TODO Auto-generated method stub
- return 0;
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#incrementRefCount(org.hornetq.core.paging.PagingStore, org.hornetq.core.server.MessageReference)
- */
- public int incrementRefCount(PagingStore pagingStore, MessageReference reference) throws Exception
+ public void setDestination(SimpleString destination)
{
// TODO Auto-generated method stub
- return 0;
+
}
- public PagingStore getPagingStore()
+ public void setDurable(boolean durable)
{
// TODO Auto-generated method stub
- return null;
+
}
- public void setPagingStore(PagingStore store)
+ public void setExpiration(long expiration)
{
// TODO Auto-generated method stub
}
- public boolean page(boolean duplicateDetection) throws Exception
+ public void setPriority(byte priority)
{
// TODO Auto-generated method stub
- return false;
+
}
- public boolean page(long transactionID, boolean duplicateDetection) throws Exception
+ public void setTimestamp(long timestamp)
{
// TODO Auto-generated method stub
- return false;
+
}
- public boolean storeIsPaging()
+ public Map<String, Object> toMap()
{
// TODO Auto-generated method stub
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getBodyEncoder()
- */
- public BodyEncoder getBodyEncoder()
- {
- // TODO Auto-generated method stub
return null;
}
- public int decrementRefCount(MessageReference reference) throws Exception
+ public void decode(HornetQBuffer buffer)
{
// TODO Auto-generated method stub
- return 0;
+
}
- public int incrementRefCount(MessageReference reference) throws Exception
+ public void encode(HornetQBuffer buffer)
{
// TODO Auto-generated method stub
- return 0;
+
}
+
}
class FakeFilter implements Filter
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/util/ServiceTestBase.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/util/ServiceTestBase.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/util/ServiceTestBase.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -353,8 +353,8 @@
public String getTextMessage(ClientMessage m)
{
- //m.getBuffer().resetReaderIndex();
- return m.getBuffer().readString();
+ //m.getBodyBuffer().resetReaderIndex();
+ return m.getBodyBuffer().readString();
}
protected ClientMessage createTextMessage(final ClientSession session, final String s, final boolean durable)
@@ -364,7 +364,7 @@
0,
System.currentTimeMillis(),
(byte)1);
- message.getBuffer().writeString(s);
+ message.getBodyBuffer().writeString(s);
return message;
}
@@ -375,7 +375,7 @@
0,
System.currentTimeMillis(),
(byte)1);
- message.getBuffer().writeBytes(b);
+ message.getBodyBuffer().writeBytes(b);
return message;
}
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/util/UnitTestCase.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/util/UnitTestCase.java 2009-11-21 23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/util/UnitTestCase.java 2009-11-22 18:47:45 UTC (rev 8367)
@@ -833,16 +833,11 @@
protected ServerMessage generateMessage(long id)
{
- ServerMessage message = new ServerMessageImpl((byte)0,
- true,
- 0,
- System.currentTimeMillis(),
- (byte)4,
- HornetQChannelBuffers.dynamicBuffer(1024));
+ ServerMessage message = new ServerMessageImpl();
message.setMessageID(id);
- message.getBuffer().writeString(UUID.randomUUID().toString());
+ message.getBodyBuffer().writeString(UUID.randomUUID().toString());
message.setDestination(new SimpleString("foo"));
@@ -873,7 +868,7 @@
0,
System.currentTimeMillis(),
(byte)1);
- message.getBuffer().writeString(s);
+ message.getBodyBuffer().writeString(s);
return message;
}
15 years, 1 month
JBoss hornetq SVN: r8366 - in branches/ClebertCallback: src/main/org/hornetq/core/asyncio/impl and 11 other directories.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2009-11-21 18:29:50 -0500 (Sat, 21 Nov 2009)
New Revision: 8366
Removed:
branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/SyncOperation.java
branches/ClebertCallback/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationSyncContextMessage.java
Modified:
branches/ClebertCallback/src/main/org/hornetq/core/asyncio/AsynchronousFile.java
branches/ClebertCallback/src/main/org/hornetq/core/asyncio/impl/AsynchronousFileImpl.java
branches/ClebertCallback/src/main/org/hornetq/core/journal/Journal.java
branches/ClebertCallback/src/main/org/hornetq/core/journal/SequentialFile.java
branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/AIOSequentialFile.java
branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/AbstractSequentialFile.java
branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/JournalImpl.java
branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/NIOSequentialFile.java
branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/TimedBuffer.java
branches/ClebertCallback/src/main/org/hornetq/core/persistence/StorageManager.java
branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
branches/ClebertCallback/src/main/org/hornetq/core/remoting/impl/PacketDecoder.java
branches/ClebertCallback/src/main/org/hornetq/core/remoting/impl/wireformat/PacketImpl.java
branches/ClebertCallback/src/main/org/hornetq/core/replication/ReplicationManager.java
branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicatedJournal.java
branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicationEndpointImpl.java
branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicationManagerImpl.java
branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/asyncio/AIOTestBase.java
branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/asyncio/AsynchronousFileTest.java
branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java
branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java
Log:
Removing sync operations on Replication and journal
Modified: branches/ClebertCallback/src/main/org/hornetq/core/asyncio/AsynchronousFile.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/asyncio/AsynchronousFile.java 2009-11-21 23:08:15 UTC (rev 8365)
+++ branches/ClebertCallback/src/main/org/hornetq/core/asyncio/AsynchronousFile.java 2009-11-21 23:29:50 UTC (rev 8366)
@@ -41,20 +41,13 @@
* */
long size() throws HornetQException;
- /** Some operations may need to be done only after persitency is done.
- * for instance, when a messaging system needs to guarantee ordering over non-persistent data,
- * it needs to make sure it will only deliver the message after all the data is persisted.
- * The sync won't perform any disk operation however it will wait for all the current pending operations
- * on this file to be finished */
- void syncCallback(AIOCallback aioCallback);
-
/** Any error will be reported on the callback interface */
void write(long position, long size, ByteBuffer directByteBuffer, AIOCallback aioCallback);
void read(long position, long size, ByteBuffer directByteBuffer, AIOCallback aioCallback) throws HornetQException;
void fill(long position, int blocks, long size, byte fillChar) throws HornetQException;
-
+
void setBufferCallback(BufferCallback callback);
int getBlockSize();
Modified: branches/ClebertCallback/src/main/org/hornetq/core/asyncio/impl/AsynchronousFileImpl.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/asyncio/impl/AsynchronousFileImpl.java 2009-11-21 23:08:15 UTC (rev 8365)
+++ branches/ClebertCallback/src/main/org/hornetq/core/asyncio/impl/AsynchronousFileImpl.java 2009-11-21 23:29:50 UTC (rev 8366)
@@ -295,9 +295,9 @@
public void run()
{
writeSemaphore.acquireUninterruptibly();
-
- final long sequence = nextWritingSequence.getAndIncrement();
+ long sequence = nextWritingSequence.getAndIncrement();
+
try
{
write(handler, sequence, position, size, directByteBuffer, aioCallback);
@@ -321,7 +321,7 @@
{
writeSemaphore.acquireUninterruptibly();
- final long sequence = nextWritingSequence.getAndIncrement();
+ long sequence = nextWritingSequence.getAndIncrement();
try
{
@@ -438,42 +438,16 @@
}
}
- // Callback methods ------------------------------------------------------------------
+ // Private ---------------------------------------------------------------------------
- public void syncCallback(final AIOCallback callback)
- {
- pendingWrites.up();
-
- writeExecutor.execute(new Runnable()
- {
- public void run()
- {
- callbackLock.lock();
-
- try
- {
- final long sequence = nextWritingSequence.getAndIncrement();
-
- // This will execute the callback immediately if nothing is pending,
- // or it will place it to the queue waiting for a response
- executeCallback(callback, sequence);
-
- }
- finally
- {
- callbackLock.unlock();
- }
- }
- });
-
- }
-
/** */
@SuppressWarnings("unused")
private void callbackDone(final AIOCallback callback, final long sequence, final ByteBuffer buffer)
{
writeSemaphore.release();
+ pendingWrites.down();
+
callbackLock.lock();
try
@@ -482,11 +456,20 @@
if (sequence == -1)
{
callback.done();
- pendingWrites.down();
}
else
{
- executeCallback(callback, sequence);
+ if (sequence == nextReadSequence)
+ {
+ nextReadSequence++;
+ callback.done();
+ flushCallbacks();
+ }
+ else
+ {
+ // System.out.println("Buffering callback");
+ pendingCallbacks.add(new CallbackHolder(sequence, callback));
+ }
}
// The buffer is not sent on callback for read operations
@@ -501,26 +484,6 @@
}
}
- /**
- * @param callback
- * @param sequence
- */
- private void executeCallback(final AIOCallback callback, final long sequence)
- {
- if (sequence == nextReadSequence)
- {
- nextReadSequence++;
- callback.done();
- pendingWrites.down();
- flushCallbacks();
- }
- else
- {
- // System.out.println("Buffering callback");
- pendingCallbacks.add(new CallbackHolder(sequence, callback));
- }
- }
-
private void flushCallbacks()
{
while (!pendingCallbacks.isEmpty() && pendingCallbacks.peek().sequence == nextReadSequence)
@@ -535,7 +498,6 @@
{
holder.callback.done();
}
- pendingWrites.down();
nextReadSequence++;
}
}
@@ -588,8 +550,6 @@
}
}
- // Private ---------------------------------------------------------------------------
-
private void pollEvents()
{
if (!opened)
Modified: branches/ClebertCallback/src/main/org/hornetq/core/journal/Journal.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/journal/Journal.java 2009-11-21 23:08:15 UTC (rev 8365)
+++ branches/ClebertCallback/src/main/org/hornetq/core/journal/Journal.java 2009-11-21 23:29:50 UTC (rev 8366)
@@ -112,7 +112,5 @@
void perfBlast(int pages) throws Exception;
- void sync(IOCompletion callback);
-
}
Modified: branches/ClebertCallback/src/main/org/hornetq/core/journal/SequentialFile.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/journal/SequentialFile.java 2009-11-21 23:08:15 UTC (rev 8365)
+++ branches/ClebertCallback/src/main/org/hornetq/core/journal/SequentialFile.java 2009-11-21 23:29:50 UTC (rev 8366)
@@ -80,9 +80,6 @@
void sync() throws Exception;
- /** This method will make sure the parameter callback will be invoked after all pending sync operations are done */
- void syncCallback(IOAsyncTask callback);
-
long size() throws Exception;
void renameTo(String newFileName) throws Exception;
Modified: branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/AIOSequentialFile.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/AIOSequentialFile.java 2009-11-21 23:08:15 UTC (rev 8365)
+++ branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/AIOSequentialFile.java 2009-11-21 23:29:50 UTC (rev 8366)
@@ -304,14 +304,4 @@
throw new IllegalStateException("File not opened");
}
}
-
- /* (non-Javadoc)
- * @see org.hornetq.core.journal.impl.AbstractSequentialFile#syncCallbackDirect(org.hornetq.core.journal.IOAsyncTask)
- */
- @Override
- protected void syncCallbackDirect(IOAsyncTask callback)
- {
- aioFile.syncCallback(callback);
- }
-
}
Modified: branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/AbstractSequentialFile.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/AbstractSequentialFile.java 2009-11-21 23:08:15 UTC (rev 8365)
+++ branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/AbstractSequentialFile.java 2009-11-21 23:29:50 UTC (rev 8366)
@@ -16,6 +16,7 @@
import java.io.File;
import java.nio.ByteBuffer;
import java.util.List;
+import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicLong;
import org.hornetq.core.journal.IOAsyncTask;
@@ -189,30 +190,11 @@
write(bytes, false, DummyCallback.getInstance());
}
}
-
- /**
- * invoke the callback after all pending operations are complete.
- */
- public void syncCallback(IOAsyncTask callback)
- {
- if (timedBuffer != null)
- {
- timedBuffer.syncCallback(callback);
- }
- else
- {
- syncCallbackDirect(callback);
- }
- }
-
-
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
- protected abstract void syncCallbackDirect(IOAsyncTask callback);
-
protected File getFile()
{
return file;
@@ -270,22 +252,15 @@
{
public void flushBuffer(final ByteBuffer buffer, final boolean requestedSync, final List<IOAsyncTask> callbacks)
{
- if (buffer == null)
+ buffer.flip();
+
+ if (buffer.limit() == 0)
{
- syncCallbackDirect(new DelegateCallback(callbacks));
+ factory.releaseBuffer(buffer);
}
else
{
- buffer.flip();
-
- if (buffer.limit() == 0)
- {
- factory.releaseBuffer(buffer);
- }
- else
- {
- writeDirect(buffer, requestedSync, new DelegateCallback(callbacks));
- }
+ writeDirect(buffer, requestedSync, new DelegateCallback(callbacks));
}
}
Modified: branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/JournalImpl.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/JournalImpl.java 2009-11-21 23:08:15 UTC (rev 8365)
+++ branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/JournalImpl.java 2009-11-21 23:29:50 UTC (rev 8366)
@@ -864,31 +864,7 @@
callback.waitCompletion();
}
}
-
- public void sync(IOCompletion callback)
- {
- callback.lineUp();
- compactingLock.readLock().lock();
-
- try
- {
- lockAppend.lock();
- try
- {
- currentFile.getFile().syncCallback(callback);
- }
- finally
- {
- lockAppend.unlock();
- }
- }
- finally
- {
- compactingLock.readLock().unlock();
- }
- }
-
public void appendAddRecord(final long id, final byte recordType, final EncodingSupport record, final boolean sync, final IOCompletion callback) throws Exception
{
if (LOAD_TRACE)
Modified: branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/NIOSequentialFile.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/NIOSequentialFile.java 2009-11-21 23:08:15 UTC (rev 8365)
+++ branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/NIOSequentialFile.java 2009-11-21 23:29:50 UTC (rev 8366)
@@ -220,18 +220,6 @@
internalWrite(bytes, sync, null);
}
-
- /* (non-Javadoc)
- * @see org.hornetq.core.journal.impl.AbstractSequentialFile#syncCallbackDirect(org.hornetq.core.journal.IOAsyncTask)
- */
- @Override
- protected void syncCallbackDirect(IOAsyncTask callback)
- {
- // Nothing to be done on NIO.
- // Timed buffer took care of everything
- callback.done();
- }
-
/**
* @param bytes
* @param sync
@@ -255,5 +243,4 @@
callback.done();
}
}
-
}
Modified: branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/TimedBuffer.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/TimedBuffer.java 2009-11-21 23:08:15 UTC (rev 8365)
+++ branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/TimedBuffer.java 2009-11-21 23:29:50 UTC (rev 8366)
@@ -225,30 +225,15 @@
return true;
}
}
-
- /**
- * This method will make sure this callback will be executed after all the pending callbacks
- */
- public synchronized void syncCallback(IOAsyncTask callback)
+ public synchronized void addBytes(final byte[] bytes, final boolean sync, final IOAsyncTask callback)
{
- resumeTimerIfNeeded();
-
- callbacks.add(callback);
-
- pendingSync = true;
-
- if (flushOnSync)
+ if (buffer.writerIndex() == 0)
{
- flush();
+ // Resume latch
+ latchTimer.down();
}
- }
-
- public synchronized void addBytes(final byte[] bytes, final boolean sync, final IOAsyncTask callback)
- {
- resumeTimerIfNeeded();
-
buffer.writeBytes(bytes);
callbacks.add(callback);
@@ -274,57 +259,35 @@
}
}
- private void resumeTimerIfNeeded()
- {
- if (buffer.writerIndex() == 0 && callbacks.size() == 0)
- {
- // Resume latch
- latchTimer.down();
- }
- }
-
public synchronized void flush()
{
- if (buffer.writerIndex() > 0 || callbacks.size() > 0)
+ if (buffer.writerIndex() > 0)
{
- // Stop latch
latchTimer.up();
-
- if (buffer.writerIndex() == 0 && callbacks.size() > 0)
+
+ int pos = buffer.writerIndex();
+
+ if (logRates)
{
- // This is to perform a sync callback.
- // When we get to here, means we have sync callbacks waiting with no buffer
- // on this case we need to call sync on the file to make sure no other callbacks are pending
- bufferObserver.flushBuffer(null, pendingSync, callbacks);
-
- callbacks = new LinkedList<IOAsyncTask>();
+ bytesFlushed += pos;
}
- else
- {
- int pos = buffer.writerIndex();
-
- if (logRates)
- {
- bytesFlushed += pos;
- }
-
- ByteBuffer directBuffer = bufferObserver.newBuffer(bufferSize, pos);
-
- // Putting a byteArray on a native buffer is much faster, since it will do in a single native call.
- // Using directBuffer.put(buffer) would make several append calls for each byte
-
- directBuffer.put(buffer.array(), 0, pos);
-
- bufferObserver.flushBuffer(directBuffer, pendingSync, callbacks);
-
- callbacks = new LinkedList<IOAsyncTask>();
-
- active = false;
- pendingSync = false;
-
- buffer.clear();
- bufferLimit = 0;
- }
+
+ ByteBuffer directBuffer = bufferObserver.newBuffer(bufferSize, pos);
+
+ // Putting a byteArray on a native buffer is much faster, since it will do in a single native call.
+ // Using directBuffer.put(buffer) would make several append calls for each byte
+
+ directBuffer.put(buffer.array(), 0, pos);
+
+ bufferObserver.flushBuffer(directBuffer, pendingSync, callbacks);
+
+ callbacks = new LinkedList<IOAsyncTask>();
+
+ active = false;
+ pendingSync = false;
+
+ buffer.clear();
+ bufferLimit = 0;
}
}
Modified: branches/ClebertCallback/src/main/org/hornetq/core/persistence/StorageManager.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/persistence/StorageManager.java 2009-11-21 23:08:15 UTC (rev 8365)
+++ branches/ClebertCallback/src/main/org/hornetq/core/persistence/StorageManager.java 2009-11-21 23:29:50 UTC (rev 8366)
@@ -161,6 +161,4 @@
void deleteGrouping(GroupBinding groupBinding) throws Exception;
-
- void sync();
}
Modified: branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2009-11-21 23:08:15 UTC (rev 8365)
+++ branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2009-11-21 23:29:50 UTC (rev 8366)
@@ -515,11 +515,6 @@
messageJournal.appendDeleteRecord(recordID, syncNonTransactional, getIOContext());
}
- public void sync()
- {
- messageJournal.sync(OperationContextImpl.getInstance());
- }
-
// Transactional operations
public void storeMessageTransactional(final long txID, final ServerMessage message) throws Exception
Deleted: branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/SyncOperation.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/SyncOperation.java 2009-11-21 23:08:15 UTC (rev 8365)
+++ branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/SyncOperation.java 2009-11-21 23:29:50 UTC (rev 8366)
@@ -1,154 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.core.persistence.impl.journal;
-
-import java.util.concurrent.Executor;
-
-import org.hornetq.core.journal.IOAsyncTask;
-import org.hornetq.core.persistence.OperationContext;
-
-/**
- * A SyncOperation
- *
- * @author <mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
- *
- *
- */
-public class SyncOperation implements OperationContext
-{
-
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- OperationContext ctx;
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- public SyncOperation (OperationContext ctx)
- {
- this.ctx = ctx;
- }
-
- // Public --------------------------------------------------------
-
- /**
- *
- * @see org.hornetq.core.persistence.OperationContext#complete()
- */
- public void complete()
- {
- ctx.complete();
- }
-
- /**
- *
- * @see org.hornetq.core.asyncio.AIOCallback#done()
- */
- public void done()
- {
- ctx.done();
- }
-
- /**
- * @param runnable
- * @see org.hornetq.core.persistence.OperationContext#executeOnCompletion(org.hornetq.core.journal.IOAsyncTask)
- */
- public void executeOnCompletion(IOAsyncTask runnable)
- {
- ctx.executeOnCompletion(runnable);
- }
-
- /**
- * @return
- * @see org.hornetq.core.persistence.OperationContext#hasReplication()
- */
- public boolean hasReplication()
- {
- return ctx.hasReplication();
- }
-
- /**
- * @return
- * @see org.hornetq.core.persistence.OperationContext#isSync()
- */
- public boolean isSync()
- {
- return true;
- }
-
- /**
- *
- * @see org.hornetq.core.journal.IOCompletion#lineUp()
- */
- public void lineUp()
- {
- ctx.lineUp();
- }
-
- /**
- * @param errorCode
- * @param errorMessage
- * @see org.hornetq.core.asyncio.AIOCallback#onError(int, java.lang.String)
- */
- public void onError(int errorCode, String errorMessage)
- {
- ctx.onError(errorCode, errorMessage);
- }
-
- /**
- *
- * @see org.hornetq.core.persistence.OperationContext#replicationDone()
- */
- public void replicationDone()
- {
- ctx.replicationDone();
- }
-
- /**
- *
- * @see org.hornetq.core.persistence.OperationContext#replicationLineUp()
- */
- public void replicationLineUp()
- {
- ctx.replicationLineUp();
- }
-
- /**
- * @see org.hornetq.core.persistence.OperationContext#setExecutor(java.util.concurrent.Executor)
- */
- public void setExecutor(Executor executor)
- {
- ctx.setExecutor(executor);
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.persistence.OperationContext#reattach()
- */
- public void reinstall()
- {
- OperationContextImpl.setInstance(this);
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Modified: branches/ClebertCallback/src/main/org/hornetq/core/remoting/impl/PacketDecoder.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/remoting/impl/PacketDecoder.java 2009-11-21 23:08:15 UTC (rev 8365)
+++ branches/ClebertCallback/src/main/org/hornetq/core/remoting/impl/PacketDecoder.java 2009-11-21 23:29:50 UTC (rev 8366)
@@ -29,7 +29,6 @@
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.REPLICATION_APPEND_TX;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.REPLICATION_COMMIT_ROLLBACK;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.REPLICATION_COMPARE_DATA;
-import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.REPLICATION_SYNC;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.REPLICATION_DELETE;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.REPLICATION_DELETE_TX;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.REPLICATION_LARGE_MESSAGE_BEGIN;
@@ -94,7 +93,6 @@
import org.hornetq.core.remoting.impl.wireformat.ReplicationAddTXMessage;
import org.hornetq.core.remoting.impl.wireformat.ReplicationCommitMessage;
import org.hornetq.core.remoting.impl.wireformat.ReplicationCompareDataMessage;
-import org.hornetq.core.remoting.impl.wireformat.ReplicationSyncContextMessage;
import org.hornetq.core.remoting.impl.wireformat.ReplicationDeleteMessage;
import org.hornetq.core.remoting.impl.wireformat.ReplicationDeleteTXMessage;
import org.hornetq.core.remoting.impl.wireformat.ReplicationLargeMessageBeingMessage;
@@ -416,11 +414,6 @@
packet = new ReplicationDeleteMessage();
break;
}
- case REPLICATION_SYNC:
- {
- packet = new ReplicationSyncContextMessage();
- break;
- }
case REPLICATION_DELETE_TX:
{
packet = new ReplicationDeleteTXMessage();
Modified: branches/ClebertCallback/src/main/org/hornetq/core/remoting/impl/wireformat/PacketImpl.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/remoting/impl/wireformat/PacketImpl.java 2009-11-21 23:08:15 UTC (rev 8365)
+++ branches/ClebertCallback/src/main/org/hornetq/core/remoting/impl/wireformat/PacketImpl.java 2009-11-21 23:29:50 UTC (rev 8366)
@@ -172,8 +172,6 @@
public static final byte REPLICATION_LARGE_MESSAGE_WRITE = 91;
public static final byte REPLICATION_COMPARE_DATA = 92;
-
- public static final byte REPLICATION_SYNC = 93;
// Static --------------------------------------------------------
public PacketImpl(final byte type)
Deleted: branches/ClebertCallback/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationSyncContextMessage.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationSyncContextMessage.java 2009-11-21 23:08:15 UTC (rev 8365)
+++ branches/ClebertCallback/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationSyncContextMessage.java 2009-11-21 23:29:50 UTC (rev 8366)
@@ -1,80 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.core.remoting.impl.wireformat;
-
-import org.hornetq.core.remoting.spi.HornetQBuffer;
-
-/**
- * Message sent when a Replication Context is complete without any persistence replicated.
- * On that case we need to go over the cluster to make sure we get the data sent at the right order.
- *
- * @author <mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
- *
- *
- */
-public class ReplicationSyncContextMessage extends PacketImpl
-{
-
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- public ReplicationSyncContextMessage()
- {
- super(REPLICATION_SYNC);
- }
-
- // Public --------------------------------------------------------
-
- @Override
- public int getRequiredBufferSize()
- {
- return BASIC_PACKET_SIZE;
-
- }
-
- @Override
- public void encodeBody(final HornetQBuffer buffer)
- {
- }
-
- @Override
- public void decodeBody(final HornetQBuffer buffer)
- {
- }
-
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
- // Public --------------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Modified: branches/ClebertCallback/src/main/org/hornetq/core/replication/ReplicationManager.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/replication/ReplicationManager.java 2009-11-21 23:08:15 UTC (rev 8365)
+++ branches/ClebertCallback/src/main/org/hornetq/core/replication/ReplicationManager.java 2009-11-21 23:29:50 UTC (rev 8366)
@@ -84,6 +84,4 @@
*/
void compareJournals(JournalLoadInformation[] journalInfo) throws HornetQException;
- void sync(OperationContext ctx);
-
}
Modified: branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicatedJournal.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicatedJournal.java 2009-11-21 23:08:15 UTC (rev 8365)
+++ branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicatedJournal.java 2009-11-21 23:29:50 UTC (rev 8366)
@@ -25,7 +25,6 @@
import org.hornetq.core.journal.TransactionFailureCallback;
import org.hornetq.core.journal.impl.JournalImpl.ByteArrayEncoding;
import org.hornetq.core.logging.Logger;
-import org.hornetq.core.persistence.OperationContext;
import org.hornetq.core.persistence.impl.journal.JournalStorageManager;
import org.hornetq.core.replication.ReplicationManager;
@@ -434,15 +433,6 @@
localJournal.appendUpdateRecordTransactional(txID, id, recordType, record);
}
- /* (non-Javadoc)
- * @see org.hornetq.core.journal.Journal#sync()
- */
- public void sync(IOCompletion ctx)
- {
- replicationManager.sync((OperationContext)ctx);
- localJournal.sync(ctx);
- }
-
/**
* @param committedRecords
* @param preparedTransactions
Modified: branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicationEndpointImpl.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicationEndpointImpl.java 2009-11-21 23:08:15 UTC (rev 8365)
+++ branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicationEndpointImpl.java 2009-11-21 23:29:50 UTC (rev 8366)
@@ -17,7 +17,6 @@
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.REPLICATION_LARGE_MESSAGE_END;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.REPLICATION_LARGE_MESSAGE_WRITE;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.REPLICATION_COMPARE_DATA;
-import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.REPLICATION_SYNC;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -163,11 +162,6 @@
handleCompareDataMessage((ReplicationCompareDataMessage)packet);
response = new NullResponseMessage();
}
- else if (packet.getType() == REPLICATION_SYNC)
- {
- // https://jira.jboss.org/jira/browse/HORNETQ-218
- // Nothing to be done, we just needed a round trip to process events in order
- }
else
{
log.warn("Packet " + packet + " can't be processed by the ReplicationEndpoint");
Modified: branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicationManagerImpl.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicationManagerImpl.java 2009-11-21 23:08:15 UTC (rev 8365)
+++ branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicationManagerImpl.java 2009-11-21 23:29:50 UTC (rev 8366)
@@ -29,7 +29,6 @@
import org.hornetq.core.paging.PagedMessage;
import org.hornetq.core.persistence.OperationContext;
import org.hornetq.core.persistence.impl.journal.OperationContextImpl;
-import org.hornetq.core.persistence.impl.journal.SyncOperation;
import org.hornetq.core.remoting.Channel;
import org.hornetq.core.remoting.ChannelHandler;
import org.hornetq.core.remoting.Packet;
@@ -421,31 +420,6 @@
replicatingChannel.sendBlocking(new ReplicationCompareDataMessage(journalInfo));
}
-
- public void sync(OperationContext context)
- {
- boolean executeNow = false;
- synchronized (replicationLock)
- {
- context.replicationLineUp();
- if (pendingTokens.isEmpty())
- {
- // this means the list is empty and we should process it now
- executeNow = true;
- }
- else
- {
- // adding the sync to be executed in order
- // as soon as the reponses are back from the backup
- this.pendingTokens.add(new SyncOperation(context));
- }
- }
- if (executeNow)
- {
- context.replicationDone();
- }
- }
-
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@@ -492,7 +466,7 @@
ctx.replicationDone();
}
}
-
+
public OperationContext getContext()
{
return OperationContextImpl.getInstance();
Modified: branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/asyncio/AIOTestBase.java
===================================================================
--- branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/asyncio/AIOTestBase.java 2009-11-21 23:08:15 UTC (rev 8365)
+++ branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/asyncio/AIOTestBase.java 2009-11-21 23:29:50 UTC (rev 8366)
@@ -85,34 +85,25 @@
protected static class CountDownCallback implements AIOCallback
{
- private final CountDownLatch latchDone;
+ private final CountDownLatch latch;
- private final CountDownLatch waitCallback;
-
private final List<Integer> outputList;
private final int order;
private final AtomicInteger errors;
- public CountDownCallback(final CountDownLatch latch, final AtomicInteger errors, final List<Integer> outputList, final int order, final CountDownLatch waitCallback)
+ public CountDownCallback(final CountDownLatch latch, final AtomicInteger errors, final List<Integer> outputList, final int order)
{
- this.latchDone = latch;
+ this.latch = latch;
this.outputList = outputList;
this.order = order;
this.errors = errors;
-
- this.waitCallback = waitCallback;
}
- public CountDownCallback(final CountDownLatch latch, final AtomicInteger errors, final List<Integer> outputList, final int order)
- {
- this(latch, errors, outputList, order, null);
- }
-
volatile boolean doneCalled = false;
volatile int errorCalled = 0;
@@ -121,26 +112,15 @@
public void done()
{
- if (waitCallback != null)
- {
- try
- {
- waitCallback.await();
- }
- catch (Exception e)
- {
- e.printStackTrace(); // -> junit report
- }
- }
if (outputList != null)
{
outputList.add(order);
}
doneCalled = true;
timesDoneCalled.incrementAndGet();
- if (latchDone != null)
+ if (latch != null)
{
- latchDone.countDown();
+ latch.countDown();
}
}
@@ -155,11 +135,11 @@
{
errors.incrementAndGet();
}
- if (latchDone != null)
+ if (latch != null)
{
// even thought an error happened, we need to inform the latch,
// or the test won't finish
- latchDone.countDown();
+ latch.countDown();
}
}
Modified: branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/asyncio/AsynchronousFileTest.java
===================================================================
--- branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/asyncio/AsynchronousFileTest.java 2009-11-21 23:08:15 UTC (rev 8365)
+++ branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/asyncio/AsynchronousFileTest.java 2009-11-21 23:29:50 UTC (rev 8366)
@@ -22,7 +22,6 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import junit.framework.TestSuite;
@@ -421,60 +420,6 @@
}
}
- public void testOrderOnSynCallback() throws Exception
- {
- boolean closed = false;
- final AsynchronousFileImpl controller = new AsynchronousFileImpl(executor, pollerExecutor);
- ByteBuffer buffer = null;
- try
- {
- final int NUMBER_LINES = 100;
- final int SIZE = 512;
-
- controller.open(FILE_NAME, 100);
-
- controller.fill(0, 1, NUMBER_LINES * SIZE, (byte)'j');
-
- CountDownLatch latch = new CountDownLatch(NUMBER_LINES * 2);
-
- buffer = AsynchronousFileImpl.newBuffer(SIZE);
- buffer.rewind();
- for (int j = 0; j < SIZE; j++)
- {
- buffer.put((byte)(j % Byte.MAX_VALUE));
- }
-
- ArrayList<Integer> result = new ArrayList<Integer>();
-
- for (int i = 0; i < NUMBER_LINES * 2; i++)
- {
- CountDownCallback aio = new CountDownCallback(latch, null, result, i);
- if (i % 2 == 0)
- {
- controller.write(i * SIZE, SIZE, buffer, aio);
- }
- else
- {
- controller.syncCallback(aio);
- }
- }
-
- controller.close();
- closed = true;
-
- // We are not waiting the latch, as close should already hold for any writes
- CountDownCallback.checkResults(NUMBER_LINES * 2, result);
- }
- finally
- {
- AsynchronousFileImpl.destroyBuffer(buffer);
- if (!closed)
- {
- controller.close();
- }
- }
- }
-
public void testBufferCallbackAwaysSameBuffer() throws Exception
{
boolean closed = false;
Modified: branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java
===================================================================
--- branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java 2009-11-21 23:08:15 UTC (rev 8365)
+++ branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java 2009-11-21 23:29:50 UTC (rev 8366)
@@ -17,16 +17,11 @@
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
import org.hornetq.core.asyncio.impl.AsynchronousFileImpl;
-import org.hornetq.core.buffers.ChannelBuffers;
-import org.hornetq.core.journal.IOAsyncTask;
import org.hornetq.core.journal.SequentialFile;
import org.hornetq.core.journal.SequentialFileFactory;
import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.tests.util.UnitTestCase;
/**
@@ -44,9 +39,9 @@
protected void setUp() throws Exception
{
super.setUp();
-
+
factory = createFactory();
-
+
factory.start();
}
@@ -54,13 +49,13 @@
protected void tearDown() throws Exception
{
assertEquals(0, AsynchronousFileImpl.getTotalMaxIO());
-
+
factory.stop();
-
+
factory = null;
-
+
forceGC();
-
+
super.tearDown();
}
@@ -177,139 +172,7 @@
sf2.close();
}
-
- public void testOrder() throws Exception
- {
- SequentialFile sf = factory.createSequentialFile("order-test.hq", 100);
-
- sf.open();
-
- factory.activateBuffer(sf);
-
- final int records = 5000;
-
- sf.fill(0, records * 1024, (byte)0);
-
-
- final ArrayList<Integer> result = new ArrayList<Integer>();
-
- final CountDownLatch latch = new CountDownLatch(records);
-
- HornetQBuffer buffer = ChannelBuffers.wrappedBuffer(new byte[512]);
-
- for (int i = 0 ; i < records; i++)
- {
- final int toadd = i;
- IOAsyncTask callback = new IOAsyncTask()
- {
-
- public void onError(int errorCode, String errorMessage)
- {
- }
-
- public void done()
- {
- result.add(toadd);
-
- latch.countDown();
- }
-
- };
-
- if (i % 2 == 0)
- {
- sf.disableAutoFlush();
- sf.fits(512);
- sf.write(buffer, false, callback);
- sf.enableAutoFlush();
- }
- else
- {
- sf.syncCallback(callback);
- }
- }
-
- assertTrue(latch.await(5, TimeUnit.SECONDS));
-
- assertEquals(records, result.size());
-
- int i = 0;
-
- for (Integer r : result)
- {
- assertEquals(i++, r.intValue());
- }
-
-
- factory.deactivateBuffer();
-
- sf.close();
- }
-
- public void testOrder2() throws Exception
- {
- SequentialFile sf = factory.createSequentialFile("order-test.hq", 100);
-
- sf.open();
-
- factory.activateBuffer(sf);
-
- final int records = 1000;
-
- sf.fill(0, records * 1024, (byte)0);
-
-
- final ArrayList<Integer> result = new ArrayList<Integer>();
-
- final CountDownLatch latch = new CountDownLatch(records);
-
- HornetQBuffer buffer = ChannelBuffers.wrappedBuffer(new byte[512]);
-
- for (int i = 0 ; i < records; i++)
- {
- final int toadd = i;
- IOAsyncTask callback = new IOAsyncTask()
- {
-
- public void onError(int errorCode, String errorMessage)
- {
- }
-
- public void done()
- {
- result.add(toadd);
-
- latch.countDown();
- }
-
- };
-
- if (i == 10)
- {
- sf.write(buffer, false, callback);
- }
- else
- {
- sf.syncCallback(callback);
- }
- }
-
- assertTrue(latch.await(5, TimeUnit.SECONDS));
-
- assertEquals(records, result.size());
-
- int i = 0;
-
- for (Integer r : result)
- {
- assertEquals(i++, r.intValue());
- }
-
- factory.deactivateBuffer();
-
- sf.close();
- }
-
+
public void testRename() throws Exception
{
SequentialFile sf = factory.createSequentialFile("test1.hq", 1);
@@ -321,7 +184,7 @@
assertEquals(1, fileNames.size());
assertTrue(fileNames.contains("test1.hq"));
-
+
sf.renameTo("test1.cmp");
fileNames = factory.listFiles("cmp");
@@ -341,7 +204,7 @@
assertEquals(0, fileNames.size());
}
-
+
public void testWriteandRead() throws Exception
{
SequentialFile sf = factory.createSequentialFile("write.hq", 1);
@@ -359,7 +222,7 @@
String s3 = "echidna";
byte[] bytes3 = s3.getBytes("UTF-8");
ByteBuffer bb3 = factory.wrapBuffer(bytes3);
-
+
long initialPos = sf.position();
sf.writeDirect(bb1, true);
long bytesWritten = sf.position() - initialPos;
@@ -442,6 +305,7 @@
sf.writeDirect(bb2, true);
bytesWritten = sf.position() - initialPos;
+
assertEquals(bb2.limit(), bytesWritten);
initialPos = sf.position();
@@ -518,9 +382,9 @@
try
{
-
+
bb1 = factory.wrapBuffer(bytes1);
-
+
sf.writeDirect(bb1, true);
fail("Should throw exception");
Modified: branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java
===================================================================
--- branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java 2009-11-21 23:08:15 UTC (rev 8365)
+++ branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java 2009-11-21 23:29:50 UTC (rev 8366)
@@ -634,17 +634,10 @@
*/
public void setTimedBuffer(TimedBuffer buffer)
{
+ // TODO Auto-generated method stub
}
- /* (non-Javadoc)
- * @see org.hornetq.core.journal.SequentialFile#syncCallback(org.hornetq.core.journal.IOAsyncTask)
- */
- public void syncCallback(IOAsyncTask callback)
- {
- callback.done();
- }
-
}
/* (non-Javadoc)
15 years, 1 month
JBoss hornetq SVN: r8365 - in branches/ClebertCallback: src/main/org/hornetq/core/persistence and 9 other directories.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2009-11-21 18:08:15 -0500 (Sat, 21 Nov 2009)
New Revision: 8365
Modified:
branches/ClebertCallback/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java
branches/ClebertCallback/src/main/org/hornetq/core/persistence/OperationContext.java
branches/ClebertCallback/src/main/org/hornetq/core/persistence/StorageManager.java
branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/OperationContextImpl.java
branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/SyncOperation.java
branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/nullpm/NullStorageManager.java
branches/ClebertCallback/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
branches/ClebertCallback/src/main/org/hornetq/core/replication/ReplicationManager.java
branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicationManagerImpl.java
branches/ClebertCallback/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
branches/ClebertCallback/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
branches/ClebertCallback/src/main/org/hornetq/core/server/impl/ServerSessionPacketHandler.java
branches/ClebertCallback/tests/src/org/hornetq/tests/integration/client/OrderTest.java
branches/ClebertCallback/tests/src/org/hornetq/tests/integration/replication/ReplicationOrderTest.java
branches/ClebertCallback/tests/src/org/hornetq/tests/integration/replication/ReplicationTest.java
branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java
Log:
Simplifying ordering and switch context
Modified: branches/ClebertCallback/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java 2009-11-21 20:49:38 UTC (rev 8364)
+++ branches/ClebertCallback/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java 2009-11-21 23:08:15 UTC (rev 8365)
@@ -744,7 +744,7 @@
// TODO: Talk to Andy and Jeff about a better way to sync this...
System.out.println("Waiting");
final CountDownLatch latch = new CountDownLatch(1);
- OperationContextImpl.getContext().executeOnCompletion(new IOAsyncTask()
+ OperationContextImpl.getInstance().executeOnCompletion(new IOAsyncTask()
{
public void done()
@@ -759,7 +759,7 @@
});
- OperationContextImpl.getContext().complete();
+ OperationContextImpl.getInstance().complete();
latch.await(5, TimeUnit.SECONDS);
System.out.println("Done");
Modified: branches/ClebertCallback/src/main/org/hornetq/core/persistence/OperationContext.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/persistence/OperationContext.java 2009-11-21 20:49:38 UTC (rev 8364)
+++ branches/ClebertCallback/src/main/org/hornetq/core/persistence/OperationContext.java 2009-11-21 23:08:15 UTC (rev 8365)
@@ -13,6 +13,8 @@
package org.hornetq.core.persistence;
+import java.util.concurrent.Executor;
+
import org.hornetq.core.journal.IOAsyncTask;
import org.hornetq.core.journal.IOCompletion;
@@ -29,7 +31,16 @@
{
boolean hasReplication();
+
+ /** Reattach the context to the current thread */
+ void reinstall();
+
+ /** The executor used on responses.
+ * If this is not set, it will use the current thread. */
+ void setExecutor(Executor executor);
+ /** Execute the task when all IO operations are complete,
+ * Or execute it immediately if nothing is pending. */
void executeOnCompletion(IOAsyncTask runnable);
void replicationLineUp();
Modified: branches/ClebertCallback/src/main/org/hornetq/core/persistence/StorageManager.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/persistence/StorageManager.java 2009-11-21 20:49:38 UTC (rev 8364)
+++ branches/ClebertCallback/src/main/org/hornetq/core/persistence/StorageManager.java 2009-11-21 23:08:15 UTC (rev 8365)
@@ -15,6 +15,7 @@
import java.util.List;
import java.util.Map;
+import java.util.concurrent.Executor;
import javax.transaction.xa.Xid;
@@ -47,6 +48,13 @@
*/
public interface StorageManager extends HornetQComponent
{
+
+ /** Get the context associated with the thread for later reuse */
+ OperationContext getContext();
+
+ /** It just creates an OperationContext without associating it to any threads */
+ OperationContext newContext(Executor executor);
+
// Message related operations
void pageClosed(SimpleString storeName, int pageNumber);
Modified: branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2009-11-21 20:49:38 UTC (rev 8364)
+++ branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2009-11-21 23:08:15 UTC (rev 8365)
@@ -55,6 +55,7 @@
import org.hornetq.core.paging.PagingManager;
import org.hornetq.core.paging.impl.PageTransactionInfoImpl;
import org.hornetq.core.persistence.GroupingInfo;
+import org.hornetq.core.persistence.OperationContext;
import org.hornetq.core.persistence.QueueBindingInfo;
import org.hornetq.core.persistence.StorageManager;
import org.hornetq.core.postoffice.Binding;
@@ -294,14 +295,7 @@
*/
public void completeOperations()
{
- if (replicator != null)
- {
- replicator.closeContext();
- }
- else
- {
- OperationContextImpl.getContext().complete();
- }
+ OperationContextImpl.getInstance().complete();
}
public boolean isReplicated()
@@ -373,9 +367,26 @@
// TODO: shouldn't those page methods be on the PageManager? ^^^^
+
+ /* (non-Javadoc)
+ * @see org.hornetq.core.persistence.StorageManager#getContext()
+ */
+ public OperationContext getContext()
+ {
+ return OperationContextImpl.getInstance();
+ }
+
+ /* (non-Javadoc)
+ * @see org.hornetq.core.persistence.StorageManager#newContext()
+ */
+ public OperationContext newContext(Executor executor)
+ {
+ return new OperationContextImpl(executor);
+ }
+
public void afterCompleteOperations(IOAsyncTask run)
{
- OperationContextImpl.getContext().executeOnCompletion(run);
+ OperationContextImpl.getInstance().executeOnCompletion(run);
}
public UUID getPersistentID()
@@ -506,7 +517,7 @@
public void sync()
{
- messageJournal.sync(OperationContextImpl.getContext());
+ messageJournal.sync(OperationContextImpl.getInstance());
}
// Transactional operations
@@ -1390,7 +1401,7 @@
private IOCompletion getIOContext()
{
- return OperationContextImpl.getContext();
+ return OperationContextImpl.getInstance();
}
private void checkAndCreateDir(final String dir, final boolean create)
@@ -1917,7 +1928,6 @@
}
}
-
}
Modified: branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/OperationContextImpl.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/OperationContextImpl.java 2009-11-21 20:49:38 UTC (rev 8364)
+++ branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/OperationContextImpl.java 2009-11-21 23:08:15 UTC (rev 8365)
@@ -16,21 +16,32 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.concurrent.Executor;
+import java.util.concurrent.atomic.AtomicInteger;
import org.hornetq.core.journal.IOAsyncTask;
import org.hornetq.core.persistence.OperationContext;
+import sun.security.util.PendingException;
+
/**
- * A ReplicationToken
- *
+ *
+ * This class will hold operations when there are IO operations...
+ * and it will
+ *
* @author <mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
*/
public class OperationContextImpl implements OperationContext
{
private static final ThreadLocal<OperationContext> tlContext = new ThreadLocal<OperationContext>();
- public static OperationContext getContext()
+ public static void setInstance(OperationContext context)
{
+ tlContext.set(context);
+ }
+
+ public static OperationContext getInstance()
+ {
OperationContext token = tlContext.get();
if (token == null)
{
@@ -53,6 +64,14 @@
private int stored = 0;
private int replicated = 0;
+
+ private int errorCode = -1;
+
+ private String errorMessage = null;
+
+ private Executor executor;
+
+ private final AtomicInteger executorsPending = new AtomicInteger(0);
/**
* @param executor
@@ -62,6 +81,21 @@
super();
}
+ public OperationContextImpl(final Executor executor)
+ {
+ super();
+ this.executor = executor;
+ }
+
+ /*
+ * @see org.hornetq.core.persistence.OperationContext#reinstall()
+ */
+ public void reinstall()
+ {
+ setInstance(this);
+ }
+
+
/** To be called by the replication manager, when new replication is added to the queue */
public void lineUp()
{
@@ -72,6 +106,12 @@
{
replicationLineUp++;
}
+
+ /** this method needs to be called before the executor became operational */
+ public void setExecutor(Executor executor)
+ {
+ this.executor = executor;
+ }
public synchronized void replicationDone()
{
@@ -85,7 +125,7 @@
}
/** You may have several actions to be done after a replication operation is completed. */
- public synchronized void executeOnCompletion(IOAsyncTask completion)
+ public synchronized void executeOnCompletion(final IOAsyncTask completion)
{
if (tasks == null)
{
@@ -94,9 +134,30 @@
minimalStore = storeLineUp;
}
+ // On this case, we can just execute the context directly
if (replicationLineUp == replicated && storeLineUp == stored)
{
- completion.done();
+ if (executor != null)
+ {
+ // We want to avoid the executor if everything is complete...
+ // However, we can't execute the context if there are executions pending
+ // We need to use the executor on this case
+ if (executorsPending.get() == 0)
+ {
+ // No need to use an executor here or a context switch
+ // there are no actions pending.. hence we can just execute the task directly on the same thread
+ completion.done();
+ }
+ else
+ {
+ execute(completion);
+ }
+ }
+ else
+ {
+ // Execute without an executor
+ completion.done();
+ }
}
else
{
@@ -122,19 +183,64 @@
if (!holder.executed && stored >= holder.storeLined && replicated >= holder.replicationLined)
{
holder.executed = true;
- holder.task.done();
+
+ if (executor != null)
+ {
+ // If set, we use an executor to avoid the server being single threaded
+ execute(holder.task);
+ }
+ else
+ {
+ holder.task.done();
+ }
+
iter.remove();
}
+ else
+ {
+ // The actions need to be done in order...
+ // so it must achieve both conditions before we can proceed to more tasks
+ break;
+ }
}
}
}
+ /**
+ * @param holder
+ */
+ private void execute(final IOAsyncTask task)
+ {
+ executorsPending.incrementAndGet();
+ executor.execute(new Runnable()
+ {
+ public void run()
+ {
+ task.done();
+ executorsPending.decrementAndGet();
+ }
+ });
+ }
+
/* (non-Javadoc)
* @see org.hornetq.core.replication.ReplicationToken#complete()
*/
public void complete()
{
tlContext.set(null);
+
+ // TODO: test and fix exceptions on the Context
+ if (tasks != null && errorMessage != null)
+ {
+ for (TaskHolder run : tasks)
+ {
+ run.task.onError(errorCode, errorMessage);
+ }
+ }
+
+ // We hold errors until the complete is set, or the callbacks will never get informed
+ errorCode = -1;
+ errorMessage = null;
}
public boolean isSync()
@@ -147,13 +253,8 @@
*/
public void onError(int errorCode, String errorMessage)
{
- if (tasks != null)
- {
- for (TaskHolder run : tasks)
- {
- run.task.onError(errorCode, errorMessage);
- }
- }
+ this.errorCode = errorCode;
+ this.errorMessage = errorMessage;
}
class TaskHolder
@@ -174,4 +275,5 @@
}
}
+
}
Modified: branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/SyncOperation.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/SyncOperation.java 2009-11-21 20:49:38 UTC (rev 8364)
+++ branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/SyncOperation.java 2009-11-21 23:08:15 UTC (rev 8365)
@@ -13,6 +13,8 @@
package org.hornetq.core.persistence.impl.journal;
+import java.util.concurrent.Executor;
+
import org.hornetq.core.journal.IOAsyncTask;
import org.hornetq.core.persistence.OperationContext;
@@ -125,6 +127,22 @@
ctx.replicationLineUp();
}
+ /**
+ * @see org.hornetq.core.persistence.OperationContext#setExecutor(java.util.concurrent.Executor)
+ */
+ public void setExecutor(Executor executor)
+ {
+ ctx.setExecutor(executor);
+ }
+
+ /* (non-Javadoc)
+ * @see org.hornetq.core.persistence.OperationContext#reattach()
+ */
+ public void reinstall()
+ {
+ OperationContextImpl.setInstance(this);
+ }
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
Modified: branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/nullpm/NullStorageManager.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/nullpm/NullStorageManager.java 2009-11-21 20:49:38 UTC (rev 8364)
+++ branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/nullpm/NullStorageManager.java 2009-11-21 23:08:15 UTC (rev 8365)
@@ -15,6 +15,7 @@
import java.util.List;
import java.util.Map;
+import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicLong;
import javax.transaction.xa.Xid;
@@ -26,6 +27,7 @@
import org.hornetq.core.paging.PagedMessage;
import org.hornetq.core.paging.PagingManager;
import org.hornetq.core.persistence.GroupingInfo;
+import org.hornetq.core.persistence.OperationContext;
import org.hornetq.core.persistence.QueueBindingInfo;
import org.hornetq.core.persistence.StorageManager;
import org.hornetq.core.postoffice.Binding;
@@ -356,4 +358,20 @@
{
}
+ /* (non-Javadoc)
+ * @see org.hornetq.core.persistence.StorageManager#getContext()
+ */
+ public OperationContext getContext()
+ {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.hornetq.core.persistence.StorageManager#newContext()
+ */
+ public OperationContext newContext(Executor executor)
+ {
+ return null;
+ }
+
}
Modified: branches/ClebertCallback/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java 2009-11-21 20:49:38 UTC (rev 8364)
+++ branches/ClebertCallback/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java 2009-11-21 23:08:15 UTC (rev 8365)
@@ -917,10 +917,6 @@
}
}
}
- else
- {
- storageManager.sync();
- }
message.incrementRefCount(reference);
}
@@ -931,6 +927,8 @@
}
else
{
+ // This will use the same thread if there are no pending operations
+ // avoiding a context switch on this case
storageManager.afterCompleteOperations(new IOAsyncTask()
{
public void onError(int errorCode, String errorMessage)
Modified: branches/ClebertCallback/src/main/org/hornetq/core/replication/ReplicationManager.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/replication/ReplicationManager.java 2009-11-21 20:49:38 UTC (rev 8364)
+++ branches/ClebertCallback/src/main/org/hornetq/core/replication/ReplicationManager.java 2009-11-21 23:08:15 UTC (rev 8365)
@@ -50,8 +50,6 @@
void appendRollbackRecord(byte journalID, long txID) throws Exception;
- void closeContext();
-
/** A list of tokens that are still waiting for replications to be completed */
Set<OperationContext> getActiveTokens();
Modified: branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicationManagerImpl.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicationManagerImpl.java 2009-11-21 20:49:38 UTC (rev 8364)
+++ branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicationManagerImpl.java 2009-11-21 23:08:15 UTC (rev 8365)
@@ -392,25 +392,7 @@
started = false;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.replication.ReplicationManager#completeToken()
- */
- public void closeContext()
- {
- final OperationContext token = getContext();
- if (token != null)
- {
- // Remove from pending tokens as soon as this is complete
- if (!token.hasReplication())
- {
- sync(token);
- }
- token.complete();
- }
- }
-
-
/* method for testcases only
* @see org.hornetq.core.replication.ReplicationManager#getPendingTokens()
*/
@@ -513,7 +495,7 @@
public OperationContext getContext()
{
- return OperationContextImpl.getContext();
+ return OperationContextImpl.getInstance();
}
/**
Modified: branches/ClebertCallback/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2009-11-21 20:49:38 UTC (rev 8364)
+++ branches/ClebertCallback/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2009-11-21 23:08:15 UTC (rev 8365)
@@ -22,6 +22,7 @@
import java.util.Set;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@@ -61,6 +62,7 @@
import org.hornetq.core.paging.impl.PagingManagerImpl;
import org.hornetq.core.paging.impl.PagingStoreFactoryNIO;
import org.hornetq.core.persistence.GroupingInfo;
+import org.hornetq.core.persistence.OperationContext;
import org.hornetq.core.persistence.QueueBindingInfo;
import org.hornetq.core.persistence.StorageManager;
import org.hornetq.core.persistence.impl.journal.JournalStorageManager;
@@ -646,6 +648,10 @@
}
Channel channel = connection.getChannel(channelID, sendWindowSize);
+
+ Executor sessionExecutor = executorFactory.getExecutor();
+
+ OperationContext sessionContext = storageManager.newContext(sessionExecutor);
final ServerSessionImpl session = new ServerSessionImpl(name,
username,
@@ -661,7 +667,8 @@
postOffice,
resourceManager,
securityStore,
- executorFactory.getExecutor(),
+ sessionContext,
+ sessionExecutor,
channel,
managementService,
// queueFactory,
@@ -670,7 +677,7 @@
sessions.put(name, session);
- ServerSessionPacketHandler handler = new ServerSessionPacketHandler(session);
+ ServerSessionPacketHandler handler = new ServerSessionPacketHandler(session, sessionContext);
session.setHandler(handler);
Modified: branches/ClebertCallback/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2009-11-21 20:49:38 UTC (rev 8364)
+++ branches/ClebertCallback/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2009-11-21 23:08:15 UTC (rev 8365)
@@ -39,6 +39,7 @@
import org.hornetq.core.management.ManagementService;
import org.hornetq.core.management.Notification;
import org.hornetq.core.paging.PagingStore;
+import org.hornetq.core.persistence.OperationContext;
import org.hornetq.core.persistence.StorageManager;
import org.hornetq.core.persistence.impl.journal.OperationContextImpl;
import org.hornetq.core.postoffice.Binding;
@@ -187,6 +188,10 @@
private final HornetQServer server;
private final SimpleString managementAddress;
+
+ /** We always use the same operation context for the session.
+ * With that we can perform extra checks */
+ private final OperationContext sessionOperationContext;
// The current currentLargeMessage being processed
private volatile LargeServerMessage currentLargeMessage;
@@ -213,6 +218,7 @@
final PostOffice postOffice,
final ResourceManager resourceManager,
final SecurityStore securityStore,
+ final OperationContext sessionOperationContext,
final Executor executor,
final Channel channel,
final ManagementService managementService,
@@ -242,6 +248,8 @@
this.resourceManager = resourceManager;
this.securityStore = securityStore;
+
+ this.sessionOperationContext = sessionOperationContext;
this.executor = executor;
@@ -1739,8 +1747,6 @@
doSendResponse(confirmPacket, response, flush, closeChannel);
}
});
-
- storageManager.completeOperations();
}
/**
Modified: branches/ClebertCallback/src/main/org/hornetq/core/server/impl/ServerSessionPacketHandler.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/server/impl/ServerSessionPacketHandler.java 2009-11-21 20:49:38 UTC (rev 8364)
+++ branches/ClebertCallback/src/main/org/hornetq/core/server/impl/ServerSessionPacketHandler.java 2009-11-21 23:08:15 UTC (rev 8365)
@@ -45,6 +45,7 @@
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_XA_SUSPEND;
import org.hornetq.core.logging.Logger;
+import org.hornetq.core.persistence.OperationContext;
import org.hornetq.core.remoting.ChannelHandler;
import org.hornetq.core.remoting.Packet;
import org.hornetq.core.remoting.impl.wireformat.CreateQueueMessage;
@@ -80,16 +81,20 @@
* @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
* @author <a href="mailto:andy.taylor@jboss.org>Andy Taylor</a>
+ * @author <a href="mailto:clebert.suconic@jboss.org>Clebert Suconic</a>
*/
public class ServerSessionPacketHandler implements ChannelHandler
{
private static final Logger log = Logger.getLogger(ServerSessionPacketHandler.class);
private final ServerSession session;
+
+ private final OperationContext sessionContext;
- public ServerSessionPacketHandler(final ServerSession session)
+ public ServerSessionPacketHandler(final ServerSession session, OperationContext sessionContext)
{
this.session = session;
+ this.sessionContext = sessionContext;
}
public long getID()
@@ -101,6 +106,11 @@
{
byte type = packet.getType();
+ if (sessionContext != null)
+ {
+ sessionContext.reinstall();
+ }
+
try
{
switch (type)
@@ -289,5 +299,12 @@
{
log.error("Caught unexpected exception", t);
}
+ finally
+ {
+ if (sessionContext != null)
+ {
+ sessionContext.complete();
+ }
+ }
}
}
Modified: branches/ClebertCallback/tests/src/org/hornetq/tests/integration/client/OrderTest.java
===================================================================
--- branches/ClebertCallback/tests/src/org/hornetq/tests/integration/client/OrderTest.java 2009-11-21 20:49:38 UTC (rev 8364)
+++ branches/ClebertCallback/tests/src/org/hornetq/tests/integration/client/OrderTest.java 2009-11-21 23:08:15 UTC (rev 8365)
@@ -13,18 +13,11 @@
package org.hornetq.tests.integration.client;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
import org.hornetq.core.client.ClientConsumer;
import org.hornetq.core.client.ClientMessage;
import org.hornetq.core.client.ClientProducer;
import org.hornetq.core.client.ClientSession;
import org.hornetq.core.client.ClientSessionFactory;
-import org.hornetq.core.client.SessionFailureListener;
-import org.hornetq.core.client.impl.ClientSessionInternal;
-import org.hornetq.core.exception.HornetQException;
-import org.hornetq.core.remoting.RemotingConnection;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.ServiceTestBase;
@@ -47,9 +40,6 @@
protected void setUp() throws Exception
{
super.setUp();
- server = createServer(true, true);
- server.getConfiguration().setJournalFileSize(10 * 1024 * 1024);
- server.start();
}
protected void tearDown() throws Exception
@@ -64,8 +54,21 @@
// Public --------------------------------------------------------
- public void testSimpleOrder() throws Exception
+ public void testSimpleOrderNoStorage() throws Exception
{
+ doTestSimpleOrder(false);
+ }
+
+ public void testSimpleOrderPersistence() throws Exception
+ {
+ doTestSimpleOrder(true);
+ }
+
+ public void doTestSimpleOrder(final boolean persistent) throws Exception
+ {
+ server = createServer(persistent, true);
+ server.start();
+
ClientSessionFactory sf = createNettyFactory();
sf.setBlockOnNonPersistentSend(false);
@@ -92,16 +95,16 @@
boolean started = false;
- for (int start = 0; start < 3; start++)
+ for (int start = 0; start < 2; start++)
{
- if (start == 2)
+ if (persistent && start == 1)
{
started = true;
server.stop();
server.start();
}
-
+
session = sf.createSession(true, true);
session.start();
@@ -142,40 +145,6 @@
}
- private void fail(ClientSession session) throws InterruptedException
- {
-
- final CountDownLatch latch = new CountDownLatch(1);
-
- class MyListener implements SessionFailureListener
- {
- public void connectionFailed(HornetQException me)
- {
- latch.countDown();
- }
-
- public void beforeReconnect(HornetQException exception)
- {
- }
- }
-
- MyListener listener = new MyListener();
- session.addFailureListener(listener);
-
- RemotingConnection conn = ((ClientSessionInternal)session).getConnection();
-
- // Simulate failure on connection
- conn.fail(new HornetQException(HornetQException.NOT_CONNECTED));
-
- // Wait to be informed of failure
-
- boolean ok = latch.await(1000, TimeUnit.MILLISECONDS);
-
- assertTrue(ok);
-
- session.removeFailureListener(listener);
- }
-
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
Modified: branches/ClebertCallback/tests/src/org/hornetq/tests/integration/replication/ReplicationOrderTest.java
===================================================================
--- branches/ClebertCallback/tests/src/org/hornetq/tests/integration/replication/ReplicationOrderTest.java 2009-11-21 20:49:38 UTC (rev 8364)
+++ branches/ClebertCallback/tests/src/org/hornetq/tests/integration/replication/ReplicationOrderTest.java 2009-11-21 23:08:15 UTC (rev 8365)
@@ -52,17 +52,6 @@
// Public --------------------------------------------------------
- public void test() throws Exception
- {
- for (int i = 0; i < 100; i++)
- {
- System.out.println("<<<<<< " + i + " >>>>>>>");
- testMixedPersistentAndNonPersistentMessagesOrderWithReplicatedBackup();
- tearDown();
- setUp();
- }
- }
-
public void testMixedPersistentAndNonPersistentMessagesOrderWithReplicatedBackup() throws Exception
{
doTestMixedPersistentAndNonPersistentMessagesOrderWithReplicatedBackup(false);
Modified: branches/ClebertCallback/tests/src/org/hornetq/tests/integration/replication/ReplicationTest.java
===================================================================
--- branches/ClebertCallback/tests/src/org/hornetq/tests/integration/replication/ReplicationTest.java 2009-11-21 20:49:38 UTC (rev 8364)
+++ branches/ClebertCallback/tests/src/org/hornetq/tests/integration/replication/ReplicationTest.java 2009-11-21 23:08:15 UTC (rev 8365)
@@ -51,6 +51,7 @@
import org.hornetq.core.paging.impl.PagedMessageImpl;
import org.hornetq.core.paging.impl.PagingManagerImpl;
import org.hornetq.core.paging.impl.PagingStoreFactoryNIO;
+import org.hornetq.core.persistence.OperationContext;
import org.hornetq.core.persistence.StorageManager;
import org.hornetq.core.persistence.impl.journal.OperationContextImpl;
import org.hornetq.core.remoting.Interceptor;
@@ -368,7 +369,6 @@
Journal replicatedJournal = new ReplicatedJournal((byte)1, new FakeJournal(), manager);
- Thread.sleep(100);
TestInterceptor.value.set(false);
for (int i = 0; i < 500; i++)
@@ -377,7 +377,7 @@
}
final CountDownLatch latch = new CountDownLatch(1);
- OperationContextImpl.getContext().executeOnCompletion(new IOAsyncTask()
+ OperationContextImpl.getInstance().executeOnCompletion(new IOAsyncTask()
{
public void onError(int errorCode, String errorMessage)
@@ -390,8 +390,6 @@
}
});
- manager.closeContext();
-
server.stop();
assertTrue(latch.await(50, TimeUnit.SECONDS));
@@ -409,7 +407,7 @@
private void blockOnReplication(ReplicationManagerImpl manager) throws Exception
{
final CountDownLatch latch = new CountDownLatch(1);
- OperationContextImpl.getContext().executeOnCompletion(new IOAsyncTask()
+ OperationContextImpl.getInstance().executeOnCompletion(new IOAsyncTask()
{
public void onError(int errorCode, String errorMessage)
@@ -422,8 +420,6 @@
}
});
- manager.closeContext();
-
assertTrue(latch.await(30, TimeUnit.SECONDS));
}
@@ -468,7 +464,7 @@
replicatedJournal.appendPrepareRecord(1, new FakeData(), false);
final CountDownLatch latch = new CountDownLatch(1);
- OperationContextImpl.getContext().executeOnCompletion(new IOAsyncTask()
+ OperationContextImpl.getInstance().executeOnCompletion(new IOAsyncTask()
{
public void onError(int errorCode, String errorMessage)
@@ -481,8 +477,6 @@
}
});
- manager.closeContext();
-
assertTrue(latch.await(1, TimeUnit.SECONDS));
assertEquals(0, manager.getActiveTokens().size());
@@ -521,6 +515,8 @@
final CountDownLatch latch = new CountDownLatch(numberOfAdds);
+ OperationContext ctx = OperationContextImpl.getInstance();
+
for (int i = 0; i < numberOfAdds; i++)
{
final int nAdd = i;
@@ -529,12 +525,8 @@
{
replicatedJournal.appendPrepareRecord(i, new FakeData(), false);
}
- else
- {
- manager.sync(OperationContextImpl.getContext());
- }
- OperationContextImpl.getContext().executeOnCompletion(new IOAsyncTask()
+ ctx.executeOnCompletion(new IOAsyncTask()
{
public void onError(int errorCode, String errorMessage)
@@ -543,12 +535,11 @@
public void done()
{
+ System.out.println("Add " + nAdd);
executions.add(nAdd);
latch.countDown();
}
});
-
- manager.closeContext();
}
assertTrue(latch.await(10, TimeUnit.SECONDS));
Modified: branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java
===================================================================
--- branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java 2009-11-21 20:49:38 UTC (rev 8364)
+++ branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java 2009-11-21 23:08:15 UTC (rev 8365)
@@ -44,6 +44,7 @@
import org.hornetq.core.paging.impl.PagingStoreImpl;
import org.hornetq.core.paging.impl.TestSupportPageStore;
import org.hornetq.core.persistence.GroupingInfo;
+import org.hornetq.core.persistence.OperationContext;
import org.hornetq.core.persistence.QueueBindingInfo;
import org.hornetq.core.persistence.StorageManager;
import org.hornetq.core.postoffice.Binding;
@@ -1247,6 +1248,22 @@
{
}
+ /* (non-Javadoc)
+ * @see org.hornetq.core.persistence.StorageManager#getContext()
+ */
+ public OperationContext getContext()
+ {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.hornetq.core.persistence.StorageManager#newContext(java.util.concurrent.Executor)
+ */
+ public OperationContext newContext(Executor executor)
+ {
+ return null;
+ }
+
}
class FakeStoreFactory implements PagingStoreFactory
15 years, 1 month
JBoss hornetq SVN: r8364 - in branches/ClebertCallback/src/main/org/hornetq/core: replication and 1 other directories.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2009-11-21 15:49:38 -0500 (Sat, 21 Nov 2009)
New Revision: 8364
Removed:
branches/ClebertCallback/src/main/org/hornetq/core/replication/ReplicationContext.java
branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicationContextImpl.java
Modified:
branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/OperationContextImpl.java
Log:
tweaks
Modified: branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/OperationContextImpl.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/OperationContextImpl.java 2009-11-21 20:37:23 UTC (rev 8363)
+++ branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/OperationContextImpl.java 2009-11-21 20:49:38 UTC (rev 8364)
@@ -54,8 +54,6 @@
private int replicated = 0;
- private boolean empty = false;
-
/**
* @param executor
*/
Deleted: branches/ClebertCallback/src/main/org/hornetq/core/replication/ReplicationContext.java
===================================================================
Deleted: branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicationContextImpl.java
===================================================================
15 years, 1 month
JBoss hornetq SVN: r8363 - in branches/ClebertCallback: src/main/org/hornetq/core/asyncio/impl and 11 other directories.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2009-11-21 15:37:23 -0500 (Sat, 21 Nov 2009)
New Revision: 8363
Modified:
branches/ClebertCallback/src/main/org/hornetq/core/asyncio/AsynchronousFile.java
branches/ClebertCallback/src/main/org/hornetq/core/asyncio/impl/AsynchronousFileImpl.java
branches/ClebertCallback/src/main/org/hornetq/core/journal/Journal.java
branches/ClebertCallback/src/main/org/hornetq/core/journal/SequentialFile.java
branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/AIOSequentialFile.java
branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/AbstractSequentialFile.java
branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/JournalImpl.java
branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/NIOSequentialFile.java
branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/TimedBuffer.java
branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
branches/ClebertCallback/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
branches/ClebertCallback/src/main/org/hornetq/core/replication/ReplicationManager.java
branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicatedJournal.java
branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicationManagerImpl.java
branches/ClebertCallback/tests/src/org/hornetq/tests/integration/client/OrderTest.java
branches/ClebertCallback/tests/src/org/hornetq/tests/integration/replication/ReplicationOrderTest.java
branches/ClebertCallback/tests/src/org/hornetq/tests/integration/replication/ReplicationTest.java
branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/asyncio/AIOTestBase.java
branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/asyncio/AsynchronousFileTest.java
branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java
branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java
Log:
sync on files
Modified: branches/ClebertCallback/src/main/org/hornetq/core/asyncio/AsynchronousFile.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/asyncio/AsynchronousFile.java 2009-11-21 17:13:50 UTC (rev 8362)
+++ branches/ClebertCallback/src/main/org/hornetq/core/asyncio/AsynchronousFile.java 2009-11-21 20:37:23 UTC (rev 8363)
@@ -41,13 +41,20 @@
* */
long size() throws HornetQException;
+ /** Some operations may need to be done only after persitency is done.
+ * for instance, when a messaging system needs to guarantee ordering over non-persistent data,
+ * it needs to make sure it will only deliver the message after all the data is persisted.
+ * The sync won't perform any disk operation however it will wait for all the current pending operations
+ * on this file to be finished */
+ void syncCallback(AIOCallback aioCallback);
+
/** Any error will be reported on the callback interface */
void write(long position, long size, ByteBuffer directByteBuffer, AIOCallback aioCallback);
void read(long position, long size, ByteBuffer directByteBuffer, AIOCallback aioCallback) throws HornetQException;
void fill(long position, int blocks, long size, byte fillChar) throws HornetQException;
-
+
void setBufferCallback(BufferCallback callback);
int getBlockSize();
Modified: branches/ClebertCallback/src/main/org/hornetq/core/asyncio/impl/AsynchronousFileImpl.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/asyncio/impl/AsynchronousFileImpl.java 2009-11-21 17:13:50 UTC (rev 8362)
+++ branches/ClebertCallback/src/main/org/hornetq/core/asyncio/impl/AsynchronousFileImpl.java 2009-11-21 20:37:23 UTC (rev 8363)
@@ -295,9 +295,9 @@
public void run()
{
writeSemaphore.acquireUninterruptibly();
+
+ final long sequence = nextWritingSequence.getAndIncrement();
- long sequence = nextWritingSequence.getAndIncrement();
-
try
{
write(handler, sequence, position, size, directByteBuffer, aioCallback);
@@ -321,7 +321,7 @@
{
writeSemaphore.acquireUninterruptibly();
- long sequence = nextWritingSequence.getAndIncrement();
+ final long sequence = nextWritingSequence.getAndIncrement();
try
{
@@ -438,16 +438,42 @@
}
}
- // Private ---------------------------------------------------------------------------
+ // Callback methods ------------------------------------------------------------------
+ public void syncCallback(final AIOCallback callback)
+ {
+ pendingWrites.up();
+
+ writeExecutor.execute(new Runnable()
+ {
+ public void run()
+ {
+ callbackLock.lock();
+
+ try
+ {
+ final long sequence = nextWritingSequence.getAndIncrement();
+
+ // This will execute the callback immediately if nothing is pending,
+ // or it will place it to the queue waiting for a response
+ executeCallback(callback, sequence);
+
+ }
+ finally
+ {
+ callbackLock.unlock();
+ }
+ }
+ });
+
+ }
+
/** */
@SuppressWarnings("unused")
private void callbackDone(final AIOCallback callback, final long sequence, final ByteBuffer buffer)
{
writeSemaphore.release();
- pendingWrites.down();
-
callbackLock.lock();
try
@@ -456,20 +482,11 @@
if (sequence == -1)
{
callback.done();
+ pendingWrites.down();
}
else
{
- if (sequence == nextReadSequence)
- {
- nextReadSequence++;
- callback.done();
- flushCallbacks();
- }
- else
- {
- // System.out.println("Buffering callback");
- pendingCallbacks.add(new CallbackHolder(sequence, callback));
- }
+ executeCallback(callback, sequence);
}
// The buffer is not sent on callback for read operations
@@ -484,6 +501,26 @@
}
}
+ /**
+ * @param callback
+ * @param sequence
+ */
+ private void executeCallback(final AIOCallback callback, final long sequence)
+ {
+ if (sequence == nextReadSequence)
+ {
+ nextReadSequence++;
+ callback.done();
+ pendingWrites.down();
+ flushCallbacks();
+ }
+ else
+ {
+ // System.out.println("Buffering callback");
+ pendingCallbacks.add(new CallbackHolder(sequence, callback));
+ }
+ }
+
private void flushCallbacks()
{
while (!pendingCallbacks.isEmpty() && pendingCallbacks.peek().sequence == nextReadSequence)
@@ -498,6 +535,7 @@
{
holder.callback.done();
}
+ pendingWrites.down();
nextReadSequence++;
}
}
@@ -550,6 +588,8 @@
}
}
+ // Private ---------------------------------------------------------------------------
+
private void pollEvents()
{
if (!opened)
Modified: branches/ClebertCallback/src/main/org/hornetq/core/journal/Journal.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/journal/Journal.java 2009-11-21 17:13:50 UTC (rev 8362)
+++ branches/ClebertCallback/src/main/org/hornetq/core/journal/Journal.java 2009-11-21 20:37:23 UTC (rev 8363)
@@ -112,5 +112,7 @@
void perfBlast(int pages) throws Exception;
+ void sync(IOCompletion callback);
+
}
Modified: branches/ClebertCallback/src/main/org/hornetq/core/journal/SequentialFile.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/journal/SequentialFile.java 2009-11-21 17:13:50 UTC (rev 8362)
+++ branches/ClebertCallback/src/main/org/hornetq/core/journal/SequentialFile.java 2009-11-21 20:37:23 UTC (rev 8363)
@@ -80,6 +80,9 @@
void sync() throws Exception;
+ /** This method will make sure the parameter callback will be invoked after all pending sync operations are done */
+ void syncCallback(IOAsyncTask callback);
+
long size() throws Exception;
void renameTo(String newFileName) throws Exception;
Modified: branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/AIOSequentialFile.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/AIOSequentialFile.java 2009-11-21 17:13:50 UTC (rev 8362)
+++ branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/AIOSequentialFile.java 2009-11-21 20:37:23 UTC (rev 8363)
@@ -304,4 +304,14 @@
throw new IllegalStateException("File not opened");
}
}
+
+ /* (non-Javadoc)
+ * @see org.hornetq.core.journal.impl.AbstractSequentialFile#syncCallbackDirect(org.hornetq.core.journal.IOAsyncTask)
+ */
+ @Override
+ protected void syncCallbackDirect(IOAsyncTask callback)
+ {
+ aioFile.syncCallback(callback);
+ }
+
}
Modified: branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/AbstractSequentialFile.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/AbstractSequentialFile.java 2009-11-21 17:13:50 UTC (rev 8362)
+++ branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/AbstractSequentialFile.java 2009-11-21 20:37:23 UTC (rev 8363)
@@ -16,7 +16,6 @@
import java.io.File;
import java.nio.ByteBuffer;
import java.util.List;
-import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicLong;
import org.hornetq.core.journal.IOAsyncTask;
@@ -190,11 +189,30 @@
write(bytes, false, DummyCallback.getInstance());
}
}
+
+ /**
+ * invoke the callback after all pending operations are complete.
+ */
+ public void syncCallback(IOAsyncTask callback)
+ {
+ if (timedBuffer != null)
+ {
+ timedBuffer.syncCallback(callback);
+ }
+ else
+ {
+ syncCallbackDirect(callback);
+ }
+ }
+
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
+ protected abstract void syncCallbackDirect(IOAsyncTask callback);
+
protected File getFile()
{
return file;
@@ -252,15 +270,22 @@
{
public void flushBuffer(final ByteBuffer buffer, final boolean requestedSync, final List<IOAsyncTask> callbacks)
{
- buffer.flip();
-
- if (buffer.limit() == 0)
+ if (buffer == null)
{
- factory.releaseBuffer(buffer);
+ syncCallbackDirect(new DelegateCallback(callbacks));
}
else
{
- writeDirect(buffer, requestedSync, new DelegateCallback(callbacks));
+ buffer.flip();
+
+ if (buffer.limit() == 0)
+ {
+ factory.releaseBuffer(buffer);
+ }
+ else
+ {
+ writeDirect(buffer, requestedSync, new DelegateCallback(callbacks));
+ }
}
}
Modified: branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/JournalImpl.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/JournalImpl.java 2009-11-21 17:13:50 UTC (rev 8362)
+++ branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/JournalImpl.java 2009-11-21 20:37:23 UTC (rev 8363)
@@ -864,7 +864,31 @@
callback.waitCompletion();
}
}
+
+ public void sync(IOCompletion callback)
+ {
+ callback.lineUp();
+ compactingLock.readLock().lock();
+
+ try
+ {
+ lockAppend.lock();
+ try
+ {
+ currentFile.getFile().syncCallback(callback);
+ }
+ finally
+ {
+ lockAppend.unlock();
+ }
+ }
+ finally
+ {
+ compactingLock.readLock().unlock();
+ }
+ }
+
public void appendAddRecord(final long id, final byte recordType, final EncodingSupport record, final boolean sync, final IOCompletion callback) throws Exception
{
if (LOAD_TRACE)
Modified: branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/NIOSequentialFile.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/NIOSequentialFile.java 2009-11-21 17:13:50 UTC (rev 8362)
+++ branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/NIOSequentialFile.java 2009-11-21 20:37:23 UTC (rev 8363)
@@ -220,6 +220,18 @@
internalWrite(bytes, sync, null);
}
+
+ /* (non-Javadoc)
+ * @see org.hornetq.core.journal.impl.AbstractSequentialFile#syncCallbackDirect(org.hornetq.core.journal.IOAsyncTask)
+ */
+ @Override
+ protected void syncCallbackDirect(IOAsyncTask callback)
+ {
+ // Nothing to be done on NIO.
+ // Timed buffer took care of everything
+ callback.done();
+ }
+
/**
* @param bytes
* @param sync
@@ -243,4 +255,5 @@
callback.done();
}
}
+
}
Modified: branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/TimedBuffer.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/TimedBuffer.java 2009-11-21 17:13:50 UTC (rev 8362)
+++ branches/ClebertCallback/src/main/org/hornetq/core/journal/impl/TimedBuffer.java 2009-11-21 20:37:23 UTC (rev 8363)
@@ -225,15 +225,30 @@
return true;
}
}
+
- public synchronized void addBytes(final byte[] bytes, final boolean sync, final IOAsyncTask callback)
+ /**
+ * This method will make sure this callback will be executed after all the pending callbacks
+ */
+ public synchronized void syncCallback(IOAsyncTask callback)
{
- if (buffer.writerIndex() == 0)
+ resumeTimerIfNeeded();
+
+ callbacks.add(callback);
+
+ pendingSync = true;
+
+ if (flushOnSync)
{
- // Resume latch
- latchTimer.down();
+ flush();
}
+ }
+
+ public synchronized void addBytes(final byte[] bytes, final boolean sync, final IOAsyncTask callback)
+ {
+ resumeTimerIfNeeded();
+
buffer.writeBytes(bytes);
callbacks.add(callback);
@@ -259,35 +274,57 @@
}
}
+ private void resumeTimerIfNeeded()
+ {
+ if (buffer.writerIndex() == 0 && callbacks.size() == 0)
+ {
+ // Resume latch
+ latchTimer.down();
+ }
+ }
+
public synchronized void flush()
{
- if (buffer.writerIndex() > 0)
+ if (buffer.writerIndex() > 0 || callbacks.size() > 0)
{
+ // Stop latch
latchTimer.up();
-
- int pos = buffer.writerIndex();
-
- if (logRates)
+
+ if (buffer.writerIndex() == 0 && callbacks.size() > 0)
{
- bytesFlushed += pos;
+ // This is to perform a sync callback.
+ // When we get to here, means we have sync callbacks waiting with no buffer
+ // on this case we need to call sync on the file to make sure no other callbacks are pending
+ bufferObserver.flushBuffer(null, pendingSync, callbacks);
+
+ callbacks = new LinkedList<IOAsyncTask>();
}
-
- ByteBuffer directBuffer = bufferObserver.newBuffer(bufferSize, pos);
-
- // Putting a byteArray on a native buffer is much faster, since it will do in a single native call.
- // Using directBuffer.put(buffer) would make several append calls for each byte
-
- directBuffer.put(buffer.array(), 0, pos);
-
- bufferObserver.flushBuffer(directBuffer, pendingSync, callbacks);
-
- callbacks = new LinkedList<IOAsyncTask>();
-
- active = false;
- pendingSync = false;
-
- buffer.clear();
- bufferLimit = 0;
+ else
+ {
+ int pos = buffer.writerIndex();
+
+ if (logRates)
+ {
+ bytesFlushed += pos;
+ }
+
+ ByteBuffer directBuffer = bufferObserver.newBuffer(bufferSize, pos);
+
+ // Putting a byteArray on a native buffer is much faster, since it will do in a single native call.
+ // Using directBuffer.put(buffer) would make several append calls for each byte
+
+ directBuffer.put(buffer.array(), 0, pos);
+
+ bufferObserver.flushBuffer(directBuffer, pendingSync, callbacks);
+
+ callbacks = new LinkedList<IOAsyncTask>();
+
+ active = false;
+ pendingSync = false;
+
+ buffer.clear();
+ bufferLimit = 0;
+ }
}
}
Modified: branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2009-11-21 17:13:50 UTC (rev 8362)
+++ branches/ClebertCallback/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2009-11-21 20:37:23 UTC (rev 8363)
@@ -506,10 +506,7 @@
public void sync()
{
- if (replicator != null)
- {
- replicator.sync();
- }
+ messageJournal.sync(OperationContextImpl.getContext());
}
// Transactional operations
Modified: branches/ClebertCallback/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java 2009-11-21 17:13:50 UTC (rev 8362)
+++ branches/ClebertCallback/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java 2009-11-21 20:37:23 UTC (rev 8363)
@@ -919,10 +919,7 @@
}
else
{
- if (storageManager.isReplicated())
- {
- storageManager.sync();
- }
+ storageManager.sync();
}
message.incrementRefCount(reference);
Modified: branches/ClebertCallback/src/main/org/hornetq/core/replication/ReplicationManager.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/replication/ReplicationManager.java 2009-11-21 17:13:50 UTC (rev 8362)
+++ branches/ClebertCallback/src/main/org/hornetq/core/replication/ReplicationManager.java 2009-11-21 20:37:23 UTC (rev 8363)
@@ -86,6 +86,6 @@
*/
void compareJournals(JournalLoadInformation[] journalInfo) throws HornetQException;
- void sync();
+ void sync(OperationContext ctx);
}
Modified: branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicatedJournal.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicatedJournal.java 2009-11-21 17:13:50 UTC (rev 8362)
+++ branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicatedJournal.java 2009-11-21 20:37:23 UTC (rev 8363)
@@ -25,6 +25,7 @@
import org.hornetq.core.journal.TransactionFailureCallback;
import org.hornetq.core.journal.impl.JournalImpl.ByteArrayEncoding;
import org.hornetq.core.logging.Logger;
+import org.hornetq.core.persistence.OperationContext;
import org.hornetq.core.persistence.impl.journal.JournalStorageManager;
import org.hornetq.core.replication.ReplicationManager;
@@ -433,6 +434,15 @@
localJournal.appendUpdateRecordTransactional(txID, id, recordType, record);
}
+ /* (non-Javadoc)
+ * @see org.hornetq.core.journal.Journal#sync()
+ */
+ public void sync(IOCompletion ctx)
+ {
+ replicationManager.sync((OperationContext)ctx);
+ localJournal.sync(ctx);
+ }
+
/**
* @param committedRecords
* @param preparedTransactions
Modified: branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicationManagerImpl.java
===================================================================
--- branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicationManagerImpl.java 2009-11-21 17:13:50 UTC (rev 8362)
+++ branches/ClebertCallback/src/main/org/hornetq/core/replication/impl/ReplicationManagerImpl.java 2009-11-21 20:37:23 UTC (rev 8363)
@@ -439,9 +439,29 @@
replicatingChannel.sendBlocking(new ReplicationCompareDataMessage(journalInfo));
}
- public void sync()
+
+ public void sync(OperationContext context)
{
- sync(OperationContextImpl.getContext());
+ boolean executeNow = false;
+ synchronized (replicationLock)
+ {
+ context.replicationLineUp();
+ if (pendingTokens.isEmpty())
+ {
+ // this means the list is empty and we should process it now
+ executeNow = true;
+ }
+ else
+ {
+ // adding the sync to be executed in order
+ // as soon as the reponses are back from the backup
+ this.pendingTokens.add(new SyncOperation(context));
+ }
+ }
+ if (executeNow)
+ {
+ context.replicationDone();
+ }
}
// Package protected ---------------------------------------------
@@ -490,31 +510,6 @@
ctx.replicationDone();
}
}
-
- private void sync(OperationContext context)
- {
- boolean executeNow = false;
- synchronized (replicationLock)
- {
- context.replicationLineUp();
- if (pendingTokens.isEmpty())
- {
- // this means the list is empty and we should process it now
- executeNow = true;
- }
- else
- {
- // adding the sync to be executed in order
- // as soon as the reponses are back from the backup
- this.pendingTokens.add(new SyncOperation(context));
- }
- }
- if (executeNow)
- {
- context.replicationDone();
- }
- }
-
public OperationContext getContext()
{
Modified: branches/ClebertCallback/tests/src/org/hornetq/tests/integration/client/OrderTest.java
===================================================================
--- branches/ClebertCallback/tests/src/org/hornetq/tests/integration/client/OrderTest.java 2009-11-21 17:13:50 UTC (rev 8362)
+++ branches/ClebertCallback/tests/src/org/hornetq/tests/integration/client/OrderTest.java 2009-11-21 20:37:23 UTC (rev 8363)
@@ -64,63 +64,48 @@
// Public --------------------------------------------------------
- public void testLoop() throws Exception
- {
- for (int i = 0 ; i < 50; i ++)
- {
- testSimpleOrder();
- tearDown();
- setUp();
- }
- }
-
public void testSimpleOrder() throws Exception
{
ClientSessionFactory sf = createNettyFactory();
- sf.setBlockOnNonPersistentSend(true);
- sf.setBlockOnPersistentSend(true);
+ sf.setBlockOnNonPersistentSend(false);
+ sf.setBlockOnPersistentSend(false);
sf.setBlockOnAcknowledge(true);
-
ClientSession session = sf.createSession(true, true, 0);
-
+
try
{
session.createQueue("queue", "queue", true);
ClientProducer prod = session.createProducer("queue");
-
for (int i = 0; i < 100; i++)
{
- ClientMessage msg = session.createClientMessage(i == 0);
+ ClientMessage msg = session.createClientMessage(i % 2 == 0);
msg.setBody(session.createBuffer(new byte[1024]));
msg.putIntProperty("id", i);
prod.send(msg);
}
session.close();
-
+
boolean started = false;
for (int start = 0; start < 3; start++)
{
-
-
- if (start == 20)
+
+ if (start == 2)
{
started = true;
server.stop();
server.start();
}
-
+
session = sf.createSession(true, true);
-
+
session.start();
-
-// fail(session);
-
+
ClientConsumer cons = session.createConsumer("queue");
for (int i = 0; i < 100; i++)
@@ -144,7 +129,7 @@
assertEquals(i, msg.getIntProperty("id").intValue());
}
}
-
+
session.close();
}
@@ -156,11 +141,10 @@
}
}
-
-
+
private void fail(ClientSession session) throws InterruptedException
{
-
+
final CountDownLatch latch = new CountDownLatch(1);
class MyListener implements SessionFailureListener
@@ -178,8 +162,6 @@
MyListener listener = new MyListener();
session.addFailureListener(listener);
-
-
RemotingConnection conn = ((ClientSessionInternal)session).getConnection();
// Simulate failure on connection
@@ -190,12 +172,10 @@
boolean ok = latch.await(1000, TimeUnit.MILLISECONDS);
assertTrue(ok);
-
+
session.removeFailureListener(listener);
}
-
-
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
Modified: branches/ClebertCallback/tests/src/org/hornetq/tests/integration/replication/ReplicationOrderTest.java
===================================================================
--- branches/ClebertCallback/tests/src/org/hornetq/tests/integration/replication/ReplicationOrderTest.java 2009-11-21 17:13:50 UTC (rev 8362)
+++ branches/ClebertCallback/tests/src/org/hornetq/tests/integration/replication/ReplicationOrderTest.java 2009-11-21 20:37:23 UTC (rev 8363)
@@ -52,12 +52,12 @@
// Public --------------------------------------------------------
- public void _test() throws Exception
+ public void test() throws Exception
{
for (int i = 0; i < 100; i++)
{
System.out.println("<<<<<< " + i + " >>>>>>>");
- testTxMixedPersistentAndNonPersistentMessagesOrderWithReplicatedBackup();
+ testMixedPersistentAndNonPersistentMessagesOrderWithReplicatedBackup();
tearDown();
setUp();
}
@@ -80,7 +80,7 @@
ClientSessionFactory csf = new ClientSessionFactoryImpl(getConnectorTransportConfiguration(true));
csf.setBlockOnNonPersistentSend(false);
- csf.setBlockOnPersistentSend(true);
+ csf.setBlockOnPersistentSend(false);
ClientSession session = null;
if (transactional)
{
Modified: branches/ClebertCallback/tests/src/org/hornetq/tests/integration/replication/ReplicationTest.java
===================================================================
--- branches/ClebertCallback/tests/src/org/hornetq/tests/integration/replication/ReplicationTest.java 2009-11-21 17:13:50 UTC (rev 8362)
+++ branches/ClebertCallback/tests/src/org/hornetq/tests/integration/replication/ReplicationTest.java 2009-11-21 20:37:23 UTC (rev 8363)
@@ -531,7 +531,7 @@
}
else
{
- manager.sync();
+ manager.sync(OperationContextImpl.getContext());
}
OperationContextImpl.getContext().executeOnCompletion(new IOAsyncTask()
@@ -961,5 +961,12 @@
{
}
+ /* (non-Javadoc)
+ * @see org.hornetq.core.journal.Journal#sync(org.hornetq.core.journal.IOCompletion)
+ */
+ public void sync(IOCompletion callback)
+ {
+ }
+
}
}
Modified: branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/asyncio/AIOTestBase.java
===================================================================
--- branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/asyncio/AIOTestBase.java 2009-11-21 17:13:50 UTC (rev 8362)
+++ branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/asyncio/AIOTestBase.java 2009-11-21 20:37:23 UTC (rev 8363)
@@ -85,25 +85,34 @@
protected static class CountDownCallback implements AIOCallback
{
- private final CountDownLatch latch;
+ private final CountDownLatch latchDone;
+ private final CountDownLatch waitCallback;
+
private final List<Integer> outputList;
private final int order;
private final AtomicInteger errors;
- public CountDownCallback(final CountDownLatch latch, final AtomicInteger errors, final List<Integer> outputList, final int order)
+ public CountDownCallback(final CountDownLatch latch, final AtomicInteger errors, final List<Integer> outputList, final int order, final CountDownLatch waitCallback)
{
- this.latch = latch;
+ this.latchDone = latch;
this.outputList = outputList;
this.order = order;
this.errors = errors;
+
+ this.waitCallback = waitCallback;
}
+ public CountDownCallback(final CountDownLatch latch, final AtomicInteger errors, final List<Integer> outputList, final int order)
+ {
+ this(latch, errors, outputList, order, null);
+ }
+
volatile boolean doneCalled = false;
volatile int errorCalled = 0;
@@ -112,15 +121,26 @@
public void done()
{
+ if (waitCallback != null)
+ {
+ try
+ {
+ waitCallback.await();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(); // -> junit report
+ }
+ }
if (outputList != null)
{
outputList.add(order);
}
doneCalled = true;
timesDoneCalled.incrementAndGet();
- if (latch != null)
+ if (latchDone != null)
{
- latch.countDown();
+ latchDone.countDown();
}
}
@@ -135,11 +155,11 @@
{
errors.incrementAndGet();
}
- if (latch != null)
+ if (latchDone != null)
{
// even thought an error happened, we need to inform the latch,
// or the test won't finish
- latch.countDown();
+ latchDone.countDown();
}
}
Modified: branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/asyncio/AsynchronousFileTest.java
===================================================================
--- branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/asyncio/AsynchronousFileTest.java 2009-11-21 17:13:50 UTC (rev 8362)
+++ branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/asyncio/AsynchronousFileTest.java 2009-11-21 20:37:23 UTC (rev 8363)
@@ -22,6 +22,7 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import junit.framework.TestSuite;
@@ -420,6 +421,60 @@
}
}
+ public void testOrderOnSynCallback() throws Exception
+ {
+ boolean closed = false;
+ final AsynchronousFileImpl controller = new AsynchronousFileImpl(executor, pollerExecutor);
+ ByteBuffer buffer = null;
+ try
+ {
+ final int NUMBER_LINES = 100;
+ final int SIZE = 512;
+
+ controller.open(FILE_NAME, 100);
+
+ controller.fill(0, 1, NUMBER_LINES * SIZE, (byte)'j');
+
+ CountDownLatch latch = new CountDownLatch(NUMBER_LINES * 2);
+
+ buffer = AsynchronousFileImpl.newBuffer(SIZE);
+ buffer.rewind();
+ for (int j = 0; j < SIZE; j++)
+ {
+ buffer.put((byte)(j % Byte.MAX_VALUE));
+ }
+
+ ArrayList<Integer> result = new ArrayList<Integer>();
+
+ for (int i = 0; i < NUMBER_LINES * 2; i++)
+ {
+ CountDownCallback aio = new CountDownCallback(latch, null, result, i);
+ if (i % 2 == 0)
+ {
+ controller.write(i * SIZE, SIZE, buffer, aio);
+ }
+ else
+ {
+ controller.syncCallback(aio);
+ }
+ }
+
+ controller.close();
+ closed = true;
+
+ // We are not waiting the latch, as close should already hold for any writes
+ CountDownCallback.checkResults(NUMBER_LINES * 2, result);
+ }
+ finally
+ {
+ AsynchronousFileImpl.destroyBuffer(buffer);
+ if (!closed)
+ {
+ controller.close();
+ }
+ }
+ }
+
public void testBufferCallbackAwaysSameBuffer() throws Exception
{
boolean closed = false;
Modified: branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java
===================================================================
--- branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java 2009-11-21 17:13:50 UTC (rev 8362)
+++ branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java 2009-11-21 20:37:23 UTC (rev 8363)
@@ -17,11 +17,16 @@
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
import org.hornetq.core.asyncio.impl.AsynchronousFileImpl;
+import org.hornetq.core.buffers.ChannelBuffers;
+import org.hornetq.core.journal.IOAsyncTask;
import org.hornetq.core.journal.SequentialFile;
import org.hornetq.core.journal.SequentialFileFactory;
import org.hornetq.core.logging.Logger;
+import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.tests.util.UnitTestCase;
/**
@@ -39,9 +44,9 @@
protected void setUp() throws Exception
{
super.setUp();
-
+
factory = createFactory();
-
+
factory.start();
}
@@ -49,13 +54,13 @@
protected void tearDown() throws Exception
{
assertEquals(0, AsynchronousFileImpl.getTotalMaxIO());
-
+
factory.stop();
-
+
factory = null;
-
+
forceGC();
-
+
super.tearDown();
}
@@ -172,7 +177,139 @@
sf2.close();
}
-
+
+ public void testOrder() throws Exception
+ {
+ SequentialFile sf = factory.createSequentialFile("order-test.hq", 100);
+
+ sf.open();
+
+ factory.activateBuffer(sf);
+
+ final int records = 5000;
+
+ sf.fill(0, records * 1024, (byte)0);
+
+
+ final ArrayList<Integer> result = new ArrayList<Integer>();
+
+ final CountDownLatch latch = new CountDownLatch(records);
+
+ HornetQBuffer buffer = ChannelBuffers.wrappedBuffer(new byte[512]);
+
+ for (int i = 0 ; i < records; i++)
+ {
+ final int toadd = i;
+ IOAsyncTask callback = new IOAsyncTask()
+ {
+
+ public void onError(int errorCode, String errorMessage)
+ {
+ }
+
+ public void done()
+ {
+ result.add(toadd);
+
+ latch.countDown();
+ }
+
+ };
+
+ if (i % 2 == 0)
+ {
+ sf.disableAutoFlush();
+ sf.fits(512);
+ sf.write(buffer, false, callback);
+ sf.enableAutoFlush();
+ }
+ else
+ {
+ sf.syncCallback(callback);
+ }
+ }
+
+ assertTrue(latch.await(5, TimeUnit.SECONDS));
+
+ assertEquals(records, result.size());
+
+ int i = 0;
+
+ for (Integer r : result)
+ {
+ assertEquals(i++, r.intValue());
+ }
+
+
+ factory.deactivateBuffer();
+
+ sf.close();
+ }
+
+ public void testOrder2() throws Exception
+ {
+ SequentialFile sf = factory.createSequentialFile("order-test.hq", 100);
+
+ sf.open();
+
+ factory.activateBuffer(sf);
+
+ final int records = 1000;
+
+ sf.fill(0, records * 1024, (byte)0);
+
+
+ final ArrayList<Integer> result = new ArrayList<Integer>();
+
+ final CountDownLatch latch = new CountDownLatch(records);
+
+ HornetQBuffer buffer = ChannelBuffers.wrappedBuffer(new byte[512]);
+
+ for (int i = 0 ; i < records; i++)
+ {
+ final int toadd = i;
+ IOAsyncTask callback = new IOAsyncTask()
+ {
+
+ public void onError(int errorCode, String errorMessage)
+ {
+ }
+
+ public void done()
+ {
+ result.add(toadd);
+
+ latch.countDown();
+ }
+
+ };
+
+ if (i == 10)
+ {
+ sf.write(buffer, false, callback);
+ }
+ else
+ {
+ sf.syncCallback(callback);
+ }
+ }
+
+ assertTrue(latch.await(5, TimeUnit.SECONDS));
+
+ assertEquals(records, result.size());
+
+ int i = 0;
+
+ for (Integer r : result)
+ {
+ assertEquals(i++, r.intValue());
+ }
+
+ factory.deactivateBuffer();
+
+ sf.close();
+ }
+
public void testRename() throws Exception
{
SequentialFile sf = factory.createSequentialFile("test1.hq", 1);
@@ -184,7 +321,7 @@
assertEquals(1, fileNames.size());
assertTrue(fileNames.contains("test1.hq"));
-
+
sf.renameTo("test1.cmp");
fileNames = factory.listFiles("cmp");
@@ -204,7 +341,7 @@
assertEquals(0, fileNames.size());
}
-
+
public void testWriteandRead() throws Exception
{
SequentialFile sf = factory.createSequentialFile("write.hq", 1);
@@ -222,7 +359,7 @@
String s3 = "echidna";
byte[] bytes3 = s3.getBytes("UTF-8");
ByteBuffer bb3 = factory.wrapBuffer(bytes3);
-
+
long initialPos = sf.position();
sf.writeDirect(bb1, true);
long bytesWritten = sf.position() - initialPos;
@@ -305,7 +442,6 @@
sf.writeDirect(bb2, true);
bytesWritten = sf.position() - initialPos;
-
assertEquals(bb2.limit(), bytesWritten);
initialPos = sf.position();
@@ -382,9 +518,9 @@
try
{
-
+
bb1 = factory.wrapBuffer(bytes1);
-
+
sf.writeDirect(bb1, true);
fail("Should throw exception");
Modified: branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java
===================================================================
--- branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java 2009-11-21 17:13:50 UTC (rev 8362)
+++ branches/ClebertCallback/tests/src/org/hornetq/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java 2009-11-21 20:37:23 UTC (rev 8363)
@@ -634,10 +634,17 @@
*/
public void setTimedBuffer(TimedBuffer buffer)
{
- // TODO Auto-generated method stub
}
+ /* (non-Javadoc)
+ * @see org.hornetq.core.journal.SequentialFile#syncCallback(org.hornetq.core.journal.IOAsyncTask)
+ */
+ public void syncCallback(IOAsyncTask callback)
+ {
+ callback.done();
+ }
+
}
/* (non-Javadoc)
15 years, 1 month
JBoss hornetq SVN: r8362 - branches.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2009-11-21 12:13:50 -0500 (Sat, 21 Nov 2009)
New Revision: 8362
Removed:
branches/ClebertTemporary/
Log:
Deleting a temporary branch
15 years, 1 month