Search in sources :

Example 1 with GridCacheSetProxy

use of org.apache.ignite.internal.processors.datastructures.GridCacheSetProxy in project ignite by apache.

the class CacheDataStructuresManager method onReconnected.

/**
     * @param clusterRestarted Cluster restarted flag.
     * @throws IgniteCheckedException If failed.
     */
public void onReconnected(boolean clusterRestarted) throws IgniteCheckedException {
    for (Map.Entry<IgniteUuid, GridCacheSetProxy> e : setsMap.entrySet()) {
        GridCacheSetProxy set = e.getValue();
        if (clusterRestarted) {
            set.blockOnRemove();
            setsMap.remove(e.getKey(), set);
        } else
            set.needCheckNotRemoved();
    }
    for (Map.Entry<IgniteUuid, GridCacheQueueProxy> e : queuesMap.entrySet()) {
        GridCacheQueueProxy queue = e.getValue();
        if (clusterRestarted) {
            queue.delegate().onRemoved(false);
            queuesMap.remove(e.getKey(), queue);
        }
    }
}
Also used : GridCacheSetProxy(org.apache.ignite.internal.processors.datastructures.GridCacheSetProxy) IgniteUuid(org.apache.ignite.lang.IgniteUuid) GridCacheQueueProxy(org.apache.ignite.internal.processors.datastructures.GridCacheQueueProxy) Map(java.util.Map) ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 2 with GridCacheSetProxy

use of org.apache.ignite.internal.processors.datastructures.GridCacheSetProxy in project ignite by apache.

the class CacheDataStructuresManager method set0.

/**
     * @param name Name of set.
     * @param collocated Collocation flag.
     * @param create If {@code true} set will be created in case it is not in cache.
     * @return Set.
     * @throws IgniteCheckedException If failed.
     */
@SuppressWarnings("unchecked")
@Nullable
private <T> IgniteSet<T> set0(String name, boolean collocated, boolean create) throws IgniteCheckedException {
    cctx.gate().enter();
    try {
        GridCacheSetHeaderKey key = new GridCacheSetHeaderKey(name);
        GridCacheSetHeader hdr;
        IgniteInternalCache cache = cctx.cache().withNoRetries();
        if (create) {
            hdr = new GridCacheSetHeader(IgniteUuid.randomUuid(), collocated);
            GridCacheSetHeader old = (GridCacheSetHeader) cache.getAndPutIfAbsent(key, hdr);
            if (old != null)
                hdr = old;
        } else
            hdr = (GridCacheSetHeader) cache.get(key);
        if (hdr == null)
            return null;
        GridCacheSetProxy<T> set = setsMap.get(hdr.id());
        if (set == null) {
            GridCacheSetProxy<T> old = setsMap.putIfAbsent(hdr.id(), set = new GridCacheSetProxy<>(cctx, new GridCacheSetImpl<T>(cctx, name, hdr)));
            if (old != null)
                set = old;
        }
        return set;
    } finally {
        cctx.gate().leave();
    }
}
Also used : GridCacheSetProxy(org.apache.ignite.internal.processors.datastructures.GridCacheSetProxy) BROADCAST(org.apache.ignite.internal.GridClosureCallMode.BROADCAST) IgniteInternalCache(org.apache.ignite.internal.processors.cache.IgniteInternalCache) GridCacheSetHeaderKey(org.apache.ignite.internal.processors.datastructures.GridCacheSetHeaderKey) GridCacheSetHeader(org.apache.ignite.internal.processors.datastructures.GridCacheSetHeader) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

GridCacheSetProxy (org.apache.ignite.internal.processors.datastructures.GridCacheSetProxy)2 Map (java.util.Map)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 BROADCAST (org.apache.ignite.internal.GridClosureCallMode.BROADCAST)1 IgniteInternalCache (org.apache.ignite.internal.processors.cache.IgniteInternalCache)1 GridCacheQueueProxy (org.apache.ignite.internal.processors.datastructures.GridCacheQueueProxy)1 GridCacheSetHeader (org.apache.ignite.internal.processors.datastructures.GridCacheSetHeader)1 GridCacheSetHeaderKey (org.apache.ignite.internal.processors.datastructures.GridCacheSetHeaderKey)1 IgniteUuid (org.apache.ignite.lang.IgniteUuid)1 Nullable (org.jetbrains.annotations.Nullable)1