Search in sources :

Example 81 with ClusterGroup

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

the class GridJobExecutionLoadTestClientSemaphore method call.

/**
 * {@inheritDoc}
 */
@Nullable
@Override
public Object call() throws Exception {
    final IgniteInClosure<IgniteFuture<?>> lsnr = new CI1<IgniteFuture<?>>() {

        @Override
        public void apply(IgniteFuture<?> t) {
            tasksSem.release();
        }
    };
    ClusterGroup rmts = g.cluster().forRemotes();
    while (!finish) {
        tasksSem.acquire();
        g.compute(rmts).executeAsync(GridJobExecutionLoadTestTask.class, null).listen(lsnr);
        txCnt.increment();
    }
    return null;
}
Also used : IgniteFuture(org.apache.ignite.lang.IgniteFuture) ClusterGroup(org.apache.ignite.cluster.ClusterGroup) CI1(org.apache.ignite.internal.util.typedef.CI1) Nullable(org.jetbrains.annotations.Nullable)

Example 82 with ClusterGroup

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

the class PlatformDotNetEntityFrameworkCacheExtension method startBackgroundCleanup.

/**
 * Starts the background cleanup of old cache entries.
 *
 * @param grid Grid.
 * @param metaCache Meta cache.
 * @param dataCacheName Data cache name.
 * @param currentVersions Current versions.
 */
private void startBackgroundCleanup(Ignite grid, final Cache<CleanupNodeId, UUID> metaCache, final String dataCacheName, final Map<String, EntryProcessorResult<Long>> currentVersions) {
    if (cleanupFlags.containsKey(dataCacheName))
        // Current node already performs cleanup.
        return;
    if (!trySetGlobalCleanupFlag(grid, metaCache))
        return;
    cleanupFlags.put(dataCacheName, true);
    final ClusterGroup dataNodes = grid.cluster().forDataNodes(dataCacheName);
    IgniteFuture f = grid.compute(dataNodes).broadcastAsync(new RemoveOldEntriesRunnable(dataCacheName, currentVersions));
    f.listen(new CleanupCompletionListener(metaCache, dataCacheName));
}
Also used : ClusterGroup(org.apache.ignite.cluster.ClusterGroup) IgniteFuture(org.apache.ignite.lang.IgniteFuture)

Example 83 with ClusterGroup

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

the class GridJobStealingSelfTest method testSingleNodeProjection.

/**
 * Tests that a job is not cancelled if there are no
 * available thief nodes in projection.
 *
 * @throws Exception If failed.
 */
@Test
public void testSingleNodeProjection() throws Exception {
    ClusterGroup prj = ignite1.cluster().forNodeIds(Collections.singleton(ignite1.cluster().localNode().id()));
    executeAsync(compute(prj), new JobStealingSpreadTask(2), null).get(TASK_EXEC_TIMEOUT_MS);
    assertEquals(1, jobDistrMap.keySet().size());
    assertEquals(2, jobDistrMap.get(ignite1.cluster().localNode().id()).size());
}
Also used : ClusterGroup(org.apache.ignite.cluster.ClusterGroup) GridCommonTest(org.apache.ignite.testframework.junits.common.GridCommonTest) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 84 with ClusterGroup

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

the class GridFailoverTaskWithPredicateSelfTest method testJobNotFailedOverWithStaticProjection.

/**
 * Tests that in case of failover our predicate is intersected with projection
 * (logical AND is performed).
 *
 * @throws Exception If error happens.
 */
@Test
public void testJobNotFailedOverWithStaticProjection() throws Exception {
    failed.set(false);
    routed.set(false);
    try {
        Ignite ignite1 = startGrid(NODE1);
        Ignite ignite2 = startGrid(NODE2);
        Ignite ignite3 = startGrid(NODE3);
        assert ignite1 != null;
        assert ignite2 != null;
        assert ignite3 != null;
        // Get projection only for first 2 nodes.
        ClusterGroup nodes = ignite1.cluster().forNodeIds(Arrays.asList(ignite1.cluster().localNode().id(), ignite2.cluster().localNode().id()));
        // On failover NODE3 shouldn't be taken into account.
        Integer res = (Integer) compute(nodes.forPredicate(p)).withTimeout(10000).execute(JobFailTask.class.getName(), "1");
        assert res == 1;
    } catch (ClusterTopologyException ignored) {
        failed.set(true);
    } finally {
        assertTrue(failed.get());
        assertFalse(routed.get());
        stopGrid(NODE1);
        stopGrid(NODE2);
        stopGrid(NODE3);
    }
}
Also used : ClusterGroup(org.apache.ignite.cluster.ClusterGroup) Ignite(org.apache.ignite.Ignite) ClusterTopologyException(org.apache.ignite.cluster.ClusterTopologyException) GridCommonTest(org.apache.ignite.testframework.junits.common.GridCommonTest) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 85 with ClusterGroup

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

the class IgniteCountDownLatchAbstractSelfTest method testLatchBroadcast.

/**
 * @throws Exception If failed.
 */
@Test
public void testLatchBroadcast() throws Exception {
    Ignite ignite = grid(0);
    ClusterGroup srvsGrp = ignite.cluster().forServers();
    int numOfSrvs = srvsGrp.nodes().size();
    ignite.destroyCache("testCache");
    IgniteCache<Object, Object> cache = ignite.createCache("testCache");
    for (ClusterNode node : srvsGrp.nodes()) cache.put(String.valueOf(node.id()), 0);
    for (int i = 0; i < 500; i++) {
        IgniteCountDownLatch latch1 = createLatch1(ignite, numOfSrvs);
        IgniteCountDownLatch latch2 = createLatch2(ignite, numOfSrvs);
        ignite.compute(srvsGrp).broadcast(new IgniteRunnableJob(latch1, latch2, i));
        assertTrue(latch2.await(10000));
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) ClusterGroup(org.apache.ignite.cluster.ClusterGroup) Ignite(org.apache.ignite.Ignite) IgniteCountDownLatch(org.apache.ignite.IgniteCountDownLatch) Test(org.junit.Test)

Aggregations

ClusterGroup (org.apache.ignite.cluster.ClusterGroup)99 Ignite (org.apache.ignite.Ignite)51 Test (org.junit.Test)49 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)36 UUID (java.util.UUID)26 CountDownLatch (java.util.concurrent.CountDownLatch)18 ClusterNode (org.apache.ignite.cluster.ClusterNode)16 GridCommonTest (org.apache.ignite.testframework.junits.common.GridCommonTest)14 IgniteException (org.apache.ignite.IgniteException)12 ArrayList (java.util.ArrayList)9 IgniteCompute (org.apache.ignite.IgniteCompute)8 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)6 IgniteCluster (org.apache.ignite.IgniteCluster)6 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)6 GridConcurrentHashSet (org.apache.ignite.internal.util.GridConcurrentHashSet)5 IgniteFuture (org.apache.ignite.lang.IgniteFuture)5 Map (java.util.Map)4 IgniteEx (org.apache.ignite.internal.IgniteEx)4 IgniteClusterEx (org.apache.ignite.internal.cluster.IgniteClusterEx)4 GridAbsPredicate (org.apache.ignite.internal.util.lang.GridAbsPredicate)4