[jboss-cvs] JBoss Messaging SVN: r7455 - in branches/clebert_temp_expirement: tests/src/org/jboss/messaging/tests/unit/core/journal/impl and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jun 24 12:29:53 EDT 2009
Author: clebert.suconic at jboss.com
Date: 2009-06-24 12:29:53 -0400 (Wed, 24 Jun 2009)
New Revision: 7455
Modified:
branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java
branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalImplTestUnit.java
Log:
Fixing transaction commit / prepare
Modified: branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java
===================================================================
--- branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java 2009-06-24 15:58:58 UTC (rev 7454)
+++ branches/clebert_temp_expirement/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java 2009-06-24 16:29:53 UTC (rev 7455)
@@ -148,7 +148,7 @@
public static final byte DELETE_RECORD = 16;
- public static final int SIZE_COMPLETE_TRANSACTION_RECORD = BASIC_SIZE + SIZE_INT + SIZE_LONG + SIZE_INT;
+ public static final int SIZE_COMPLETE_TRANSACTION_RECORD = BASIC_SIZE + SIZE_LONG + SIZE_INT;
public static final int SIZE_PREPARE_RECORD = SIZE_COMPLETE_TRANSACTION_RECORD + SIZE_INT;
@@ -1285,7 +1285,7 @@
transactionInfos.put(transactionID, journalTransaction);
}
- boolean healthy = checkTransactionHealth(currentFile, journalTransaction, orderedFiles, numberOfRecords);
+ boolean healthy = checkTransactionHealth(file, journalTransaction, orderedFiles, numberOfRecords);
if (healthy)
{
@@ -1323,7 +1323,7 @@
throw new IllegalStateException("Cannot find tx " + transactionID);
}
- boolean healthy = checkTransactionHealth(currentFile,
+ boolean healthy = checkTransactionHealth(file,
journalTransaction,
orderedFiles,
numberOfRecords);
@@ -1930,9 +1930,14 @@
wholeFileBuffer.get(record);
}
+
+ // Case this is a transaction, this will contain the number of records on a transaction, at the currentFile
+ int transactionCheckNumberOfRecords = 0;
if (recordType == PREPARE_RECORD || recordType == COMMIT_RECORD)
{
+ transactionCheckNumberOfRecords = wholeFileBuffer.getInt();
+
if (recordType == PREPARE_RECORD)
{
// Add the variable size required for preparedTransactions
@@ -2055,22 +2060,18 @@
case PREPARE_RECORD:
{
- int numberOfRecords = wholeFileBuffer.getInt();
-
byte extraData[] = new byte[preparedTransactionExtraDataSize];
wholeFileBuffer.get(extraData);
- reader.prepareRecord(transactionID, extraData, numberOfRecords);
+ reader.prepareRecord(transactionID, extraData, transactionCheckNumberOfRecords);
break;
}
case COMMIT_RECORD:
{
- int numberOfRecords = wholeFileBuffer.getInt();
-
- reader.commitRecord(transactionID, numberOfRecords);
+ reader.commitRecord(transactionID, transactionCheckNumberOfRecords);
break;
}
case ROLLBACK_RECORD:
@@ -2129,13 +2130,11 @@
final List<JournalFile> orderedFiles,
final int numberOfRecords)
{
- boolean healthy = true;
-
// (I) First we get the summary of what we really have on the files now:
// FileID, NumberOfElements
Map<Integer, AtomicInteger> currentSummary = journalTransaction.getElementsSummary();
-
+
AtomicInteger value = currentSummary.get(currentFile.getFileID());
Integer intValue = value == null ? 0 : value.intValue();
Modified: branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalImplTestUnit.java
===================================================================
--- branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalImplTestUnit.java 2009-06-24 15:58:58 UTC (rev 7454)
+++ branches/clebert_temp_expirement/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalImplTestUnit.java 2009-06-24 16:29:53 UTC (rev 7455)
@@ -2316,9 +2316,9 @@
loadAndCheck();
}
- public void testAddReload() throws Exception
+ public void testSimpleAddTXReload() throws Exception
{
- setup(10, 10 * 1024, true);
+ setup(2, 10 * 1024, true);
createJournal();
startJournal();
load();
@@ -2332,6 +2332,26 @@
}
+ public void testSimpleAddTXXAReload() throws Exception
+ {
+ setup(2, 10 * 1024, true);
+ createJournal();
+ startJournal();
+ load();
+ addTx(1, 1);
+
+ EncodingSupport xid = new SimpleEncoding(10, (byte)'p');
+
+ prepare(1, xid);
+
+
+ stopJournal();
+ createJournal();
+ startJournal();
+ loadAndCheck();
+
+ }
+
public void testAddUpdateDeleteTransactionalRestartAndContinue() throws Exception
{
setup(10, 10 * 1024, true);
More information about the jboss-cvs-commits
mailing list