use of org.apache.ignite.Ignite in project camel by apache.
the class IgniteMessagingEndpoint method createIgniteMessaging.
private IgniteMessaging createIgniteMessaging() {
Ignite ignite = ignite();
IgniteMessaging messaging = clusterGroupExpression == null ? ignite.message() : ignite.message(clusterGroupExpression.getClusterGroup(ignite));
return messaging;
}
use of org.apache.ignite.Ignite in project ignite by apache.
the class ComputeBroadcastExample method main.
/**
* Executes example.
*
* @param args Command line arguments, none required.
* @throws IgniteException If example execution failed.
*/
public static void main(String[] args) throws IgniteException {
try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
System.out.println();
System.out.println(">>> Compute broadcast example started.");
// Print hello message on all nodes.
hello(ignite);
// Gather system info from all nodes.
gatherSystemInfo(ignite);
}
}
use of org.apache.ignite.Ignite in project ignite by apache.
the class MemoryPoliciesExample method main.
/**
* Executes example.
*
* @param args Command line arguments, none required.
* @throws IgniteException If example execution failed.
*/
public static void main(String[] args) throws IgniteException {
try (Ignite ignite = Ignition.start("examples/config/example-memory-policies.xml")) {
System.out.println();
System.out.println(">>> Memory policies example started.");
/**
* Preparing configurations for 2 caches that will be bound to the memory region defined by
* '10MB_Region_Eviction' memory policy from 'example-memory-policies.xml' configuration.
*/
CacheConfiguration<Integer, Integer> firstCacheCfg = new CacheConfiguration<>("firstCache");
firstCacheCfg.setMemoryPolicyName(POLICY_40MB_EVICTION);
firstCacheCfg.setCacheMode(CacheMode.PARTITIONED);
firstCacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
CacheConfiguration<Integer, Integer> secondCacheCfg = new CacheConfiguration<>("secondCache");
secondCacheCfg.setMemoryPolicyName(POLICY_40MB_EVICTION);
secondCacheCfg.setCacheMode(CacheMode.REPLICATED);
secondCacheCfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
IgniteCache<Integer, Integer> firstCache = ignite.createCache(firstCacheCfg);
IgniteCache<Integer, Integer> secondCache = ignite.createCache(secondCacheCfg);
System.out.println(">>> Started two caches bound to '" + POLICY_40MB_EVICTION + "' memory region.");
/**
* Preparing a configuration for a cache that will be bound to the memory region defined by
* '5MB_Region_Swapping' memory policy from 'example-memory-policies.xml' configuration.
*/
CacheConfiguration<Integer, Integer> thirdCacheCfg = new CacheConfiguration<>("thirdCache");
thirdCacheCfg.setMemoryPolicyName(POLICY_30MB_MEMORY_MAPPED_FILE);
IgniteCache<Integer, Integer> thirdCache = ignite.createCache(thirdCacheCfg);
System.out.println(">>> Started a cache bound to '" + POLICY_30MB_MEMORY_MAPPED_FILE + "' memory region.");
/**
* Preparing a configuration for a cache that will be bound to the default memory region defined by
* default 'Default_Region' memory policy from 'example-memory-policies.xml' configuration.
*/
CacheConfiguration<Integer, Integer> fourthCacheCfg = new CacheConfiguration<>("fourthCache");
IgniteCache<Integer, Integer> fourthCache = ignite.createCache(fourthCacheCfg);
System.out.println(">>> Started a cache bound to '" + POLICY_DEFAULT + "' memory region.");
System.out.println(">>> Destroying caches...");
firstCache.destroy();
secondCache.destroy();
thirdCache.destroy();
fourthCache.destroy();
}
}
use of org.apache.ignite.Ignite in project ignite by apache.
the class CacheStarSchemaExample method main.
/**
* Executes example.
*
* @param args Command line arguments, none required.
*/
public static void main(String[] args) {
try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
System.out.println();
System.out.println(">>> Cache star schema example started.");
CacheConfiguration<Integer, FactPurchase> factCacheCfg = new CacheConfiguration<>(FACT_CACHE_NAME);
factCacheCfg.setCacheMode(CacheMode.PARTITIONED);
factCacheCfg.setIndexedTypes(Integer.class, FactPurchase.class);
CacheConfiguration<Integer, DimStore> dimStoreCacheCfg = new CacheConfiguration<>(DIM_STORE_CACHE_NAME);
dimStoreCacheCfg.setCacheMode(CacheMode.REPLICATED);
dimStoreCacheCfg.setIndexedTypes(Integer.class, DimStore.class);
CacheConfiguration<Integer, DimProduct> dimProdCacheCfg = new CacheConfiguration<>(DIM_PROD_CACHE_NAME);
dimProdCacheCfg.setCacheMode(CacheMode.REPLICATED);
dimProdCacheCfg.setIndexedTypes(Integer.class, DimProduct.class);
// Auto-close cache at the end of the example.
try (IgniteCache<Integer, FactPurchase> factCache = ignite.getOrCreateCache(factCacheCfg);
IgniteCache<Integer, DimStore> dimStoreCache = ignite.getOrCreateCache(dimStoreCacheCfg);
IgniteCache<Integer, DimProduct> dimProdCache = ignite.getOrCreateCache(dimProdCacheCfg)) {
populateDimensions(dimStoreCache, dimProdCache);
populateFacts(factCache);
queryStorePurchases();
queryProductPurchases();
} finally {
// Distributed cache could be removed from cluster only by #destroyCache() call.
ignite.destroyCache(FACT_CACHE_NAME);
ignite.destroyCache(DIM_STORE_CACHE_NAME);
ignite.destroyCache(DIM_PROD_CACHE_NAME);
}
}
}
use of org.apache.ignite.Ignite in project ignite by apache.
the class CacheLoadOnlyStoreExample method main.
/**
* Executes example.
*
* @param args Command line arguments, none required.
* @throws IgniteException If example execution failed.
*/
public static void main(String[] args) throws IgniteException {
try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
System.out.println();
System.out.println(">>> CacheLoadOnlyStoreExample started.");
ProductLoader productLoader = new ProductLoader("examples/src/main/resources/person.csv");
productLoader.setThreadsCount(2);
productLoader.setBatchSize(10);
productLoader.setBatchQueueSize(1);
try (IgniteCache<Long, Person> cache = ignite.getOrCreateCache(cacheConfiguration(productLoader))) {
// load data.
cache.loadCache(null);
System.out.println(">>> Loaded number of items: " + cache.size(CachePeekMode.PRIMARY));
System.out.println(">>> Data for the person by id1: " + cache.get(1L));
} finally {
// Distributed cache could be removed from cluster only by #destroyCache() call.
ignite.destroyCache(CACHE_NAME);
}
}
}
Aggregations