[jboss-cvs] JBoss Messaging SVN: r5454 - in trunk: src/main/org/jboss/messaging/core/journal/impl and 21 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Dec 2 22:59:55 EST 2008
Author: clebert.suconic at jboss.com
Date: 2008-12-02 22:59:55 -0500 (Tue, 02 Dec 2008)
New Revision: 5454
Modified:
trunk/src/main/org/jboss/messaging/core/journal/SequentialFileFactory.java
trunk/src/main/org/jboss/messaging/core/journal/impl/AbstractSequentialFactory.java
trunk/src/main/org/jboss/messaging/core/paging/PagingStore.java
trunk/src/main/org/jboss/messaging/core/paging/PagingStoreFactory.java
trunk/src/main/org/jboss/messaging/core/paging/impl/PagingManagerImpl.java
trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreFactoryNIO.java
trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java
trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java
trunk/tests/src/org/jboss/messaging/tests/integration/asyncio/AIOTestBase.java
trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/ChunkTestBase.java
trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/MessageChunkTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/consumer/ConsumerTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/journal/AIOSequentialFileFactoryTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/journal/RealAIOJournalImplTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/paging/PagingIntegrationTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/paging/PagingManagerIntegrationTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/paging/PagingStoreIntegrationTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/queue/DeadLetterAddressTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/queue/ExpiryAddressTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/queue/ExpiryRunnerTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/scheduling/ScheduledMessageTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/xa/BasicXaRecoveryTest.java
trunk/tests/src/org/jboss/messaging/tests/performance/paging/MeasurePagingMultiThreadTest.java
trunk/tests/src/org/jboss/messaging/tests/stress/journal/AddAndRemoveStressTest.java
trunk/tests/src/org/jboss/messaging/tests/stress/journal/ValidateTransactionHealthTest.java
trunk/tests/src/org/jboss/messaging/tests/stress/paging/PageStressTest.java
trunk/tests/src/org/jboss/messaging/tests/timing/core/journal/impl/RealJournalImplAIOTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/AIOSequentialFileTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/PostOfficeImplTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/GroupingRoundRobinDistributionPolicyTest.java
trunk/tests/src/org/jboss/messaging/tests/util/ServiceTestBase.java
trunk/tests/src/org/jboss/messaging/tests/util/SpawnedVMSupport.java
trunk/tests/src/org/jboss/messaging/tests/util/UnitTestCase.java
Log:
Paging code review and other tweaks
Modified: trunk/src/main/org/jboss/messaging/core/journal/SequentialFileFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/journal/SequentialFileFactory.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/src/main/org/jboss/messaging/core/journal/SequentialFileFactory.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -54,5 +54,10 @@
* The journal will complete the buffer when reusing the buffer.
* Look at JournalImpl#newBuffer for more information about this */
void clearBuffer(ByteBuffer buffer);
+
+ /**
+ * Create the directory if it doesn't exist yet
+ */
+ void createDirs() throws Exception;
}
Modified: trunk/src/main/org/jboss/messaging/core/journal/impl/AbstractSequentialFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/journal/impl/AbstractSequentialFactory.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/src/main/org/jboss/messaging/core/journal/impl/AbstractSequentialFactory.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -46,6 +46,16 @@
{
this.journalDir = journalDir;
}
+
+ /**
+ * Create the directory if it doesn't exist yet
+ */
+ public void createDirs() throws Exception
+ {
+ File file = new File(journalDir);
+ file.mkdirs();
+ }
+
public List<String> listFiles(final String extension) throws Exception
{
Modified: trunk/src/main/org/jboss/messaging/core/paging/PagingStore.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/paging/PagingStore.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/src/main/org/jboss/messaging/core/paging/PagingStore.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -22,6 +22,8 @@
package org.jboss.messaging.core.paging;
+import java.util.concurrent.Executor;
+
import org.jboss.messaging.core.server.MessagingComponent;
import org.jboss.messaging.util.SimpleString;
@@ -69,6 +71,9 @@
* @throws Exception
*/
boolean startDepaging();
+
+ /** When start depaging from a global perspective, we don't want all the stores depaging at once what could saturate the servers */
+ boolean startDepaging(Executor executor);
LastPageRecord getLastPageRecord();
Modified: trunk/src/main/org/jboss/messaging/core/paging/PagingStoreFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/paging/PagingStoreFactory.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/src/main/org/jboss/messaging/core/paging/PagingStoreFactory.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -39,7 +39,7 @@
{
PagingStore newStore(SimpleString destinationName, QueueSettings queueSettings);
- Executor getPagingExecutor();
+ Executor getGlobalDepagerExecutor();
void stop() throws InterruptedException;
Modified: trunk/src/main/org/jboss/messaging/core/paging/impl/PagingManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/paging/impl/PagingManagerImpl.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/src/main/org/jboss/messaging/core/paging/impl/PagingManagerImpl.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -63,8 +63,6 @@
private final AtomicBoolean globalMode = new AtomicBoolean(false);
- private final AtomicBoolean globalDepageRunning = new AtomicBoolean(false);
-
private final ConcurrentMap<SimpleString, PagingStore> stores = new ConcurrentHashMap<SimpleString, PagingStore>();
private final HierarchicalRepository<QueueSettings> queueSettingsRepository;
@@ -265,21 +263,21 @@
started = false;
- pagingSPI.stop();
-
for (PagingStore store : stores.values())
{
store.stop();
}
+
+ pagingSPI.stop();
}
- public void startGlobalDepage()
+ public synchronized void startGlobalDepage()
{
- if (globalDepageRunning.compareAndSet(false, true))
+ for (PagingStore store: stores.values())
{
- Runnable globalDepageRunnable = new GlobalDepager();
- pagingSPI.getPagingExecutor().execute(globalDepageRunnable);
+ store.startDepaging(pagingSPI.getGlobalDepagerExecutor());
}
+ globalMode.set(false);
}
/* (non-Javadoc)
@@ -322,56 +320,4 @@
// Inner classes -------------------------------------------------
- private class GlobalDepager implements Runnable
- {
- public void run()
- {
- try
- {
- while (globalSize.get() < maxGlobalSize && started)
- {
- boolean depaged = false;
- // Round robin depaging one page at the time from each
- // destination
- for (PagingStore store : stores.values())
- {
- if (globalSize.get() < maxGlobalSize)
- {
- if (store.isPaging())
- {
- depaged = true;
- try
- {
- store.readPage();
- }
- catch (Exception e)
- {
- log.error(e.getMessage(), e);
- }
- }
- }
- }
- if (!depaged)
- {
- break;
- }
- }
-
- if (globalSize.get() < maxGlobalSize && started)
- {
- globalMode.set(false);
- // Clearing possible messages still in page-mode
- for (PagingStore store : stores.values())
- {
- store.startDepaging();
- }
- }
- }
- finally
- {
- globalDepageRunning.set(false);
- }
- }
- }
-
}
Modified: trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreFactoryNIO.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreFactoryNIO.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreFactoryNIO.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -22,7 +22,6 @@
package org.jboss.messaging.core.paging.impl;
-import java.io.File;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -36,7 +35,9 @@
import org.jboss.messaging.core.persistence.StorageManager;
import org.jboss.messaging.core.postoffice.PostOffice;
import org.jboss.messaging.core.settings.impl.QueueSettings;
+import org.jboss.messaging.util.Base64;
import org.jboss.messaging.util.JBMThreadFactory;
+import org.jboss.messaging.util.OrderedExecutorFactory;
import org.jboss.messaging.util.SimpleString;
/**
@@ -53,7 +54,11 @@
private final String directory;
- private final ExecutorService executor;
+ private final ExecutorService parentExecutor;
+
+ private final OrderedExecutorFactory executorFactory;
+
+ private final Executor globalDepagerExecutor;
private PagingManager pagingManager;
@@ -69,40 +74,39 @@
{
this.directory = directory;
- executor = Executors.newCachedThreadPool(new JBMThreadFactory("JBM-depaging-threads"));
+ parentExecutor = Executors.newCachedThreadPool(new JBMThreadFactory("JBM-depaging-threads"));
+
+ executorFactory = new OrderedExecutorFactory(parentExecutor);
+
+ globalDepagerExecutor = executorFactory.getExecutor();
}
// Public --------------------------------------------------------
- public Executor getPagingExecutor()
+ public Executor getGlobalDepagerExecutor()
{
- return executor;
+ return globalDepagerExecutor;
}
public void stop() throws InterruptedException
{
- executor.shutdown();
+ parentExecutor.shutdown();
- executor.awaitTermination(30, TimeUnit.SECONDS);
+ parentExecutor.awaitTermination(30, TimeUnit.SECONDS);
}
public PagingStore newStore(final SimpleString destinationName, final QueueSettings settings)
{
- // FIXME: This directory creation should be done inside PagingStoreImpl::start, or this method should be made
- // synchornized
- final String destinationDirectory = directory + "/" + destinationName.toString();
+
+ final String destinationDirectory = directory + "/" + Base64.encodeBytes(destinationName.getData(), Base64.URL_SAFE);
- File destinationFile = new File(destinationDirectory);
-
- destinationFile.mkdirs();
-
return new PagingStoreImpl(pagingManager,
storageManager,
postOffice,
newFileFactory(destinationDirectory),
destinationName,
settings,
- executor);
+ executorFactory.getExecutor());
}
public void setPagingManager(final PagingManager pagingManager)
Modified: trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -26,8 +26,7 @@
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.ReadWriteLock;
@@ -65,7 +64,7 @@
// Attributes ----------------------------------------------------
private final StorageManager storageManager;
-
+
private final PostOffice postOffice;
private final DecimalFormat format = new DecimalFormat("000000000");
@@ -86,7 +85,7 @@
private final PagingManager pagingManager;
- private final ExecutorService executor;
+ private final Executor executor;
// Bytes consumed by the queue on the memory
private final AtomicLong sizeInBytes = new AtomicLong();
@@ -126,7 +125,6 @@
log.info(message);
}
-
// Constructors --------------------------------------------------
public PagingStoreImpl(final PagingManager pagingManager,
@@ -135,36 +133,36 @@
final SequentialFileFactory fileFactory,
final SimpleString storeName,
final QueueSettings queueSettings,
- final ExecutorService executor)
+ final Executor executor)
{
if (pagingManager == null)
{
throw new IllegalStateException("Paging Manager can't be null");
}
-
+
this.storageManager = storageManager;
-
+
this.postOffice = postOffice;
-
+
this.fileFactory = fileFactory;
-
+
this.storeName = storeName;
-
+
maxSize = queueSettings.getMaxSizeBytes();
-
+
if (queueSettings.getPageSizeBytes() != null)
{
this.pageSize = queueSettings.getPageSizeBytes();
- }
+ }
else
{
this.pageSize = pagingManager.getDefaultPageSize();
}
dropMessagesWhenFull = queueSettings.isDropMessagesWhenFull();
-
+
this.executor = executor;
-
+
this.pagingManager = pagingManager;
}
@@ -221,29 +219,29 @@
* @return
* @throws Exception
*/
- //FIXME - why is this public?
+ // FIXME - why is this public?
public boolean readPage() throws Exception
{
Page page = depage();
-
+
if (page == null)
{
if (lastPageRecord != null)
{
clearLastPageRecord(lastPageRecord);
}
-
+
lastPageRecord = null;
-
+
return false;
}
-
+
page.open();
-
+
PagedMessage messages[] = page.read();
-
+
boolean addressNotFull = onDepage(page.getPageId(), storeName, messages);
-
+
page.delete();
return addressNotFull;
@@ -257,7 +255,7 @@
public Page depage() throws Exception
{
writeLock.lock();
- currentPageLock.writeLock().lock(); // Make sure no checks are done on currentPage while we are depaging
+ currentPageLock.writeLock().lock(); // Make sure no checks are done on currentPage while we are depaging
try
{
@@ -315,7 +313,6 @@
}
-
public long addSize(final long size) throws Exception
{
final long maxSize = getMaxSizeBytes();
@@ -326,12 +323,13 @@
{
// if destination configured to drop messages && size is over the
// limit, we return -1 which means drop the message
- if (getAddressSize() + size > maxSize || pagingManager.getMaxGlobalSize() > 0 && pagingManager.getGlobalSize() + size > pagingManager.getMaxGlobalSize())
+ if (getAddressSize() + size > maxSize || pagingManager.getMaxGlobalSize() > 0 &&
+ pagingManager.getGlobalSize() + size > pagingManager.getMaxGlobalSize())
{
if (!printedDropMessagesWarning)
{
printedDropMessagesWarning = true;
-
+
log.warn("Messages are being dropped on adress " + getStoreName());
}
@@ -345,17 +343,17 @@
else
{
final long currentGlobalSize = pagingManager.addGlobalSize(size);
-
+
final long maxGlobalSize = pagingManager.getMaxGlobalSize();
final long addressSize = addAddressSize(size);
-
+
if (size > 0)
{
if (maxGlobalSize > 0 && currentGlobalSize > maxGlobalSize)
{
pagingManager.setGlobalPageMode(true);
-
+
if (startPaging())
{
if (isTrace)
@@ -410,18 +408,23 @@
}
}
-
public boolean page(final PagedMessage message) throws Exception
{
+
+ if (!running)
+ {
+ throw new IllegalStateException ("PagingStore(" + this.getStoreName() + ") not initialized");
+ }
+
// Max-size is set, but reject is activated, what means.. never page on
// this address
if (dropMessagesWhenFull)
{
return false;
}
-
+
currentPageLock.readLock().lock();
-
+
try
{
// First check done concurrently, to avoid synchronization and increase throughput
@@ -435,7 +438,6 @@
currentPageLock.readLock().unlock();
}
-
writeLock.lock();
try
@@ -461,7 +463,7 @@
currentPageLock.writeLock().unlock();
}
}
-
+
currentPageLock.readLock().lock();
try
@@ -505,8 +507,14 @@
}
}
+
public boolean startDepaging()
{
+ return startDepaging(executor);
+ }
+
+ public boolean startDepaging(Executor executor)
+ {
currentPageLock.readLock().lock();
try
{
@@ -520,7 +528,7 @@
{
if (dequeueThread == null)
{
- dequeueThread = new DepageRunnable();
+ dequeueThread = new DepageRunnable(executor);
executor.execute(dequeueThread);
return true;
}
@@ -564,10 +572,7 @@
try
{
running = false;
-
- executor.shutdown();
- executor.awaitTermination(60, TimeUnit.SECONDS);
-
+
if (currentPage != null)
{
currentPage.close();
@@ -581,60 +586,79 @@
}
}
- public synchronized void start() throws Exception
+ public void start() throws Exception
{
- if (running)
+ writeLock.lock();
+
+ try
{
- // don't throw an exception.
- // You could have two threads adding PagingStore to a
- // ConcurrentHashMap,
- // and having both threads calling init. One of the calls should just
- // need to be ignored
- return;
- }
- currentPageLock.writeLock().lock();
+ if (running)
+ {
+ // don't throw an exception.
+ // You could have two threads adding PagingStore to a
+ // ConcurrentHashMap,
+ // and having both threads calling init. One of the calls should just
+ // need to be ignored
+ return;
+ }
+ else
+ {
+ currentPageLock.writeLock().lock();
+
+ fileFactory.createDirs();
- firstPageId = Integer.MAX_VALUE;
- currentPageId = 0;
- currentPage = null;
+ firstPageId = Integer.MAX_VALUE;
+ currentPageId = 0;
+ currentPage = null;
- try
- {
- List<String> files = fileFactory.listFiles("page");
+ try
+ {
+ List<String> files = fileFactory.listFiles("page");
- numberOfPages = files.size();
+ numberOfPages = files.size();
- for (String fileName : files)
- {
- final int fileId = getPageIdFromFileName(fileName);
+ for (String fileName : files)
+ {
+ final int fileId = getPageIdFromFileName(fileName);
- if (fileId > currentPageId)
- {
- currentPageId = fileId;
+ if (fileId > currentPageId)
+ {
+ currentPageId = fileId;
+ }
+
+ if (fileId < firstPageId)
+ {
+ firstPageId = fileId;
+ }
+ }
+
+ running = true;
+
+ if (numberOfPages != 0)
+ {
+ startPaging();
+ }
}
-
- if (fileId < firstPageId)
+ finally
{
- firstPageId = fileId;
+ currentPageLock.writeLock().unlock();
}
}
-
- running = true;
-
- if (numberOfPages != 0)
- {
- startPaging();
- }
}
finally
{
- currentPageLock.writeLock().unlock();
+ writeLock.unlock();
}
}
public boolean startPaging() throws Exception
{
+ if (!running)
+ {
+ return false;
+ }
+
// First check without any global locks.
// (Faster)
currentPageLock.readLock().lock();
@@ -659,7 +683,7 @@
if (currentPage == null)
{
openNewPage();
-
+
return true;
}
else
@@ -672,8 +696,6 @@
writeLock.unlock();
}
}
-
-
// TestSupportPageStore ------------------------------------------
@@ -687,8 +709,7 @@
// Protected -----------------------------------------------------
// Private -------------------------------------------------------
-
-
+
/**
* This method will remove files from the page system and and route them, doing it transactionally
*
@@ -696,10 +717,8 @@
*
* If persistent messages are also used, it will update eventual PageTransactions
*/
-
- private boolean onDepage(final int pageId,
- final SimpleString destination,
- final PagedMessage[] data) throws Exception
+
+ private boolean onDepage(final int pageId, final SimpleString destination, final PagedMessage[] data) throws Exception
{
trace("Depaging....");
@@ -712,7 +731,7 @@
if (lastPage == null)
{
lastPage = new LastPageRecordImpl(pageId, destination);
-
+
setLastPageRecord(lastPage);
}
else
@@ -725,7 +744,7 @@
}
lastPage.setLastId(pageId);
-
+
storageManager.storeLastPage(depageTransactionID, lastPage);
HashSet<PageTransactionInfo> pageTransactionsToUpdate = new HashSet<PageTransactionInfo>();
@@ -739,10 +758,10 @@
pagedMessage = (ServerMessage)msg.getMessage(storageManager);
final long transactionIdDuringPaging = msg.getTransactionID();
-
+
if (transactionIdDuringPaging >= 0)
{
- final PageTransactionInfo pageTransactionInfo = pagingManager.getTransaction(transactionIdDuringPaging);
+ final PageTransactionInfo pageTransactionInfo = pagingManager.getTransaction(transactionIdDuringPaging);
// http://wiki.jboss.org/wiki/JBossMessaging2Paging
// This is the Step D described on the "Transactions on Paging"
@@ -819,7 +838,6 @@
}
-
private long addAddressSize(final long delta)
{
return sizeInBytes.addAndGet(delta);
@@ -837,7 +855,7 @@
try
{
numberOfPages++;
-
+
currentPageId++;
if (currentPageId < firstPageId)
@@ -865,14 +883,14 @@
public void clearLastPageRecord(final LastPageRecord lastRecord) throws Exception
{
trace("Clearing lastRecord information " + lastRecord.getLastId());
-
+
storageManager.storeDelete(lastRecord.getRecordId());
}
private Page createPage(final int page) throws Exception
{
String fileName = createFileName(page);
-
+
SequentialFile file = fileFactory.createSequentialFile(fileName, 1000);
file.open();
@@ -912,28 +930,34 @@
private class DepageRunnable implements Runnable
{
- public DepageRunnable()
+ private final Executor followingExecutor;
+
+ public DepageRunnable(Executor followingExecutor)
{
+ this.followingExecutor = followingExecutor;
}
public void run()
{
try
{
- boolean needMorePages = true;
- while (needMorePages && running)
+ if (running)
{
- needMorePages = readPage();
+ boolean needMorePages = readPage();
+ if (needMorePages)
+ {
+ followingExecutor.execute(this);
+ }
+ else
+ {
+ clearDequeueThread();
+ }
}
}
catch (Exception e)
{
log.error(e, e);
}
- finally
- {
- clearDequeueThread();
- }
}
}
}
Modified: trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -502,26 +502,8 @@
storageManager.loadMessages(this, queues, resourceManager);
+ pagingManager.startGlobalDepage();
- // If Paging was interrupted due a server stop, during restart we need to resume depaging those addresses
- for (SimpleString destination : addressManager.getMappings().keySet())
- {
- PagingStore store = pagingManager.getPageStore(destination);
-
- // FIXME this should be changed as soon as we change the threading model
- if (!pagingManager.isGlobalPageMode())
- {
- if (store.isPaging() && store.getMaxSizeBytes() < 0)
- {
- pagingManager.setGlobalPageMode(true);
- }
- else
- {
- store.startDepaging();
- }
- }
- }
-
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/asyncio/AIOTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/asyncio/AIOTestBase.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/asyncio/AIOTestBase.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -30,7 +30,6 @@
import org.jboss.messaging.core.asyncio.AIOCallback;
import org.jboss.messaging.core.asyncio.impl.AsynchronousFileImpl;
import org.jboss.messaging.tests.util.UnitTestCase;
-import org.jboss.messaging.util.UUIDGenerator;
/**
* The base class for AIO Tests
@@ -41,16 +40,15 @@
{
// The AIO Test must use a local filesystem. Sometimes $HOME is on a NFS on
// most enterprise systems
- protected String fileDir = System.getProperty("java.io.tmpdir", "/tmp") + "/journal-test-" + UUIDGenerator.getInstance().generateSimpleStringUUID().toString();
- protected String FILE_NAME = fileDir + "/fileUsedOnNativeTests.log";
+ protected String FILE_NAME = getTestDir() + "/fileUsedOnNativeTests.log";
@Override
protected void setUp() throws Exception
{
super.setUp();
- File file = new File(fileDir);
+ File file = new File(getTestDir());
deleteDirectory(file);
@@ -70,7 +68,6 @@
{
super.tearDown();
assertEquals(0, AsynchronousFileImpl.getTotalMaxIO());
- deleteDirectory(new File(fileDir));
}
protected void encodeBufer(final ByteBuffer buffer)
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/ChunkTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/ChunkTestBase.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/ChunkTestBase.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -81,7 +81,6 @@
protected void tearDown() throws Exception
{
super.tearDown();
- deleteData();
}
protected void testChunks(final boolean realFiles,
@@ -136,7 +135,7 @@
if (useFile)
{
- File tmpData = createLargeFile(temporaryDir, "someFile.dat", numberOfIntegers);
+ File tmpData = createLargeFile(getTemporaryDir(), "someFile.dat", numberOfIntegers);
for (int i = 0; i < numberOfMessages; i++)
{
@@ -208,7 +207,7 @@
if (realFiles)
{
- consumer = session.createFileConsumer(new File(clientLargeMessagesDir), ADDRESS);
+ consumer = session.createFileConsumer(new File(getClientLargeMessagesDir()), ADDRESS);
}
else
{
@@ -307,7 +306,7 @@
ClientFileMessage clientMessage = session.createFileMessage(true);
- File tmpFile = createLargeFile(temporaryDir, "tmpUpload.data", numberOfIntegers);
+ File tmpFile = createLargeFile(getTemporaryDir(), "tmpUpload.data", numberOfIntegers);
clientMessage.setFile(tmpFile);
@@ -372,7 +371,7 @@
{
session.start();
- ClientConsumer consumer = session.createFileConsumer(new File(clientLargeMessagesDir), queueToRead);
+ ClientConsumer consumer = session.createFileConsumer(new File(getClientLargeMessagesDir()), queueToRead);
ClientMessage clientMessage = consumer.receive(5000);
@@ -440,7 +439,7 @@
*/
protected void validateNoFilesOnLargeDir() throws Exception
{
- File largeMessagesFileDir = new File(largeMessagesDir);
+ File largeMessagesFileDir = new File(getLargeMessagesDir());
// Deleting the file is async... we keep looking for a period of the time until the file is really gone
for (int i = 0; i < 100; i++)
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/MessageChunkTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/MessageChunkTest.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/MessageChunkTest.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -81,7 +81,7 @@
{
clearData();
- createLargeFile(largeMessagesDir, "1234.tmp", 13333);
+ createLargeFile(getLargeMessagesDir(), "1234.tmp", 13333);
Configuration config = createDefaultConfig();
@@ -92,7 +92,7 @@
try
{
- File directoryLarge = new File(largeMessagesDir);
+ File directoryLarge = new File(getLargeMessagesDir());
assertEquals(0, directoryLarge.list().length);
}
@@ -199,7 +199,7 @@
{
clearData();
- File file = createLargeFile(temporaryDir, "test.tst", 13333);
+ File file = createLargeFile(getTemporaryDir(), "test.tst", 13333);
checkFileRead(file, 13333);
}
@@ -318,7 +318,7 @@
producer.close();
- ClientConsumer consumer = session.createFileConsumer(new File(clientLargeMessagesDir), queue[1]);
+ ClientConsumer consumer = session.createFileConsumer(new File(getClientLargeMessagesDir()), queue[1]);
ClientMessage msg = consumer.receive(5000);
assertNull(consumer.receive(1000));
assertNotNull(msg);
@@ -330,7 +330,7 @@
session.stop();
- ClientConsumer consumer1 = session.createFileConsumer(new File(clientLargeMessagesDir), queue[0]);
+ ClientConsumer consumer1 = session.createFileConsumer(new File(getClientLargeMessagesDir()), queue[0]);
session.start();
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/consumer/ConsumerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/consumer/ConsumerTest.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/consumer/ConsumerTest.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -44,11 +44,12 @@
public class ConsumerTest extends UnitTestCase
{
private static final Logger log = Logger.getLogger(ConsumerTest.class);
-
+
private MessagingService messagingService;
- private SimpleString QUEUE = new SimpleString("ConsumerTestQueue");
+ private final SimpleString QUEUE = new SimpleString("ConsumerTestQueue");
+ @Override
protected void setUp() throws Exception
{
Configuration conf = new ConfigurationImpl();
@@ -63,11 +64,14 @@
messagingService.start();
}
+ @Override
protected void tearDown() throws Exception
{
messagingService.stop();
messagingService = null;
+
+ super.tearDown();
}
public void testSimpleConsumerBrowser() throws Exception
@@ -346,7 +350,7 @@
session.close();
}
-
+
public void testSetMessageHandlerWithMessagesPending() throws Exception
{
ClientSessionFactory sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"));
@@ -366,13 +370,13 @@
}
ClientConsumer consumer = session.createConsumer(QUEUE, null, true);
-
+
session.start();
-
+
Thread.sleep(100);
-
- //Message should be in consumer
-
+
+ // Message should be in consumer
+
class MyHandler implements MessageHandler
{
public void onMessage(final ClientMessage message)
@@ -380,29 +384,29 @@
try
{
Thread.sleep(10);
-
+
message.acknowledge();
}
catch (Exception e)
- {
- }
- }
+ {
+ }
+ }
}
-
+
consumer.setMessageHandler(new MyHandler());
-
- //Let a few messages get processed
+
+ // Let a few messages get processed
Thread.sleep(100);
-
- //Now set null
-
+
+ // Now set null
+
consumer.setMessageHandler(null);
-
- //Give a bit of time for some queued executors to run
-
+
+ // Give a bit of time for some queued executors to run
+
Thread.sleep(500);
-
- //Make sure no exceptions were thrown from onMessage
+
+ // Make sure no exceptions were thrown from onMessage
assertNull(consumer.getLastException());
session.close();
@@ -501,7 +505,7 @@
ClientMessage message2 = consumer.receive(1000);
assertEquals("m" + i, message2.getBody().getString());
- if(i < 50)
+ if (i < 50)
{
message2.acknowledge();
}
@@ -513,7 +517,7 @@
session.close();
}
- public void testConsumerAckImmediateCloseSession() throws Exception
+ public void testConsumerAckImmediateCloseSession() throws Exception
{
ClientSessionFactory sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"));
@@ -539,7 +543,7 @@
ClientMessage message2 = consumer.receive(1000);
assertEquals("m" + i, message2.getBody().getString());
- if(i < 50)
+ if (i < 50)
{
message2.acknowledge();
}
@@ -554,7 +558,7 @@
assertEquals(messagingService.getServer().getPostOffice().getBinding(QUEUE).getQueue().getMessageCount(), 0);
}
- private ClientMessage createMessage(ClientSession session, String msg)
+ private ClientMessage createMessage(final ClientSession session, final String msg)
{
ClientMessage message = session.createClientMessage(JBossTextMessage.TYPE,
false,
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/journal/AIOSequentialFileFactoryTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/journal/AIOSequentialFileFactoryTest.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/journal/AIOSequentialFileFactoryTest.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -44,8 +44,6 @@
public class AIOSequentialFileFactoryTest extends SequentialFileFactoryTestBase
{
- protected String journalDir = System.getProperty("java.io.tmpdir", "/tmp") + "/journal-test";
-
@Override
protected void setUp() throws Exception
{
@@ -59,25 +57,23 @@
System.getProperty("os.version")));
}
- File file = new File(journalDir);
+ File file = new File(getTestDir());
deleteDirectory(file);
- file.mkdir();
+ file.mkdirs();
}
@Override
protected void tearDown() throws Exception
{
super.tearDown();
-
- deleteDirectory(new File(journalDir));
}
@Override
protected SequentialFileFactory createFactory()
{
- return new AIOSequentialFileFactory(journalDir);
+ return new AIOSequentialFileFactory(getTestDir());
}
public void testBuffer() throws Exception
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/journal/RealAIOJournalImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/journal/RealAIOJournalImplTest.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/journal/RealAIOJournalImplTest.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -47,9 +47,6 @@
{
private static final Logger log = Logger.getLogger(RealAIOJournalImplTest.class);
- // Need to run the test over a local disk (no NFS)
- protected String journalDir = System.getProperty("java.io.tmpdir", "/tmp") + "/journal-test";
-
@Override
protected void setUp() throws Exception
{
@@ -67,19 +64,18 @@
protected void tearDown() throws Exception
{
super.tearDown();
- deleteDirectory(new File(journalDir));
}
@Override
protected SequentialFileFactory getFileFactory() throws Exception
{
- File file = new File(journalDir);
+ File file = new File(getTestDir());
deleteDirectory(file);
file.mkdir();
- return new AIOSequentialFileFactory(journalDir);
+ return new AIOSequentialFileFactory(getTestDir());
}
@Override
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/paging/PagingIntegrationTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/paging/PagingIntegrationTest.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/paging/PagingIntegrationTest.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -24,8 +24,6 @@
import java.io.File;
-import org.jboss.messaging.core.asyncio.impl.AsynchronousFileImpl;
-import org.jboss.messaging.core.journal.impl.AIOSequentialFileFactory;
import org.jboss.messaging.core.journal.impl.NIOSequentialFileFactory;
import org.jboss.messaging.tests.unit.core.paging.impl.PageImplTestBase;
@@ -41,8 +39,6 @@
// Attributes ----------------------------------------------------
- protected String journalDir = System.getProperty("java.io.tmpdir", "/tmp") + "/journal-test";
-
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
@@ -51,7 +47,7 @@
public void testPageWithNIO() throws Exception
{
- testAdd(new NIOSequentialFileFactory(journalDir), 1000);
+ testAdd(new NIOSequentialFileFactory(getTestDir()), 1000);
}
// Package protected ---------------------------------------------
@@ -62,7 +58,7 @@
protected void setUp() throws Exception
{
super.setUp();
- File fileJournalDir = new File(journalDir);
+ File fileJournalDir = new File(getTestDir());
deleteDirectory(fileJournalDir);
fileJournalDir.mkdirs();
}
@@ -71,7 +67,6 @@
protected void tearDown() throws Exception
{
super.tearDown();
- deleteDirectory(new File(journalDir));
}
// Private -------------------------------------------------------
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/paging/PagingManagerIntegrationTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/paging/PagingManagerIntegrationTest.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/paging/PagingManagerIntegrationTest.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -54,8 +54,6 @@
// Attributes ----------------------------------------------------
- protected String journalDir = System.getProperty("java.io.tmpdir", "/tmp") + "/journal-test2";
-
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
@@ -67,7 +65,7 @@
HierarchicalRepository<QueueSettings> queueSettings = new HierarchicalObjectRepository<QueueSettings>();
queueSettings.setDefault(new QueueSettings());
- PagingManagerImpl managerImpl = new PagingManagerImpl(new PagingStoreFactoryNIO(journalDir),
+ PagingManagerImpl managerImpl = new PagingManagerImpl(new PagingStoreFactoryNIO(getPageDir()),
null,
queueSettings,
-1,
@@ -115,7 +113,7 @@
queueSettings.addMatch("simple-test", simpleTestSettings);
- PagingManagerImpl managerImpl = new PagingManagerImpl(new PagingStoreFactoryNIO(journalDir),
+ PagingManagerImpl managerImpl = new PagingManagerImpl(new PagingStoreFactoryNIO(getJournalDir()),
null,
queueSettings,
-1,
@@ -193,7 +191,7 @@
private void recreateDirectory()
{
- File fileJournalDir = new File(journalDir);
+ File fileJournalDir = new File(getJournalDir());
deleteDirectory(fileJournalDir);
fileJournalDir.mkdirs();
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/paging/PagingStoreIntegrationTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/paging/PagingStoreIntegrationTest.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/paging/PagingStoreIntegrationTest.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -40,8 +40,6 @@
// Attributes ----------------------------------------------------
- protected String journalDir = System.getProperty("java.io.tmpdir", "/tmp") + "/journal-test";
-
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
@@ -57,7 +55,7 @@
System.getProperty("os.arch"),
System.getProperty("os.version")));
}
- testConcurrentPaging(new AIOSequentialFileFactory(journalDir), 10);
+ testConcurrentPaging(new AIOSequentialFileFactory(getTestDir()), 10);
}
public void testPageWithNIO() throws Exception
@@ -67,7 +65,7 @@
{
recreateDirectory();
System.out.println("Test " + i);
- testConcurrentPaging(new NIOSequentialFileFactory(journalDir), 1);
+ testConcurrentPaging(new NIOSequentialFileFactory(getTestDir()), 1);
}
}
@@ -93,7 +91,7 @@
private void recreateDirectory()
{
- File fileJournalDir = new File(journalDir);
+ File fileJournalDir = new File(getTestDir());
deleteDirectory(fileJournalDir);
fileJournalDir.mkdirs();
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/queue/DeadLetterAddressTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/queue/DeadLetterAddressTest.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/queue/DeadLetterAddressTest.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -276,6 +276,7 @@
}
messagingService = null;
clientSession = null;
+ super.tearDown();
}
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/queue/ExpiryAddressTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/queue/ExpiryAddressTest.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/queue/ExpiryAddressTest.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -218,6 +218,8 @@
}
messagingService = null;
clientSession = null;
+
+ super.tearDown();
}
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/queue/ExpiryRunnerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/queue/ExpiryRunnerTest.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/queue/ExpiryRunnerTest.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -338,6 +338,8 @@
}
messagingService = null;
clientSession = null;
+
+ super.tearDown();
}
private static class DummyMessageHandler implements Runnable
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -95,6 +95,7 @@
@Override
protected void setUp() throws Exception
{
+ super.setUp();
Configuration config = createDefaultConfig(true);
messagingService = createService(false, config);
messagingService.start();
@@ -104,6 +105,7 @@
protected void tearDown() throws Exception
{
messagingService.stop();
+ super.tearDown();
}
class Listener implements FailureListener
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/scheduling/ScheduledMessageTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/scheduling/ScheduledMessageTest.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/scheduling/ScheduledMessageTest.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -82,7 +82,7 @@
// ignore
}
}
- deleteData();
+ super.tearDown();
}
public void testRecoveredMessageDeliveredCorrectly() throws Exception
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/xa/BasicXaRecoveryTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/xa/BasicXaRecoveryTest.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/xa/BasicXaRecoveryTest.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -35,8 +35,6 @@
import org.jboss.messaging.core.client.ClientSessionFactory;
import org.jboss.messaging.core.config.Configuration;
import org.jboss.messaging.core.exception.MessagingException;
-import org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory;
-import org.jboss.messaging.core.remoting.spi.ConnectorFactory;
import org.jboss.messaging.core.server.MessagingService;
import org.jboss.messaging.core.settings.impl.QueueSettings;
import org.jboss.messaging.core.transaction.impl.XidImpl;
@@ -52,15 +50,23 @@
*/
public class BasicXaRecoveryTest extends ServiceTestBase
{
- private Map<String, QueueSettings> queueSettings = new HashMap<String, QueueSettings>();
+ private final Map<String, QueueSettings> queueSettings = new HashMap<String, QueueSettings>();
+
private MessagingService messagingService;
+
private ClientSession clientSession;
+
private ClientProducer clientProducer;
+
private ClientConsumer clientConsumer;
+
private ClientSessionFactory sessionFactory;
+
private Configuration configuration;
- private SimpleString atestq = new SimpleString("atestq");
+ private final SimpleString atestq = new SimpleString("atestq");
+
+ @Override
protected void setUp() throws Exception
{
clearData();
@@ -68,17 +74,18 @@
configuration = createDefaultConfig();
configuration.setSecurityEnabled(false);
configuration.setJournalMinFiles(2);
- configuration.setPagingDirectory(pageDir);
+ configuration.setPagingDirectory(getPageDir());
messagingService = createService(true, configuration, queueSettings);
- //start the server
+ // start the server
messagingService.start();
- //then we create a client as normal
+ // then we create a client as normal
createClients(true, false);
}
+ @Override
protected void tearDown() throws Exception
{
if (clientSession != null)
@@ -105,6 +112,8 @@
}
messagingService = null;
clientSession = null;
+
+ super.tearDown();
}
public void testBasicSendWithCommit() throws Exception
@@ -115,7 +124,7 @@
public void testBasicSendWithCommitWithServerStopped() throws Exception
{
- testBasicSendWithCommit(true);
+ testBasicSendWithCommit(true);
}
public void testBasicSendWithRollback() throws Exception
@@ -135,7 +144,7 @@
public void testMultipleBeforeSendWithCommitWithServerStopped() throws Exception
{
- testMultipleBeforeSendWithCommit(true);
+ testMultipleBeforeSendWithCommit(true);
}
public void testMultipleTxSendWithCommit() throws Exception
@@ -215,50 +224,50 @@
public void testMultipleTxReceiveWithRollbackWithServerStopped() throws Exception
{
- testMultipleTxReceiveWithRollback(true);
+ testMultipleTxReceiveWithRollback(true);
}
-
+
public void testPagingServerRestarted() throws Exception
{
testPaging(true);
}
-
+
public void testPaging() throws Exception
{
testPaging(false);
}
-
- public void testPaging(boolean restartServer) throws Exception
+
+ public void testPaging(final boolean restartServer) throws Exception
{
Xid xid = new XidImpl("xa1".getBytes(), 1, new GUID().toString().getBytes());
-
+
SimpleString pageQueue = new SimpleString("pagequeue");
-
+
QueueSettings pageQueueSettings = new QueueSettings();
- pageQueueSettings.setMaxSizeBytes(100*1024);
- pageQueueSettings.setPageSizeBytes(10*1024);
-
+ pageQueueSettings.setMaxSizeBytes(100 * 1024);
+ pageQueueSettings.setPageSizeBytes(10 * 1024);
+
queueSettings.put(pageQueue.toString(), pageQueueSettings);
addSettings();
-
+
clientSession.createQueue(pageQueue, pageQueue, null, true, true, true);
-
+
clientSession.start(xid, XAResource.TMNOFLAGS);
-
+
ClientProducer pageProducer = clientSession.createProducer(pageQueue);
-
+
for (int i = 0; i < 1000; i++)
{
ClientMessage m = createBytesMessage(new byte[512], true);
pageProducer.send(m);
}
-
+
pageProducer.close();
clientSession.end(xid, XAResource.TMSUCCESS);
clientSession.prepare(xid);
-
+
if (restartServer)
{
stopAndRestartServer();
@@ -267,7 +276,7 @@
{
recreateClients();
}
-
+
Xid[] xids = clientSession.recover(XAResource.TMSTARTRSCAN);
assertEquals(xids.length, 1);
assertEquals(xids[0].getFormatId(), xid.getFormatId());
@@ -277,11 +286,11 @@
clientSession.commit(xid, true);
clientSession.close();
-
+
clientSession = sessionFactory.createSession(false, false, false);
clientSession.start();
-
+
ClientConsumer pageConsumer = clientSession.createConsumer(pageQueue);
for (int i = 0; i < 1000; i++)
@@ -290,40 +299,40 @@
assertNotNull(m);
m.acknowledge();
clientSession.commit();
- }
-
+ }
+
}
-
+
public void testRollbackPaging() throws Exception
{
testRollbackPaging(false);
}
-
+
public void testRollbackPagingServerRestarted() throws Exception
{
testRollbackPaging(true);
}
-
- public void testRollbackPaging(boolean restartServer) throws Exception
+
+ public void testRollbackPaging(final boolean restartServer) throws Exception
{
- Xid xid = new XidImpl("xa1".getBytes(), 1, new GUID().toString().getBytes());
-
+ Xid xid = new XidImpl("xa1".getBytes(), 1, new GUID().toString().getBytes());
+
SimpleString pageQueue = new SimpleString("pagequeue");
-
+
QueueSettings pageQueueSettings = new QueueSettings();
- pageQueueSettings.setMaxSizeBytes(100*1024);
- pageQueueSettings.setPageSizeBytes(10*1024);
-
+ pageQueueSettings.setMaxSizeBytes(100 * 1024);
+ pageQueueSettings.setPageSizeBytes(10 * 1024);
+
queueSettings.put(pageQueue.toString(), pageQueueSettings);
addSettings();
-
+
clientSession.createQueue(pageQueue, pageQueue, null, true, true, true);
-
+
clientSession.start(xid, XAResource.TMNOFLAGS);
-
+
ClientProducer pageProducer = clientSession.createProducer(pageQueue);
-
+
for (int i = 0; i < 1000; i++)
{
ClientMessage m = createBytesMessage(new byte[512], true);
@@ -332,7 +341,7 @@
clientSession.end(xid, XAResource.TMSUCCESS);
clientSession.prepare(xid);
-
+
if (restartServer)
{
stopAndRestartServer();
@@ -341,7 +350,7 @@
{
recreateClients();
}
-
+
Xid[] xids = clientSession.recover(XAResource.TMSTARTRSCAN);
assertEquals(1, xids.length);
assertEquals(xids[0].getFormatId(), xid.getFormatId());
@@ -355,16 +364,15 @@
ClientConsumer pageConsumer = clientSession.createConsumer(pageQueue);
assertNull(pageConsumer.receive(100));
-
+
}
-
+
public void testNonPersistent() throws Exception
{
testNonPersistent(true);
testNonPersistent(false);
}
-
public void testNonPersistent(final boolean commit) throws Exception
{
Xid xid = new XidImpl("xa1".getBytes(), 1, new GUID().toString().getBytes());
@@ -401,7 +409,7 @@
clientSession.rollback(xid);
}
}
-
+
public void testNonPersistentMultipleIDs() throws Exception
{
for (int i = 0; i < 10; i++)
@@ -412,7 +420,7 @@
ClientMessage m2 = createTextMessage("m2", false);
ClientMessage m3 = createTextMessage("m3", false);
ClientMessage m4 = createTextMessage("m4", false);
-
+
clientSession.start(xid, XAResource.TMNOFLAGS);
clientProducer.send(m1);
clientProducer.send(m2);
@@ -420,15 +428,14 @@
clientProducer.send(m4);
clientSession.end(xid, XAResource.TMSUCCESS);
clientSession.prepare(xid);
-
+
if (i == 2)
{
clientSession.commit(xid, true);
}
-
+
recreateClients();
-
-
+
}
stopAndRestartServer();
@@ -437,8 +444,8 @@
assertEquals(9, xids.length);
}
-
- public void testBasicSendWithCommit(boolean stopServer) throws Exception
+
+ public void testBasicSendWithCommit(final boolean stopServer) throws Exception
{
Xid xid = new XidImpl("xa1".getBytes(), 1, new GUID().toString().getBytes());
@@ -469,10 +476,10 @@
assertEquals(xids[0].getFormatId(), xid.getFormatId());
assertEqualsByteArrays(xids[0].getBranchQualifier(), xid.getBranchQualifier());
assertEqualsByteArrays(xids[0].getGlobalTransactionId(), xid.getGlobalTransactionId());
-
+
xids = clientSession.recover(XAResource.TMENDRSCAN);
assertEquals(xids.length, 0);
-
+
clientSession.commit(xid, true);
clientSession.start();
ClientMessage m = clientConsumer.receive(1000);
@@ -489,7 +496,7 @@
assertEquals(m.getBody().getString(), "m4");
}
- public void testBasicSendWithRollback(boolean stopServer) throws Exception
+ public void testBasicSendWithRollback(final boolean stopServer) throws Exception
{
Xid xid = new XidImpl("xa1".getBytes(), 1, new GUID().toString().getBytes());
@@ -529,7 +536,7 @@
assertNull(m);
}
- public void testMultipleBeforeSendWithCommit(boolean stopServer) throws Exception
+ public void testMultipleBeforeSendWithCommit(final boolean stopServer) throws Exception
{
Xid xid = new XidImpl("xa1".getBytes(), 1, new GUID().toString().getBytes());
ClientMessage m1 = createTextMessage("m1");
@@ -588,7 +595,7 @@
assertEquals(m.getBody().getString(), "m8");
}
- public void testMultipleTxSendWithCommit(boolean stopServer) throws Exception
+ public void testMultipleTxSendWithCommit(final boolean stopServer) throws Exception
{
Xid xid = new XidImpl("xa1".getBytes(), 1, new GUID().toString().getBytes());
Xid xid2 = new XidImpl("xa2".getBytes(), 1, new GUID().toString().getBytes());
@@ -662,7 +669,7 @@
assertEquals(m.getBody().getString(), "m4");
}
- public void testMultipleTxSendWithRollback(boolean stopServer) throws Exception
+ public void testMultipleTxSendWithRollback(final boolean stopServer) throws Exception
{
Xid xid = new XidImpl("xa1".getBytes(), 1, new GUID().toString().getBytes());
Xid xid2 = new XidImpl("xa2".getBytes(), 1, new GUID().toString().getBytes());
@@ -714,7 +721,7 @@
assertNull(m);
}
- public void testMultipleTxSendWithCommitAndRollback(boolean stopServer) throws Exception
+ public void testMultipleTxSendWithCommitAndRollback(final boolean stopServer) throws Exception
{
Xid xid = new XidImpl("xa1".getBytes(), 1, new GUID().toString().getBytes());
Xid xid2 = new XidImpl("xa2".getBytes(), 1, new GUID().toString().getBytes());
@@ -778,7 +785,7 @@
assertNull(m);
}
- public void testMultipleTxSameXidSendWithCommit(boolean stopServer) throws Exception
+ public void testMultipleTxSameXidSendWithCommit(final boolean stopServer) throws Exception
{
Xid xid = new XidImpl("xa1".getBytes(), 1, new GUID().toString().getBytes());
ClientMessage m1 = createTextMessage("m1");
@@ -851,7 +858,7 @@
assertEquals(m.getBody().getString(), "m8");
}
- public void testBasicReceiveWithCommit(boolean stopServer) throws Exception
+ public void testBasicReceiveWithCommit(final boolean stopServer) throws Exception
{
Xid xid = new XidImpl("xa1".getBytes(), 1, new GUID().toString().getBytes());
ClientMessage m1 = createTextMessage("m1");
@@ -909,7 +916,7 @@
assertNull(m);
}
- public void testBasicReceiveWithRollback(boolean stopServer) throws Exception
+ public void testBasicReceiveWithRollback(final boolean stopServer) throws Exception
{
Xid xid = new XidImpl("xa1".getBytes(), 1, new GUID().toString().getBytes());
ClientMessage m1 = createTextMessage("m1");
@@ -977,7 +984,7 @@
assertEquals(m.getBody().getString(), "m4");
}
- public void testMultipleTxReceiveWithCommit(boolean stopServer) throws Exception
+ public void testMultipleTxReceiveWithCommit(final boolean stopServer) throws Exception
{
Xid xid = new XidImpl("xa1".getBytes(), 1, new GUID().toString().getBytes());
Xid xid2 = new XidImpl("xa2".getBytes(), 1, new GUID().toString().getBytes());
@@ -1022,7 +1029,7 @@
m = clientConsumer2.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBody().getString(), "m8");
+ assertEquals(m.getBody().getString(), "m8");
clientSession2.end(xid2, XAResource.TMSUCCESS);
clientSession2.prepare(xid2);
clientSession2.close();
@@ -1067,7 +1074,7 @@
assertNull(m);
}
- public void testMultipleTxReceiveWithRollback(boolean stopServer) throws Exception
+ public void testMultipleTxReceiveWithRollback(final boolean stopServer) throws Exception
{
Xid xid = new XidImpl("xa1".getBytes(), 1, new GUID().toString().getBytes());
Xid xid2 = new XidImpl("xa2".getBytes(), 1, new GUID().toString().getBytes());
@@ -1138,7 +1145,7 @@
clientSession.end(xid, XAResource.TMSUCCESS);
clientSession.prepare(xid);
- if (stopServer)
+ if (stopServer)
{
stopAndRestartServer();
}
@@ -1173,20 +1180,20 @@
protected void stopAndRestartServer() throws Exception
{
- //now stop and start the server
+ // now stop and start the server
clientSession.close();
clientSession = null;
messagingService.stop();
messagingService = null;
messagingService = createService(true, configuration, queueSettings);
-
+
messagingService.start();
createClients();
}
private void addSettings()
{
- for (Map.Entry<String, QueueSettings> setting: this.queueSettings.entrySet())
+ for (Map.Entry<String, QueueSettings> setting : queueSettings.entrySet())
{
messagingService.getServer().getQueueSettingsRepository().addMatch(setting.getKey(), setting.getValue());
}
@@ -1199,22 +1206,30 @@
createClients();
}
- private ClientMessage createTextMessage(String s)
+ private ClientMessage createTextMessage(final String s)
{
return createTextMessage(s, true);
}
- private ClientMessage createTextMessage(String s, boolean durable)
+ private ClientMessage createTextMessage(final String s, final boolean durable)
{
- ClientMessage message = clientSession.createClientMessage(JBossTextMessage.TYPE, durable, 0, System.currentTimeMillis(), (byte) 1);
+ ClientMessage message = clientSession.createClientMessage(JBossTextMessage.TYPE,
+ durable,
+ 0,
+ System.currentTimeMillis(),
+ (byte)1);
message.getBody().putString(s);
message.getBody().flip();
return message;
}
- private ClientMessage createBytesMessage(byte[] b, boolean durable)
+ private ClientMessage createBytesMessage(final byte[] b, final boolean durable)
{
- ClientMessage message = clientSession.createClientMessage(JBossBytesMessage.TYPE, durable, 0, System.currentTimeMillis(), (byte) 1);
+ ClientMessage message = clientSession.createClientMessage(JBossBytesMessage.TYPE,
+ durable,
+ 0,
+ System.currentTimeMillis(),
+ (byte)1);
message.getBody().putBytes(b);
message.getBody().flip();
return message;
@@ -1225,8 +1240,7 @@
createClients(false, true);
}
- private void createClients(boolean createQueue, boolean commitACKs)
- throws MessagingException
+ private void createClients(final boolean createQueue, final boolean commitACKs) throws MessagingException
{
sessionFactory = createInVMFactory();
@@ -1238,8 +1252,8 @@
clientProducer = clientSession.createProducer(atestq);
clientConsumer = clientSession.createConsumer(atestq);
}
-
- private void assertEqualXids(Xid[] xids, Xid... origXids)
+
+ private void assertEqualXids(final Xid[] xids, final Xid... origXids)
{
assertEquals(xids.length, origXids.length);
for (Xid xid : xids)
@@ -1248,7 +1262,7 @@
for (Xid origXid : origXids)
{
found = Arrays.equals(origXid.getBranchQualifier(), xid.getBranchQualifier());
- if(found)
+ if (found)
{
assertEquals(xid.getFormatId(), origXid.getFormatId());
assertEqualsByteArrays(xid.getBranchQualifier(), origXid.getBranchQualifier());
@@ -1256,7 +1270,7 @@
break;
}
}
- if(!found)
+ if (!found)
{
fail("correct xid not found: " + xid);
}
Modified: trunk/tests/src/org/jboss/messaging/tests/performance/paging/MeasurePagingMultiThreadTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/performance/paging/MeasurePagingMultiThreadTest.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/tests/src/org/jboss/messaging/tests/performance/paging/MeasurePagingMultiThreadTest.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -62,15 +62,13 @@
// Public --------------------------------------------------------
@Override
- public void tearDown() throws Exception
+ protected void tearDown() throws Exception
{
super.tearDown();
-
- deleteData();
}
@Override
- public void setUp() throws Exception
+ protected void setUp() throws Exception
{
super.setUp();
clearData();
Modified: trunk/tests/src/org/jboss/messaging/tests/stress/journal/AddAndRemoveStressTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/stress/journal/AddAndRemoveStressTest.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/tests/src/org/jboss/messaging/tests/stress/journal/AddAndRemoveStressTest.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -20,10 +20,8 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-
package org.jboss.messaging.tests.stress.journal;
-
import java.io.File;
import java.util.ArrayList;
@@ -43,55 +41,49 @@
*/
public class AddAndRemoveStressTest extends UnitTestCase
{
-
- protected String journalDir = System.getProperty("java.io.tmpdir", "/tmp") + "/journal-test";
-
+
// Constants -----------------------------------------------------
- private static final LoadManager dummyLoader = new LoadManager(){
+ private static final LoadManager dummyLoader = new LoadManager()
+ {
- public void addPreparedTransaction(
- PreparedTransactionInfo preparedTransaction)
+ public void addPreparedTransaction(final PreparedTransactionInfo preparedTransaction)
{
}
- public void addRecord(RecordInfo info)
+ public void addRecord(final RecordInfo info)
{
}
- public void deleteRecord(long id)
+ public void deleteRecord(final long id)
{
}
- public void updateRecord(RecordInfo info)
+ public void updateRecord(final RecordInfo info)
{
- }};
-
+ }
+ };
private static final long NUMBER_OF_MESSAGES = 210000l;
-
+
// Attributes ----------------------------------------------------
-
+
// Static --------------------------------------------------------
-
+
// Constructors --------------------------------------------------
-
+
// Public --------------------------------------------------------
-
+
public void testInsertAndLoad() throws Exception
{
-
- File file = new File(journalDir);
- deleteDirectory(file);
- file.mkdirs();
-
- SequentialFileFactory factory = new AIOSequentialFileFactory(journalDir);
- JournalImpl impl = new JournalImpl(10*1024*1024, 60, true, false, factory, "jbm", "jbm", 1000, 0);
+ SequentialFileFactory factory = new AIOSequentialFileFactory(getTestDir());
+ JournalImpl impl = new JournalImpl(10 * 1024 * 1024, 60, true, false, factory, "jbm", "jbm", 1000, 0);
+
impl.start();
-
+
impl.load(dummyLoader);
-
+
for (long i = 1; i <= NUMBER_OF_MESSAGES; i++)
{
if (i % 10000 == 0)
@@ -100,15 +92,14 @@
}
impl.appendAddRecord(i, (byte)0, new SimpleEncoding(1024, (byte)'f'));
}
-
+
impl.stop();
-
-
- factory = new AIOSequentialFileFactory(journalDir);
- impl = new JournalImpl(10*1024*1024, 60, true, false, factory, "jbm", "jbm", 1000, 0);
+ factory = new AIOSequentialFileFactory(getTestDir());
+ impl = new JournalImpl(10 * 1024 * 1024, 60, true, false, factory, "jbm", "jbm", 1000, 0);
+
impl.start();
-
+
impl.load(dummyLoader);
for (long i = 1; i <= NUMBER_OF_MESSAGES; i++)
@@ -117,25 +108,22 @@
{
System.out.println("Delete " + i);
}
-
+
impl.appendDeleteRecord(i);
}
-
+
impl.stop();
-
- factory = new AIOSequentialFileFactory(journalDir);
- impl = new JournalImpl(10*1024*1024, 60, true, false, factory, "jbm", "jbm", 1000, 0);
+ factory = new AIOSequentialFileFactory(getTestDir());
+ impl = new JournalImpl(10 * 1024 * 1024, 60, true, false, factory, "jbm", "jbm", 1000, 0);
+
impl.start();
-
-
ArrayList<RecordInfo> info = new ArrayList<RecordInfo>();
- ArrayList<PreparedTransactionInfo> trans = new ArrayList<PreparedTransactionInfo>();
-
+ ArrayList<PreparedTransactionInfo> trans = new ArrayList<PreparedTransactionInfo>();
+
impl.load(info, trans);
-
if (info.size() > 0)
{
System.out.println("Info ID: " + info.get(0).id);
@@ -143,16 +131,29 @@
assertEquals(0, info.size());
assertEquals(0, trans.size());
-
-
+
}
-
+
// Package protected ---------------------------------------------
-
+
// Protected -----------------------------------------------------
-
+
+ @Override
+ protected void setUp()
+ {
+ File file = new File(getTestDir());
+ deleteDirectory(file);
+ file.mkdirs();
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
// Private -------------------------------------------------------
-
+
// Inner classes -------------------------------------------------
-
+
}
Modified: trunk/tests/src/org/jboss/messaging/tests/stress/journal/ValidateTransactionHealthTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/stress/journal/ValidateTransactionHealthTest.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/tests/src/org/jboss/messaging/tests/stress/journal/ValidateTransactionHealthTest.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -43,71 +43,89 @@
*/
public class ValidateTransactionHealthTest extends UnitTestCase
{
-
+
// Constants -----------------------------------------------------
-
+
// Attributes ----------------------------------------------------
- protected String journalDir = System.getProperty("java.io.tmpdir", "/tmp") + "/journal-test";
// Static --------------------------------------------------------
-
+
// Constructors --------------------------------------------------
-
+
// Public --------------------------------------------------------
-
+
public void testAIO() throws Exception
{
- internalTest("aio", journalDir, 10000, 100, true, true, 1);
+ internalTest("aio", getTestDir(), 10000, 100, true, true, 1);
}
-
+
public void testAIOHugeTransaction() throws Exception
{
- internalTest("aio", journalDir, 10000, 10000, true, true, 1);
+ internalTest("aio", getTestDir(), 10000, 10000, true, true, 1);
}
-
+
public void testAIOMultiThread() throws Exception
{
- internalTest("aio", journalDir, 1000, 100, true, true, 10);
+ internalTest("aio", getTestDir(), 1000, 100, true, true, 10);
}
-
+
public void testAIONonTransactional() throws Exception
{
- internalTest("aio", journalDir, 10000, 0, true, true, 1);
+ internalTest("aio", getTestDir(), 10000, 0, true, true, 1);
}
-
+
public void testAIONonTransactionalNoExternalProcess() throws Exception
{
- internalTest("aio", journalDir, 1000, 0, true, false, 10);
+ internalTest("aio", getTestDir(), 1000, 0, true, false, 10);
}
-
+
public void testNIO() throws Exception
{
- internalTest("nio", journalDir, 10000, 100, true, true, 1);
+ internalTest("nio", getTestDir(), 10000, 100, true, true, 1);
}
-
+
public void testNIOHugeTransaction() throws Exception
{
- internalTest("nio", journalDir, 10000, 10000, true, true, 1);
+ internalTest("nio", getTestDir(), 10000, 10000, true, true, 1);
}
-
+
public void testNIOMultiThread() throws Exception
{
- internalTest("nio", journalDir, 1000, 100, true, true, 10);
+ internalTest("nio", getTestDir(), 1000, 100, true, true, 10);
}
-
+
public void testNIONonTransactional() throws Exception
{
- internalTest("nio", journalDir, 10000, 0, true, true, 1);
+ internalTest("nio", getTestDir(), 10000, 0, true, true, 1);
}
-
+
// Package protected ---------------------------------------------
-
+
// Protected -----------------------------------------------------
-
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ @Override
+ protected void setUp()
+ {
+ File file = new File(getTestDir());
+ deleteDirectory(file);
+ file.mkdir();
+ }
+
// Private -------------------------------------------------------
-
- private void internalTest(String type, String journalDir,
- long numberOfRecords, int transactionSize, boolean append, boolean externalProcess, int numberOfThreads) throws Exception
+
+ private void internalTest(final String type,
+ final String journalDir,
+ final long numberOfRecords,
+ final int transactionSize,
+ final boolean append,
+ final boolean externalProcess,
+ final int numberOfThreads) throws Exception
{
try
{
@@ -117,29 +135,32 @@
System.out.println("AIO not found, test being ignored on this platform");
return;
}
-
+
// This property could be set to false for debug purposes.
if (append)
{
- File file = new File(journalDir);
- deleteDirectory(file);
- file.mkdir();
-
if (externalProcess)
{
- Process process = SpawnedVMSupport.spawnVM(RemoteJournalAppender.class
- .getCanonicalName(), type, journalDir, Long
- .toString(numberOfRecords), Integer.toString(transactionSize), Integer.toString(numberOfThreads));
+ Process process = SpawnedVMSupport.spawnVM(RemoteJournalAppender.class.getCanonicalName(),
+ type,
+ journalDir,
+ Long.toString(numberOfRecords),
+ Integer.toString(transactionSize),
+ Integer.toString(numberOfThreads));
process.waitFor();
assertEquals(RemoteJournalAppender.OK, process.exitValue());
}
else
{
- JournalImpl journal = RemoteJournalAppender.appendData(type, journalDir, numberOfRecords, transactionSize, numberOfThreads);
+ JournalImpl journal = RemoteJournalAppender.appendData(type,
+ journalDir,
+ numberOfRecords,
+ transactionSize,
+ numberOfThreads);
journal.stop();
}
}
-
+
reload(type, journalDir, numberOfRecords, numberOfThreads);
}
finally
@@ -148,13 +169,11 @@
deleteDirectory(file);
}
}
-
- private void reload(String type, String journalDir, long numberOfRecords, int numberOfThreads)
- throws Exception
+
+ private void reload(final String type, final String journalDir, final long numberOfRecords, final int numberOfThreads) throws Exception
{
- JournalImpl journal = RemoteJournalAppender.createJournal(type,
- journalDir);
-
+ JournalImpl journal = RemoteJournalAppender.createJournal(type, journalDir);
+
journal.start();
Loader loadTest = new Loader(numberOfRecords);
journal.load(loadTest);
@@ -162,73 +181,75 @@
assertEquals(0, loadTest.numberOfPreparedTransactions);
assertEquals(0, loadTest.numberOfUpdates);
assertEquals(0, loadTest.numberOfDeletes);
-
+
if (loadTest.ex != null)
{
throw loadTest.ex;
}
}
-
+
// Inner classes -------------------------------------------------
-
+
class Loader implements LoadManager
{
int numberOfPreparedTransactions = 0;
+
int numberOfAdds = 0;
+
int numberOfDeletes = 0;
+
int numberOfUpdates = 0;
+
long expectedRecords = 0;
-
+
Exception ex = null;
-
+
long lastID = 0;
-
- public Loader(long expectedRecords)
+
+ public Loader(final long expectedRecords)
{
this.expectedRecords = expectedRecords;
}
-
- public void addPreparedTransaction(
- PreparedTransactionInfo preparedTransaction)
+
+ public void addPreparedTransaction(final PreparedTransactionInfo preparedTransaction)
{
numberOfPreparedTransactions++;
-
+
}
-
- public void addRecord(RecordInfo info)
+
+ public void addRecord(final RecordInfo info)
{
if (info.id == lastID)
{
System.out.println("id = " + info.id + " last id = " + lastID);
}
-
+
ByteBuffer buffer = ByteBuffer.wrap(info.data);
long recordValue = buffer.getLong();
-
+
if (recordValue != info.id)
{
- ex = new Exception("Content not as expected (" + recordValue
- + " != " + info.id + ")");
-
+ ex = new Exception("Content not as expected (" + recordValue + " != " + info.id + ")");
+
}
-
+
lastID = info.id;
numberOfAdds++;
-
+
}
-
- public void deleteRecord(long id)
+
+ public void deleteRecord(final long id)
{
numberOfDeletes++;
-
+
}
-
- public void updateRecord(RecordInfo info)
+
+ public void updateRecord(final RecordInfo info)
{
numberOfUpdates++;
-
+
}
-
+
}
-
+
}
Modified: trunk/tests/src/org/jboss/messaging/tests/stress/paging/PageStressTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/stress/paging/PageStressTest.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/tests/src/org/jboss/messaging/tests/stress/paging/PageStressTest.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -37,7 +37,7 @@
// Constants -----------------------------------------------------
// Attributes ----------------------------------------------------
-
+
private MessagingService messagingService;
// Static --------------------------------------------------------
@@ -45,19 +45,18 @@
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
-
+
public void testStopDuringGlobalDepage() throws Exception
{
testStopDuringDepage(true);
}
-
+
public void testStopDuringRegularDepage() throws Exception
{
testStopDuringDepage(false);
}
-
-
- public void testStopDuringDepage(boolean globalPage) throws Exception
+
+ public void testStopDuringDepage(final boolean globalPage) throws Exception
{
Configuration config = createDefaultConfig();
@@ -89,7 +88,7 @@
{
final int NUMBER_OF_MESSAGES = 60000;
-
+
session = factory.createSession(null, null, false, false, true, false, 1024 * NUMBER_OF_MESSAGES);
SimpleString address = new SimpleString("page-adr");
@@ -103,7 +102,9 @@
for (int i = 0; i < NUMBER_OF_MESSAGES; i++)
{
if (i % 10000 == 0)
+ {
System.out.println("Sent " + i);
+ }
prod.send(message);
}
@@ -113,7 +114,6 @@
ClientConsumer consumer = session.createConsumer(address);
-
int msgs = 0;
ClientMessage msg = null;
do
@@ -122,33 +122,33 @@
if (msg != null)
{
msg.acknowledge();
- if ((++msgs) % 1000 == 0)
+ if (++msgs % 1000 == 0)
{
System.out.println("Received " + msgs);
}
}
- } while (msg != null);
+ }
+ while (msg != null);
session.commit();
-
+
session.close();
-
+
messagingService.stop();
-
+
System.out.println("server stopped, nr msgs: " + msgs);
messagingService = createService(true, config, settings);
messagingService.start();
-
-
+
factory = createInVMFactory();
-
+
session = factory.createSession(false, false, false);
consumer = session.createConsumer(address);
-
+
session.start();
-
+
msg = null;
do
{
@@ -157,15 +157,16 @@
{
msg.acknowledge();
session.commit();
- if ((++msgs) % 1000 == 0)
+ if (++msgs % 1000 == 0)
{
System.out.println("Received " + msgs);
}
- }
- } while (msg != null);
-
+ }
+ }
+ while (msg != null);
+
System.out.println("msgs second time: " + msgs);
-
+
assertEquals(NUMBER_OF_MESSAGES, msgs);
}
finally
@@ -186,7 +187,7 @@
testPageOnMultipleDestinations(false);
}
- public void testPageOnMultipleDestinations(boolean globalPage) throws Exception
+ public void testPageOnMultipleDestinations(final boolean globalPage) throws Exception
{
Configuration config = createDefaultConfig();
@@ -232,7 +233,9 @@
for (int i = 0; i < NUMBER_OF_MESSAGES; i++)
{
if (i % 10000 == 0)
+ {
System.out.println(i);
+ }
prod.send(message);
}
@@ -280,7 +283,7 @@
}
- private int readMessages(ClientSession session, ClientConsumer consumer, SimpleString queue) throws MessagingException
+ private int readMessages(final ClientSession session, final ClientConsumer consumer, final SimpleString queue) throws MessagingException
{
session.start();
int msgs = 0;
@@ -306,45 +309,23 @@
return msgs;
}
-
- /**
- * @param globalPage
- * @param settings
- * @return
- */
- private Configuration createConfig(boolean globalPage, HashMap<String, QueueSettings> settings)
- {
- Configuration config = createDefaultConfig();
- if (globalPage)
- {
- config.setPagingMaxGlobalSizeBytes(20 * 1024 * 1024);
- QueueSettings setting = new QueueSettings();
- setting.setMaxSizeBytes(-1);
- settings.put("page-adr", setting);
- }
- else
- {
- config.setPagingMaxGlobalSizeBytes(-1);
- QueueSettings setting = new QueueSettings();
- setting.setMaxSizeBytes(20 * 1024 * 1024);
- settings.put("page-adr", setting);
- }
- return config;
- }
-
-
-
-
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
+ @Override
protected void setUp() throws Exception
{
clearData();
}
+ @Override
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
// Private -------------------------------------------------------
// Inner classes -------------------------------------------------
Modified: trunk/tests/src/org/jboss/messaging/tests/timing/core/journal/impl/RealJournalImplAIOTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/timing/core/journal/impl/RealJournalImplAIOTest.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/tests/src/org/jboss/messaging/tests/timing/core/journal/impl/RealJournalImplAIOTest.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -40,9 +40,6 @@
{
private static final Logger log = Logger.getLogger(RealJournalImplAIOTest.class);
- // Need to run the test over a local disk (no NFS)
- protected String journalDir = System.getProperty("java.io.tmpdir", "/tmp") + "/journal-test";
-
@Override
protected void setUp() throws Exception
{
@@ -60,22 +57,18 @@
protected void tearDown() throws Exception
{
super.tearDown();
-
- deleteDirectory(new File(journalDir));
}
protected SequentialFileFactory getFileFactory() throws Exception
{
- File file = new File(journalDir);
+ File file = new File(getTestDir());
- log.debug("deleting directory " + journalDir);
-
deleteDirectory(file);
file.mkdir();
- return new AIOSequentialFileFactory(journalDir);
+ return new AIOSequentialFileFactory(getTestDir());
}
}
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/AIOSequentialFileTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/AIOSequentialFileTest.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/AIOSequentialFileTest.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -61,7 +61,7 @@
public void testAlignment() throws Exception
{
- SequentialFile file = new MockAIOSequentialFileImpl("/tmp", "nothing", 1);
+ SequentialFile file = new MockAIOSequentialFileImpl(getTestDir(), "nothing", 1);
try
{
@@ -85,7 +85,7 @@
public void testCalculateblockStart() throws Exception
{
- SequentialFile file = new MockAIOSequentialFileImpl("/tmp", "nothing", 1);
+ SequentialFile file = new MockAIOSequentialFileImpl(getTestDir(), "nothing", 1);
try
{
@@ -109,7 +109,7 @@
public void testClose() throws Exception
{
- SequentialFile file = new MockAIOSequentialFileImpl("/tmp", "nothing", 1);
+ SequentialFile file = new MockAIOSequentialFileImpl(getTestDir(), "nothing", 1);
try
{
@@ -486,7 +486,7 @@
private SequentialFile openFile() throws Exception
{
- return openFile("/tmp", "nothing");
+ return openFile(getTemporaryDir(), "nothing");
}
private SequentialFile openFile(final String directory, final String fileName) throws Exception
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -564,4 +564,12 @@
}
+ /* (non-Javadoc)
+ * @see org.jboss.messaging.core.journal.SequentialFileFactory#createDirs()
+ */
+ public void createDirs() throws Exception
+ {
+ // nothing to be done on the fake Sequential file
+ }
+
}
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/PostOfficeImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/PostOfficeImplTest.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/PostOfficeImplTest.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -1401,9 +1401,10 @@
ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
- PagingManager pgm = EasyMock.createMock(PagingManager.class);
+ PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
pgm.setPostOffice(EasyMock.isA(PostOffice.class));
pgm.start();
+ pgm.startGlobalDepage();
EasyMock.expect(pgm.addSize(EasyMock.isA(ServerMessage.class))).andReturn(-1l);
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/GroupingRoundRobinDistributionPolicyTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/GroupingRoundRobinDistributionPolicyTest.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/GroupingRoundRobinDistributionPolicyTest.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -42,12 +42,14 @@
protected void setUp() throws Exception
{
+ super.setUp();
policy = new GroupingRoundRobinDistributionPolicy();
}
protected void tearDown() throws Exception
{
policy = null;
+ super.tearDown();
}
public void testSingleConsumerSingleGroup() throws Exception
Modified: trunk/tests/src/org/jboss/messaging/tests/util/ServiceTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/util/ServiceTestBase.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/tests/src/org/jboss/messaging/tests/util/ServiceTestBase.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -67,20 +67,6 @@
protected static final String NETTY_CONNECTOR_FACTORY = NettyConnectorFactory.class.getCanonicalName();
- protected String baseDir = System.getProperty("java.io.tmpdir", "/tmp") + "/jbm-unit-test";
-
- protected String journalDir = baseDir + "/journal";
-
- protected String bindingsDir = baseDir + "/bindings";
-
- protected String pageDir = baseDir + "/page";
-
- protected String largeMessagesDir = baseDir + "/large-msg";
-
- protected String clientLargeMessagesDir = baseDir + "/client-large-msg";
-
- protected String temporaryDir = baseDir + "/temporary";
-
// Static --------------------------------------------------------
private final Logger log = Logger.getLogger(this.getClass());
@@ -94,20 +80,14 @@
protected void clearData()
{
- deleteAndCreateDir(journalDir);
- deleteAndCreateDir(bindingsDir);
- deleteAndCreateDir(pageDir);
- deleteAndCreateDir(largeMessagesDir);
- deleteAndCreateDir(clientLargeMessagesDir);
- deleteAndCreateDir(temporaryDir);
+ deleteAndCreateDir(getJournalDir());
+ deleteAndCreateDir(getBindingsDir());
+ deleteAndCreateDir(getPageDir());
+ deleteAndCreateDir(getLargeMessagesDir());
+ deleteAndCreateDir(getClientLargeMessagesDir());
+ deleteAndCreateDir(getTemporaryDir());
}
- protected void deleteData()
- {
- log.info("deleting directory " + baseDir);
- deleteDirectory(new File(baseDir));
- }
-
protected void deleteAndCreateDir(String directory)
{
File file = new File(directory);
@@ -125,9 +105,9 @@
if (realFiles)
{
service = MessagingServiceImpl.newNioStorageMessagingServer(configuration,
- journalDir,
- bindingsDir,
- largeMessagesDir);
+ getJournalDir(),
+ getBindingsDir(),
+ getLargeMessagesDir());
}
else
{
@@ -176,8 +156,8 @@
configuration.setSecurityEnabled(false);
configuration.setJournalMinFiles(2);
configuration.setJournalFileSize(100 * 1024);
- configuration.setPagingDirectory(pageDir);
- configuration.setLargeMessagesDirectory(largeMessagesDir);
+ configuration.setPagingDirectory(getPageDir());
+ configuration.setLargeMessagesDirectory(getLargeMessagesDir());
configuration.getAcceptorConfigurations().clear();
Modified: trunk/tests/src/org/jboss/messaging/tests/util/SpawnedVMSupport.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/util/SpawnedVMSupport.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/tests/src/org/jboss/messaging/tests/util/SpawnedVMSupport.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -42,6 +42,7 @@
/**
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
* @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * @author <a href="mailto:csuconic at redhat.com">Clebert Suconic</a>
*
* @version <tt>$Revision$</tt>
*
Modified: trunk/tests/src/org/jboss/messaging/tests/util/UnitTestCase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/util/UnitTestCase.java 2008-12-02 21:59:25 UTC (rev 5453)
+++ trunk/tests/src/org/jboss/messaging/tests/util/UnitTestCase.java 2008-12-03 03:59:55 UTC (rev 5454)
@@ -18,7 +18,7 @@
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
+ */
package org.jboss.messaging.tests.util;
@@ -33,8 +33,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
-import java.util.concurrent.AbstractExecutorService;
-import java.util.concurrent.TimeUnit;
import javax.transaction.xa.Xid;
@@ -42,6 +40,8 @@
import org.easymock.EasyMock;
import org.easymock.IArgumentMatcher;
+import org.jboss.messaging.core.client.ClientMessage;
+import org.jboss.messaging.core.client.ClientSession;
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.journal.EncodingSupport;
import org.jboss.messaging.core.remoting.impl.ByteBufferWrapper;
@@ -50,8 +50,6 @@
import org.jboss.messaging.core.server.Queue;
import org.jboss.messaging.core.server.ServerMessage;
import org.jboss.messaging.core.server.impl.ServerMessageImpl;
-import org.jboss.messaging.core.client.ClientMessage;
-import org.jboss.messaging.core.client.ClientSession;
import org.jboss.messaging.jms.client.JBossTextMessage;
/**
@@ -59,6 +57,7 @@
* Helper base class for our unit tests
*
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:csuconic at redhat.com">Clebert</a>
*
*/
public class UnitTestCase extends TestCase
@@ -68,32 +67,46 @@
public static final String INVM_ACCEPTOR_FACTORY = "org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory";
public static final String INVM_CONNECTOR_FACTORY = "org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory";
+
// Attributes ----------------------------------------------------
-
+
+ private String testDir = System.getProperty("java.io.tmpdir", "/tmp") + "/jbm-unit-test";
+
+ private String journalDir = testDir + "/journal";
+
+ private String bindingsDir = testDir + "/bindings";
+
+ private String pageDir = testDir + "/page";
+
+ private String largeMessagesDir = testDir + "/large-msg";
+
+ private String clientLargeMessagesDir = testDir + "/client-large-msg";
+
+ private String temporaryDir = testDir + "/temporary";
+
// Static --------------------------------------------------------
-
+
public static String dumpBytes(byte[] bytes)
{
StringBuffer buff = new StringBuffer();
-
+
buff.append(System.identityHashCode(bytes) + ", size: " + bytes.length + " [");
-
+
for (int i = 0; i < bytes.length; i++)
{
buff.append(bytes[i]);
-
+
if (i != bytes.length - 1)
{
buff.append(", ");
}
}
-
+
buff.append("]");
-
- return buff.toString();
+
+ return buff.toString();
}
-
-
+
public static String dumbBytesHex(final byte[] buffer, int bytesPerLine)
{
@@ -104,7 +117,7 @@
for (int i = 0; i < buffer.length; i++)
{
buff.append(String.format("%1$2X", buffer[i]));
- if (i + 1 < buffer.length)
+ if (i + 1 < buffer.length)
{
buff.append(", ");
}
@@ -114,12 +127,10 @@
}
}
buff.append("]");
-
+
return buff.toString();
}
-
-
public static void assertEqualsByteArrays(byte[] expected, byte[] actual)
{
assertEquals(expected.length, actual.length);
@@ -146,20 +157,17 @@
assertNotNull(expected);
assertNotNull(actual);
assertEquals(expected.size(), actual.size());
-
+
for (int i = 0; i < expected.size(); i++)
{
Xid expectedXid = expected.get(i);
Xid actualXid = actual.get(i);
- UnitTestCase.assertEqualsByteArrays(expectedXid.getBranchQualifier(), actualXid
- .getBranchQualifier());
+ UnitTestCase.assertEqualsByteArrays(expectedXid.getBranchQualifier(), actualXid.getBranchQualifier());
assertEquals(expectedXid.getFormatId(), actualXid.getFormatId());
- UnitTestCase.assertEqualsByteArrays(expectedXid.getGlobalTransactionId(), actualXid
- .getGlobalTransactionId());
+ UnitTestCase.assertEqualsByteArrays(expectedXid.getGlobalTransactionId(), actualXid.getGlobalTransactionId());
}
}
-
public static MessagingException messagingExceptionMatch(final int errorID)
{
EasyMock.reportMatcher(new IArgumentMatcher()
@@ -172,29 +180,92 @@
public boolean matches(Object argument)
{
- MessagingException ex = (MessagingException) argument;
-
+ MessagingException ex = (MessagingException)argument;
+
return ex.getCode() == errorID;
}
-
+
});
-
+
return null;
}
-
+
// Constructors --------------------------------------------------
-
+
// Public --------------------------------------------------------
-
+
+ /**
+ * @return the testDir
+ */
+ public String getTestDir()
+ {
+ return testDir;
+ }
+
+ /**
+ * @return the journalDir
+ */
+ public String getJournalDir()
+ {
+ return journalDir;
+ }
+
+ /**
+ * @return the bindingsDir
+ */
+ public String getBindingsDir()
+ {
+ return bindingsDir;
+ }
+
+ /**
+ * @return the pageDir
+ */
+ public String getPageDir()
+ {
+ return pageDir;
+ }
+
+ /**
+ * @return the largeMessagesDir
+ */
+ public String getLargeMessagesDir()
+ {
+ return largeMessagesDir;
+ }
+
+ /**
+ * @return the clientLargeMessagesDir
+ */
+ public String getClientLargeMessagesDir()
+ {
+ return clientLargeMessagesDir;
+ }
+
+ /**
+ * @return the temporaryDir
+ */
+ public String getTemporaryDir()
+ {
+ return temporaryDir;
+ }
+
// Package protected ---------------------------------------------
-
+
// Protected -----------------------------------------------------
-
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ deleteDirectory(new File(getTestDir()));
+ }
+
protected byte[] autoEncode(Object... args)
{
-
+
int size = 0;
-
+
for (Object arg : args)
{
if (arg instanceof Byte)
@@ -223,56 +294,53 @@
}
else
{
- throw new IllegalArgumentException(
- "method autoEncode doesn't know how to convert "
- + arg.getClass() + " yet");
+ throw new IllegalArgumentException("method autoEncode doesn't know how to convert " + arg.getClass() +
+ " yet");
}
}
-
+
ByteBuffer buffer = ByteBuffer.allocate(size);
-
+
for (Object arg : args)
{
if (arg instanceof Byte)
{
- buffer.put(((Byte) arg).byteValue());
+ buffer.put(((Byte)arg).byteValue());
}
else if (arg instanceof Boolean)
{
- Boolean b = (Boolean) arg;
- buffer.put((byte) (b.booleanValue() ? 1 : 0));
+ Boolean b = (Boolean)arg;
+ buffer.put((byte)(b.booleanValue() ? 1 : 0));
}
else if (arg instanceof Integer)
{
- buffer.putInt(((Integer) arg).intValue());
+ buffer.putInt(((Integer)arg).intValue());
}
else if (arg instanceof Long)
{
- buffer.putLong(((Long) arg).longValue());
+ buffer.putLong(((Long)arg).longValue());
}
else if (arg instanceof Float)
{
- buffer.putFloat(((Float) arg).floatValue());
+ buffer.putFloat(((Float)arg).floatValue());
}
else if (arg instanceof Double)
{
- buffer.putDouble(((Double) arg).doubleValue());
+ buffer.putDouble(((Double)arg).doubleValue());
}
else
{
- throw new IllegalArgumentException(
- "method autoEncode doesn't know how to convert "
- + arg.getClass() + " yet");
+ throw new IllegalArgumentException("method autoEncode doesn't know how to convert " + arg.getClass() +
+ " yet");
}
}
-
+
return buffer.array();
}
-
-
+
protected ByteBuffer compareByteBuffer(final byte expectedArray[])
{
-
+
EasyMock.reportMatcher(new IArgumentMatcher()
{
@@ -283,17 +351,17 @@
public boolean matches(Object argument)
{
- ByteBuffer buffer = (ByteBuffer) argument;
-
+ ByteBuffer buffer = (ByteBuffer)argument;
+
buffer.rewind();
byte[] compareArray = new byte[buffer.limit()];
buffer.get(compareArray);
-
+
if (compareArray.length != expectedArray.length)
{
return false;
}
-
+
for (int i = 0; i < expectedArray.length; i++)
{
if (expectedArray[i] != compareArray[i])
@@ -301,18 +369,18 @@
return false;
}
}
-
+
return true;
}
-
+
});
-
+
return null;
}
protected EncodingSupport compareEncodingSupport(final byte expectedArray[])
{
-
+
EasyMock.reportMatcher(new IArgumentMatcher()
{
@@ -323,21 +391,21 @@
public boolean matches(Object argument)
{
- EncodingSupport encoding = (EncodingSupport) argument;
+ EncodingSupport encoding = (EncodingSupport)argument;
final int size = encoding.getEncodeSize();
-
+
if (size != expectedArray.length)
{
System.out.println(size + " != " + expectedArray.length);
return false;
}
-
+
byte[] compareArray = new byte[size];
-
+
MessagingBuffer buffer = new ByteBufferWrapper(ByteBuffer.wrap(compareArray));
encoding.encode(buffer);
-
+
for (int i = 0; i < expectedArray.length; i++)
{
if (expectedArray[i] != compareArray[i])
@@ -345,17 +413,15 @@
return false;
}
}
-
+
return true;
}
-
+
});
-
+
return null;
}
-
-
protected boolean deleteDirectory(File directory)
{
if (directory.isDirectory())
@@ -373,110 +439,113 @@
return directory.delete();
}
-
- protected void copyRecursive(File from , File to) throws Exception
- {
- if (from.isDirectory())
- {
- if (!to.exists())
- {
- to.mkdir();
- }
-
- String[] subs = from.list();
-
- for (int i = 0; i < subs.length; i++)
- {
- copyRecursive(new File(from, subs[i]),
- new File(to, subs[i]));
- }
- }
- else
- {
- InputStream in = null;
-
- OutputStream out = null;
-
- try
- {
- in = new BufferedInputStream(new FileInputStream(from));
-
- out = new BufferedOutputStream(new FileOutputStream(to));
-
- int b;
-
- while ((b = in.read()) != -1)
- {
- out.write(b);
- }
- }
- finally
- {
- if (in != null)
- {
- in.close();
- }
-
- if (out != null)
- {
- out.close();
- }
- }
- }
+
+ protected void copyRecursive(File from, File to) throws Exception
+ {
+ if (from.isDirectory())
+ {
+ if (!to.exists())
+ {
+ to.mkdir();
+ }
+
+ String[] subs = from.list();
+
+ for (int i = 0; i < subs.length; i++)
+ {
+ copyRecursive(new File(from, subs[i]), new File(to, subs[i]));
+ }
+ }
+ else
+ {
+ InputStream in = null;
+
+ OutputStream out = null;
+
+ try
+ {
+ in = new BufferedInputStream(new FileInputStream(from));
+
+ out = new BufferedOutputStream(new FileOutputStream(to));
+
+ int b;
+
+ while ((b = in.read()) != -1)
+ {
+ out.write(b);
+ }
+ }
+ finally
+ {
+ if (in != null)
+ {
+ in.close();
+ }
+
+ if (out != null)
+ {
+ out.close();
+ }
+ }
+ }
}
-
+
protected void assertRefListsIdenticalRefs(List<MessageReference> l1, List<MessageReference> l2)
{
if (l1.size() != l2.size())
{
fail("Lists different sizes: " + l1.size() + ", " + l2.size());
}
-
+
Iterator<MessageReference> iter1 = l1.iterator();
Iterator<MessageReference> iter2 = l2.iterator();
-
+
while (iter1.hasNext())
{
MessageReference o1 = iter1.next();
MessageReference o2 = iter2.next();
-
+
assertTrue(o1 == o2);
- }
+ }
}
-
+
protected ServerMessage generateMessage(long id)
{
- ServerMessage message = new ServerMessageImpl((byte)0, true, 0, System.currentTimeMillis(), (byte)4, new ByteBufferWrapper(ByteBuffer.allocateDirect(1024)));
-
+ ServerMessage message = new ServerMessageImpl((byte)0,
+ true,
+ 0,
+ System.currentTimeMillis(),
+ (byte)4,
+ new ByteBufferWrapper(ByteBuffer.allocateDirect(1024)));
+
message.setMessageID(id);
-
+
byte[] bytes = new byte[1024];
-
+
for (int i = 0; i < 1024; i++)
{
bytes[i] = (byte)i;
}
-
- //message.setPayload(bytes);
-
+
+ // message.setPayload(bytes);
+
message.getBody().putString(UUID.randomUUID().toString());
-
+
return message;
}
-
+
protected MessageReference generateReference(Queue queue, long id)
{
ServerMessage message = generateMessage(id);
-
+
return message.createReference(queue);
}
-
- protected int calculateRecordSize(int size, int alignment)
+
+ protected int calculateRecordSize(int size, int alignment)
{
return ((size / alignment) + (size % alignment != 0 ? 1 : 0)) * alignment;
}
-
protected ClientMessage createTextMessage(String s, ClientSession clientSession)
{
return createTextMessage(s, true, clientSession);
@@ -484,47 +553,17 @@
protected ClientMessage createTextMessage(String s, boolean durable, ClientSession clientSession)
{
- ClientMessage message = clientSession.createClientMessage(JBossTextMessage.TYPE, durable, 0, System.currentTimeMillis(), (byte) 1);
+ ClientMessage message = clientSession.createClientMessage(JBossTextMessage.TYPE,
+ durable,
+ 0,
+ System.currentTimeMillis(),
+ (byte)1);
message.getBody().putString(s);
message.getBody().flip();
return message;
}
// Private -------------------------------------------------------
-
+
// Inner classes -------------------------------------------------
-
- public static class DirectExecutorService extends AbstractExecutorService
- {
- public boolean awaitTermination(long timeout, TimeUnit unit)
- throws InterruptedException
- {
- return false;
- }
- public boolean isShutdown()
- {
- return false;
- }
-
- public void shutdown()
- {
- }
-
- public boolean isTerminated()
- {
- return false;
- }
-
- public List<Runnable> shutdownNow()
- {
- return null;
- }
-
- public void execute(Runnable command)
- {
- command.run();
- }
- }
-
-
}
More information about the jboss-cvs-commits
mailing list