Class SegmentCacheManager.CompositeSegmentCache
- java.lang.Object
-
- mondrian.rolap.agg.SegmentCacheManager.CompositeSegmentCache
-
- All Implemented Interfaces:
SegmentCache
- Enclosing class:
- SegmentCacheManager
static class SegmentCacheManager.CompositeSegmentCache extends Object implements SegmentCache
Makes a collection ofSegmentCacheWorkerobjects (each of which is backed by aSegmentCacheappear to be a SegmentCache.For most operations, it is easier to operate on a single cache. It is usually clear whether operations should quit when finding the first match, or to operate on all workers. (For example,
remove(mondrian.spi.SegmentHeader)tries to remove the segment header from all workers, and returns whether it was removed from any of them.) This class just does what seems most typical. If you want another behavior for a particular operation, operate on the workers directly.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface mondrian.spi.SegmentCache
SegmentCache.SegmentCacheInjector, SegmentCache.SegmentCacheListener
-
-
Field Summary
Fields Modifier and Type Field Description (package private) List<SegmentCacheWorker>workers
-
Constructor Summary
Constructors Constructor Description CompositeSegmentCache(List<SegmentCacheWorker> workers)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(SegmentCache.SegmentCacheListener listener)Adds a listener to this segment cache implementation.SegmentBodyget(SegmentHeader header)Returns a SegmentBody once the cache has returned any results, or null if no segment corresponding to the header could be found.List<SegmentHeader>getSegmentHeaders()Returns a list of all segments present in the cache.booleanput(SegmentHeader header, SegmentBody body)Stores a segment data in the cache.booleanremove(SegmentHeader header)Removes a segment from the cache.voidremoveListener(SegmentCache.SegmentCacheListener listener)Unregisters a listener from this segment cache implementation.booleansupportsRichIndex()Tells Mondrian whether this segment cache uses theSegmentHeaderobjects as an index, thus preserving them in a serialized state, or if it uses its identification number only.voidtearDown()Tear down and clean up the cache.
-
-
-
Field Detail
-
workers
final List<SegmentCacheWorker> workers
-
-
Constructor Detail
-
CompositeSegmentCache
public CompositeSegmentCache(List<SegmentCacheWorker> workers)
-
-
Method Detail
-
get
public SegmentBody get(SegmentHeader header)
Description copied from interface:SegmentCacheReturns a SegmentBody once the cache has returned any results, or null if no segment corresponding to the header could be found.Cache implementations are at liberty to 'forget' segments. Therefore it is allowable for this method to return null at any time
- Specified by:
getin interfaceSegmentCache- Parameters:
header- The header of the segment to find. Consider this as a key.- Returns:
- A SegmentBody, or
nullif no corresponding segment could be found in cache.
-
getSegmentHeaders
public List<SegmentHeader> getSegmentHeaders()
Description copied from interface:SegmentCacheReturns a list of all segments present in the cache.- Specified by:
getSegmentHeadersin interfaceSegmentCache- Returns:
- A List of segment headers describing the contents of the cache.
-
put
public boolean put(SegmentHeader header, SegmentBody body)
Description copied from interface:SegmentCacheStores a segment data in the cache.- Specified by:
putin interfaceSegmentCache- Parameters:
header- The header of the segment.body- The segment body to cache.- Returns:
- Whether the cache write succeeded
-
remove
public boolean remove(SegmentHeader header)
Description copied from interface:SegmentCacheRemoves a segment from the cache.- Specified by:
removein interfaceSegmentCache- Parameters:
header- The header of the segment we want to remove.- Returns:
- True if the segment was found and removed, false otherwise.
-
tearDown
public void tearDown()
Description copied from interface:SegmentCacheTear down and clean up the cache.- Specified by:
tearDownin interfaceSegmentCache
-
addListener
public void addListener(SegmentCache.SegmentCacheListener listener)
Description copied from interface:SegmentCacheAdds a listener to this segment cache implementation. The listener will get notified viaSegmentCache.SegmentCacheListener.SegmentCacheEventinstances.- Specified by:
addListenerin interfaceSegmentCache- Parameters:
listener- The listener to attach to this cache.
-
removeListener
public void removeListener(SegmentCache.SegmentCacheListener listener)
Description copied from interface:SegmentCacheUnregisters a listener from this segment cache implementation.- Specified by:
removeListenerin interfaceSegmentCache- Parameters:
listener- The listener to remove.
-
supportsRichIndex
public boolean supportsRichIndex()
Description copied from interface:SegmentCacheTells Mondrian whether this segment cache uses theSegmentHeaderobjects as an index, thus preserving them in a serialized state, or if it uses its identification number only.Not using a rich index prevents Mondrian from doing partial cache invalidation.
It is assumed that this method returns fairly quickly, and for a given cache always returns the same value.
- Specified by:
supportsRichIndexin interfaceSegmentCache- Returns:
- Whether this segment cache preserves headers in serialized state
-
-