Search in sources :

Example 81 with Ignite

use of org.apache.ignite.Ignite in project ignite by apache.

the class GridSessionSetJobAttributeSelfTest method checkTask.

/**
 * @param num Number.
 * @throws IgniteCheckedException if failed.
 */
private void checkTask(int num) throws IgniteCheckedException {
    Ignite ignite = G.ignite(getTestIgniteInstanceName());
    ComputeTaskFuture<?> fut = executeAsync(ignite.compute(), GridTaskSessionTestTask.class, num);
    Object res = fut.get();
    assert (Integer) res == SPLIT_COUNT - 1 : "Invalid result [num=" + num + ", fut=" + fut + ']';
}
Also used : Ignite(org.apache.ignite.Ignite)

Example 82 with Ignite

use of org.apache.ignite.Ignite in project ignite by apache.

the class GridSessionSetJobAttributeWaitListenerSelfTest method testSetAttribute.

/**
 * @throws Exception If failed.
 */
public void testSetAttribute() throws Exception {
    Ignite ignite = G.ignite(getTestIgniteInstanceName());
    ignite.compute().localDeployTask(GridTaskSessionTestTask.class, GridTaskSessionTestTask.class.getClassLoader());
    for (int i = 0; i < 5; i++) {
        refreshInitialData();
        ComputeTaskFuture<?> fut = ignite.compute().executeAsync(GridTaskSessionTestTask.class.getName(), null);
        assert fut != null;
        try {
            // Wait until jobs begin execution.
            boolean await = startSignal.await(WAIT_TIME, TimeUnit.MILLISECONDS);
            assert await : "Jobs did not start.";
            Object res = fut.get();
            assert (Integer) res == SPLIT_COUNT : "Invalid result [i=" + i + ", fut=" + fut + ']';
        } finally {
            // We must wait for the jobs to be sure that they have completed
            // their execution since they use static variable (shared for the tests).
            fut.get();
        }
    }
}
Also used : Ignite(org.apache.ignite.Ignite)

Example 83 with Ignite

use of org.apache.ignite.Ignite in project ignite by apache.

the class LazyQuerySelfTest method checkSingleNode.

/**
 * Check local query execution.
 *
 * @param parallelism Query parallelism.
 * @throws Exception If failed.
 */
public void checkSingleNode(int parallelism) throws Exception {
    Ignite srv = startGrid();
    srv.createCache(cacheConfiguration(parallelism));
    populateBaseQueryData(srv);
    checkBaseOperations(srv);
}
Also used : Ignite(org.apache.ignite.Ignite)

Example 84 with Ignite

use of org.apache.ignite.Ignite in project ignite by apache.

the class GridMarshallerAbstractTest method testServices.

/**
 * @throws Exception If failed.
 */
public void testServices() throws Exception {
    IgniteConfiguration cfg = optimize(getConfiguration("g1"));
    try (Ignite g1 = G.start(cfg)) {
        IgniteServices services = grid().services(grid().cluster().forNode(g1.cluster().localNode()));
        services.deployNodeSingleton("test", new DummyService());
        GridMarshallerTestBean inBean = newTestBean(services);
        byte[] buf = marshal(inBean);
        GridMarshallerTestBean outBean = unmarshal(buf);
        assert inBean.getObjectField() != null;
        assert outBean.getObjectField() != null;
        assert inBean.getObjectField().getClass().equals(IgniteServicesImpl.class);
        assert outBean.getObjectField().getClass().equals(IgniteServicesImpl.class);
        assert inBean != outBean;
        assert inBean.equals(outBean);
        ClusterGroup inPrj = services.clusterGroup();
        ClusterGroup outPrj = ((IgniteServices) outBean.getObjectField()).clusterGroup();
        assert inPrj.getClass().equals(outPrj.getClass());
        assert F.eqNotOrdered(inPrj.nodes(), outPrj.nodes());
        outBean.checkNullResources();
    }
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) DummyService(org.apache.ignite.internal.processors.service.DummyService) IgniteServices(org.apache.ignite.IgniteServices) ClusterGroup(org.apache.ignite.cluster.ClusterGroup) Ignite(org.apache.ignite.Ignite)

