Search in sources :

Example 1 with BroadcasterCache

use of org.atmosphere.runtime.BroadcasterCache in project atmosphere by Atmosphere.

the class AtmosphereResourceStateRecovery method retrieveCache.

public List<Object> retrieveCache(AtmosphereResource r, BroadcasterTracker tracker, boolean force) {
    List<Object> cachedMessages = new LinkedList<Object>();
    for (String broadcasterID : tracker.ids()) {
        Broadcaster b = factory.lookup(broadcasterID, false);
        BroadcasterCache cache;
        logger.trace("About to retrieve cached messages for resource {} with Broadcaster {}, tracked by " + b, r.uuid(), r.getBroadcaster());
        if (b != null && (force || !b.getID().equalsIgnoreCase(r.getBroadcaster().getID()))) {
            // We cannot add the resource now. we need to first make sure there is no cached message.
            cache = b.getBroadcasterConfig().getBroadcasterCache();
            List<Object> t = cache.retrieveFromCache(b.getID(), r.uuid());
            t = b.getBroadcasterConfig().applyFilters(r, t);
            if (!t.isEmpty()) {
                logger.trace("Found Cached Messages For AtmosphereResource {} with Broadcaster {}", r.uuid(), broadcasterID);
                cachedMessages.addAll(t);
            }
        } else {
            logger.trace("Broadcaster {} is no longer available for {}", broadcasterID, r);
        }
    }
    return cachedMessages;
}
Also used : Broadcaster(org.atmosphere.runtime.Broadcaster) LinkedList(java.util.LinkedList) BroadcasterCache(org.atmosphere.runtime.BroadcasterCache)

Aggregations

LinkedList (java.util.LinkedList)1 Broadcaster (org.atmosphere.runtime.Broadcaster)1 BroadcasterCache (org.atmosphere.runtime.BroadcasterCache)1