/** {@inheritDoc} */ @Override public GridDeployment getDeployment(final IgniteUuid ldrId) { synchronized (mux) { return F.find(F.flat(cache.values()), null, new P1<SharedDeployment>() { @Override public boolean apply(SharedDeployment d) { return d.classLoaderId().equals(ldrId); } }); } }
/** * Gets explicit lock candidate for given key. * * @param key Key to lookup. * @param ver Version to lookup (if {@code null} - return any). * @return Last added explicit lock candidate, if any, or {@code null}. */ @Nullable public GridCacheMvccCandidate candidate(IgniteTxKey key, @Nullable final GridCacheVersion ver) { lock(); try { Deque<GridCacheMvccCandidate> deque = cands.get(key); if (deque != null) { assert !deque.isEmpty(); return ver == null ? deque.peekFirst() : F.find(deque, null, new P1<GridCacheMvccCandidate>() { @Override public boolean apply(GridCacheMvccCandidate cand) { return cand.version().equals(ver); } }); } return null; } finally { unlock(); } }
/** * Looks up for resource by name (either full class name or alias). * * @param rsrcName Resource name (either full class name or alias). * @return Tuple of resource class and alias or {@code null}, if * resource is not found. The second tuple member is * {@code null} if the resource has no alias. */ @Nullable public IgniteBiTuple<Class<?>, String> findResource(final String rsrcName) { // Find by alias. Class<?> cls = rsrcsByAlias.get(rsrcName); if (cls != null) return F.<Class<?>, String>t(cls, rsrcName); // Find by class name. cls = F.find(rsrcs, null, new P1<Class<?>>() { @Override public boolean apply(Class<?> cls0) { return cls0.getName().equals(rsrcName); } }); return cls != null ? F.<Class<?>, String>t(cls, null) : null; }
/** * Finds the {@link org.apache.ignite.Ignite}, which has a local node * with given ID. * * @param nodeId ID for grid's local node. * @return A grid instance or {@code null}, if the grid * is not found. */ @Nullable private Ignite findGridForNodeId(final UUID nodeId) { return F.find(G.allGrids(), null, new P1<Ignite>() { @Override public boolean apply(Ignite e) { return nodeId.equals(e.cluster().localNode().id()); } }); } }
/** * @param nodes Destination nodes. * @param topic Topic to send the message to. * @param msg Message to send. * @param plc Type of processing. * @throws IgniteCheckedException Thrown in case of any errors. */ public void sendToGridTopic( Collection<? extends ClusterNode> nodes, GridTopic topic, Message msg, byte plc ) throws IgniteCheckedException { assert F.find(nodes, null, F.localNode(locNodeId)) == null : "Internal Ignite code should never call the method with local node in a node list."; IgniteCheckedException err = null; for (ClusterNode node : nodes) { try { send(node, topic, topic.ordinal(), msg, plc, false, 0, false, null, false); } catch (IgniteCheckedException e) { if (err == null) err = e; else err.addSuppressed(e); } } if (err != null) throw err; }
ClusterNode targetNode = F.find(subgrid, subgrid.get(0), new IgnitePredicate<ClusterNode>() {
/** * Sends message accounting for local and remote nodes. * * @param nodes Nodes to receive event. * @param topic Topic to send the message to. * @param msg Event to be sent. * @param plc Type of processing. * @throws IgniteCheckedException If sending failed. */ private void sendMessage(Collection<? extends ClusterNode> nodes, GridTopic topic, GridEventStorageMessage msg, byte plc) throws IgniteCheckedException { ClusterNode locNode = F.find(nodes, null, F.localNode(ctx.localNodeId())); Collection<? extends ClusterNode> rmtNodes = F.view(nodes, F.remoteNodes(ctx.localNodeId())); if (locNode != null) ctx.io().sendToGridTopic(locNode, topic, msg, plc); if (!rmtNodes.isEmpty()) { msg.responseTopicBytes(U.marshal(marsh, msg.responseTopic())); ctx.io().sendToGridTopic(rmtNodes, topic, msg, plc); } }
final String cacheName = (cacheNameNode == null || "null".equals(cacheNameNode.asText())) ? null : cacheNameNode.asText(); GridCacheSqlMetadata meta = F.find(metas, null, new P1<GridCacheSqlMetadata>() { @Override public boolean apply(GridCacheSqlMetadata meta) { return F.eq(meta.cacheName(), cacheName); JsonNode idx = F.find(indexes, null, new P1<JsonNode>() { @Override public boolean apply(JsonNode idx) { return metaIdx.name().equals(idx.get("name").asText());
IgniteCacheProxy<?, ?> publicCache = F.find(publicCaches, null, new P1<IgniteCacheProxy<?, ?>>() { @Override public boolean apply(IgniteCacheProxy<?, ?> c) { return F.eq(c.getName(), cacheName);
/** * @throws Exception If failed. */ @Test public void testManyTasksRun() throws Exception { GridClientCompute compute = client.compute(); for (int i = 0; i < 1000; i++) assertEquals(new Integer("executing".length()), compute.execute(TestTask.class.getName(), "executing")); GridClientFactory.stop(client.id(), true); IgniteKernal g = (IgniteKernal)grid(0); Map<GridRestCommand, GridRestCommandHandler> handlers = U.field(g.context().rest(), "handlers"); GridTaskCommandHandler taskHnd = (GridTaskCommandHandler)F.find(handlers.values(), null, new P1<GridRestCommandHandler>() { @Override public boolean apply(GridRestCommandHandler e) { return e instanceof GridTaskCommandHandler; } }); assertNotNull("GridTaskCommandHandler was not found", taskHnd); ConcurrentLinkedHashMap taskDesc = U.field(taskHnd, "taskDescs"); assertTrue("Task result map size exceeded max value [mapSize=" + taskDesc.sizex() + ", " + "maxSize=" + MAX_TASK_RESULTS + ']', taskDesc.sizex() <= MAX_TASK_RESULTS); }
ClusterNode locNode = F.find(nodes, null, F.localNode(locNodeId));
/** * Tests correct behavior in case of 1 REST-enabled node * with default settings. * * @throws Exception If failed. */ @Test public void testOneNodeDefaultHostAndPort() throws Exception { startRestNode("grid1", null, null); checkConnectivityByIp(LOOPBACK_IP, getAllIps()); String extIp = F.find(U.allLocalIps(), null, new IpV4AddressPredicate()); checkConnectivityByIp(extIp, getAllIps()); }
/** * @param evts Events. * @param g Grid. * @param parts Parts. */ private void checkPartitionUnloadEvents(Collection<Event> evts, Ignite g, Collection<GridDhtLocalPartition> parts) { assertEquals(parts.size(), evts.size()); for (Event evt : evts) { CacheRebalancingEvent unloadEvt = (CacheRebalancingEvent)evt; final int part = unloadEvt.partition(); assertNotNull("Unexpected partition: " + part, F.find(parts, null, new IgnitePredicate<GridDhtLocalPartition>() { @Override public boolean apply(GridDhtLocalPartition e) { return e.id() == part; } })); assertEquals(g.cache(DEFAULT_CACHE_NAME).getName(), unloadEvt.cacheName()); assertEquals(g.cluster().localNode().id(), unloadEvt.node().id()); } } }
node = F.find(ctx.discovery().allNodes(), null, new P1<ClusterNode>() { @Override public boolean apply(ClusterNode n) {
/** {@inheritDoc} */ @Override public GridDeployment getDeployment(final IgniteUuid ldrId) { synchronized (mux) { return F.find(F.flat(cache.values()), null, new P1<SharedDeployment>() { @Override public boolean apply(SharedDeployment d) { return d.classLoaderId().equals(ldrId); } }); } }
/** * Gets explicit lock candidate for given key. * * @param key Key to lookup. * @param ver Version to lookup (if {@code null} - return any). * @return Last added explicit lock candidate, if any, or {@code null}. */ @Nullable public GridCacheMvccCandidate candidate(IgniteTxKey key, @Nullable final GridCacheVersion ver) { lock(); try { Deque<GridCacheMvccCandidate> deque = cands.get(key); if (deque != null) { assert !deque.isEmpty(); return ver == null ? deque.peekFirst() : F.find(deque, null, new P1<GridCacheMvccCandidate>() { @Override public boolean apply(GridCacheMvccCandidate cand) { return cand.version().equals(ver); } }); } return null; } finally { unlock(); } }
/** * @param nodes Destination nodes. * @param topic Topic to send the message to. * @param msg Message to send. * @param plc Type of processing. * @throws IgniteCheckedException Thrown in case of any errors. */ public void sendToGridTopic( Collection<? extends ClusterNode> nodes, GridTopic topic, Message msg, byte plc ) throws IgniteCheckedException { assert F.find(nodes, null, F.localNode(locNodeId)) == null : "Internal Ignite code should never call the method with local node in a node list."; IgniteCheckedException err = null; for (ClusterNode node : nodes) { try { send(node, topic, topic.ordinal(), msg, plc, false, 0, false, null, false); } catch (IgniteCheckedException e) { if (err == null) err = e; else err.addSuppressed(e); } } if (err != null) throw err; }
/** * Sends message accounting for local and remote nodes. * * @param nodes Nodes to receive event. * @param topic Topic to send the message to. * @param msg Event to be sent. * @param plc Type of processing. * @throws IgniteCheckedException If sending failed. */ private void sendMessage(Collection<? extends ClusterNode> nodes, GridTopic topic, GridEventStorageMessage msg, byte plc) throws IgniteCheckedException { ClusterNode locNode = F.find(nodes, null, F.localNode(ctx.localNodeId())); Collection<? extends ClusterNode> rmtNodes = F.view(nodes, F.remoteNodes(ctx.localNodeId())); if (locNode != null) ctx.io().sendToGridTopic(locNode, topic, msg, plc); if (!rmtNodes.isEmpty()) { msg.responseTopicBytes(U.marshal(marsh, msg.responseTopic())); ctx.io().sendToGridTopic(rmtNodes, topic, msg, plc); } }
ClusterNode locNode = F.find(nodes, null, F.localNode(locNodeId));
node = F.find(ctx.discovery().allNodes(), null, new P1<ClusterNode>() { @Override public boolean apply(ClusterNode n) {