org.apache.ignite.internal.util.typedef.F.find()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.6k)|赞(0)|评价(0)|浏览(80)

本文整理了Java中org.apache.ignite.internal.util.typedef.F.find()方法的一些代码示例,展示了F.find()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。F.find()方法的具体详情如下:
包路径:org.apache.ignite.internal.util.typedef.F
类名称:F
方法名:find

F.find介绍

暂无

代码示例

代码示例来源:origin: apache/ignite

/** {@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);
      }
    });
  }
}

代码示例来源:origin: apache/ignite

/**
 * 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();
  }
}

代码示例来源:origin: apache/ignite

/**
 * 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;
}

代码示例来源:origin: apache/ignite

/**
   * 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());
      }
    });
  }
}

代码示例来源:origin: apache/ignite

/**
 * @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;
}

代码示例来源:origin: apache/ignite

ClusterNode targetNode = F.find(subgrid, subgrid.get(0), new IgnitePredicate<ClusterNode>() {

代码示例来源:origin: apache/ignite

/**
 * 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);
  }
}

代码示例来源:origin: apache/ignite

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());

代码示例来源:origin: apache/ignite

IgniteCacheProxy<?, ?> publicCache = F.find(publicCaches, null, new P1<IgniteCacheProxy<?, ?>>() {
  @Override public boolean apply(IgniteCacheProxy<?, ?> c) {
    return F.eq(c.getName(), cacheName);

代码示例来源:origin: apache/ignite

/**
 * @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);
}

代码示例来源:origin: apache/ignite

ClusterNode locNode = F.find(nodes, null, F.localNode(locNodeId));

代码示例来源:origin: apache/ignite

/**
 * 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());
}

代码示例来源:origin: apache/ignite

/**
   * @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());
    }
  }
}

代码示例来源:origin: apache/ignite

node = F.find(ctx.discovery().allNodes(), null, new P1<ClusterNode>() {
  @Override
  public boolean apply(ClusterNode n) {

代码示例来源:origin: org.apache.ignite/ignite-core

/** {@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);
      }
    });
  }
}

代码示例来源:origin: org.apache.ignite/ignite-core

/**
 * 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();
  }
}

代码示例来源:origin: org.apache.ignite/ignite-core

/**
 * @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;
}

代码示例来源:origin: org.apache.ignite/ignite-core

/**
 * 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);
  }
}

代码示例来源:origin: org.apache.ignite/ignite-core

ClusterNode locNode = F.find(nodes, null, F.localNode(locNodeId));

代码示例来源:origin: org.apache.ignite/ignite-core

node = F.find(ctx.discovery().allNodes(), null, new P1<ClusterNode>() {
  @Override
  public boolean apply(ClusterNode n) {

相关文章