/** * 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 type == EVT_DISCOVERY_CUSTOM_EVT || F.contains(EVTS_DISCOVERY_ALL, type); }
/** {@inheritDoc} */ @Override public boolean hasKey(KeyCacheObject key) { return F.contains(keys, key); }
/** * @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; }
/** * @param failedNodes Node failed as result of resolve process. */ void onFinishResolve(Set<Long> failedNodes) { Map<Long, GridFutureAdapter<Boolean>> futs; synchronized (this) { if (state == State.DONE) { assert resErr != null; return; } assert state == State.RESOLVE_STARTED : state; state = State.DONE; resFailedNodes = failedNodes; futs = nodeFuts; // nodeFuts should not be modified after state changed to DONE. } for (Map.Entry<Long, GridFutureAdapter<Boolean>> e : futs.entrySet()) { Boolean res = !F.contains(resFailedNodes, e.getKey()); e.getValue().onDone(res); } onDone(); }
/** {@inheritDoc} */ @Override public ClientProtocol create(Configuration conf) throws IOException { if (FRAMEWORK_NAME.equals(conf.get(MRConfig.FRAMEWORK_NAME))) { Collection<String> addrs = conf.getTrimmedStringCollection(MRConfig.MASTER_ADDRESS); if (F.isEmpty(addrs)) throw new IOException("Failed to create client protocol because Ignite node addresses are not " + "specified (did you set " + MRConfig.MASTER_ADDRESS + " property?)."); if (F.contains(addrs, "local")) throw new IOException("Local execution mode is not supported, please point " + MRConfig.MASTER_ADDRESS + " to real Ignite nodes."); Collection<String> addrs0 = new ArrayList<>(addrs.size()); // Set up port by default if need for (String addr : addrs) { if (!addr.contains(":")) addrs0.add(addr + ':' + ConnectorConfiguration.DFLT_TCP_PORT); else addrs0.add(addr); } return new HadoopClientProtocol(conf, client(conf.get(MRConfig.MASTER_ADDRESS), addrs0)); } return null; }
/** * Checks for explicit events configuration. * * @param ignite Grid instance. * @return {@code true} if all task events explicitly specified in configuration. */ public static boolean checkExplicitTaskMonitoring(Ignite ignite) { int[] evts = ignite.configuration().getIncludeEventTypes(); if (F.isEmpty(evts)) return false; for (int evt : VISOR_TASK_EVTS) { if (!F.contains(evts, evt)) return false; } return true; }
/** * @param nodeQueries Active queries map. * @param nodes Cluster nodes. * @param mgr Discovery manager. */ void init(GridLongList nodeQueries, Collection<ClusterNode> nodes, GridDiscoveryManager mgr) { synchronized (this) { assert !initDone; assert waitNodes == null; waitNodes = new HashSet<>(); for (ClusterNode node : nodes) { if (!node.isLocal() && mgr.alive(node) && !F.contains(rcvd, node.id())) waitNodes.add(node.id()); } initDone = waitNodes.isEmpty(); if (nodeQueries != null) mergeToActiveQueries(mgr.localNode().id(), nodeQueries); if (initDone && !prevQueriesDone) prevQueriesDone = activeQueries.isEmpty() && rcvdAcks.isEmpty(); } }
/** * @param arr Array. * @param sort {@code True} to sort. */ private static void doArray(long[] arr, boolean sort) { int lim = 10000; for (int i = 0; i < arr.length; i++) arr[i] = ThreadLocalRandom.current().nextLong(lim); Arrays.sort(arr); long start = System.currentTimeMillis(); for (int i = 0; i < MAX; i++) { if (sort) Arrays.binarySearch(arr, ThreadLocalRandom.current().nextInt(lim)); else F.contains(arr, ThreadLocalRandom.current().nextInt(lim)); } long time = System.currentTimeMillis() - start; X.println("Array long test time [time=" + time + ", len=" + arr.length + ", sort=" + sort + ']'); }
/** * @param arr Array. * @param sort {@code True} to sort. */ private static void doArray(int[] arr, boolean sort) { int lim = 10000; for (int i = 0; i < arr.length; i++) arr[i] = ThreadLocalRandom.current().nextInt(lim); Arrays.sort(arr); long start = System.currentTimeMillis(); for (int i = 0; i < MAX; i++) { if (sort) Arrays.binarySearch(arr, ThreadLocalRandom.current().nextInt(lim)); else F.contains(arr, ThreadLocalRandom.current().nextInt(lim)); } long time = System.currentTimeMillis() - start; X.println("Array test time [time=" + time + ", len=" + arr.length + ", sort=" + sort + ']'); }
if (topVer.topologyVersion() > 0 && !F.contains(allIds, id)) continue;
/** * @param node Node. * @return Future finished when communication error resolve is done or {@code null} if another * resolve process should be started. */ @Nullable IgniteInternalFuture<Boolean> nodeStatusFuture(ClusterNode node) { GridFutureAdapter<Boolean> fut; synchronized (this) { if (state == State.DONE) { if (resolveTopVer != 0 && node.order() <= resolveTopVer) { Boolean res = !F.contains(resFailedNodes, node.order()); return new GridFinishedFuture<>(res); } else return null; } fut = nodeFuts.get(node.order()); if (fut == null) nodeFuts.put(node.order(), fut = new GridFutureAdapter<>()); } if (impl.node(node.order()) == null) fut.onDone(false); return fut; }
/** {@inheritDoc} */ @Override public void sendMessage(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackC) throws IgniteSpiException { if (msg instanceof GridIoMessage) { Object msg0 = ((GridIoMessage)msg).message(); synchronized (this) { if (recordCls != null && msg0.getClass().equals(recordCls)) recordedMsgs.add(msg0); Set<UUID> blockNodes = blockCls.get(msg0.getClass()); if (F.contains(blockNodes, node.id())) { log.info("Block message [node=" + node.attribute(IgniteNodeAttributes.ATTR_IGNITE_INSTANCE_NAME) + ", msg=" + msg0 + ']'); blockedMsgs.add(new T2<>(node, (GridIoMessage)msg)); notifyAll(); return; } } } super.sendMessage(node, msg, ackC); }
/** {@inheritDoc} */ @Override public void sendMessage(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackC) throws IgniteSpiException { if (msg instanceof GridIoMessage) { Object msg0 = ((GridIoMessage)msg).message(); synchronized (this) { Set<UUID> blockNodes = blockCls.get(msg0.getClass()); if (F.contains(blockNodes, node.id())) { log.info("Block message [node=" + node.attribute(IgniteNodeAttributes.ATTR_IGNITE_INSTANCE_NAME) + ", msg=" + msg0 + ']'); blockedMsgs.add(new T2<>(node, (GridIoMessage)msg)); return; } } } super.sendMessage(node, msg, ackC); }
/** {@inheritDoc} */ @Override public void sendMessage(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackClosure) throws IgniteSpiException { if (msg instanceof GridIoMessage) { Object msg0 = ((GridIoMessage)msg).message(); synchronized (this) { Set<UUID> blockNodes = blockCls.get(msg0.getClass()); if (F.contains(blockNodes, node.id())) { log.info("Block message [node=" + node.attribute(IgniteNodeAttributes.ATTR_IGNITE_INSTANCE_NAME) + ", msg=" + msg0 + ']'); blockedMsgs.add(new T2<>(node, (GridIoMessage)msg)); return; } } } super.sendMessage(node, msg, ackClosure); }
@Override public boolean apply(Event evt) { return evt.localOrder() > startEvtOrder && (arg.getTypeArgument() == null || F.contains(arg.getTypeArgument(), evt.type())) && (evt.timestamp() >= startEvtTime) && (arg.getTaskName() == null || filterByTaskName(evt, arg.getTaskName())) && (arg.getTaskSessionId() == null || filterByTaskSessionId(evt, arg.getTaskSessionId())); } });
if (!F.contains(rmvIdxs, head)) { GridCacheQueueHeader newHdr = new GridCacheQueueHeader(hdr.id(), hdr.capacity(),
if (parts == null || !F.contains(parts, part.id())) {
/** * @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(IgniteTxEntry e, boolean primaryOnly) { GridCacheContext cacheCtx = e.context(); if (!cacheCtx.isNear()) 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.localNodeId())) return true; GridCacheEntryEx cached = e.cached(); int part = cached != null ? cached.partition() : cacheCtx.affinity().partition(e.key()); List<ClusterNode> affNodes = cacheCtx.affinity().nodesByPartition(part, topologyVersion()); e.locallyMapped(F.contains(affNodes, cctx.localNode())); if (primaryOnly) { ClusterNode primary = F.first(affNodes); if (primary == null && !cacheCtx.affinityNode()) return false; assert primary != null : "Primary node is null for affinity nodes: " + affNodes; return primary.isLocal(); } else return e.locallyMapped(); }
if (F.contains(msg.failedNodes(), msg.creatorNodeId())) { msg0 = new TcpDiscoveryStatusCheckMessage(msg);