Search in sources :

Example 11 with CollectionConfiguration

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

the class GridCacheQueueApiSelfAbstractTest method testPrepareQueue.

/**
     * JUnit.
     *
     * @throws Exception If failed.
     */
public void testPrepareQueue() throws Exception {
    // Random sequence names.
    String queueName1 = UUID.randomUUID().toString();
    String queueName2 = UUID.randomUUID().toString();
    CollectionConfiguration colCfg = config(false);
    IgniteQueue queue1 = grid(0).queue(queueName1, 0, colCfg);
    IgniteQueue queue2 = grid(0).queue(queueName2, 0, colCfg);
    IgniteQueue queue3 = grid(0).queue(queueName1, 0, colCfg);
    assertNotNull(queue1);
    assertNotNull(queue2);
    assertNotNull(queue3);
    assert queue1.equals(queue3);
    assert queue3.equals(queue1);
    assert !queue3.equals(queue2);
    queue1.close();
    queue2.close();
    queue3.close();
    assertNull(grid(0).queue(queueName1, 0, null));
    assertNull(grid(0).queue(queueName2, 0, null));
}
Also used : IgniteQueue(org.apache.ignite.IgniteQueue) CollectionConfiguration(org.apache.ignite.configuration.CollectionConfiguration)

Example 12 with CollectionConfiguration

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

the class GridCacheQueueMultiNodeAbstractSelfTest method testAddMultinode.

/**
     * @param collocated Collocation flag.
     * @throws Exception If failed.
     */
private void testAddMultinode(final boolean collocated) throws Exception {
    final String queueName = UUID.randomUUID().toString();
    info("Queue name: " + queueName + ", collocated: " + collocated);
    try {
        Collection<IgniteInternalFuture> futs = new ArrayList<>();
        final int THREADS_PER_NODE = 3;
        final int ITEMS_PER_THREAD = 1000;
        for (int i = 0; i < GRID_CNT; i++) {
            final int idx = i;
            futs.add(GridTestUtils.runMultiThreadedAsync(new Callable<Void>() {

                @Override
                public Void call() throws Exception {
                    CollectionConfiguration colCfg = config(collocated);
                    IgniteQueue<Integer> queue = grid(idx).queue(queueName, 0, colCfg);
                    for (int i = 0; i < ITEMS_PER_THREAD; i++) assertTrue(queue.add(i));
                    return null;
                }
            }, THREADS_PER_NODE, "testPutMultiNode"));
        }
        for (IgniteInternalFuture fut : futs) fut.get();
        IgniteQueue<Integer> queue = grid(0).queue(queueName, 0, null);
        assertEquals(THREADS_PER_NODE * ITEMS_PER_THREAD * GRID_CNT, queue.size());
        int[] items = new int[ITEMS_PER_THREAD];
        Integer item;
        while ((item = queue.poll()) != null) items[item]++;
        for (int i = 0; i < ITEMS_PER_THREAD; i++) assertEquals(THREADS_PER_NODE * GRID_CNT, items[i]);
    } finally {
        grid(0).queue(queueName, 0, null).close();
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ArrayList(java.util.ArrayList) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) Callable(java.util.concurrent.Callable) IgniteCallable(org.apache.ignite.lang.IgniteCallable) CollectionConfiguration(org.apache.ignite.configuration.CollectionConfiguration)

Example 13 with CollectionConfiguration

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

the class IgniteClientReconnectCollectionsTest method testQueueReconnectRemoved.

/**
     * @throws Exception If failed.
     */
public void testQueueReconnectRemoved() throws Exception {
    CollectionConfiguration colCfg = new CollectionConfiguration();
    colCfg.setCacheMode(PARTITIONED);
    colCfg.setAtomicityMode(TRANSACTIONAL);
    queueReconnectRemoved(colCfg);
    colCfg = new CollectionConfiguration();
    colCfg.setCacheMode(PARTITIONED);
    colCfg.setAtomicityMode(ATOMIC);
    queueReconnectRemoved(colCfg);
}
Also used : CollectionConfiguration(org.apache.ignite.configuration.CollectionConfiguration)

Example 14 with CollectionConfiguration

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

the class IgniteClientReconnectCollectionsTest method testSetReconnect.

/**
     * @throws Exception If failed.
     */
public void testSetReconnect() throws Exception {
    CollectionConfiguration colCfg = new CollectionConfiguration();
    colCfg.setCacheMode(PARTITIONED);
    colCfg.setAtomicityMode(TRANSACTIONAL);
    setReconnect(colCfg);
    colCfg = new CollectionConfiguration();
    colCfg.setCacheMode(PARTITIONED);
    colCfg.setAtomicityMode(ATOMIC);
    setReconnect(colCfg);
}
Also used : CollectionConfiguration(org.apache.ignite.configuration.CollectionConfiguration)

Example 15 with CollectionConfiguration

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

the class IgniteClientReconnectCollectionsTest method testSetReconnectInProgress.

/**
     * @throws Exception If failed.
     */
public void testSetReconnectInProgress() throws Exception {
    CollectionConfiguration colCfg = new CollectionConfiguration();
    colCfg.setCacheMode(PARTITIONED);
    colCfg.setAtomicityMode(ATOMIC);
    setReconnectInProgress(colCfg);
    colCfg = new CollectionConfiguration();
    colCfg.setCacheMode(PARTITIONED);
    colCfg.setAtomicityMode(TRANSACTIONAL);
    setReconnectInProgress(colCfg);
}
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