org.mmbase.cache
Class ReleaseStrategy

Package class diagram package ReleaseStrategy
java.lang.Object
  extended by org.mmbase.cache.ReleaseStrategy
Direct Known Subclasses:
BasicReleaseStrategy, BetterStrategy, ChainedReleaseStrategy, ConstraintsMatchingStrategy

public abstract class ReleaseStrategy
extends Object

This class is the base for all cache release strategies. You should extend this to create your own. It will contain a number of usefull utility methods to analyze query objecs and cached search results. Feel free to add those In case you miss one developing your own strategies.

Since:
MMBase-1.8
Version:
$Id: ReleaseStrategy.java 45253 2011-02-16 19:33:09Z michiel $
Author:
Ernst Bunders

Nested Class Summary
static class ReleaseStrategy.StrategyResult
           
 
Constructor Summary
ReleaseStrategy()
           
 
Method Summary
 void clear()
           
protected abstract  boolean doEvaluate(NodeEvent event, SearchQuery query, List<MMObjectNode> cachedResult)
          implement this method to create your own strategy.
protected abstract  boolean doEvaluate(RelationEvent event, SearchQuery query, List<MMObjectNode> cachedResult)
          implement this method to create your own strategy.
 boolean equals(Object ob)
           
 ReleaseStrategy.StrategyResult evaluate(NodeEvent event, SearchQuery query, List<MMObjectNode> cachedResult)
          This method checks if evaluation should happen (active), keeps the time of the operation and updates the statistics.
 ReleaseStrategy.StrategyResult evaluate(RelationEvent event, SearchQuery query, List<MMObjectNode> cachedResult)
           
 int getAvgEvaluationTimeInMilis()
           
protected static List<Constraint> getConstraintsForField(String fieldName, MMObjectBuilder builder, Constraint constraint, SearchQuery query)
          utility for specializations: get all the constraints in the query that apply to a certain field TODO MM: This method is used like this: if(getConstraintsForField(fieldName, eventBuilder, constraint, query).size() > 0){ return false;} IOW, only the size of the return list is used, and then even whether it is 0 or not.
abstract  String getDescription()
           
abstract  String getName()
           
protected static List<SortOrder> getSortordersForField(String fieldName, MMObjectBuilder builder, List<SortOrder> sortOrders, SearchQuery query)
          utility for specializations: get all the sortorders in the query that apply to a certain field TODO MM: See remark at getConstraintsForField(java.lang.String, org.mmbase.module.core.MMObjectBuilder, org.mmbase.storage.search.Constraint, org.mmbase.storage.search.SearchQuery)
 int getTotalEvaluated()
           
 long getTotalEvaluationTimeMillis()
           
 int getTotalPreserved()
           
 int hashCode()
           
 boolean isEnabled()
           
 void setEnabled(boolean newStatus)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReleaseStrategy

public ReleaseStrategy()
Method Detail

getName

public abstract String getName()

getDescription

public abstract String getDescription()

getAvgEvaluationTimeInMilis

public int getAvgEvaluationTimeInMilis()

getTotalEvaluationTimeMillis

public long getTotalEvaluationTimeMillis()

evaluate

public final ReleaseStrategy.StrategyResult evaluate(NodeEvent event,
                                                     SearchQuery query,
                                                     List<MMObjectNode> cachedResult)
This method checks if evaluation should happen (active), keeps the time of the operation and updates the statistics. To implement you own strategy override doEvaluate(NodeEvent event, SearchQuery query, List cachedResult).


evaluate

public final ReleaseStrategy.StrategyResult evaluate(RelationEvent event,
                                                     SearchQuery query,
                                                     List<MMObjectNode> cachedResult)

getTotalPreserved

public int getTotalPreserved()

getTotalEvaluated

public int getTotalEvaluated()

doEvaluate

protected abstract boolean doEvaluate(NodeEvent event,
                                      SearchQuery query,
                                      List<MMObjectNode> cachedResult)
implement this method to create your own strategy.

Parameters:
event - a node event
query -
cachedResult -
Returns:
true if the cache entry should be released

doEvaluate

protected abstract boolean doEvaluate(RelationEvent event,
                                      SearchQuery query,
                                      List<MMObjectNode> cachedResult)
implement this method to create your own strategy.

Parameters:
event - a relation event
query -
cachedResult -
Returns:
true if the cache entry should be released

setEnabled

public void setEnabled(boolean newStatus)

isEnabled

public boolean isEnabled()

clear

public void clear()

equals

public boolean equals(Object ob)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

getConstraintsForField

protected static List<Constraint> getConstraintsForField(String fieldName,
                                                         MMObjectBuilder builder,
                                                         Constraint constraint,
                                                         SearchQuery query)
utility for specializations: get all the constraints in the query that apply to a certain field TODO MM: This method is used like this: if(getConstraintsForField(fieldName, eventBuilder, constraint, query).size() > 0){ return false;} IOW, only the size of the return list is used, and then even whether it is 0 or not. I think it is a waste to construct a complete new list, only for that. Perhaps the method should return an Iterator?, and can be used with only 'hasNext()', constructing a longer list then necessary is avoided then.

Parameters:
fieldName -
builder -
constraint -
query -

getSortordersForField

protected static List<SortOrder> getSortordersForField(String fieldName,
                                                       MMObjectBuilder builder,
                                                       List<SortOrder> sortOrders,
                                                       SearchQuery query)
utility for specializations: get all the sortorders in the query that apply to a certain field TODO MM: See remark at getConstraintsForField(java.lang.String, org.mmbase.module.core.MMObjectBuilder, org.mmbase.storage.search.Constraint, org.mmbase.storage.search.SearchQuery)

Parameters:
fieldName -
builder -
sortOrders -
query -


MMBase2 Core 2.0-SNAPSHOT - 2014-09-22T23:08