Author: borges
Date: 2011-08-03 06:41:28 -0400 (Wed, 03 Aug 2011)
New Revision: 11100
Modified:
trunk/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/JournalImpl.java
Log:
Revert correct handling of AtomicLong. Document usage as reference.
Modified:
trunk/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/JournalImpl.java
===================================================================
---
trunk/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/JournalImpl.java 2011-08-03
10:18:10 UTC (rev 11099)
+++
trunk/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/JournalImpl.java 2011-08-03
10:41:28 UTC (rev 11100)
@@ -1902,6 +1902,7 @@
int lastDataPos = JournalImpl.SIZE_HEADER;
+ // AtomicLong is used only as a reference, not as an Atomic value
final AtomicLong maxID = new AtomicLong(-1);
for (final JournalFile file : orderedFiles)
@@ -1913,9 +1914,17 @@
int resultLastPost = JournalImpl.readJournalFile(fileFactory, file, new
JournalReaderCallback()
{
+ private void checkID(final long id)
+ {
+ if (id > maxID.longValue())
+ {
+ maxID.set(id);
+ }
+ }
+
public void onReadAddRecord(final RecordInfo info) throws Exception
{
- setAtomicLong(info.id, maxID);
+ checkID(info.id);
hasData.set(true);
@@ -1926,7 +1935,7 @@
public void onReadUpdateRecord(final RecordInfo info) throws Exception
{
- setAtomicLong(info.id, maxID);
+ checkID(info.id);
hasData.set(true);
@@ -1967,7 +1976,7 @@
public void onReadAddRecordTX(final long transactionID, final RecordInfo
info) throws Exception
{
- setAtomicLong(info.id, maxID);
+ checkID(info.id);
hasData.set(true);
@@ -2212,7 +2221,10 @@
{
for (RecordInfo info : transaction.recordInfos)
{
- setAtomicLong(info.id, maxID);
+ if (info.id > maxID.get())
+ {
+ maxID.set(info.id);
+ }
}
PreparedTransactionInfo info = new
PreparedTransactionInfo(transaction.transactionID, transaction.extraData);
@@ -2679,23 +2691,6 @@
}
- private static final void setAtomicLong(final long target, AtomicLong atomic)
- {
- while (true)
- {
- long value = atomic.get();
- if (target > value)
- {
- if (atomic.compareAndSet(value, target))
- return;
- }
- else
- {
- return;
- }
- }
- }
-
/**
* @param name
* @return
Show replies by date