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;
}
Aggregations