Tabnine Logo
ClusterGroup.node
Code IndexAdd Tabnine to your IDE (free)

How to use
node
method
in
org.apache.ignite.cluster.ClusterGroup

Best Java code snippets using org.apache.ignite.cluster.ClusterGroup.node (Showing top 20 results out of 315)

origin: apache/ignite

  @Override public boolean apply(ClusterNode n) {
    return cctx.discovery().cacheAffinityNode(n, cctx.name()) &&
      (prj == null || prj.node(n.id()) != null) &&
      (part == null || owners.contains(n));
  }
});
origin: apache/ignite

/** {@inheritDoc} */
@Override public boolean isValid(int timeout) throws SQLException {
  ensureNotClosed();
  if (timeout < 0)
    throw new SQLException("Invalid timeout: " + timeout);
  try {
    JdbcConnectionValidationTask task = new JdbcConnectionValidationTask(cacheName,
      nodeId == null ? ignite : null);
    if (nodeId != null) {
      ClusterGroup grp = ignite.cluster().forServers().forNodeId(nodeId);
      if (grp.nodes().isEmpty())
        throw new SQLException("Failed to establish connection with node (is it a server node?): " +
          nodeId);
      assert grp.nodes().size() == 1;
      if (grp.node().isDaemon())
        throw new SQLException("Failed to establish connection with node (is it a server node?): " +
          nodeId);
      return ignite.compute(grp).callAsync(task).get(timeout, SECONDS);
    }
    else
      return task.call();
  }
  catch (IgniteClientDisconnectedException | ComputeTaskTimeoutException e) {
    throw new SQLException("Failed to establish connection.", SqlStateCode.CONNECTION_FAILURE, e);
  }
  catch (IgniteException ignored) {
    return false;
  }
}
origin: apache/ignite

UUID nodeId = snapshot.keySet().iterator().next();
return prj.node(nodeId);
origin: apache/ignite

/**
 * @throws Exception If failed.
 */
@Test
public void testAgeClusterGroupSerialization() throws Exception {
  Marshaller marshaller = ignite.configuration().getMarshaller();
  ClusterGroup grp = ignite.cluster().forYoungest();
  ClusterNode node = grp.node();
  byte[] arr = marshaller.marshal(grp);
  ClusterGroup obj = marshaller.unmarshal(arr, null);
  assertEquals(node.id(), obj.node().id());
  try (Ignite ignore = startGrid()) {
    obj = marshaller.unmarshal(arr, null);
    assertEquals(grp.node().id(), obj.node().id());
    assertFalse(node.id().equals(obj.node().id()));
  }
}
origin: apache/ignite

/**
 * @throws Exception If failed.
 */
@Test
public void testYoungest() throws Exception {
  ClusterGroup youngest = ignite.cluster().forYoungest();
  ClusterNode node = null;
  long maxOrder = Long.MIN_VALUE;
  for (ClusterNode n : ignite.cluster().nodes()) {
    if (n.order() > maxOrder) {
      node = n;
      maxOrder = n.order();
    }
  }
  assertEquals(youngest.node(), ignite.cluster().forNode(node).node());
  ClusterGroup emptyGrp = ignite.cluster().forAttribute("nonExistent", "val");
  assertEquals(0, emptyGrp.forYoungest().nodes().size());
}
origin: apache/ignite

/**
 * @throws Exception If failed.
 */
@Test
public void testRandom() throws Exception {
  assertTrue(ignite.cluster().nodes().contains(ignite.cluster().forRandom().node()));
}
origin: apache/ignite

/**
 * @throws Exception If failed.
 */
@Test
public void testOldest() throws Exception {
  ClusterGroup oldest = ignite.cluster().forOldest();
  ClusterNode node = null;
  long minOrder = Long.MAX_VALUE;
  for (ClusterNode n : ignite.cluster().nodes()) {
    if (n.order() < minOrder) {
      node = n;
      minOrder = n.order();
    }
  }
  assertEquals(oldest.node(), ignite.cluster().forNode(node).node());
  ClusterGroup emptyGrp = ignite.cluster().forAttribute("nonExistent", "val");
  assertEquals(0, emptyGrp.forOldest().nodes().size());
}
origin: apache/ignite

/**
 * @throws Exception If failed.
 */
