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());
}
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);
}
}
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();
}
}
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));
}
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));
}
Aggregations