/** * Gets a set from cache or creates one if it's not cached. * * @param name Set name. * @param grpName Group name. If present, will override groupName from configuration. * @param cfg Set configuration if new set should be created. * @return Set instance. * @throws IgniteCheckedException If failed. */ @Nullable public <T> IgniteSet<T> set(final String name, @Nullable final String grpName, @Nullable final CollectionConfiguration cfg) throws IgniteCheckedException { A.notNull(name, "name"); final boolean create = cfg != null; final boolean collocated = isCollocated(cfg); final boolean separated = !collocated && U.isOldestNodeVersionAtLeast(SEPARATE_CACHE_PER_NON_COLLOCATED_SET_SINCE, ctx.grid().cluster().nodes()); return getCollection(new CX1<GridCacheContext, IgniteSet<T>>() { @Override public IgniteSet<T> applyx(GridCacheContext cctx) throws IgniteCheckedException { return cctx.dataStructures().set(name, collocated, create, separated); } }, cfg, name, grpName, SET, create, separated); }
/** * Gets a set from cache or creates one if it's not cached. * * @param name Set name. * @param grpName Group name. If present, will override groupName from configuration. * @param cfg Set configuration if new set should be created. * @return Set instance. * @throws IgniteCheckedException If failed. */ @SuppressWarnings("unchecked") @Nullable public <T> IgniteSet<T> set(final String name, @Nullable final String grpName, @Nullable final CollectionConfiguration cfg) throws IgniteCheckedException { A.notNull(name, "name"); final boolean create = cfg != null; final boolean collocated = isCollocated(cfg); final boolean separated = !collocated && U.isOldestNodeVersionAtLeast(SEPARATE_CACHE_PER_NON_COLLOCATED_SET_SINCE, ctx.grid().cluster().nodes()); return getCollection(new CX1<GridCacheContext, IgniteSet<T>>() { @Override public IgniteSet<T> applyx(GridCacheContext cctx) throws IgniteCheckedException { return cctx.dataStructures().set(name, collocated, create, separated); } }, cfg, name, grpName, SET, create, separated); }