@Test
public void testNewNodes() throws Exception {
  ClusterGroup youngest = ignite.cluster().forYoungest();
  ClusterGroup oldest = ignite.cluster().forOldest();
  ClusterNode old = oldest.node();
  ClusterNode last = youngest.node();
  assertNotNull(last);
  try (Ignite g = startGrid(NODES_CNT)) {
    ClusterNode n = g.cluster().localNode();
    ClusterNode latest = youngest.node();
    assertNotNull(latest);
    assertEquals(latest.id(), n.id());
    assertEquals(oldest.node(), old);
  }
}
origin: apache/ignite

  /**
   * @param expOldestIgnite Expected oldest ignite.
   * @throws InterruptedException If failed.
   */
  private void remoteListenForOldest(Ignite expOldestIgnite) throws InterruptedException {
    ClusterGroup grp = ignite1.cluster().forOldest();

    assertEquals(1, grp.nodes().size());
    assertEquals(expOldestIgnite.cluster().localNode().id(), grp.node().id());

    ignite1.message(grp).remoteListen(null, new P2<UUID, Object>() {
      @Override public boolean apply(UUID nodeId, Object msg) {
        System.out.println("Received new message [msg=" + msg + ", senderNodeId=" + nodeId + ']');

        MSG_CNT.incrementAndGet();

        return true;
      }
    });

    ignite1.message().send(null, MSG_1);

    Thread.sleep(3000);

    assertEquals(1, MSG_CNT.get());
  }
}
origin: apache/ignite

/**
 * Compares checksums between primary and backup partitions of specified caches.
 * Works properly only on idle cluster - there may be false positive conflict reports if data in cluster is being
 * concurrently updated.
 *
 * @param ig Ignite instance.
 * @param caches Cache names (if null, all user caches will be verified).
 * @return Conflicts result.
 * @throws IgniteException If none caches or node found.
 */
protected IdleVerifyResultV2 idleVerify(Ignite ig, String... caches) {
  IgniteEx ig0 = (IgniteEx)ig;
  Set<String> cacheNames = new HashSet<>();
  if (F.isEmpty(caches))
    cacheNames.addAll(ig0.cacheNames());
  else
    Collections.addAll(cacheNames, caches);
  if (cacheNames.isEmpty())
    throw new IgniteException("None cache for checking.");
  ClusterNode node = !ig0.localNode().isClient() ? ig0.localNode() : ig0.cluster().forServers().forRandom().node();
  if (node == null)
    throw new IgniteException("None server node for verification.");
  VisorIdleVerifyTaskArg taskArg = new VisorIdleVerifyTaskArg(cacheNames);
  return ig.compute().execute(
    VisorIdleVerifyTaskV2.class.getName(),
    new VisorTaskArgument<>(node.id(), taskArg, false)
  );
}
origin: org.apache.ignite/ignite-core

/** {@inheritDoc} */
@Override public boolean isValid(int timeout) throws SQLException {
  ensureNotClosed();
  if (timeout < 0)
    throw new SQLException("Invalid timeout: " + timeout);
  try {
    JdbcConnectionValidationTask task = new JdbcConnectionValidationTask(cacheName,
      nodeId == null ? ignite : null);
    if (nodeId != null) {
      ClusterGroup grp = ignite.cluster().forServers().forNodeId(nodeId);
      if (grp.nodes().isEmpty())
        throw new SQLException("Failed to establish connection with node (is it a server node?): " +
          nodeId);
      assert grp.nodes().size() == 1;
      if (grp.node().isDaemon())
        throw new SQLException("Failed to establish connection with node (is it a server node?): " +
          nodeId);
      return ignite.compute(grp).callAsync(task).get(timeout, SECONDS);
    }
    else
      return task.call();
  }
  catch (IgniteClientDisconnectedException | ComputeTaskTimeoutException e) {
    throw new SQLException("Failed to establish connection.", SqlStateCode.CONNECTION_FAILURE, e);
  }
  catch (IgniteException ignored) {
    return false;
  }
}
origin: apache/ignite

