Search in sources :

Example 1 with BackingMapManager

use of com.tangosol.net.BackingMapManager 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);
}
Also used : BackingMapManager(com.tangosol.net.BackingMapManager) ReadWriteBackingMap(com.tangosol.net.cache.ReadWriteBackingMap) DefaultConfigurableCacheFactory(com.tangosol.net.DefaultConfigurableCacheFactory) BackingMapManager(com.tangosol.net.BackingMapManager) ReadWriteBackingMap(com.tangosol.net.cache.ReadWriteBackingMap) Map(java.util.Map) NearCache(com.tangosol.net.cache.NearCache) NamedCache(com.tangosol.net.NamedCache) Cache(org.jivesoftware.util.cache.Cache)

Aggregations

BackingMapManager (com.tangosol.net.BackingMapManager)1 DefaultConfigurableCacheFactory (com.tangosol.net.DefaultConfigurableCacheFactory)1 NamedCache (com.tangosol.net.NamedCache)1 NearCache (com.tangosol.net.cache.NearCache)1 ReadWriteBackingMap (com.tangosol.net.cache.ReadWriteBackingMap)1 Map (java.util.Map)1 Cache (org.jivesoftware.util.cache.Cache)1