Search in sources :

Example 36 with CollectionConfiguration

use of org.apache.ignite.configuration.CollectionConfiguration in project ignite by apache.

the class GridCacheQueueApiSelfAbstractTest method testReuseCache.

/**
     * @throws Exception If failed.
     */
public void testReuseCache() throws Exception {
    CollectionConfiguration colCfg = collectionConfiguration();
    IgniteQueue queue1 = grid(0).queue("Queue1", 0, colCfg);
    IgniteQueue queue2 = grid(0).queue("Queue2", 0, colCfg);
    assertEquals(getQueueCache(queue1), getQueueCache(queue2));
}
Also used : IgniteQueue(org.apache.ignite.IgniteQueue) CollectionConfiguration(org.apache.ignite.configuration.CollectionConfiguration)

Example 37 with CollectionConfiguration

use of org.apache.ignite.configuration.CollectionConfiguration in project ignite by apache.

the class GridCacheQueueCleanupSelfTest method collectionConfiguration.

/** {@inheritDoc} */
@Override
protected CollectionConfiguration collectionConfiguration() {
    CollectionConfiguration colCfg = super.collectionConfiguration();
    colCfg.setBackups(0);
    return colCfg;
}
Also used : CollectionConfiguration(org.apache.ignite.configuration.CollectionConfiguration)

Example 38 with CollectionConfiguration

use of org.apache.ignite.configuration.CollectionConfiguration in project ignite by apache.

the class GridCacheQueueMultiNodeConsistencySelfTest method collectionConfiguration.

/** {@inheritDoc} */
@Override
protected CollectionConfiguration collectionConfiguration() {
    CollectionConfiguration colCfg = super.collectionConfiguration();
    colCfg.setBackups(backups);
    return colCfg;
}
Also used : CollectionConfiguration(org.apache.ignite.configuration.CollectionConfiguration)

Example 39 with CollectionConfiguration

use of org.apache.ignite.configuration.CollectionConfiguration in project ignite by apache.

the class IgniteDataStructureWithJobTest method testJobWithRestart.

/**
     * @throws Exception If failed.
     */
public void testJobWithRestart() throws Exception {
    Ignite ignite = startGrid(0);
    final AtomicBoolean stop = new AtomicBoolean();
    final long endTime = System.currentTimeMillis() + 60_000;
    IgniteInternalFuture<?> fut = GridTestUtils.runAsync(new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            while (!Thread.currentThread().isInterrupted() && !stop.get() && U.currentTimeMillis() < endTime) {
                try (Ignite ignored = startGrid(1)) {
                    Thread.sleep(500);
                }
            }
            return null;
        }
    });
    try {
        int iter = 0;
        while (System.currentTimeMillis() < endTime) {
            try {
                ignite.compute().broadcast(new IgniteClosure<IgniteSet, Integer>() {

                    @Override
                    public Integer apply(IgniteSet set) {
                        assertNotNull(set);
                        return 1;
                    }
                }, ignite.set("set", new CollectionConfiguration()));
            } catch (IgniteException ignore) {
            // No-op.
            }
            if (iter++ % 1000 == 0)
                log.info("Iteration: " + iter);
        }
    } finally {
        stop.set(true);
    }
    fut.get();
}
Also used : IgniteException(org.apache.ignite.IgniteException) CollectionConfiguration(org.apache.ignite.configuration.CollectionConfiguration) IgniteSet(org.apache.ignite.IgniteSet) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) IgniteException(org.apache.ignite.IgniteException) Ignite(org.apache.ignite.Ignite)

Example 40 with CollectionConfiguration

use of org.apache.ignite.configuration.CollectionConfiguration in project ignite by apache.

the class IgniteClientDataStructuresAbstractTest method testSet.

/**
     * @param creator Creator node.
     * @param other Other node.
     * @throws Exception If failed.
     */
private void testSet(Ignite creator, Ignite other) throws Exception {
    assertNull(creator.set("set1", null));
    assertNull(other.set("set1", null));
    CollectionConfiguration colCfg = new CollectionConfiguration();
    try (IgniteSet<Integer> set = creator.set("set1", colCfg)) {
        assertNotNull(set);
        assertEquals(0, set.size());
        assertFalse(set.contains(1));
        assertTrue(set.add(1));
        assertTrue(set.contains(1));
        IgniteSet<Integer> set0 = other.set("set1", null);
        assertTrue(set0.contains(1));
        assertEquals(1, set0.size());
        assertTrue(set0.remove(1));
        assertFalse(set.contains(1));
    }
    assertNull(creator.set("set1", null));
    assertNull(other.set("set1", null));
}
Also used : CollectionConfiguration(org.apache.ignite.configuration.CollectionConfiguration)

Aggregations

CollectionConfiguration (org.apache.ignite.configuration.CollectionConfiguration)48 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)14 ArrayList (java.util.ArrayList)8 IgniteException (org.apache.ignite.IgniteException)8 IgniteQueue (org.apache.ignite.IgniteQueue)7 IgniteCallable (org.apache.ignite.lang.IgniteCallable)7 Test (org.junit.Test)6 Callable (java.util.concurrent.Callable)5 Ignite (org.apache.ignite.Ignite)4 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 IgniteEx (org.apache.ignite.internal.IgniteEx)4 IgniteInstanceResource (org.apache.ignite.resources.IgniteInstanceResource)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 IgniteQueueEndpoint (org.apache.camel.component.ignite.queue.IgniteQueueEndpoint)3 IgniteSetEndpoint (org.apache.camel.component.ignite.set.IgniteSetEndpoint)3 IgniteSet (org.apache.ignite.IgniteSet)3 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)3 HashSet (java.util.HashSet)2 JndiRegistry (org.apache.camel.impl.JndiRegistry)2 IgniteClientDisconnectedException (org.apache.ignite.IgniteClientDisconnectedException)2