assertEquals(grid(gridMaxOrder(clusterSize, true)).localNode().id(), evenYoungest.node().id());
assertEquals(grid(1).localNode().id(), evenOldest.node().id());
assertEquals(grid(gridMaxOrder(clusterSize, false)).localNode().id(), oddYoungest.node().id());
assertEquals(grid(2).localNode().id(), oddOldest.node().id());
  assertEquals(grid(gridMaxOrder(clusterSize, true)).localNode().id(), evenYoungest.node().id());
  assertEquals(grid(1).localNode().id(), evenOldest.node().id());
  assertEquals(grid(gridMaxOrder(clusterSize, false)).localNode().id(), oddYoungest.node().id());
  assertEquals(grid(2).localNode().id(), oddOldest.node().id());
origin: org.apache.ignite/ignite-core

UUID nodeId = snapshot.keySet().iterator().next();
return prj.node(nodeId);
origin: apache/ignite

  /**
   * @throws Exception If failed.
   */
  @Test
  public void testConsistentId() throws Exception {
    Object id0 = grid(0).localNode().consistentId();
    Serializable id1 = grid(0).configuration().getConsistentId();

    assertEquals(id0, id1);
    assertEquals(grid(0).name(), id0);
    assertEquals(id0, grid(1).cluster().forRemotes().node().consistentId());

    for (int i = 0; i < 4; ++i) {
      stopAllGrids();

      startGrids(2);

      assertEquals(id0, grid(0).localNode().consistentId());
    }
  }
}
origin: org.apache.ignite/ignite-core

  @Override public boolean apply(ClusterNode n) {
    return cctx.discovery().cacheAffinityNode(n, cctx.name()) &&
      (prj == null || prj.node(n.id()) != null) &&
      (part == null || owners.contains(n));
  }
});
origin: opendedup/sdfs

public boolean isMaster() {
  return ig.cluster().forOldest().node().equals(ig.cluster().localNode());
}
origin: io.vertx/vertx-ignite

ClusterNode ownerNode = ignite.cluster().forNodeId(UUID.fromString(ownerId)).node();
if (ownerNode == null) {
 queue.remove(ownerId);
origin: vert-x3/vertx-ignite

ClusterNode ownerNode = ignite.cluster().forNodeId(UUID.fromString(ownerId)).node();
if (ownerNode == null) {
 queue.remove(ownerId);
origin: opendedup/sdfs

IgniteCache<Long, Long> db = ig.getOrCreateCache(cacheCfg);
while (ig.cluster().forOldest().node() == null) {
  Thread.sleep(3000);
  System.out.println("waiting for system to come up");
if (ig.cluster().forOldest().node().equals(ig.cluster().localNode())) {
  Object[] obj = new Object[2];
  obj[0] = cdb;
origin: opendedup/sdfs

idb = ig.getOrCreateCache(cacheCfg);
while (ig.cluster().forOldest().node() == null) {
  try {
    Thread.sleep(3000);
if (ig.cluster().forOldest().node().equals(ig.cluster().localNode())) {
  Object[] obj = new Object[2];
  obj[0] = this;
org.apache.ignite.clusterClusterGroupnode

Javadoc

Gets first node from the list of nodes in this cluster group. This method is specifically useful for cluster groups with one node only.

Popular methods of ClusterGroup

  • nodes
    Gets the read-only collection of nodes in this cluster group.
  • forPredicate
    Creates a new cluster group which includes all nodes that pass the given predicate filter.
  • forAttribute
    Creates a new cluster group for nodes containing given name and value specified in user attributes.
  • forClients
    Creates a cluster group of nodes started in client mode.
  • forDataNodes
    Creates a cluster group for all data nodes that have the cache with the specified name running.
  • forNodeIds
    Creates a cluster group over nodes with specified node IDs.
  • forRandom
    Creates a cluster group with one random node from the current cluster group.
  • forRemotes
    Gets cluster group consisting from the nodes in this cluster group excluding the local node.
  • forServers
    Creates a cluster group of nodes started in server mode.
  • hostNames
    Gets the read-only collection of hostnames in this cluster group.
  • ignite
    Gets instance of grid.
  • metrics
    Gets a metrics snapshot for this cluster group.
  • ignite,
  • metrics,
  • predicate,
  • forCacheNodes,
  • forClientNodes,
  • forDaemons,
  • forHost,
  • forNodeId,
  • forOldest

Popular in Java

  • Updating database using SQL prepared statement
  • notifyDataSetChanged (ArrayAdapter)
  • onCreateOptionsMenu (Activity)
  • getSystemService (Context)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • JFileChooser (javax.swing)
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now