mondrian.spi
Interface SegmentCache

All Known Implementing Classes:
MockSegmentCache

public interface SegmentCache

SPI definition of the segments cache.

Lookups are performed using SegmentHeaders and SegmentBodys. Both are immutable and fully serializable.

There are two ways to declare a SegmentCache implementation in Mondrian. The first one (and the one which will be used by default) is to set the MondrianProperties.SegmentCache property. The second one is to use the Java Services API. You will need to create a jar file, accessible through the same class loader as Mondrian, and add a file called /META-INF/services/mondrian.spi.SegmentCache which contains the name of the segment cache implementation to use. If more than one SegmentCache Java service is found, the first one found is used. This is a non-deterministic choice as there are no guarantees as to which will appear first. This later mean of discovery is overridden by defining the MondrianProperties.SegmentCache property.

Implementations are expected to be thread-safe. It is the responsibility of the cache implementation to maintain a consistent state.

Implementations must provide a default empty constructor. Segment caches are instantiated as a singleton but can be hot swapped by modifying MondrianProperties.SegmentCache.

Version:
$Id: //open/mondrian/src/main/mondrian/spi/SegmentCache.java#3 $
Author:
LBoudreau
See Also:
MondrianProperties.SegmentCache

Method Summary
 Future<Boolean> contains(SegmentHeader header)
          Checks if the cache contains a SegmentBody corresponding to the supplied SegmentHeader.
 Future<Boolean> flush(SegmentHeader.ConstrainedColumn[] region)
          Flushes a dimensionality region from the cache.
 Future<SegmentBody> get(SegmentHeader header)
          Returns a future SegmentBody object once the cache has returned any results, or null of no segment corresponding to the header could be found.
 Future<List<SegmentHeader>> getSegmentHeaders()
          Returns a list of all segments present in the cache.
 Future<Boolean> put(SegmentHeader header, SegmentBody body)
          Stores a segment data in the cache.
 Future<Boolean> remove(SegmentHeader header)
          Removes a segment from the cache.
 void tearDown()
          Tear down and clean up the cache.
 

Method Detail

get

Future<SegmentBody> get(SegmentHeader header)
Returns a future SegmentBody object once the cache has returned any results, or null of no segment corresponding to the header could be found.

Parameters:
header - The header of the segment to find. Consider this as a key.
Returns:
A Future SegmentBody or a Future null if no corresponding segment could be found in cache.

contains

Future<Boolean> contains(SegmentHeader header)
Checks if the cache contains a SegmentBody corresponding to the supplied SegmentHeader.

Parameters:
header - A header to lookup in the cache.
Returns:
A Future true or a Future false if no corresponding segment could be found in cache.

getSegmentHeaders

Future<List<SegmentHeader>> getSegmentHeaders()
Returns a list of all segments present in the cache.

Returns:
A List of segment headers describing the contents of the cache.

put

Future<Boolean> put(SegmentHeader header,
                    SegmentBody body)
Stores a segment data in the cache.

Parameters:
header - The header of the segment.
body - The segment body to cache.
Returns:
A Future object which returns true or false depending on the success of the caching operation.

remove

Future<Boolean> remove(SegmentHeader header)
Removes a segment from the cache.

Parameters:
header - The header of the segment we want to remove.
Returns:
True if the segment was found and removed, false otherwise.

flush

Future<Boolean> flush(SegmentHeader.ConstrainedColumn[] region)
Flushes a dimensionality region from the cache.

Parameters:
region - The region to flush.
Returns:
True if the operation succeeded, false otherwise.

tearDown

void tearDown()
Tear down and clean up the cache.


Get Mondrian at SourceForge.net. Fast, secure and free Open Source software downloads