/** * Default constructor. * * @param name - Name of cache data structure. */ public GridCacheInternalKeyImpl(String name) { assert !F.isEmpty(name); this.name = name; }
/** * Constructs random event router with optional set of filters to apply to streamer projection. * * @param predicates Node predicates. */ @SuppressWarnings("unchecked") public GridStreamerRandomEventRouter(Collection<GridPredicate<GridNode>> predicates) { if (!F.isEmpty(predicates)) { this.predicates = new GridPredicate[predicates.size()]; predicates.toArray(this.predicates); } }
/** * Gets simple class name taking care of empty names. * * @param cls Class to get the name for. * @return Simple class name. */ public static String getSimpleName(Class<?> cls) { String name = cls.getSimpleName(); if (F.isEmpty(name)) name = cls.getName().substring(cls.getPackage().getName().length() + 1); return name; }
/** {@inheritDoc} */ @Override public final void removeMetrics(Collection<UUID> nodeIds) throws GridSpiException { assert !F.isEmpty(nodeIds); for (UUID id : nodeIds) { metricsMap.remove(id); tsMap.remove(id); } removeMetrics0(nodeIds); }
/** * Adds owned versions to map. * * @param vers Map of owned versions. */ public void ownedVersions(Map<K, GridCacheVersion> vers) { if (F.isEmpty(vers)) return; if (owned == null) owned = new GridLeanMap<>(vers.size()); owned.putAll(vers); }
/** {@inheritDoc} */ @Override public boolean removeAll(@Nullable Collection<?> c) { boolean res = false; if (!F.isEmpty(c)) { assert c != null; for (Object o : c) { res |= remove(o); } } return res; }
/** * Synchronously waits for all futures in the collection. * * @param futs Futures to wait for. * @throws GridException If any of the futures threw exception. */ public static void waitAll(@Nullable Iterable<GridFuture<?>> futs) throws GridException { if (F.isEmpty(futs)) return; for (GridFuture fut : futs) fut.get(); }
/** * Logs warning if needed. * * @param log Logger. * @param e Error (optional). * @param longMsg Long message (or just message). * @param shortMsg Short message for quite logging. */ public static void warn(@Nullable GridLogger log, @Nullable Throwable e, String longMsg, @Nullable String shortMsg) { assert !F.isEmpty(longMsg); log(log, e, longMsg, shortMsg, LogLevel.WARN); }
/** {@inheritDoc} */ @Override public boolean addAll(@Nullable Collection<? extends E> c) { boolean res = false; if (!F.isEmpty(c)) { assert c != null; for (E e : c) { res |= add(e); } } return res; }
/** {@inheritDoc} */ @Override public boolean removeAll(@Nullable Collection<?> c) { boolean res = false; if (!F.isEmpty(c)) { assert c != null; for (Object o : c) { res |= remove(o); } } return res; }
/** * @param arr Sorted array to search in. * @param val Value. * @return {@code True} if value has been found. */ private boolean binarySearch(@Nullable int[] arr, int val) { if (F.isEmpty(arr)) return false; // If length is relatively small, full iteration is faster. return arr.length <= 128 ? F.contains(arr, val) : Arrays.binarySearch(arr, val) >= 0; }
/** {@inheritDoc} */ @Override public Set<GridCacheFlag> flags() { GridCacheFlag[] forced = cctx.forcedFlags(); if (F.isEmpty(forced)) return flags; // We don't expect too many flags, so default size is fine. Set<GridCacheFlag> ret = new HashSet<>(); ret.addAll(flags); ret.addAll(F.asList(forced)); return Collections.unmodifiableSet(ret); }
/** {@inheritDoc} */ @Override public Map<Integer, GridNode> mapPartitionsToNodes(Collection<Integer> parts) { A.notNull(parts, "parts"); Map<Integer, GridNode> map = new HashMap<>(); if (!F.isEmpty(parts)) { for (int p : parts) map.put(p, mapPartitionToNode(p)); } return map; }
/** {@inheritDoc} */ @Override public boolean apply(GridNode n) { if (!U.hasStreamer(n, streamerName)) return false; if (!F.isEmpty(streamerNames)) for (String sn : streamerNames) if (!U.hasStreamer(n, sn)) return false; return true; } }
/** {@inheritDoc} */ @Override public GridFuture<?> transformAllAsync(@Nullable Map<? extends K, ? extends GridClosure<V, V>> m) { if (F.isEmpty(m)) return new GridFinishedFuture<Object>(ctx.kernalContext()); return updateAllAsync0(null, m, null, null, false, false, null, 0, null); }
/** {@inheritDoc} */ @Override public Collection<String> getLifecycleBeansFormatted() { GridLifecycleBean[] beans = cfg.getLifecycleBeans(); return F.isEmpty(beans) ? Collections.<String>emptyList() : F.transform(beans, F.<GridLifecycleBean>string()); }
/** * @return Queue size. */ public int size() { int rmvSize = F.isEmpty(removedIndexes()) ? 0 : removedIndexes().size(); int size = (int)(tail() - head() - rmvSize); assert size >= 0 : size; return size; }
/** {@inheritDoc} */ @Override public void addAttributes(Map<String, Object> attrs) throws GridException { super.addAttributes(attrs); GridStreamerConfiguration[] cfg = ctx.config().getStreamerConfiguration(); if (F.isEmpty(cfg)) return; GridStreamerAttributes[] arr = new GridStreamerAttributes[cfg.length]; int i = 0; for (GridStreamerConfiguration c : cfg) arr[i++] = new GridStreamerAttributes(c); attrs.put(ATTR_STREAMER, arr); }
/** {@inheritDoc} */ @Override public void start() throws GridException { if (ctx.isDaemon()) return; GridConfiguration cfg = ctx.config(); GridDeploymentMode depMode = cfg.getDeploymentMode(); if (cfg.isPeerClassLoadingEnabled() && (depMode == PRIVATE || depMode == ISOLATED) && !F.isEmpty(cfg.getServiceConfiguration())) throw new GridException("Cannot deploy services in PRIVATE or ISOLATED deployment mode: " + depMode); }