refresh entry for prev as well as next

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@582575 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2007-10-07 05:10:28 +00:00
parent 84a116d2c7
commit 1d487896b4
1 changed files with 41 additions and 36 deletions

View File

@ -257,45 +257,50 @@ public class DiskIndexLinkedList implements IndexLinkedList {
* @return next entry
*/
public synchronized IndexItem getNextEntry(IndexItem current) {
IndexItem result = null;
if (current != null ) {
current = (IndexItem) refreshEntry(current);
if(current.getNextItem() >= 0){
try {
result = indexManager.getIndex(current.getNextItem());
} catch (IOException e) {
throw new RuntimeException("Failed to get next index from " + indexManager + " for " + current, e);
}
}
}
// essential last get's updated consistently
if (result != null && last != null && last.equals(result)) {
result = last;
}
return result;
}
IndexItem result = null;
if (current != null) {
current = (IndexItem) refreshEntry(current);
if (current.getNextItem() >= 0) {
try {
result = indexManager.getIndex(current.getNextItem());
} catch (IOException e) {
throw new RuntimeException("Failed to get next index from "
+ indexManager + " for " + current, e);
}
}
}
// essential last get's updated consistently
if (result != null && last != null && last.equals(result)) {
result = last;
}
return result;
}
/**
* Retrive the prev entry after this entry
*
* @param entry
* @return prev entry
*/
* Retrive the prev entry after this entry
*
* @param entry
* @return prev entry
*/
public synchronized IndexItem getPrevEntry(IndexItem current) {
IndexItem result = null;
if (current != null && current.getPreviousItem() >= 0) {
try {
result = indexManager.getIndex(current.getPreviousItem());
} catch (IOException e) {
throw new RuntimeException("Failed to get current index for " + current, e);
}
}
// essential root get's updated consistently
if (result != null && root != null && root.equals(result)) {
return root;
}
return result;
}
IndexItem result = null;
if (current != null) {
if (current.getPreviousItem() >= 0) {
current = (IndexItem) refreshEntry(current);
try {
result = indexManager.getIndex(current.getPreviousItem());
} catch (IOException e) {
throw new RuntimeException(
"Failed to get current index for " + current, e);
}
}
}
// essential root get's updated consistently
if (result != null && root != null && root.equals(result)) {
return root;
}
return result;
}
public synchronized StoreEntry getEntry(StoreEntry current) {
StoreEntry result = null;