public boolean contains(SegmentHeader header) {
   for (SegmentCacheWorker worker : workers) {
     if (worker.contains(header)) {
       return true;
     }
   }
   return false;
 }
 public boolean remove(SegmentHeader header) {
   boolean result = false;
   for (SegmentCacheWorker worker : workers) {
     if (worker.remove(header)) {
       result = true;
     }
   }
   return result;
 }
 public SegmentBody get(SegmentHeader header) {
   for (SegmentCacheWorker worker : workers) {
     final SegmentBody body = worker.get(header);
     if (body != null) {
       return body;
     }
   }
   return null;
 }
  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);
  }
 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;
   }
 }
 public boolean put(SegmentHeader header, SegmentBody body) {
   for (SegmentCacheWorker worker : workers) {
     worker.put(header, body);
   }
   return true;
 }