Author: clebert.suconic(a)jboss.com
Date: 2011-03-10 13:08:03 -0500 (Thu, 10 Mar 2011)
New Revision: 10314
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/journal/impl/JournalImpl.java
branches/Branch_2_2_EAP/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/DuplicateDetectionTest.java
Log:
tweak on printData
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/journal/impl/JournalImpl.java
===================================================================
---
branches/Branch_2_2_EAP/src/main/org/hornetq/core/journal/impl/JournalImpl.java 2011-03-10
17:56:43 UTC (rev 10313)
+++
branches/Branch_2_2_EAP/src/main/org/hornetq/core/journal/impl/JournalImpl.java 2011-03-10
18:08:03 UTC (rev 10314)
@@ -1457,12 +1457,19 @@
return this.load(dummyLoader);
}
+ public JournalLoadInformation load(final List<RecordInfo> committedRecords,
+ final
List<PreparedTransactionInfo> preparedTransactions,
+ final TransactionFailureCallback
failureCallback) throws Exception
+ {
+ return load(committedRecords, preparedTransactions, failureCallback, true);
+ }
/**
* @see JournalImpl#load(LoaderCallback)
*/
public synchronized JournalLoadInformation load(final List<RecordInfo>
committedRecords,
final
List<PreparedTransactionInfo> preparedTransactions,
- final TransactionFailureCallback
failureCallback) throws Exception
+ final TransactionFailureCallback
failureCallback,
+ final boolean fixBadTX) throws
Exception
{
final Set<Long> recordsToDelete = new HashSet<Long>();
// ArrayList was taking too long to delete elements on checkDeleteSize
@@ -1799,8 +1806,13 @@
* <p> * FileID and NumberOfElements are the transaction summary, and they will
be repeated (N)umberOfFiles times </p>
*
* */
- public synchronized JournalLoadInformation load(final LoaderCallback loadManager)
throws Exception
+ public JournalLoadInformation load(final LoaderCallback loadManager) throws Exception
{
+ return load(loadManager, true);
+ }
+
+ public synchronized JournalLoadInformation load(final LoaderCallback loadManager,
boolean fixFailingTransactions) throws Exception
+ {
if (state != JournalImpl.STATE_STARTED)
{
throw new IllegalStateException("Journal must be in started state");
@@ -2126,8 +2138,11 @@
JournalImpl.log.warn("Uncommitted transaction with id " +
transaction.transactionID +
" found and discarded");
- // I append a rollback record here, because otherwise compacting will be
throwing messages because of unknown transactions
- this.appendRollbackRecord(transaction.transactionID, false);
+ if (fixFailingTransactions)
+ {
+ // I append a rollback record here, because otherwise compacting will be
throwing messages because of unknown transactions
+ this.appendRollbackRecord(transaction.transactionID, false);
+ }
loadManager.failedTransaction(transaction.transactionID,
transaction.recordInfos,
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
===================================================================
---
branches/Branch_2_2_EAP/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2011-03-10
17:56:43 UTC (rev 10313)
+++
branches/Branch_2_2_EAP/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2011-03-10
18:08:03 UTC (rev 10314)
@@ -3163,7 +3163,7 @@
}
}
- });
+ }, false);
for (RecordInfo info : records)
{
Modified:
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/DuplicateDetectionTest.java
===================================================================
---
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/DuplicateDetectionTest.java 2011-03-10
17:56:43 UTC (rev 10313)
+++
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/DuplicateDetectionTest.java 2011-03-10
18:08:03 UTC (rev 10314)
@@ -18,6 +18,7 @@
import junit.framework.Assert;
+import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.Message;
import org.hornetq.api.core.SimpleString;
import org.hornetq.api.core.TransportConfiguration;
@@ -486,7 +487,14 @@
message.putBytesProperty(Message.HDR_DUPLICATE_DETECTION_ID, dupID2.getData());
producer.send(message);
- session.commit();
+ try
+ {
+ session.commit();
+ }
+ catch (Exception e)
+ {
+ session.rollback();
+ }
message = consumer.receive(250);
Assert.assertEquals(0, message.getObjectProperty(propKey));
@@ -552,7 +560,15 @@
message = createMessage(session, 4);
producer.send(message);
- session.commit();
+ try
+ {
+ session.commit();
+ }
+ catch (HornetQException e)
+ {
+ assertEquals(e.getCode(), HornetQException.TRANSACTION_ROLLED_BACK);
+ session.rollback();
+ }
ClientConsumer consumer = session.createConsumer(queueName);
@@ -1671,14 +1687,34 @@
message = createMessage(session, 1);
message.putBytesProperty(Message.HDR_DUPLICATE_DETECTION_ID, dupID.getData());
producer.send(message);
- session.commit();
+
+ try
+ {
+ session.commit();
+ }
+ catch (HornetQException e)
+ {
+ assertEquals(e.getCode(), HornetQException.TRANSACTION_ROLLED_BACK);
+ session.rollback();
+ }
+
message2 = consumer.receiveImmediate();
Assert.assertNull(message2);
message = createMessage(session, 2);
message.putBytesProperty(Message.HDR_DUPLICATE_DETECTION_ID, dupID2.getData());
producer.send(message);
- session.commit();
+
+ try
+ {
+ session.commit();
+ }
+ catch (HornetQException e)
+ {
+ assertEquals(e.getCode(), HornetQException.TRANSACTION_ROLLED_BACK);
+ session.rollback();
+ }
+
message2 = consumer.receiveImmediate();
Assert.assertNull(message2);