use of org.apache.ignite.internal.processors.datastructures.GridCacheSetHeaderKey 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();
}
}
Aggregations