[jboss-cvs] JBoss Messaging SVN: r4839 - in branches/Branch_JBMESSAGING-1314: src/main/org/jboss/messaging/core/postoffice/impl and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Aug 19 18:48:29 EDT 2008
Author: clebert.suconic at jboss.com
Date: 2008-08-19 18:48:29 -0400 (Tue, 19 Aug 2008)
New Revision: 4839
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/postoffice/impl/PostOfficeImpl.java
branches/Branch_JBMESSAGING-1314/tests/src/org/jboss/messaging/tests/integration/paging/PagingManagerIntegrationTest.java
branches/Branch_JBMESSAGING-1314/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingStoreImplTest.java
branches/Branch_JBMESSAGING-1314/tests/src/org/jboss/messaging/tests/unit/core/server/impl/ServerSessionImplTest.java
Log:
Changes before integrating Transactions on Paging
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-19 19:14:24 UTC (rev 4838)
+++ branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java 2008-08-19 22:48:29 UTC (rev 4839)
@@ -139,6 +139,8 @@
final Page returnPage;
if (currentPageId == firstPageId)
{
+ firstPageId = Integer.MAX_VALUE;
+
if (currentPage != null)
{
returnPage = currentPage;
@@ -147,11 +149,23 @@
}
else
{
- returnPage = createPage(currentPageId);
+ // sanity check... it shouldn't happen!
+ throw new IllegalStateException("CurrentPage is null");
}
- firstPageId = Integer.MAX_VALUE;
+ if (returnPage.getNumberOfMessages() == 0)
+ {
+ returnPage.open();
+ returnPage.delete();
+ return null;
+ }
+ else
+ {
+ openNewPage();
+ }
+
+
return returnPage;
}
else
Modified: branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java
===================================================================
--- branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java 2008-08-19 19:14:24 UTC (rev 4838)
+++ branches/Branch_JBMESSAGING-1314/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java 2008-08-19 22:48:29 UTC (rev 4839)
@@ -51,8 +51,6 @@
import org.jboss.messaging.util.ConcurrentSet;
import org.jboss.messaging.util.SimpleString;
-import com.sun.org.apache.bcel.internal.generic.StoreInstruction;
-
/**
*
* A PostOfficeImpl
@@ -63,7 +61,7 @@
public class PostOfficeImpl implements PostOffice
{
- private static final long MAX_SIZE = 100 * 1024 * 1024;
+ private static final long MAX_SIZE = 10 * 1024 * 1024;
private static final Logger log = Logger.getLogger(PostOfficeImpl.class);
Modified: branches/Branch_JBMESSAGING-1314/tests/src/org/jboss/messaging/tests/integration/paging/PagingManagerIntegrationTest.java
===================================================================
--- branches/Branch_JBMESSAGING-1314/tests/src/org/jboss/messaging/tests/integration/paging/PagingManagerIntegrationTest.java 2008-08-19 19:14:24 UTC (rev 4838)
+++ branches/Branch_JBMESSAGING-1314/tests/src/org/jboss/messaging/tests/integration/paging/PagingManagerIntegrationTest.java 2008-08-19 22:48:29 UTC (rev 4839)
@@ -85,6 +85,10 @@
assertEqualsByteArrays(msg.getBody().array(), msgs[0].getBody().array());
+ assertTrue(store.isPaging());
+
+ assertNull(store.dequeuePage());
+
assertFalse(store.writeOnCurrentPage(msg));
}
Modified: branches/Branch_JBMESSAGING-1314/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingStoreImplTest.java
===================================================================
--- branches/Branch_JBMESSAGING-1314/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingStoreImplTest.java 2008-08-19 19:14:24 UTC (rev 4838)
+++ branches/Branch_JBMESSAGING-1314/tests/src/org/jboss/messaging/tests/unit/core/paging/impl/PagingStoreImplTest.java 2008-08-19 22:48:29 UTC (rev 4839)
@@ -146,15 +146,19 @@
Page page = storeImpl.dequeuePage();
-
page.open();
ServerMessage msg[] = page.read();
+ assertEquals(10, msg.length);
+ assertEquals(1, storeImpl.getNumberOfPages());
+
+ page = storeImpl.dequeuePage();
+
+ assertNull(page);
+
assertEquals(0, storeImpl.getNumberOfPages());
- assertEquals(10, msg.length);
-
for (int i = 0; i < 10; i++)
{
assertEquals(i + 1l, msg[i].getMessageID());
@@ -223,10 +227,28 @@
}
}
- assertEquals(0, storeImpl.getNumberOfPages());
+ assertEquals(1, storeImpl.getNumberOfPages());
+ assertTrue(storeImpl.isPaging());
+
ServerMessage msg = createMessage(100, destination, buffers.get(0));
+ assertTrue(storeImpl.writeOnCurrentPage(msg));
+
+ Page newPage = storeImpl.dequeuePage();
+
+ newPage.open();
+
+ assertEquals(1, newPage.read().length);
+
+ newPage.delete();
+
+ assertEquals(1, storeImpl.getNumberOfPages());
+
+ assertTrue(storeImpl.isPaging());
+
+ assertNull(storeImpl.dequeuePage());
+
assertFalse(storeImpl.isPaging());
assertFalse(storeImpl.writeOnCurrentPage(msg));
@@ -237,8 +259,6 @@
Page page = storeImpl.dequeuePage();
- assertEquals(0, storeImpl.getNumberOfPages());
-
page.open();
ServerMessage msgs[] = page.read();
@@ -249,9 +269,18 @@
assertEqualsByteArrays(buffers.get(0).array(), msgs[0].getBody().array());
+ assertEquals(1, storeImpl.getNumberOfPages());
+
+ assertTrue(storeImpl.isPaging());
+
assertNull(storeImpl.dequeuePage());
+ assertEquals(0, storeImpl.getNumberOfPages());
+ page.open();
+
+
+
}
Modified: branches/Branch_JBMESSAGING-1314/tests/src/org/jboss/messaging/tests/unit/core/server/impl/ServerSessionImplTest.java
===================================================================
--- branches/Branch_JBMESSAGING-1314/tests/src/org/jboss/messaging/tests/unit/core/server/impl/ServerSessionImplTest.java 2008-08-19 19:14:24 UTC (rev 4838)
+++ branches/Branch_JBMESSAGING-1314/tests/src/org/jboss/messaging/tests/unit/core/server/impl/ServerSessionImplTest.java 2008-08-19 22:48:29 UTC (rev 4839)
@@ -89,6 +89,7 @@
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
* @author <a href="mailto:ataylor at redhat.com">Andy Taylor</a>
+* @author <a href="mailto:ataylor at redhat.com">Clebert Suconic</a>
*/
public class ServerSessionImplTest extends UnitTestCase
{
More information about the jboss-cvs-commits
mailing list