Class SegmentCacheManager
- java.lang.Object
-
- mondrian.rolap.agg.SegmentCacheManager
-
public class SegmentCacheManager extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSegmentCacheManager.AbortExceptionException which someone can throw to indicate to the Actor that whatever it was doing is not needed anymore.static classSegmentCacheManager.Command<T>static classSegmentCacheManager.FlushCommandCommand to flush a particular region from cache.static classSegmentCacheManager.FlushResultResult of aSegmentCacheManager.FlushCommand.classSegmentCacheManager.SegmentCacheIndexRegistryRegistry of all the indexes that were created for this cache manager, perRolapStar.static interfaceSegmentCacheManager.VisitorVisitor for messages (commands and events).
-
Field Summary
Fields Modifier and Type Field Description ExecutorServicecacheExecutorExecutor with which to send requests to external caches.SegmentCachecompositeCacheList<SegmentCacheWorker>segmentCacheWorkersExecutorServicesqlExecutorExecutor with which to execute SQL requests.Threadthread
-
Constructor Summary
Constructors Constructor Description SegmentCacheManager(MondrianServer server)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Texecute(SegmentCacheManager.Command<T> command)voidexternalSegmentCreated(SegmentHeader header, MondrianServer server)Tells the cache that a segment is newly available in an external cache.voidexternalSegmentDeleted(SegmentHeader header, MondrianServer server)Tells the cache that a segment is no longer available in an external cache.SegmentBuilder.SegmentConvertergetConverter(RolapStar star, SegmentHeader header)SegmentCacheManager.SegmentCacheIndexRegistrygetIndexRegistry()booleanloadCacheForStar(RolapStar star)Load external cached elements for received star.voidloadFailed(RolapStar star, SegmentHeader header, Throwable throwable)Informs cache manager that a segment load failed.voidloadSucceeded(RolapStar star, SegmentHeader header, SegmentBody body)Adds a segment to segment index.SegmentWithDatapeek(CellRequest request)Makes a quick request to the aggregation manager to see whether the cell value required by a particular cell request is in external cache.voidprintCacheState(CacheControl.CellRegion region, PrintWriter pw, Locus locus)voidremove(RolapStar star, SegmentHeader header)Removes a segment from segment index.voidshutdown()Shuts down this cache manager and all active threads and indexes.
-
-
-
Field Detail
-
thread
public final Thread thread
-
cacheExecutor
public final ExecutorService cacheExecutor
Executor with which to send requests to external caches.
-
sqlExecutor
public final ExecutorService sqlExecutor
Executor with which to execute SQL requests.TODO: create using factory and/or configuration parameters. Executor should be shared within MondrianServer or target JDBC database.
-
segmentCacheWorkers
public final List<SegmentCacheWorker> segmentCacheWorkers
-
compositeCache
public final SegmentCache compositeCache
-
-
Constructor Detail
-
SegmentCacheManager
public SegmentCacheManager(MondrianServer server)
-
-
Method Detail
-
loadCacheForStar
public boolean loadCacheForStar(RolapStar star)
Load external cached elements for received star. Similar toexternalSegmentCreatedbut the index is created if not there.- Parameters:
star- the star for which the cache is loaded- Returns:
- true if elements existed for this star.
-
execute
public <T> T execute(SegmentCacheManager.Command<T> command)
-
getIndexRegistry
public SegmentCacheManager.SegmentCacheIndexRegistry getIndexRegistry()
-
loadSucceeded
public void loadSucceeded(RolapStar star, SegmentHeader header, SegmentBody body)
Adds a segment to segment index.Called when a SQL statement has finished loading a segment.
Does not add the segment to the external cache. That is a potentially long-duration operation, better carried out by a worker.
- Parameters:
header- segment headerbody- segment body
-
loadFailed
public void loadFailed(RolapStar star, SegmentHeader header, Throwable throwable)
Informs cache manager that a segment load failed.Called when a SQL statement receives an error while loading a segment.
- Parameters:
header- segment headerthrowable- Error
-
remove
public void remove(RolapStar star, SegmentHeader header)
Removes a segment from segment index.Call is asynchronous. It comes back immediately.
Does not remove it from the external cache.
- Parameters:
header- segment header
-
externalSegmentCreated
public void externalSegmentCreated(SegmentHeader header, MondrianServer server)
Tells the cache that a segment is newly available in an external cache.
-
externalSegmentDeleted
public void externalSegmentDeleted(SegmentHeader header, MondrianServer server)
Tells the cache that a segment is no longer available in an external cache.
-
printCacheState
public void printCacheState(CacheControl.CellRegion region, PrintWriter pw, Locus locus)
-
shutdown
public void shutdown()
Shuts down this cache manager and all active threads and indexes.
-
getConverter
public SegmentBuilder.SegmentConverter getConverter(RolapStar star, SegmentHeader header)
-
peek
public SegmentWithData peek(CellRequest request)
Makes a quick request to the aggregation manager to see whether the cell value required by a particular cell request is in external cache.'Quick' is relative. It is an asynchronous request (due to the aggregation manager being an actor) and therefore somewhat slow. If the segment is in cache, will save batching up future requests and re-executing the query. Win should be particularly noticeable for queries running on a populated cache. Without this feature, every query would require at least two iterations.
Request does not issue SQL to populate the segment. Nor does it try to find existing segments for rollup. Those operations can wait until next phase.
Client is responsible for adding the segment to its private cache.
- Parameters:
request- Cell request- Returns:
- Segment with data, or null if not in cache
-
-