[jboss-cvs] JBoss Messaging SVN: r4873 - in branches/Branch_JBMESSAGING-1314: src/main/org/jboss/messaging/core/paging/impl and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Aug 26 13:42:47 EDT 2008
Author: clebert.suconic at jboss.com
Date: 2008-08-26 13:42:47 -0400 (Tue, 26 Aug 2008)
New Revision: 4873
Modified:
branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/LastPageRecord.java
branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/Page.java
branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/PageTransactionInfo.java
branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/Pager.java
branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/PagingManager.java
branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/PagingStore.java
branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/PagingStoreFactory.java
branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/impl/LastPageRecordImpl.java
branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/impl/PageImpl.java
branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/impl/PageMessageImpl.java
branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/impl/PageTransactionInfoImpl.java
branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/impl/PagingManagerFactoryNIO.java
branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java
branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java
branches/Branch_JBMESSAGING-1314/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PageTransactionImplTest.java
Log:
Small tweaks and comments
Modified: branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/LastPageRecord.java
===================================================================
--- branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/LastPageRecord.java 2008-08-26 17:06:04 UTC (rev 4872)
+++ branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/LastPageRecord.java 2008-08-26 17:42:47 UTC (rev 4873)
@@ -46,16 +46,20 @@
// Public --------------------------------------------------------
+ /** Internal record with the primary key, used on the journal/database*/
long getRecordId();
+ /** Internal record with the primary key, used on the journal/database*/
void setRecordId(long recordId);
SimpleString getDestination();
void setDestination(SimpleString destination);
+ /** Last Page ID*/
long getLastId();
+ /** Last Page ID*/
void setLastId(long lastId);
// Package protected ---------------------------------------------
Modified: branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/Page.java
===================================================================
--- branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/Page.java 2008-08-26 17:06:04 UTC (rev 4872)
+++ branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/Page.java 2008-08-26 17:42:47 UTC (rev 4873)
@@ -26,10 +26,8 @@
/**
*
- * Page could be used to enqueue files for any Datatype implementing EncodingSupport
+ * <p>Look at the <a href="http://wiki.jboss.org/auth/wiki/JBossMessaging2Paging">WIKI</a> for more information.</p>
*
- * Paging was written this way as it would be easier to refactor Paging to other datatypes we could require later (such as ACKs, transactions... etc).
- *
* @author <a href="mailto:clebert.suconic at jboss.com">Clebert Suconic</a>
*
*/
Modified: branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/PageTransactionInfo.java
===================================================================
--- branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/PageTransactionInfo.java 2008-08-26 17:06:04 UTC (rev 4872)
+++ branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/PageTransactionInfo.java 2008-08-26 17:42:47 UTC (rev 4873)
@@ -24,11 +24,10 @@
package org.jboss.messaging.core.paging;
import org.jboss.messaging.core.journal.EncodingSupport;
-import org.jboss.messaging.util.SimpleString;
/**
*
- * This records contains information about tra
+ * <p>Look at the <a href="http://wiki.jboss.org/auth/wiki/JBossMessaging2Paging">WIKI</a> for more information.</p>
*
* @author <a href="mailto:clebert.suconic at jboss.com">Clebert Suconic</a>
*
@@ -50,8 +49,6 @@
int decrement();
- int decrement(int elements);
-
int getNumberOfMessages();
}
Modified: branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/Pager.java
===================================================================
--- branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/Pager.java 2008-08-26 17:06:04 UTC (rev 4872)
+++ branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/Pager.java 2008-08-26 17:42:47 UTC (rev 4873)
@@ -30,6 +30,8 @@
/**
*
+ * <p>Look at the <a href="http://wiki.jboss.org/auth/wiki/JBossMessaging2Paging">WIKI</a> for more information.</p>
+ *
* @author <a href="mailto:clebert.suconic at jboss.com">Clebert Suconic</a>
*/
public interface Pager
Modified: branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/PagingManager.java
===================================================================
--- branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/PagingManager.java 2008-08-26 17:06:04 UTC (rev 4872)
+++ branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/PagingManager.java 2008-08-26 17:42:47 UTC (rev 4873)
@@ -27,9 +27,9 @@
/**
*
- * A PagingManager
+ * <p>Look at the <a href="http://wiki.jboss.org/auth/wiki/JBossMessaging2Paging">WIKI</a> for more information.</p>
*
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:clebert.suconic at jboss.com">Clebert Suconic</a>
*
*/
public interface PagingManager extends MessagingComponent
Modified: branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/PagingStore.java
===================================================================
--- branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/PagingStore.java 2008-08-26 17:06:04 UTC (rev 4872)
+++ branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/PagingStore.java 2008-08-26 17:42:47 UTC (rev 4873)
@@ -28,10 +28,12 @@
/**
*
- * The implementation will take care of details such as PageSize.
- * The producers will write directly to PagingStore and that will decide what
- * Page file should be used based on configured size
+ * <p>The implementation will take care of details such as PageSize.</p>
+ * <p>The producers will write directly to PagingStore and that will decide what
+ * Page file should be used based on configured size</p>
*
+ * <p>Look at the <a href="http://wiki.jboss.org/auth/wiki/JBossMessaging2Paging">WIKI</a> for more information.</p>
+
* @author <a href="mailto:clebert.suconic at jboss.com">Clebert Suconic</a>
*
*/
Modified: branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/PagingStoreFactory.java
===================================================================
--- branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/PagingStoreFactory.java 2008-08-26 17:06:04 UTC (rev 4872)
+++ branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/PagingStoreFactory.java 2008-08-26 17:42:47 UTC (rev 4873)
@@ -35,7 +35,5 @@
{
PagingStore newStore(org.jboss.messaging.util.SimpleString destinationName);
- PageMessage newElement();
- PageMessage[] newArray(int size);
}
Modified: branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/impl/LastPageRecordImpl.java
===================================================================
--- branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/impl/LastPageRecordImpl.java 2008-08-26 17:06:04 UTC (rev 4872)
+++ branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/impl/LastPageRecordImpl.java 2008-08-26 17:42:47 UTC (rev 4873)
@@ -27,6 +27,11 @@
import org.jboss.messaging.core.remoting.MessagingBuffer;
import org.jboss.messaging.util.SimpleString;
+/**
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.com">Clebert Suconic</a>
+ *
+ */
public class LastPageRecordImpl implements LastPageRecord
{
@@ -47,17 +52,18 @@
// Public --------------------------------------------------------
- public LastPageRecordImpl(long recordId)
+ public LastPageRecordImpl(final long lastId, final SimpleString destination)
{
- }
-
- public LastPageRecordImpl(long lastId, SimpleString destination)
- {
super();
this.lastId = lastId;
this.destination = destination;
}
+ public LastPageRecordImpl()
+ {
+ super();
+ }
+
public long getRecordId()
{
return recordId;
Modified: branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/impl/PageImpl.java
===================================================================
--- branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/impl/PageImpl.java 2008-08-26 17:06:04 UTC (rev 4872)
+++ branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/impl/PageImpl.java 2008-08-26 17:42:47 UTC (rev 4873)
@@ -214,13 +214,13 @@
protected PageMessage instantiateObject()
{
- return storeFactory.newElement();
+ return new PageMessageImpl();
}
protected PageMessage[] instantiateArray(final int size)
{
- return storeFactory.newArray(size);
+ return new PageMessage[size];
}
// Private -------------------------------------------------------
Modified: branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/impl/PageMessageImpl.java
===================================================================
--- branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/impl/PageMessageImpl.java 2008-08-26 17:06:04 UTC (rev 4872)
+++ branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/impl/PageMessageImpl.java 2008-08-26 17:42:47 UTC (rev 4873)
@@ -51,13 +51,13 @@
private final ServerMessage message;
private long transactionID;
- public PageMessageImpl(ServerMessage message, long transactionID)
+ public PageMessageImpl(final ServerMessage message, final long transactionID)
{
this.message = message;
this.transactionID = transactionID;
}
- public PageMessageImpl(ServerMessage message)
+ public PageMessageImpl(final ServerMessage message)
{
this.message = message;
}
@@ -80,7 +80,7 @@
// EncodingSupport implementation --------------------------------
- public void decode(MessagingBuffer buffer)
+ public void decode(final MessagingBuffer buffer)
{
transactionID = buffer.getLong();
final long messageID = buffer.getLong();
@@ -88,7 +88,7 @@
message.setMessageID(messageID);
}
- public void encode(MessagingBuffer buffer)
+ public void encode(final MessagingBuffer buffer)
{
buffer.putLong(transactionID);
buffer.putLong(message.getMessageID());
Modified: branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/impl/PageTransactionInfoImpl.java
===================================================================
--- branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/impl/PageTransactionInfoImpl.java 2008-08-26 17:06:04 UTC (rev 4872)
+++ branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/impl/PageTransactionInfoImpl.java 2008-08-26 17:42:47 UTC (rev 4873)
@@ -28,8 +28,6 @@
import org.jboss.messaging.core.paging.PageTransactionInfo;
import org.jboss.messaging.core.remoting.MessagingBuffer;
-import org.jboss.messaging.util.ConcurrentHashSet;
-import org.jboss.messaging.util.SimpleString;
/**
*
@@ -99,17 +97,6 @@
return value;
}
- public int decrement(int elements)
- {
- final int value = numberOfMessages.addAndGet(elements * -1);
- if (value < 0)
- {
- throw new IllegalStateException("Internal error Negative value on Paging transactions!");
- }
-
- return value;
- }
-
public int getNumberOfMessages()
{
return numberOfMessages.get();
Modified: branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/impl/PagingManagerFactoryNIO.java
===================================================================
--- branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/impl/PagingManagerFactoryNIO.java 2008-08-26 17:06:04 UTC (rev 4872)
+++ branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/impl/PagingManagerFactoryNIO.java 2008-08-26 17:42:47 UTC (rev 4873)
@@ -60,7 +60,7 @@
// Public --------------------------------------------------------
- public PagingStore newStore(SimpleString destinationName)
+ public PagingStore newStore(final SimpleString destinationName)
{
final String destinationDirectory = directory + "/" + destinationName.toString();
File destinationFile = new File(destinationDirectory);
@@ -69,16 +69,6 @@
return new PagingStoreImpl(newFileFactory(destinationDirectory), this, destinationName, pageSize);
}
- public PageMessage[] newArray(int size)
- {
- return new PageMessageImpl[size];
- }
-
- public PageMessage newElement()
- {
- return new PageMessageImpl();
- }
-
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
Modified: branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java
===================================================================
--- branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java 2008-08-26 17:06:04 UTC (rev 4872)
+++ branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java 2008-08-26 17:42:47 UTC (rev 4873)
@@ -88,7 +88,7 @@
// Constructors --------------------------------------------------
- public PagingStoreImpl(final SequentialFileFactory fileFactory, PagingStoreFactory storeFactory, final SimpleString storeName, final long maxPageSize)
+ public PagingStoreImpl(final SequentialFileFactory fileFactory, final PagingStoreFactory storeFactory, final SimpleString storeName, final long maxPageSize)
{
this.storeFactory = storeFactory;
this.fileFactory = fileFactory;
@@ -199,7 +199,7 @@
}
- public boolean page(PageMessage message) throws Exception
+ public boolean page(final PageMessage message) throws Exception
{
validateInit();
@@ -209,7 +209,7 @@
// This would be a synchronized block... (but using a Semaphore)
synchronizedBlockLock.acquire();
- // The only thing single-threaded done on paging is allocating the bytes on the file
+ // The only thing single-threaded done on paging is positioning and check-files (verifying if we need to open a new page file)
// After we have it allocated we keep all the threads working until we need to move to a new file (in which case we demand a writeLock, to wait for the writes to finish)
try
{
@@ -235,6 +235,7 @@
// we must get the readLock before we release the synchronizedBlockLock
// or else we could end up with files records being added to the currentPage even if the max size was already achieved.
// (Condition tested by PagingStoreTestPage::testConcurrentPaging, The test would eventually fail, 1 in 100)
+ // This is because the checkSize and positioning has to be done protected. We only allow writing the file in multi-thread.
lock.readLock().lock();
}
@@ -486,7 +487,7 @@
}
- private Page createPage(int page) throws Exception
+ private Page createPage(final int page) throws Exception
{
String fileName = createFileName(page);
SequentialFile file = fileFactory.createSequentialFile(fileName, 1000);
Modified: branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java
===================================================================
--- branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java 2008-08-26 17:06:04 UTC (rev 4872)
+++ branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java 2008-08-26 17:42:47 UTC (rev 4873)
@@ -333,8 +333,10 @@
{
MessagingBuffer buff = new ByteBufferWrapper(bb);
- LastPageRecordImpl recordImpl = new LastPageRecordImpl(record.id);
+ LastPageRecordImpl recordImpl = new LastPageRecordImpl();
+ recordImpl.setRecordId(record.id);
+
recordImpl.decode(buff);
postOffice.getPager().loadLastPage(recordImpl);
Modified: branches/Branch_JBMESSAGING-1314/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PageTransactionImplTest.java
===================================================================
--- branches/Branch_JBMESSAGING-1314/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PageTransactionImplTest.java 2008-08-26 17:06:04 UTC (rev 4872)
+++ branches/Branch_JBMESSAGING-1314/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PageTransactionImplTest.java 2008-08-26 17:42:47 UTC (rev 4873)
@@ -31,7 +31,6 @@
import org.jboss.messaging.core.remoting.impl.ByteBufferWrapper;
import org.jboss.messaging.tests.util.RandomUtil;
import org.jboss.messaging.tests.util.UnitTestCase;
-import org.jboss.messaging.util.SimpleString;
/**
*
@@ -62,8 +61,6 @@
// anything between 2 and 100
int nr1 = RandomUtil.randomPositiveInt()%98 + 2;
- SimpleString str1 = RandomUtil.randomSimpleString();
- SimpleString str2 = RandomUtil.randomSimpleString();
for (int i = 0; i < nr1; i++)
{
@@ -86,7 +83,10 @@
assertEquals(nr1, trans2.getNumberOfMessages());
- trans.decrement(nr1);
+ for (int i = 0; i < nr1; i++)
+ {
+ trans.decrement();
+ }
assertEquals(0, trans.getNumberOfMessages());
More information about the jboss-cvs-commits
mailing list