use of org.apache.ignite.configuration.CollectionConfiguration in project ignite by apache.
the class IgniteClientReconnectCollectionsTest method testQueueReconnect.
/**
* @throws Exception If failed.
*/
public void testQueueReconnect() throws Exception {
CollectionConfiguration colCfg = new CollectionConfiguration();
colCfg.setCacheMode(PARTITIONED);
colCfg.setAtomicityMode(TRANSACTIONAL);
queueReconnect(colCfg);
colCfg = new CollectionConfiguration();
colCfg.setCacheMode(PARTITIONED);
colCfg.setAtomicityMode(ATOMIC);
queueReconnect(colCfg);
}
use of org.apache.ignite.configuration.CollectionConfiguration in project ignite by apache.
the class IgniteClientReconnectCollectionsTest method testCollectionsReconnectClusterRestart.
/**
* @throws Exception If failed.
*/
public void testCollectionsReconnectClusterRestart() throws Exception {
CollectionConfiguration colCfg = new CollectionConfiguration();
colCfg.setCacheMode(PARTITIONED);
colCfg.setAtomicityMode(TRANSACTIONAL);
Ignite client = grid(serverCount());
assertTrue(client.cluster().localNode().isClient());
final IgniteQueue<Object> queue = client.queue("q", 0, colCfg);
final IgniteSet<Object> set = client.set("s", colCfg);
Ignite srv = grid(0);
reconnectServersRestart(log, client, Collections.singleton(srv), new Callable<Collection<Ignite>>() {
@Override
public Collection<Ignite> call() throws Exception {
return Collections.singleton((Ignite) startGrid(0));
}
});
GridTestUtils.assertThrows(log, new Callable<Void>() {
@Override
public Void call() throws Exception {
queue.add(1);
return null;
}
}, IllegalStateException.class, null);
GridTestUtils.assertThrows(log, new Callable<Void>() {
@Override
public Void call() throws Exception {
set.add(1);
return null;
}
}, IllegalStateException.class, null);
try (IgniteQueue<Object> queue2 = client.queue("q", 0, colCfg)) {
queue2.add(1);
}
try (IgniteSet<Object> set2 = client.set("s", colCfg)) {
set2.add(1);
}
}
use of org.apache.ignite.configuration.CollectionConfiguration in project ignite by apache.
the class GridCacheQueueApiSelfAbstractTest method testAffinityRun.
/**
* @throws Exception If failed.
*/
public void testAffinityRun() throws Exception {
final CollectionConfiguration colCfg = collectionConfiguration();
colCfg.setCollocated(false);
colCfg.setCacheMode(CacheMode.PARTITIONED);
try (final IgniteQueue<Integer> queue1 = grid(0).queue("Queue1", 0, colCfg)) {
GridTestUtils.assertThrows(log, new Callable<Void>() {
@Override
public Void call() throws Exception {
queue1.affinityRun(new IgniteRunnable() {
@Override
public void run() {
// No-op.
}
});
return null;
}
}, IgniteException.class, "Failed to execute affinityRun() for non-collocated queue: " + queue1.name() + ". This operation is supported only for collocated queues.");
}
colCfg.setCollocated(true);
try (final IgniteQueue<Integer> queue2 = grid(0).queue("Queue2", 0, colCfg)) {
queue2.add(100);
queue2.affinityRun(new IgniteRunnable() {
@IgniteInstanceResource
private IgniteEx ignite;
@Override
public void run() {
assertTrue(ignite.cachex("datastructures_0").affinity().isPrimaryOrBackup(ignite.cluster().localNode(), "Queue2"));
assertEquals(100, queue2.take().intValue());
}
});
}
}
use of org.apache.ignite.configuration.CollectionConfiguration in project ignite by apache.
the class GridCacheSetAbstractSelfTest method testIteratorClose.
/**
* @param collocated Collocation flag.
* @throws Exception If failed.
*/
@SuppressWarnings({ "BusyWait", "ErrorNotRethrown" })
private void testIteratorClose(boolean collocated) throws Exception {
CollectionConfiguration colCfg = config(collocated);
IgniteSet<Integer> set0 = grid(0).set(SET_NAME, colCfg);
for (int i = 0; i < 5000; i++) assertTrue(set0.add(i));
createIterators(set0);
System.gc();
for (int i = 0; i < 10; i++) {
try {
// Trigger weak queue poll.
set0.size();
assertSetIteratorsCleared();
} catch (AssertionFailedError e) {
if (i == 9)
throw e;
log.info("Set iterators not cleared, will wait");
Thread.sleep(500);
}
}
// Check iterators are closed on set remove.
createIterators(set0);
int idx = gridCount() > 1 ? 1 : 0;
grid(idx).set(SET_NAME, null).close();
for (int i = 0; i < 10; i++) {
try {
assertSetIteratorsCleared();
} catch (AssertionFailedError e) {
if (i == 9)
throw e;
log.info("Set iterators not cleared, will wait");
Thread.sleep(500);
}
}
}
use of org.apache.ignite.configuration.CollectionConfiguration in project ignite by apache.
the class GridCacheSetAbstractSelfTest method testCreateRemove.
/**
* @param collocated Collocation flag.
* @throws Exception If failed.
*/
private void testCreateRemove(boolean collocated) throws Exception {
for (int i = 0; i < gridCount(); i++) assertNull(grid(i).set(SET_NAME, null));
CollectionConfiguration colCfg0 = config(collocated);
IgniteSet<Integer> set0 = grid(0).set(SET_NAME, colCfg0);
assertNotNull(set0);
for (int i = 0; i < gridCount(); i++) {
CollectionConfiguration colCfg = config(collocated);
IgniteSet<Integer> set = grid(i).set(SET_NAME, colCfg);
assertNotNull(set);
assertTrue(set.isEmpty());
assertEquals(0, set.size());
assertEquals(SET_NAME, set.name());
if (collectionCacheMode() == PARTITIONED)
assertEquals(collocated, set.collocated());
}
set0.close();
GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override
public boolean apply() {
try {
for (int i = 0; i < gridCount(); i++) {
if (grid(i).set(SET_NAME, null) != null)
return false;
}
return true;
} catch (Exception e) {
fail("Unexpected exception: " + e);
return true;
}
}
}, 1000);
for (int i = 0; i < gridCount(); i++) assertNull(grid(i).set(SET_NAME, null));
}
Aggregations