Search in sources :

Example 6 with IgniteAtomicSequence

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

the class GridCacheSequenceApiSelfAbstractTest method beforeTestsStarted.

/** {@inheritDoc} */
@Override
protected void beforeTestsStarted() throws Exception {
    super.beforeTestsStarted();
    //Prepare names of mandatory sequences.
    for (int i = 0; i < SEQ_NUM; i++) seqNames[i] = UUID.randomUUID().toString();
    // Prepare mandatory sequences.
    seqArr[0] = grid().atomicSequence(seqNames[0], 0, true);
    seqArr[1] = grid().atomicSequence(seqNames[1], RND.nextLong(), true);
    seqArr[2] = grid().atomicSequence(seqNames[2], -1 * RND.nextLong(), true);
    // Check and change batch size.
    for (IgniteAtomicSequence seq : seqArr) {
        assert seq != null;
        // Compare with default batch size.
        assertEquals(BATCH_SIZE, seq.batchSize());
    }
    assertEquals(1, G.allGrids().size());
}
Also used : IgniteAtomicSequence(org.apache.ignite.IgniteAtomicSequence)

Example 7 with IgniteAtomicSequence

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

the class GridCacheSequenceApiSelfAbstractTest method testRemove.

/**
     * @throws Exception If failed.
     */
public void testRemove() throws Exception {
    String locSeqName = UUID.randomUUID().toString();
    IgniteAtomicSequence seq = grid().atomicSequence(locSeqName, 0, true);
    seq.addAndGet(153);
    seq.close();
    try {
        seq.addAndGet(153);
        fail("Exception expected.");
    } catch (IllegalStateException e) {
        info("Caught expected exception: " + e);
    }
}
Also used : IgniteAtomicSequence(org.apache.ignite.IgniteAtomicSequence)

Example 8 with IgniteAtomicSequence

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

the class GridCacheSequenceApiSelfAbstractTest method afterTestsStopped.

/** {@inheritDoc} */
@Override
protected void afterTestsStopped() throws Exception {
    try {
        // Remove mandatory sequences from cache.
        for (String seqName : seqNames) {
            IgniteAtomicSequence seq = grid().atomicSequence(seqName, 0, false);
            assertNotNull(seq);
            seq.close();
            assertNull(grid().atomicSequence(seqName, 0, false));
        }
    } finally {
        super.afterTestsStopped();
    }
}
Also used : IgniteAtomicSequence(org.apache.ignite.IgniteAtomicSequence)

Example 9 with IgniteAtomicSequence

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

the class GridCacheSequenceApiSelfAbstractTest method removeSequence.

/**
     * @param name Sequence name.
     * @throws Exception If failed.
     */
private void removeSequence(String name) throws Exception {
    IgniteAtomicSequence seq = grid().atomicSequence(name, 0, false);
    assertNotNull(seq);
    seq.close();
    assertNull(grid().atomicSequence(name, 0, false));
}
Also used : IgniteAtomicSequence(org.apache.ignite.IgniteAtomicSequence)

Example 10 with IgniteAtomicSequence

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

the class GridCacheSequenceApiSelfAbstractTest method testCacheSets.

/**
     * @throws Exception If failed.
     */
public void testCacheSets() throws Exception {
    // Make new atomic sequence in cache.
    IgniteAtomicSequence seq = grid().atomicSequence(UUID.randomUUID().toString(), 0, true);
    seq.incrementAndGet();
    GridCacheAdapter cache = ((IgniteKernal) grid()).internalCache(GridCacheUtils.ATOMICS_CACHE_NAME);
    assertNotNull(cache);
    GridTestUtils.assertThrows(log, new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            grid().cache(GridCacheUtils.ATOMICS_CACHE_NAME);
            return null;
        }
    }, IllegalStateException.class, null);
    for (String seqName : seqNames) assert null != cache.get(new GridCacheInternalKeyImpl(seqName));
}
Also used : IgniteKernal(org.apache.ignite.internal.IgniteKernal) GridCacheAdapter(org.apache.ignite.internal.processors.cache.GridCacheAdapter) GridCacheInternalKeyImpl(org.apache.ignite.internal.processors.datastructures.GridCacheInternalKeyImpl) IgniteAtomicSequence(org.apache.ignite.IgniteAtomicSequence)

Aggregations

IgniteAtomicSequence (org.apache.ignite.IgniteAtomicSequence)33 Ignite (org.apache.ignite.Ignite)8 IgniteAtomicLong (org.apache.ignite.IgniteAtomicLong)3 IgniteClientDisconnectedException (org.apache.ignite.IgniteClientDisconnectedException)3 IgniteCountDownLatch (org.apache.ignite.IgniteCountDownLatch)2 IgniteException (org.apache.ignite.IgniteException)2 Closeable (java.io.Closeable)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 Random (java.util.Random)1 BrokenBarrierException (java.util.concurrent.BrokenBarrierException)1 Callable (java.util.concurrent.Callable)1 CyclicBarrier (java.util.concurrent.CyclicBarrier)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 IgniteAtomicReference (org.apache.ignite.IgniteAtomicReference)1 IgniteAtomicStamped (org.apache.ignite.IgniteAtomicStamped)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteInterruptedException (org.apache.ignite.IgniteInterruptedException)1 IgniteLock (org.apache.ignite.IgniteLock)1