/** * Gets a queue from cache or creates one if it's not cached. * * @param name Name of queue. * @param grpName Group name. If present, will override groupName from configuration. * @param cap Max size of queue. * @param cfg Non-null queue configuration if new queue should be created. * @return Instance of queue. * @throws IgniteCheckedException If failed. */ public final <T> IgniteQueue<T> queue(final String name, @Nullable final String grpName, int cap, @Nullable final CollectionConfiguration cfg) throws IgniteCheckedException { A.notNull(name, "name"); if (cfg != null) { if (cap <= 0) cap = Integer.MAX_VALUE; } final int cap0 = cap; final boolean create = cfg != null; return getCollection(new IgniteClosureX<GridCacheContext, IgniteQueue<T>>() { @Override public IgniteQueue<T> applyx(GridCacheContext ctx) throws IgniteCheckedException { return ctx.dataStructures().queue(name, cap0, isCollocated(cfg), create); } }, cfg, name, grpName, QUEUE, create, false); }
/** * 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 queue from cache or creates one if it's not cached. * * @param name Name of queue. * @param grpName Group name. If present, will override groupName from configuration. * @param cap Max size of queue. * @param cfg Non-null queue configuration if new queue should be created. * @return Instance of queue. * @throws IgniteCheckedException If failed. */ @SuppressWarnings("unchecked") public final <T> IgniteQueue<T> queue(final String name, @Nullable final String grpName, int cap, @Nullable final CollectionConfiguration cfg) throws IgniteCheckedException { A.notNull(name, "name"); if (cfg != null) { if (cap <= 0) cap = Integer.MAX_VALUE; } final int cap0 = cap; final boolean create = cfg != null; return getCollection(new IgniteClosureX<GridCacheContext, IgniteQueue<T>>() { @Override public IgniteQueue<T> applyx(GridCacheContext ctx) throws IgniteCheckedException { return ctx.dataStructures().queue(name, cap0, isCollocated(cfg), create); } }, cfg, name, grpName, QUEUE, create, false); }
/** * 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); }