use of com.tangosol.net.cache.ReadWriteBackingMap in project Openfire by igniterealtime.
the class ClusteredCache method init.
private void init(String name, NamedCache cache) {
map = cache;
BackingMapManager backingManager = cache.getCacheService().getBackingMapManager();
Map mapBacking = null;
if (backingManager instanceof DefaultConfigurableCacheFactory.Manager) {
DefaultConfigurableCacheFactory.Manager actualManager = (DefaultConfigurableCacheFactory.Manager) backingManager;
int count = 0;
mapBacking = actualManager.getBackingMap(name);
//by the coherence api
while (mapBacking == null && count < 5) {
// Wait a full second
try {
Thread.sleep(1000);
} catch (Exception e) {
/*ignore*/
}
count++;
mapBacking = actualManager.getBackingMap(name);
}
if (mapBacking instanceof ReadWriteBackingMap) {
ReadWriteBackingMap readWriteMap = (ReadWriteBackingMap) mapBacking;
Map realBackingMap = readWriteMap.getInternalCache();
if (realBackingMap instanceof Cache) {
backingCache = (Cache) realBackingMap;
}
} else if (mapBacking instanceof Cache) {
backingCache = (Cache) mapBacking;
}
}
if (backingCache == null) {
throw new IllegalStateException("Unable to access backing cache for " + name + ". BackingMapManager is a " + backingManager.getClass().getName() + " and backing map is " + ((mapBacking != null) ? mapBacking.getClass().getName() : "null"));
}
backingCache.setName(name);
}
Aggregations