Author: borges
Date: 2011-08-03 06:47:25 -0400 (Wed, 03 Aug 2011)
New Revision: 11101
Modified:
branches/HORNETQ-720_Replication/
branches/HORNETQ-720_Replication/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/JournalImpl.java
Log:
merge from trunk
Property changes on: branches/HORNETQ-720_Replication
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk:10878-11098
+ /trunk:10878-11100
Modified:
branches/HORNETQ-720_Replication/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/JournalImpl.java
===================================================================
---
branches/HORNETQ-720_Replication/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/JournalImpl.java 2011-08-03
10:41:28 UTC (rev 11100)
+++
branches/HORNETQ-720_Replication/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/JournalImpl.java 2011-08-03
10:47:25 UTC (rev 11101)
@@ -1891,6 +1891,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)
@@ -1902,9 +1903,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);
@@ -1915,7 +1924,7 @@
public void onReadUpdateRecord(final RecordInfo info) throws Exception
{
- setAtomicLong(info.id, maxID);
+ checkID(info.id);
hasData.set(true);
@@ -1956,7 +1965,7 @@
public void onReadAddRecordTX(final long transactionID, final RecordInfo
info) throws Exception
{
- setAtomicLong(info.id, maxID);
+ checkID(info.id);
hasData.set(true);
@@ -2201,7 +2210,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);
@@ -2663,23 +2675,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