added isStoreValid() method - used by AMQStore to determine if references need to be rebuilt

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@516408 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2007-03-09 13:30:33 +00:00
parent 82d19974d8
commit dda3e2a429
3 changed files with 26 additions and 10 deletions

View File

@ -41,5 +41,11 @@ public interface ReferenceStoreAdapter extends PersistenceAdapter {
public TopicReferenceStore createTopicReferenceStore(ActiveMQTopic destination) throws IOException;
public Set<Integer> getReferenceFileIdsInUse() throws IOException;
/**
* If the store isn't valid, it can be recoverd at start-up
* @return true if the reference store is in a consistent state
*/
public boolean isStoreValid();
}

View File

@ -157,7 +157,14 @@ public class AMQPersistenceAdapter implements PersistenceAdapter,UsageListener{
}
},"ActiveMQ Journal Checkpoint Worker");
createTransactionStore();
recover();
if(referenceStoreAdapter.isStoreValid()==false){
log.warn("The ReferenceStore is not valid - recovering ...");
recover();
log.info("Finished recovering the ReferenceStore");
}else {
Location location=writeTraceMessage("RECOVERED "+new Date(),true);
asyncDataManager.setMark(location,true);
}
// Do a checkpoint periodically.
periodicCheckpointTask=new Runnable(){

View File

@ -58,18 +58,21 @@ public class TopicSubContainer {
return listContainer.placeLast(ref);
}
public ConsumerMessageRef remove(MessageId id) {
ConsumerMessageRef result = null;
if (!listContainer.isEmpty()) {
for (StoreEntry entry = listContainer.getFirst(); entry != null; entry = listContainer.getNext(entry)) {
ConsumerMessageRef ref = (ConsumerMessageRef) listContainer.get(entry);
if (ref != null && ref.getMessageId().equals(id)) {
listContainer.remove(entry);
result = ref;
if (listContainer != null && batchEntry != null && (listContainer.isEmpty() || batchEntry.equals(entry))) {
public ConsumerMessageRef remove(MessageId id){
ConsumerMessageRef result=null;
if(!listContainer.isEmpty()){
StoreEntry entry=listContainer.getFirst();
while(entry!=null){
ConsumerMessageRef ref=(ConsumerMessageRef)listContainer.get(entry);
listContainer.remove(entry);
if(ref!=null&&ref.getMessageId().equals(id)){
result=ref;
if(listContainer!=null&&batchEntry!=null&&(listContainer.isEmpty()||batchEntry.equals(entry))){
reset();
}
break;
}
entry=listContainer.getFirst();
}
}
return result;