use of org.apache.ignite.configuration.CollectionConfiguration in project ignite by apache.
the class IgniteClientReconnectCollectionsTest method testQueueReconnectInProgress.
/**
* @throws Exception If failed.
*/
public void testQueueReconnectInProgress() throws Exception {
CollectionConfiguration colCfg = new CollectionConfiguration();
colCfg.setCacheMode(PARTITIONED);
colCfg.setAtomicityMode(TRANSACTIONAL);
queueReconnectInProgress(colCfg);
colCfg = new CollectionConfiguration();
colCfg.setCacheMode(PARTITIONED);
colCfg.setAtomicityMode(ATOMIC);
queueReconnectInProgress(colCfg);
}
use of org.apache.ignite.configuration.CollectionConfiguration in project ignite by apache.
the class IgniteClientReconnectCollectionsTest method testSetReconnectRemoved.
/**
* @throws Exception If failed.
*/
public void testSetReconnectRemoved() throws Exception {
CollectionConfiguration colCfg = new CollectionConfiguration();
colCfg.setCacheMode(PARTITIONED);
colCfg.setAtomicityMode(ATOMIC);
setReconnectRemove(colCfg);
colCfg = new CollectionConfiguration();
colCfg.setCacheMode(PARTITIONED);
colCfg.setAtomicityMode(TRANSACTIONAL);
setReconnectRemove(colCfg);
}
use of org.apache.ignite.configuration.CollectionConfiguration in project ignite by apache.
the class GridCacheSetAbstractSelfTest method testCleanup.
/**
* @param collocated Collocation flag.
* @throws Exception If failed.
*/
@SuppressWarnings("WhileLoopReplaceableByForEach")
private void testCleanup(boolean collocated) throws Exception {
CollectionConfiguration colCfg = config(collocated);
final IgniteSet<Integer> set0 = grid(0).set(SET_NAME, colCfg);
assertNotNull(set0);
final Collection<Set<Integer>> sets = new ArrayList<>();
for (int i = 0; i < gridCount(); i++) {
IgniteSet<Integer> set = grid(i).set(SET_NAME, null);
assertNotNull(set);
sets.add(set);
}
Collection<Integer> items = new ArrayList<>(10_000);
for (int i = 0; i < 10_000; i++) items.add(i);
set0.addAll(items);
assertEquals(10_000, set0.size());
final AtomicBoolean stop = new AtomicBoolean();
final AtomicInteger val = new AtomicInteger(10_000);
IgniteInternalFuture<?> fut;
try {
fut = GridTestUtils.runMultiThreadedAsync(new Callable<Object>() {
@Override
public Object call() throws Exception {
try {
while (!stop.get()) {
for (Set<Integer> set : sets) set.add(val.incrementAndGet());
}
} catch (IllegalStateException e) {
log.info("Set removed: " + e);
}
return null;
}
}, 5, "set-add-thread");
set0.close();
} finally {
stop.set(true);
}
fut.get();
int cnt = 0;
GridCacheContext cctx = GridTestUtils.getFieldValue(set0, "cctx");
for (int i = 0; i < gridCount(); i++) {
Iterator<GridCacheMapEntry> entries = (grid(i)).context().cache().internalCache(cctx.name()).map().entries().iterator();
while (entries.hasNext()) {
GridCacheEntryEx entry = entries.next();
if (entry.hasValue()) {
cnt++;
log.info("Unexpected entry: " + entry);
}
}
}
assertEquals("Found unexpected cache entries", 0, cnt);
for (final Set<Integer> set : sets) {
GridTestUtils.assertThrows(log, new Callable<Void>() {
@Override
public Void call() throws Exception {
set.add(10);
return null;
}
}, IllegalStateException.class, null);
}
}
use of org.apache.ignite.configuration.CollectionConfiguration in project ignite by apache.
the class GridCacheSetAbstractSelfTest method testNodeJoinsAndLeaves.
/**
* @param collocated Collocation flag.
* @throws Exception If failed.
*/
private void testNodeJoinsAndLeaves(boolean collocated) throws Exception {
CollectionConfiguration colCfg = config(collocated);
Set<Integer> set0 = grid(0).set(SET_NAME, colCfg);
final int ITEMS = 10_000;
for (int i = 0; i < ITEMS; i++) set0.add(i);
startGrid(gridCount());
try {
IgniteSet<Integer> set1 = grid(0).set(SET_NAME, null);
assertNotNull(set1);
for (int i = 0; i < gridCount() + 1; i++) {
IgniteSet<Integer> set = grid(i).set(SET_NAME, null);
assertEquals(ITEMS, set.size());
assertSetContent(set, ITEMS);
}
} finally {
stopGrid(gridCount());
}
for (int i = 0; i < gridCount(); i++) {
IgniteSet<Integer> set = grid(i).set(SET_NAME, null);
assertSetContent(set, ITEMS);
}
}
use of org.apache.ignite.configuration.CollectionConfiguration in project ignite by apache.
the class GridCacheSetAbstractSelfTest method testIterator.
/**
* @param collocated Collocation flag.
* @throws Exception If failed.
*/
@SuppressWarnings("deprecation")
private void testIterator(boolean collocated) throws Exception {
CollectionConfiguration colCfg = config(collocated);
final IgniteSet<Integer> set0 = grid(0).set(SET_NAME, colCfg);
for (int i = 0; i < gridCount(); i++) {
IgniteSet<Integer> set = grid(i).set(SET_NAME, null);
assertFalse(set.iterator().hasNext());
}
int cnt = 0;
for (int i = 0; i < gridCount(); i++) {
Set<Integer> set = grid(i).set(SET_NAME, null);
for (int j = 0; j < 100; j++) assertTrue(set.add(cnt++));
}
for (int i = 0; i < gridCount(); i++) {
IgniteSet<Integer> set = grid(i).set(SET_NAME, null);
assertSetContent(set, cnt);
}
// Try to do not use hasNext.
Collection<Integer> data = new HashSet<>(cnt);
Iterator<Integer> iter = set0.iterator();
for (int i = 0; i < cnt; i++) assertTrue(data.add(iter.next()));
assertFalse(iter.hasNext());
assertEquals(cnt, data.size());
for (int i = 0; i < cnt; i++) assertTrue(data.contains(i));
// Iterator for empty set.
set0.clear();
for (int i = 0; i < gridCount(); i++) {
IgniteSet<Integer> set = grid(i).set(SET_NAME, null);
assertFalse(set.iterator().hasNext());
}
for (int i = 0; i < 10; i++) assertTrue(set0.add(i));
iter = set0.iterator();
while (iter.hasNext()) {
Integer val = iter.next();
if (val % 2 == 0)
iter.remove();
}
for (int i = 0; i < gridCount(); i++) {
Set<Integer> set = grid(i).set(SET_NAME, null);
assertEquals(i % 2 != 0, set.contains(i));
}
}
Aggregations