use of org.apache.ignite.configuration.CollectionConfiguration in project ignite by apache.
the class IgniteCollectionAbstractTest method collectionConfiguration.
/**
* @return Collection configuration.
*/
protected CollectionConfiguration collectionConfiguration() {
CollectionConfiguration colCfg = new CollectionConfiguration();
colCfg.setCacheMode(collectionCacheMode());
colCfg.setAtomicityMode(collectionCacheAtomicityMode());
colCfg.setOffHeapMaxMemory(collectionOffHeapMaxMemory());
if (colCfg.getCacheMode() == PARTITIONED)
colCfg.setBackups(1);
return colCfg;
}
use of org.apache.ignite.configuration.CollectionConfiguration in project ignite by apache.
the class IgniteCollectionAbstractTest method config.
/**
* @param collocated Collocated flag.
* @return Collection configuration.
*/
protected final CollectionConfiguration config(boolean collocated) {
CollectionConfiguration cfg = collectionConfiguration();
cfg.setCollocated(collocated);
return cfg;
}
use of org.apache.ignite.configuration.CollectionConfiguration in project camel by apache.
the class IgniteQueueTest method testOperations2.
@Test
@SuppressWarnings("unchecked")
public void testOperations2() {
for (int i = 0; i < 100; i++) {
template.requestBody("ignite:queue:abc?operation=ADD", "hello" + i);
}
// SIZE
int size = template.requestBody("ignite:queue:abc?operation=SIZE", "hello", int.class);
assert_().that(size).isEqualTo(100);
assert_().that(ignite().queue("abc", 0, new CollectionConfiguration()).size()).isEqualTo(100);
List<String> toRetain = Lists.newArrayList();
for (int i = 0; i < 50; i++) {
toRetain.add("hello" + i);
}
// RETAIN_ALL
boolean retained = template.requestBodyAndHeader("ignite:queue:abc?operation=CLEAR", toRetain, IgniteConstants.IGNITE_QUEUE_OPERATION, IgniteQueueOperation.RETAIN_ALL, boolean.class);
assert_().that(retained).isTrue();
// SIZE
size = template.requestBody("ignite:queue:abc?operation=SIZE", "hello", int.class);
assert_().that(size).isEqualTo(50);
assert_().that(ignite().queue("abc", 0, new CollectionConfiguration()).size()).isEqualTo(50);
// ITERATOR
Iterator<String> iterator = template.requestBody("ignite:queue:abc?operation=ITERATOR", "hello", Iterator.class);
assert_().that(Iterators.toArray(iterator, String.class)).asList().containsExactlyElementsIn(toRetain).inOrder();
// ARRAY
String[] array = template.requestBody("ignite:queue:abc?operation=ARRAY", "hello", String[].class);
assert_().that(array).asList().containsExactlyElementsIn(toRetain).inOrder();
// CLEAR
Object result = template.requestBody("ignite:queue:abc?operation=CLEAR", "hello", String.class);
assert_().that(result).isEqualTo("hello");
assert_().that(ignite().queue("abc", 0, new CollectionConfiguration()).size()).isEqualTo(0);
// SIZE
size = template.requestBody("ignite:queue:abc?operation=SIZE", "hello", int.class);
assert_().that(size).isEqualTo(0);
assert_().that(ignite().queue("abc", 0, new CollectionConfiguration()).size()).isEqualTo(0);
}
use of org.apache.ignite.configuration.CollectionConfiguration in project camel by apache.
the class IgniteQueueTest method testWithConfiguration.
@Test
public void testWithConfiguration() {
CollectionConfiguration configuration = new CollectionConfiguration();
configuration.setCacheMode(CacheMode.LOCAL);
context.getRegistry(JndiRegistry.class).bind("config", configuration);
IgniteQueueEndpoint igniteEndpoint = context.getEndpoint("ignite:queue:abc?operation=ADD&configuration=#config", IgniteQueueEndpoint.class);
template.requestBody(igniteEndpoint, "hello");
assert_().that(ignite().queue("abc", 0, configuration).size()).isEqualTo(1);
assert_().that(igniteEndpoint.getConfiguration()).isEqualTo(configuration);
}
use of org.apache.ignite.configuration.CollectionConfiguration in project ignite by apache.
the class IgniteSetExample method initializeSet.
/**
* Initialize set.
*
* @param ignite Ignite.
* @param setName Name of set.
* @return Set.
* @throws IgniteException If execution failed.
*/
private static IgniteSet<String> initializeSet(Ignite ignite, String setName) throws IgniteException {
CollectionConfiguration setCfg = new CollectionConfiguration();
setCfg.setAtomicityMode(TRANSACTIONAL);
setCfg.setCacheMode(PARTITIONED);
// Initialize new set.
IgniteSet<String> set = ignite.set(setName, setCfg);
// Initialize set items.
for (int i = 0; i < 10; i++) set.add(Integer.toString(i));
System.out.println("Set size after initializing: " + set.size());
return set;
}
Aggregations