Changeset 763


Ignore:
Timestamp:
05/08/11 23:18:44 (8 years ago)
Author:
philsmart
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • raptor-parse/trunk/src/main/java/uk/ac/cardiff/raptor/parse/DataAccessRegister.java

    r732 r763  
    2222import java.util.List; 
    2323 
     24import org.joda.time.DateTime; 
    2425import org.slf4j.Logger; 
    2526import org.slf4j.LoggerFactory; 
     
    2930import uk.ac.cardiff.model.event.ShibbolethIdpAuthenticationEvent; 
    3031import uk.ac.cardiff.raptor.parse.BaseEventParser; 
     32import uk.ac.cardiff.raptor.registry.Endpoint; 
     33import uk.ac.cardiff.raptor.registry.EndpointRegistry; 
     34import uk.ac.cardiff.raptor.store.EntryHandler; 
    3135 
    3236/** 
     
    8993    } 
    9094 
     95    /**  
     96     * Removes events from all parsing modules iff they have been released to all endpoints 
     97     */ 
     98        public void garbageCollect(List<Endpoint> endpoints) { 
     99                DateTime earliestReleaseTime = null; 
     100                for (Endpoint endpoint :endpoints){ 
     101                        if (earliestReleaseTime==null){ 
     102                                earliestReleaseTime = endpoint.getReleaseInformation().getLastReleasedEventTime(); 
     103                        } 
     104                        if (earliestReleaseTime.isBefore(endpoint.getReleaseInformation().getLastReleasedEventTime())){ 
     105                                earliestReleaseTime = endpoint.getReleaseInformation().getLastReleasedEventTime(); 
     106                        } 
     107                } 
     108                log.info("GC. Garbage collection has found all events previous to {} can be removed",earliestReleaseTime); 
     109                for (BaseEventParser parser : parsingModules){ 
     110                                EntryHandler entryHandler = parser.getEntryHandler(); 
     111                                log.info("GC. Parsing Module {} has {} events before garbage collection",parser,entryHandler.getNumberOfEntries()); 
     112                                entryHandler.removeEventsBefore(earliestReleaseTime); 
     113                                log.info("GC. Parsing Module {} has {} events after garbage collection", parser,entryHandler.getNumberOfEntries()); 
     114                                 
     115                } 
     116                                 
     117        } 
     118 
    91119 
    92120 
Note: See TracChangeset for help on using the changeset viewer.