/** * Checks whether or not this event is an internal event. * <p> * Internal event types are always recordable for notification purposes * but may not be sent down to SPI level for storage and subsequent querying. * * @param type Event type. * @return {@code true} if this is an internal event. */ private boolean isInternalEvent(int type) { return F.contains(EVTS_DISCOVERY_ALL, type); }
/** * @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; }
/** * Checks whether given url is accessible against configuration. * * @param url URL to check. * @return {@code True} if file is accessible (i.e. located in one of the sub-folders of * {@code restAccessibleFolders} list. */ private boolean isAccessible(URL url) throws IOException { // No check is made if configuration is undefined. if (accessibleFolders == null) return true; File f = new File(url.getFile()); f = f.getCanonicalFile(); do { if (F.contains(accessibleFolders, f)) return true; f = f.getParentFile(); } while (f != null); return false; } }
@Override public boolean apply(GridEvent e) { // Detects that events were lost. if (!lastFound.get() && (lastOrder == e.localOrder())) lastFound.set(true); // Retains events by lastOrder, period and type. return e.localOrder() > lastOrder && e.timestamp() > notOlderThan && (all ? F.contains(VISOR_ALL_EVTS, e.type()) : F.contains(VISOR_NON_TASK_EVTS, e.type())); } };
/** {@inheritDoc} */ @Override protected Map<UUID, GridNodeMetrics> metrics0(Collection<UUID> nodeIds) { assert !F.isEmpty(nodeIds); return F.view(metricsMap, F.contains(nodeIds)); }
/** {@inheritDoc} */ @Override public final Map<UUID, GridNodeMetrics> metrics(Collection<UUID> nodeIds) throws GridSpiException { assert !F.isEmpty(nodeIds); long now = U.currentTimeMillis(); Collection<UUID> expired = new LinkedList<>(); for (UUID id : nodeIds) { GridNodeMetrics nodeMetrics = metricsMap.get(id); Long ts = tsMap.get(id); if (nodeMetrics == null || ts == null || ts < now - metricsExpireTime) expired.add(id); } if (!expired.isEmpty()) { Map<UUID, GridNodeMetrics> refreshed = metrics0(expired); for (UUID id : refreshed.keySet()) tsMap.put(id, now); metricsMap.putAll(refreshed); } return F.view(metricsMap, F.contains(nodeIds)); }
/** * Checks for explicit events configuration. * * @param g Grid instance. * @return {@code true} if all task events explicitly specified in configuration. */ public static boolean checkExplicitTaskMonitoring(Grid g) { int[] evts = g.configuration().getIncludeEventTypes(); if (F.isEmpty(evts)) return false; for (int evt : VISOR_TASK_EVTS) { if (!F.contains(evts, evt)) return false; } return true; }
@Override public GridCacheReturn<V> applyx(Set<K> skipped, Exception e) throws GridException { if (e != null) throw U.cast(e); try { cctx.store().removeAllFromStore(GridCacheTxLocalAdapter.this, F.view(keys0, F0.not(F.contains(skipped)))); } catch (GridException ex) { throw new GridClosureException(ex); } return ret; } }));
assert addr != null; if (F.contains(locNodeAddrs, addr)) return locNodeId;
@Override public boolean apply(GridEvent event) { return event.localOrder() > startEvtOrder && (arg.typeArgument() == null || F.contains(arg.typeArgument(), event.type())) && event.timestamp() >= startEvtTime && (arg.taskName() == null || filterByTaskName(event, arg.taskName())) && (arg.taskSessionId() == null || filterByTaskSessionId(event, arg.taskSessionId())); } });
if (!F.contains(rmvIdxs, head)) { GridCacheQueueHeader newHdr = new GridCacheQueueHeader(hdr.id(), hdr.capacity(), hdr.collocated(), head, hdr.tail(), hdr.removedIndexes());
/** * @param e Transaction entry. * @param primaryOnly Flag to include backups into check or not. * @return {@code True} if entry is locally mapped as a primary or back up node. */ protected boolean isNearLocallyMapped(GridCacheTxEntry<K, V> e, boolean primaryOnly) { if (!near()) return false; // Try to take either entry-recorded primary node ID, // or transaction node ID from near-local transactions. UUID nodeId = e.nodeId() == null ? local() ? this.nodeId : null : e.nodeId(); if (nodeId != null && nodeId.equals(cctx.nodeId())) return true; GridCacheEntryEx<K, V> cached = e.cached(); int part = cached != null ? cached.partition() : cctx.affinity().partition(e.key()); List<GridNode> affNodes = cctx.affinity().nodes(part, topologyVersion()); e.locallyMapped(F.contains(affNodes, cctx.localNode())); if (primaryOnly) { GridNode primary = F.first(affNodes); if (primary == null && !isAffinityNode(cctx.config())) return false; assert primary != null : "Primary node is null for affinity nodes: " + affNodes; return primary.isLocal(); } else return e.locallyMapped(); }
if (!F.exist(F.nodeIds(nodes), F0.not(F.contains(leftIds)))) { if (log.isDebugEnabled()) log.debug("Message will not be sent because all nodes left topology [msg=" + msg + if (!F.exist(F.nodeIds(nodes), F0.not(F.contains(leftIds)))) { if (log.isDebugEnabled()) log.debug("Message will not be sent because all nodes left topology [msg=" + msg + ", nodes=" +
else if (F.contains(readers, node.id())) // Reader became primary or backup. entry.removeReader(node.id(), req.messageId()); else
Collection<String> rmtCompatibleVers = node.attribute(ATTR_COMPATIBLE_VERS); if (F.contains(rmtCompatibleVers, locBuildVer) || F.contains(locCompatibleVers, rmtBuildVer)) { String errMsg = "Local node's build version differs from remote node's, " + "but they are compatible (will continue join process) " +
if (F.contains(backupKeys, key)) { // Reader became backup. if (entry.markObsolete(ver)) removeEntry(entry);