Search in sources :

Example 21 with ClusterGroup

use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.

the class ClusterGroupSelfTest method testEmptyGroup.

/**
 * @throws Exception If failed.
 */
public void testEmptyGroup() throws Exception {
    ClusterGroup emptyGrp = ignite.cluster().forAttribute("nonExistent", "val");
    assertEquals(0, emptyGrp.forOldest().nodes().size());
    assertEquals(0, emptyGrp.forYoungest().nodes().size());
    assertEquals(0, emptyGrp.forAttribute("nonExistent2", "val").nodes().size());
    assertEquals(0, emptyGrp.forCacheNodes("cacheName").nodes().size());
    assertEquals(0, emptyGrp.forClientNodes("cacheName").nodes().size());
    assertEquals(0, emptyGrp.forClients().nodes().size());
    assertEquals(0, emptyGrp.forDaemons().nodes().size());
    assertEquals(0, emptyGrp.forDataNodes("cacheName").nodes().size());
    assertEquals(0, emptyGrp.forRandom().nodes().size());
    assertEquals(0, emptyGrp.forRemotes().nodes().size());
    assertEquals(0, emptyGrp.forServers().nodes().size());
    assertEquals(0, emptyGrp.forHost(ignite.cluster().localNode()).nodes().size());
    assertEquals(0, emptyGrp.forHost("127.0.0.1").nodes().size());
}
Also used : ClusterGroup(org.apache.ignite.cluster.ClusterGroup)

Example 22 with ClusterGroup

use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.

the class ClusterGroupSelfTest method testOldest.

/**
 * @throws Exception If failed.
 */
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());
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) ClusterGroup(org.apache.ignite.cluster.ClusterGroup)

Example 23 with ClusterGroup

use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.

the class ClusterGroupSelfTest method testClientServer.

/**
 * @throws Exception If failed.
 */
public void testClientServer() throws Exception {
    ClusterGroup srv = ignite.cluster().forServers();
    assertEquals(2, srv.nodes().size());
    assertTrue(srv.nodes().contains(ignite(0).cluster().localNode()));
    assertTrue(srv.nodes().contains(ignite(1).cluster().localNode()));
    ClusterGroup cli = ignite.cluster().forClients();
    assertEquals(2, srv.nodes().size());
    assertTrue(cli.nodes().contains(ignite(2).cluster().localNode()));
    assertTrue(cli.nodes().contains(ignite(3).cluster().localNode()));
}
Also used : ClusterGroup(org.apache.ignite.cluster.ClusterGroup)

Example 24 with ClusterGroup

use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.

the class ClusterGroupSelfTest method testNewNodes.

/**
 * @throws Exception If failed.
 */
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);
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) ClusterGroup(org.apache.ignite.cluster.ClusterGroup) Ignite(org.apache.ignite.Ignite)

Example 25 with ClusterGroup

use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.

the class IgniteComputeEmptyClusterGroupTest method testSync.

/**
 * @throws Exception If failed.
 */
public void testSync() throws Exception {
    ClusterGroup empty = ignite(0).cluster().forNodeId(UUID.randomUUID());
    assertEquals(0, empty.nodes().size());
    final IgniteCompute comp = ignite(0).compute(empty);
    GridTestUtils.assertThrows(log, new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            comp.affinityRun(DEFAULT_CACHE_NAME, 1, new FailRunnable());
            return null;
        }
    }, ClusterGroupEmptyException.class, null);
    GridTestUtils.assertThrows(log, new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            comp.apply(new FailClosure(), new Object());
            return null;
        }
    }, ClusterGroupEmptyException.class, null);
    GridTestUtils.assertThrows(log, new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            comp.affinityCall(DEFAULT_CACHE_NAME, 1, new FailCallable());
            return null;
        }
    }, ClusterGroupEmptyException.class, null);
    GridTestUtils.assertThrows(log, new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            comp.broadcast(new FailCallable());
            return null;
        }
    }, ClusterGroupEmptyException.class, null);
}
Also used : ClusterGroup(org.apache.ignite.cluster.ClusterGroup) IgniteCompute(org.apache.ignite.IgniteCompute) ClusterGroupEmptyException(org.apache.ignite.cluster.ClusterGroupEmptyException)

Aggregations

ClusterGroup (org.apache.ignite.cluster.ClusterGroup)86 Ignite (org.apache.ignite.Ignite)45 UUID (java.util.UUID)22 CountDownLatch (java.util.concurrent.CountDownLatch)17 ClusterNode (org.apache.ignite.cluster.ClusterNode)14 IgniteException (org.apache.ignite.IgniteException)11 ArrayList (java.util.ArrayList)8 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)6 IgniteCompute (org.apache.ignite.IgniteCompute)6 GridConcurrentHashSet (org.apache.ignite.internal.util.GridConcurrentHashSet)5 GridAbsPredicate (org.apache.ignite.internal.util.lang.GridAbsPredicate)5 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)4 IgniteEx (org.apache.ignite.internal.IgniteEx)4 Map (java.util.Map)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 IgniteCluster (org.apache.ignite.IgniteCluster)3 IgniteClusterEx (org.apache.ignite.internal.cluster.IgniteClusterEx)3 IgniteFuture (org.apache.ignite.lang.IgniteFuture)3 IgniteSpiException (org.apache.ignite.spi.IgniteSpiException)3 List (java.util.List)2