Search in sources :

Example 1 with Ignite

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;
}
Also used : IgniteMessaging(org.apache.ignite.IgniteMessaging) Ignite(org.apache.ignite.Ignite)

Example 2 with Ignite

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);
    }
}
Also used : Ignite(org.apache.ignite.Ignite)

Example 3 with 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();
    }
}
Also used : Ignite(org.apache.ignite.Ignite) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 4 with Ignite

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);
        }
    }
}
Also used : Ignite(org.apache.ignite.Ignite) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 5 with Ignite

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);
        }
    }
}
Also used : Ignite(org.apache.ignite.Ignite) Person(org.apache.ignite.examples.model.Person)

Aggregations

Ignite (org.apache.ignite.Ignite)1560 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)275 CountDownLatch (java.util.concurrent.CountDownLatch)188 IgniteException (org.apache.ignite.IgniteException)187 Transaction (org.apache.ignite.transactions.Transaction)166 IgniteCache (org.apache.ignite.IgniteCache)161 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)161 ArrayList (java.util.ArrayList)135 ClusterNode (org.apache.ignite.cluster.ClusterNode)121 UUID (java.util.UUID)104 Event (org.apache.ignite.events.Event)104 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)98 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)97 CacheException (javax.cache.CacheException)94 HashMap (java.util.HashMap)78 IgniteKernal (org.apache.ignite.internal.IgniteKernal)71 Map (java.util.Map)61 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)61 Callable (java.util.concurrent.Callable)60 IgniteSpiException (org.apache.ignite.spi.IgniteSpiException)60