Example 85 with Ignite

use of org.apache.ignite.Ignite in project ignite by apache.

the class ComputeUtilsTest method testGetData.

/**
 * Tests {@code getData()} method.
 */
public void testGetData() {
    ClusterNode node = grid(1).cluster().localNode();
    String upstreamCacheName = "CACHE_1_" + UUID.randomUUID();
    String datasetCacheName = "CACHE_2_" + UUID.randomUUID();
    CacheConfiguration<Integer, Integer> upstreamCacheConfiguration = new CacheConfiguration<>();
    upstreamCacheConfiguration.setName(upstreamCacheName);
    upstreamCacheConfiguration.setAffinity(new TestAffinityFunction(node));
    IgniteCache<Integer, Integer> upstreamCache = ignite.createCache(upstreamCacheConfiguration);
    CacheConfiguration<Integer, Integer> datasetCacheConfiguration = new CacheConfiguration<>();
    datasetCacheConfiguration.setName(datasetCacheName);
    datasetCacheConfiguration.setAffinity(new TestAffinityFunction(node));
    IgniteCache<Integer, Integer> datasetCache = ignite.createCache(datasetCacheConfiguration);
    upstreamCache.put(42, 42);
    datasetCache.put(0, 0);
    UUID datasetId = UUID.randomUUID();
    IgniteAtomicLong cnt = ignite.atomicLong("CNT_" + datasetId, 0, true);
    for (int i = 0; i < 10; i++) {
        Collection<TestPartitionData> data = ComputeUtils.affinityCallWithRetries(ignite, Arrays.asList(datasetCacheName, upstreamCacheName), part -> ComputeUtils.<Integer, Integer, Serializable, TestPartitionData>getData(ignite, upstreamCacheName, datasetCacheName, datasetId, 0, (upstream, upstreamSize, ctx) -> {
            cnt.incrementAndGet();
            assertEquals(1, upstreamSize);
            UpstreamEntry<Integer, Integer> e = upstream.next();
            return new TestPartitionData(e.getKey() + e.getValue());
        }), 0);
        assertEquals(1, data.size());
        TestPartitionData dataElement = data.iterator().next();
        assertEquals(84, dataElement.val.intValue());
    }
    assertEquals(1, cnt.get());
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) Arrays(java.util.Arrays) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Collection(java.util.Collection) UUID(java.util.UUID) Ignite(org.apache.ignite.Ignite) IgniteCache(org.apache.ignite.IgniteCache) Serializable(java.io.Serializable) List(java.util.List) Ignition(org.apache.ignite.Ignition) ClusterNode(org.apache.ignite.cluster.ClusterNode) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) AffinityFunction(org.apache.ignite.cache.affinity.AffinityFunction) IgniteUtils(org.apache.ignite.internal.util.IgniteUtils) AffinityFunctionContext(org.apache.ignite.cache.affinity.AffinityFunctionContext) IgniteAtomicLong(org.apache.ignite.IgniteAtomicLong) Collections(java.util.Collections) UpstreamEntry(org.apache.ignite.ml.dataset.UpstreamEntry) IgniteAtomicLong(org.apache.ignite.IgniteAtomicLong) UUID(java.util.UUID) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) UpstreamEntry(org.apache.ignite.ml.dataset.UpstreamEntry)

Aggregations

Ignite (org.apache.ignite.Ignite)2007 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)358 CountDownLatch (java.util.concurrent.CountDownLatch)238 IgniteCache (org.apache.ignite.IgniteCache)234 IgniteException (org.apache.ignite.IgniteException)216 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)215 Transaction (org.apache.ignite.transactions.Transaction)194 ArrayList (java.util.ArrayList)177 ClusterNode (org.apache.ignite.cluster.ClusterNode)152 UUID (java.util.UUID)137 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)135 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)128 CacheException (javax.cache.CacheException)112 Event (org.apache.ignite.events.Event)112 HashMap (java.util.HashMap)105 List (java.util.List)89 IgniteEx (org.apache.ignite.internal.IgniteEx)85 Map (java.util.Map)84 GridAbsPredicate (org.apache.ignite.internal.util.lang.GridAbsPredicate)81 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)78