Ejemplo n.º 1
0
 public boolean contains(SegmentHeader header) {
   for (SegmentCacheWorker worker : workers) {
     if (worker.contains(header)) {
       return true;
     }
   }
   return false;
 }
Ejemplo n.º 2
0
 public boolean remove(SegmentHeader header) {
   boolean result = false;
   for (SegmentCacheWorker worker : workers) {
     if (worker.remove(header)) {
       result = true;
     }
   }
   return result;
 }
Ejemplo n.º 3
0
 public SegmentBody get(SegmentHeader header) {
   for (SegmentCacheWorker worker : workers) {
     final SegmentBody body = worker.get(header);
     if (body != null) {
       return body;
     }
   }
   return null;
 }
Ejemplo n.º 4
0
  public SegmentCacheManager(MondrianServer server) {
    this.server = server;
    ACTOR = new Actor();
    thread = new Thread(ACTOR, "mondrian.rolap.agg.SegmentCacheManager$ACTOR");
    thread.setDaemon(true);
    thread.start();

    // Create the index registry.
    this.indexRegistry = new SegmentCacheIndexRegistry();

    // Add a local cache, if needed.
    if (!MondrianProperties.instance().DisableCaching.get()) {
      final MemorySegmentCache cache = new MemorySegmentCache();
      segmentCacheWorkers.add(new SegmentCacheWorker(cache, thread));
    }

    // Add an external cache, if configured.
    final List<SegmentCache> externalCache = SegmentCacheWorker.initCache();
    for (SegmentCache cache : externalCache) {
      // Create a worker for this external cache
      segmentCacheWorkers.add(new SegmentCacheWorker(cache, thread));
      // Hook up a listener so it can update
      // the segment index.
      cache.addListener(new AsyncCacheListener(this, server));
    }

    compositeCache = new CompositeSegmentCache(segmentCacheWorkers);
  }
Ejemplo n.º 5
0
 public List<SegmentHeader> getSegmentHeaders() {
   // Special case 0 and 1 workers, for which the 'union' operation
   // is trivial.
   switch (workers.size()) {
     case 0:
       return Collections.emptyList();
     case 1:
       return workers.get(0).getSegmentHeaders();
     default:
       final List<SegmentHeader> list = new ArrayList<SegmentHeader>();
       final Set<SegmentHeader> set = new HashSet<SegmentHeader>();
       for (SegmentCacheWorker worker : workers) {
         for (SegmentHeader header : worker.getSegmentHeaders()) {
           if (set.add(header)) {
             list.add(header);
           }
         }
       }
       return list;
   }
 }
Ejemplo n.º 6
0
 public boolean put(SegmentHeader header, SegmentBody body) {
   for (SegmentCacheWorker worker : workers) {
     worker.put(header, body);
   }
   return true;
 }