ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sevdoki...@apache.org
Subject [5/5] incubator-ignite git commit: # IGNITE-459 Need to update examples to use dynamic caches
Date Thu, 12 Mar 2015 12:49:45 GMT
# IGNITE-459 Need to update examples to use dynamic caches


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/dcd7f423
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/dcd7f423
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/dcd7f423

Branch: refs/heads/ignite-459
Commit: dcd7f423433d5f0ce475a5152c8e97307c6d9a3e
Parents: 5506cce
Author: sevdokimov <sevdokimov@gridgain.com>
Authored: Thu Mar 12 15:49:23 2015 +0300
Committer: sevdokimov <sevdokimov@gridgain.com>
Committed: Thu Mar 12 15:49:23 2015 +0300

----------------------------------------------------------------------
 examples/config/example-compute.xml             |  2 +-
 .../apache/ignite/examples/ExamplesUtils.java   | 14 +++
 .../examples/datagrid/CacheAffinityExample.java | 30 +++---
 .../examples/datagrid/CacheApiExample.java      |  4 +-
 .../datagrid/CacheContinuousQueryExample.java   | 98 ++++++++++----------
 .../datagrid/CacheDataLoaderExample.java        | 50 +++++-----
 .../examples/datagrid/CacheEventsExample.java   | 74 ++++++++-------
 .../datagrid/CachePopularNumbersExample.java    | 38 ++++----
 .../examples/datagrid/CachePutGetExample.java   | 39 ++++----
 .../examples/datagrid/CacheQueryExample.java    | 44 +++++----
 .../datagrid/CacheTransactionExample.java       | 58 ++++++------
 .../starschema/CacheStarSchemaExample.java      | 67 ++++++-------
 .../datastructures/IgniteSetExample.java        |  6 +-
 13 files changed, 288 insertions(+), 236 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcd7f423/examples/config/example-compute.xml
----------------------------------------------------------------------
diff --git a/examples/config/example-compute.xml b/examples/config/example-compute.xml
index c532e17..0bdca04 100644
--- a/examples/config/example-compute.xml
+++ b/examples/config/example-compute.xml
@@ -41,7 +41,7 @@
 
         <!-- Enable task execution events for examples. -->
         <property name="includeEventTypes">
-            <util:constant static-field="org.apache.ignite.events.EventType.EVTS_TASK_EXECUTION"/>
+            <util:constant static-field="org.apache.ignite.examples.ExamplesUtils.EVTS"/>
         </property>
 
         <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcd7f423/examples/src/main/java/org/apache/ignite/examples/ExamplesUtils.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ExamplesUtils.java b/examples/src/main/java/org/apache/ignite/examples/ExamplesUtils.java
index a1d59c9..d6cbd68 100644
--- a/examples/src/main/java/org/apache/ignite/examples/ExamplesUtils.java
+++ b/examples/src/main/java/org/apache/ignite/examples/ExamplesUtils.java
@@ -18,10 +18,14 @@
 package org.apache.ignite.examples;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
 import org.apache.ignite.cluster.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.events.*;
 import org.apache.ignite.streamer.*;
 
 import java.net.*;
+import java.util.*;
 
 /**
  *
@@ -30,6 +34,16 @@ public class ExamplesUtils {
     /** */
     private static final ClassLoader CLS_LDR = ExamplesUtils.class.getClassLoader();
 
+    /** Events of these types should be recorded in examples. */
+    public static final int[] EVTS;
+
+    static {
+        EVTS = Arrays.copyOf(EventType.EVTS_CACHE, EventType.EVTS_CACHE.length + EventType.EVTS_TASK_EXECUTION.length);
+
+        System.arraycopy(EventType.EVTS_TASK_EXECUTION, 0, EVTS, EventType.EVTS_CACHE.length,
+            EventType.EVTS_TASK_EXECUTION.length);
+    }
+
     /**
      * Exits with code {@code -1} if maximum memory is below 90% of minimally allowed threshold.
      *

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcd7f423/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAffinityExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAffinityExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAffinityExample.java
index 271df75..a0ee4fd 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAffinityExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAffinityExample.java
@@ -18,7 +18,9 @@
 package org.apache.ignite.examples.datagrid;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
 import org.apache.ignite.cluster.*;
+import org.apache.ignite.configuration.*;
 import org.apache.ignite.examples.*;
 import org.apache.ignite.lang.*;
 
@@ -30,14 +32,14 @@ import java.util.*;
  * example is to provide the simplest code example of this logic.
  * <p>
  * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-cache.xml'}.
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-compute.xml'}.
  * <p>
  * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
- * start node with {@code examples/config/example-cache.xml} configuration.
+ * start node with {@code examples/config/example-compute.xml} configuration.
  */
 public final class CacheAffinityExample {
     /** Cache name. */
-    private static final String CACHE_NAME = "partitioned";
+    private static final String CACHE_NAME = CacheAffinityExample.class.getSimpleName();
 
     /** Number of keys. */
     private static final int KEY_CNT = 20;
@@ -49,23 +51,25 @@ public final class CacheAffinityExample {
      * @throws IgniteException If example execution failed.
      */
     public static void main(String[] args) throws IgniteException {
-        try (Ignite ignite = Ignition.start("examples/config/example-cache.xml")) {
+        try (Ignite ignite = Ignition.start("examples/config/example-compute.xml")) {
             System.out.println();
             System.out.println(">>> Cache affinity example started.");
 
-            IgniteCache<Integer, String> cache = ignite.jcache(CACHE_NAME);
+            CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
 
-            // Clean up caches on all nodes before run.
-            cache.clear();
+            cfg.setCacheMode(CacheMode.PARTITIONED);
+            cfg.setName(CACHE_NAME);
 
-            for (int i = 0; i < KEY_CNT; i++)
-                cache.put(i, Integer.toString(i));
+            try (IgniteCache<Integer, String> cache = ignite.createCache(cfg)) {
+                for (int i = 0; i < KEY_CNT; i++)
+                    cache.put(i, Integer.toString(i));
 
-            // Co-locates jobs with data using IgniteCompute.affinityRun(...) method.
-            visitUsingAffinityRun();
+                // Co-locates jobs with data using IgniteCompute.affinityRun(...) method.
+                visitUsingAffinityRun();
 
-            // Co-locates jobs with data using IgniteCluster.mapKeysToNodes(...) method.
-            visitUsingMapKeysToNodes();
+                // Co-locates jobs with data using IgniteCluster.mapKeysToNodes(...) method.
+                visitUsingMapKeysToNodes();
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcd7f423/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheApiExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheApiExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheApiExample.java
index e8f34ec..078b343 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheApiExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheApiExample.java
@@ -30,10 +30,10 @@ import java.util.concurrent.*;
  * This example demonstrates some of the cache rich API capabilities.
  * <p>
  * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-cache.xml'}.
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-compute.xml'}.
  * <p>
  * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
- * start node with {@code examples/config/example-cache.xml} configuration.
+ * start node with {@code examples/config/example-compute.xml} configuration.
  */
 public class CacheApiExample {
     /** Cache name. */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcd7f423/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheContinuousQueryExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheContinuousQueryExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheContinuousQueryExample.java
index 38e392e..c35f4de 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheContinuousQueryExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheContinuousQueryExample.java
@@ -18,7 +18,9 @@
 package org.apache.ignite.examples.datagrid;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
 import org.apache.ignite.cache.query.*;
+import org.apache.ignite.configuration.*;
 import org.apache.ignite.examples.*;
 import org.apache.ignite.lang.*;
 
@@ -29,14 +31,14 @@ import javax.cache.event.*;
  * This examples demonstrates continuous query API.
  * <p>
  * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-cache.xml'}.
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-compute.xml'}.
  * <p>
  * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
- * start node with {@code examples/config/example-cache.xml} configuration.
+ * start node with {@code examples/config/example-compute.xml} configuration.
  */
 public class CacheContinuousQueryExample {
     /** Cache name. */
-    private static final String CACHE_NAME = "partitioned";
+    private static final String CACHE_NAME = CacheContinuousQueryExample.class.getSimpleName();
 
     /**
      * Executes example.
@@ -45,58 +47,60 @@ public class CacheContinuousQueryExample {
      * @throws Exception If example execution failed.
      */
     public static void main(String[] args) throws Exception {
-        try (Ignite ignite = Ignition.start("examples/config/example-cache.xml")) {
+        try (Ignite ignite = Ignition.start("examples/config/example-compute.xml")) {
             System.out.println();
             System.out.println(">>> Cache continuous query example started.");
 
-            IgniteCache<Integer, String> cache = ignite.jcache(CACHE_NAME);
+            CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
 
-            // Clean up caches on all nodes before run.
-            cache.clear();
+            cfg.setCacheMode(CacheMode.PARTITIONED);
+            cfg.setName(CACHE_NAME);
 
-            int keyCnt = 20;
+            try (IgniteCache<Integer, String> cache = ignite.createCache(cfg)) {
+                int keyCnt = 20;
 
-            // These entries will be queried by initial predicate.
-            for (int i = 0; i < keyCnt; i++)
-                cache.put(i, Integer.toString(i));
-
-            // Create new continuous query.
-            ContinuousQuery<Integer, String> qry = new ContinuousQuery<>();
-
-            qry.setInitialQuery(new ScanQuery<>(new IgniteBiPredicate<Integer, String>() {
-                @Override public boolean apply(Integer key, String val) {
-                    return key > 10;
-                }
-            }));
-
-            // Callback that is called locally when update notifications are received.
-            qry.setLocalListener(new CacheEntryUpdatedListener<Integer, String>() {
-                @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends String>> evts) {
-                    for (CacheEntryEvent<? extends Integer, ? extends String> e : evts)
-                        System.out.println("Updated entry [key=" + e.getKey() + ", val=" + e.getValue() + ']');
-                }
-            });
-
-            // This filter will be evaluated remotely on all nodes.
-            // Entry that pass this filter will be sent to the caller.
-            qry.setRemoteFilter(new CacheEntryEventFilter<Integer, String>() {
-                @Override public boolean evaluate(CacheEntryEvent<? extends Integer, ? extends String> e) {
-                    return e.getKey() > 10;
-                }
-            });
-
-            // Execute query.
-            try (QueryCursor<Cache.Entry<Integer, String>> cur = cache.query(qry)) {
-                // Iterate through existing data.
-                for (Cache.Entry<Integer, String> e : cur)
-                    System.out.println("Queried existing entry [key=" + e.getKey() + ", val=" + e.getValue() + ']');
-
-                // Add a few more keys and watch more query notifications.
-                for (int i = keyCnt; i < keyCnt + 10; i++)
+                // These entries will be queried by initial predicate.
+                for (int i = 0; i < keyCnt; i++)
                     cache.put(i, Integer.toString(i));
 
-                // Wait for a while while callback is notified about remaining puts.
-                Thread.sleep(2000);
+                // Create new continuous query.
+                ContinuousQuery<Integer, String> qry = new ContinuousQuery<>();
+
+                qry.setInitialQuery(new ScanQuery<>(new IgniteBiPredicate<Integer, String>() {
+                    @Override public boolean apply(Integer key, String val) {
+                        return key > 10;
+                    }
+                }));
+
+                // Callback that is called locally when update notifications are received.
+                qry.setLocalListener(new CacheEntryUpdatedListener<Integer, String>() {
+                    @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends String>> evts) {
+                        for (CacheEntryEvent<? extends Integer, ? extends String> e : evts)
+                            System.out.println("Updated entry [key=" + e.getKey() + ", val=" + e.getValue() + ']');
+                    }
+                });
+
+                // This filter will be evaluated remotely on all nodes.
+                // Entry that pass this filter will be sent to the caller.
+                qry.setRemoteFilter(new CacheEntryEventFilter<Integer, String>() {
+                    @Override public boolean evaluate(CacheEntryEvent<? extends Integer, ? extends String> e) {
+                        return e.getKey() > 10;
+                    }
+                });
+
+                // Execute query.
+                try (QueryCursor<Cache.Entry<Integer, String>> cur = cache.query(qry)) {
+                    // Iterate through existing data.
+                    for (Cache.Entry<Integer, String> e : cur)
+                        System.out.println("Queried existing entry [key=" + e.getKey() + ", val=" + e.getValue() + ']');
+
+                    // Add a few more keys and watch more query notifications.
+                    for (int i = keyCnt; i < keyCnt + 10; i++)
+                        cache.put(i, Integer.toString(i));
+
+                    // Wait for a while while callback is notified about remaining puts.
+                    Thread.sleep(2000);
+                }
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcd7f423/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheDataLoaderExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheDataLoaderExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheDataLoaderExample.java
index fd2f8fb..0e977f7 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheDataLoaderExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheDataLoaderExample.java
@@ -18,6 +18,8 @@
 package org.apache.ignite.examples.datagrid;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
+import org.apache.ignite.configuration.*;
 import org.apache.ignite.examples.*;
 
 /**
@@ -27,14 +29,14 @@ import org.apache.ignite.examples.*;
  * together and properly manages load on remote nodes.
  * <p>
  * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-cache.xml'}.
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-compute.xml'}.
  * <p>
  * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
- * start node with {@code examples/config/example-cache.xml} configuration.
+ * start node with {@code examples/config/example-compute.xml} configuration.
  */
 public class CacheDataLoaderExample {
     /** Cache name. */
-    private static final String CACHE_NAME = "partitioned";
+    private static final String CACHE_NAME = CacheDataLoaderExample.class.getSimpleName();
 
     /** Number of entries to load. */
     private static final int ENTRY_COUNT = 500000;
@@ -51,35 +53,39 @@ public class CacheDataLoaderExample {
     public static void main(String[] args) throws IgniteException {
         ExamplesUtils.checkMinMemory(MIN_MEMORY);
 
-        try (Ignite ignite = Ignition.start("examples/config/example-cache.xml")) {
+        try (Ignite ignite = Ignition.start("examples/config/example-compute.xml")) {
             System.out.println();
             System.out.println(">>> Cache data loader example started.");
 
-            // Clean up caches on all nodes before run.
-            ignite.jcache(CACHE_NAME).clear();
+            CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
 
-            System.out.println();
-            System.out.println(">>> Cache clear finished.");
+            cfg.setCacheMode(CacheMode.PARTITIONED);
+            cfg.setName(CACHE_NAME);
 
-            long start = System.currentTimeMillis();
+            try (IgniteCache<Integer, String> cache = ignite.createCache(cfg)) {
+                System.out.println();
+                System.out.println(">>> Cache clear finished.");
 
-            try (IgniteDataLoader<Integer, String> ldr = ignite.dataLoader(CACHE_NAME)) {
-                // Configure loader.
-                ldr.perNodeBufferSize(1024);
-                ldr.perNodeParallelLoadOperations(8);
+                try (IgniteDataLoader<Integer, String> ldr = ignite.dataLoader(CACHE_NAME)) {
+                    long start = System.currentTimeMillis();
 
-                for (int i = 0; i < ENTRY_COUNT; i++) {
-                    ldr.addData(i, Integer.toString(i));
+                    // Configure loader.
+                    ldr.perNodeBufferSize(1024);
+                    ldr.perNodeParallelLoadOperations(8);
 
-                    // Print out progress while loading cache.
-                    if (i > 0 && i % 10000 == 0)
-                        System.out.println("Loaded " + i + " keys.");
-                }
-            }
+                    for (int i = 0; i < ENTRY_COUNT; i++) {
+                        ldr.addData(i, Integer.toString(i));
 
-            long end = System.currentTimeMillis();
+                        // Print out progress while loading cache.
+                        if (i > 0 && i % 10000 == 0)
+                            System.out.println("Loaded " + i + " keys.");
+                    }
 
-            System.out.println(">>> Loaded " + ENTRY_COUNT + " keys in " + (end - start) + "ms.");
+                    long end = System.currentTimeMillis();
+
+                    System.out.println(">>> Loaded " + ENTRY_COUNT + " keys in " + (end - start) + "ms.");
+                }
+            }
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcd7f423/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEventsExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEventsExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEventsExample.java
index fab9676..aef5976 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEventsExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEventsExample.java
@@ -18,6 +18,8 @@
 package org.apache.ignite.examples.datagrid;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
+import org.apache.ignite.configuration.*;
 import org.apache.ignite.events.*;
 import org.apache.ignite.examples.*;
 import org.apache.ignite.lang.*;
@@ -28,17 +30,17 @@ import static org.apache.ignite.events.EventType.*;
 
 /**
  * This examples demonstrates events API. Note that ignite events are disabled by default and
- * must be specifically enabled, just like in {@code examples/config/example-cache.xml} file.
+ * must be specifically enabled, just like in {@code examples/config/example-compute.xml} file.
  * <p>
  * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-cache.xml'}.
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-compute.xml'}.
  * <p>
  * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
- * start node with {@code examples/config/example-cache.xml} configuration.
+ * start node with {@code examples/config/example-compute.xml} configuration.
  */
 public class CacheEventsExample {
     /** Cache name. */
-    private static final String CACHE_NAME = "partitioned";
+    private static final String CACHE_NAME = CacheEventsExample.class.getSimpleName();
 
     /**
      * Executes example.
@@ -47,49 +49,51 @@ public class CacheEventsExample {
      * @throws IgniteException If example execution failed.
      */
     public static void main(String[] args) throws IgniteException, InterruptedException {
-        try (Ignite ignite = Ignition.start("examples/config/example-cache.xml")) {
+        try (Ignite ignite = Ignition.start("examples/config/example-compute.xml")) {
             System.out.println();
             System.out.println(">>> Cache events example started.");
 
-            final IgniteCache<Integer, String> cache = ignite.jcache(CACHE_NAME);
+            CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
 
-            // Clean up caches on all nodes before run.
-            cache.clear();
+            cfg.setCacheMode(CacheMode.PARTITIONED);
+            cfg.setName(CACHE_NAME);
 
-            // This optional local callback is called for each event notification
-            // that passed remote predicate listener.
-            IgniteBiPredicate<UUID, CacheEvent> locLsnr = new IgniteBiPredicate<UUID, CacheEvent>() {
-                @Override public boolean apply(UUID uuid, CacheEvent evt) {
-                    System.out.println("Received event [evt=" + evt.name() + ", key=" + evt.key() +
-                        ", oldVal=" + evt.oldValue() + ", newVal=" + evt.newValue());
+            try (IgniteCache<Integer, String> cache = ignite.createCache(cfg)) {
+                // This optional local callback is called for each event notification
+                // that passed remote predicate listener.
+                IgniteBiPredicate<UUID, CacheEvent> locLsnr = new IgniteBiPredicate<UUID, CacheEvent>() {
+                    @Override public boolean apply(UUID uuid, CacheEvent evt) {
+                        System.out.println("Received event [evt=" + evt.name() + ", key=" + evt.key() +
+                            ", oldVal=" + evt.oldValue() + ", newVal=" + evt.newValue());
 
-                    return true; // Continue listening.
-                }
-            };
+                        return true; // Continue listening.
+                    }
+                };
 
-            // Remote listener which only accepts events for keys that are
-            // greater or equal than 10 and if event node is primary for this key.
-            IgnitePredicate<CacheEvent> rmtLsnr = new IgnitePredicate<CacheEvent>() {
-                @Override public boolean apply(CacheEvent evt) {
-                    System.out.println("Cache event [name=" + evt.name() + ", key=" + evt.key() + ']');
+                // Remote listener which only accepts events for keys that are
+                // greater or equal than 10 and if event node is primary for this key.
+                IgnitePredicate<CacheEvent> rmtLsnr = new IgnitePredicate<CacheEvent>() {
+                    @Override public boolean apply(CacheEvent evt) {
+                        System.out.println("Cache event [name=" + evt.name() + ", key=" + evt.key() + ']');
 
-                    int key = evt.key();
+                        int key = evt.key();
 
-                    return key >= 10 && ignite.affinity(CACHE_NAME).isPrimary(ignite.cluster().localNode(), key);
-                }
-            };
+                        return key >= 10 && ignite.affinity(CACHE_NAME).isPrimary(ignite.cluster().localNode(), key);
+                    }
+                };
 
-            // Subscribe to specified cache events on all nodes that have cache running.
-            // Cache events are explicitly enabled in examples/config/example-cache.xml file.
-            ignite.events(ignite.cluster().forCacheNodes(CACHE_NAME)).remoteListen(locLsnr, rmtLsnr,
-                EVT_CACHE_OBJECT_PUT, EVT_CACHE_OBJECT_READ, EVT_CACHE_OBJECT_REMOVED);
+                // Subscribe to specified cache events on all nodes that have cache running.
+                // Cache events are explicitly enabled in examples/config/example-compute.xml file.
+                ignite.events(ignite.cluster().forCacheNodes(CACHE_NAME)).remoteListen(locLsnr, rmtLsnr,
+                    EVT_CACHE_OBJECT_PUT, EVT_CACHE_OBJECT_READ, EVT_CACHE_OBJECT_REMOVED);
 
-            // Generate cache events.
-            for (int i = 0; i < 20; i++)
-                cache.put(i, Integer.toString(i));
+                // Generate cache events.
+                for (int i = 0; i < 20; i++)
+                    cache.put(i, Integer.toString(i));
 
-            // Wait for a while while callback is notified about remaining puts.
-            Thread.sleep(2000);
+                // Wait for a while while callback is notified about remaining puts.
+                Thread.sleep(2000);
+            }
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcd7f423/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java
index 89ebfc2..fcb09e1 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java
@@ -18,7 +18,9 @@
 package org.apache.ignite.examples.datagrid;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
 import org.apache.ignite.cluster.*;
+import org.apache.ignite.configuration.*;
 import org.apache.ignite.examples.*;
 
 import javax.cache.processor.*;
@@ -30,14 +32,14 @@ import static org.apache.ignite.cache.query.Query.*;
  * Real time popular numbers counter.
  * <p>
  * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-cache.xml'}.
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-compute.xml'}.
  * <p>
  * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
- * start node with {@code examples/config/example-cache.xml} configuration.
+ * start node with {@code examples/config/example-compute.xml} configuration.
  */
 public class CachePopularNumbersExample {
     /** Cache name. */
-    private static final String CACHE_NAME = "partitioned";
+    private static final String CACHE_NAME = CachePopularNumbersExample.class.getSimpleName();
 
     /** Count of most popular numbers to retrieve from cluster. */
     private static final int POPULAR_NUMBERS_CNT = 10;
@@ -60,29 +62,33 @@ public class CachePopularNumbersExample {
     public static void main(String[] args) throws IgniteException {
         Timer popularNumbersQryTimer = new Timer("numbers-query-worker");
 
-        try (Ignite ignite = Ignition.start("examples/config/example-cache.xml")) {
+        try (Ignite ignite = Ignition.start("examples/config/example-compute.xml")) {
             System.out.println();
             System.out.println(">>> Cache popular numbers example started.");
 
-            // Clean up caches on all nodes before run.
-            ignite.jcache(CACHE_NAME).clear();
+            CacheConfiguration<Integer, Long> cfg = new CacheConfiguration<>();
 
-            ClusterGroup prj = ignite.cluster().forCacheNodes(CACHE_NAME);
+            cfg.setCacheMode(CacheMode.PARTITIONED);
+            cfg.setName(CACHE_NAME);
 
-            if (prj.nodes().isEmpty()) {
-                System.out.println("Ignite does not have cache configured: " + CACHE_NAME);
+            try (IgniteCache<Integer, Long> cache = ignite.createCache(cfg)) {
+                ClusterGroup prj = ignite.cluster().forCacheNodes(CACHE_NAME);
 
-                return;
-            }
+                if (prj.nodes().isEmpty()) {
+                    System.out.println("Ignite does not have cache configured: " + CACHE_NAME);
+
+                    return;
+                }
 
-            TimerTask task = scheduleQuery(ignite, popularNumbersQryTimer, POPULAR_NUMBERS_CNT);
+                TimerTask task = scheduleQuery(ignite, popularNumbersQryTimer, POPULAR_NUMBERS_CNT);
 
-            streamData(ignite);
+                streamData(ignite);
 
-            // Force one more run to get final counts.
-            task.run();
+                // Force one more run to get final counts.
+                task.run();
 
-            popularNumbersQryTimer.cancel();
+                popularNumbersQryTimer.cancel();
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcd7f423/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePutGetExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePutGetExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePutGetExample.java
index 7b615a8..3992b5b 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePutGetExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePutGetExample.java
@@ -18,6 +18,8 @@
 package org.apache.ignite.examples.datagrid;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
+import org.apache.ignite.configuration.*;
 import org.apache.ignite.examples.*;
 
 import java.util.*;
@@ -26,14 +28,14 @@ import java.util.*;
  * This example demonstrates very basic operations on cache, such as 'put' and 'get'.
  * <p>
  * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-cache.xml'}.
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-compute.xml'}.
  * <p>
  * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
- * start node with {@code examples/config/example-cache.xml} configuration.
+ * start node with {@code examples/config/example-compute.xml} configuration.
  */
 public class CachePutGetExample {
     /** Cache name. */
-    private static final String CACHE_NAME = "partitioned";
+    private static final String CACHE_NAME = CachePutGetExample.class.getSimpleName();
 
     /**
      * Executes example.
@@ -42,15 +44,20 @@ public class CachePutGetExample {
      * @throws IgniteException If example execution failed.
      */
     public static void main(String[] args) throws IgniteException {
-        try (Ignite ignite = Ignition.start("examples/config/example-cache.xml")) {
-            // Clean up caches on all nodes before run.
-            ignite.jcache(CACHE_NAME).clear();
+        try (Ignite ignite = Ignition.start("examples/config/example-compute.xml")) {
 
-            // Individual puts and gets.
-            putGet();
+            CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
 
-            // Bulk puts and gets.
-            putAllGetAll();
+            cfg.setCacheMode(CacheMode.PARTITIONED);
+            cfg.setName(CACHE_NAME);
+
+            try (IgniteCache<Integer, String> cache = ignite.createCache(cfg)) {
+                // Individual puts and gets.
+                putGet(cache);
+
+                // Bulk puts and gets.
+                putAllGetAll(cache);
+            }
         }
     }
 
@@ -59,14 +66,10 @@ public class CachePutGetExample {
      *
      * @throws IgniteException If failed.
      */
-    private static void putGet() throws IgniteException {
+    private static void putGet(IgniteCache<Integer, String> cache) throws IgniteException {
         System.out.println();
         System.out.println(">>> Cache put-get example started.");
 
-        Ignite ignite = Ignition.ignite();
-
-        final IgniteCache<Integer, String> cache = ignite.jcache(CACHE_NAME);
-
         final int keyCnt = 20;
 
         // Store keys in cache.
@@ -84,14 +87,10 @@ public class CachePutGetExample {
      *
      * @throws IgniteException If failed.
      */
-    private static void putAllGetAll() throws IgniteException {
+    private static void putAllGetAll(IgniteCache<Integer, String> cache) throws IgniteException {
         System.out.println();
         System.out.println(">>> Starting putAll-getAll example.");
 
-        Ignite ignite = Ignition.ignite();
-
-        final IgniteCache<Integer, String> cache = ignite.jcache(CACHE_NAME);
-
         final int keyCnt = 20;
 
         // Create batch.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcd7f423/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java
index 0c6b052..6120cba 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java
@@ -18,9 +18,11 @@
 package org.apache.ignite.examples.datagrid;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
 import org.apache.ignite.cache.affinity.*;
 import org.apache.ignite.cache.query.*;
 import org.apache.ignite.cache.query.annotations.*;
+import org.apache.ignite.configuration.*;
 import org.apache.ignite.examples.*;
 
 import javax.cache.*;
@@ -62,14 +64,14 @@ import static org.apache.ignite.cache.query.Query.*;
  * </ul>
  * <p>
  * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-cache.xml'}.
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-compute.xml'}.
  * <p>
  * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
- * start node with {@code examples/config/example-cache.xml} configuration.
+ * start node with {@code examples/config/example-compute.xml} configuration.
  */
 public class CacheQueryExample {
     /** Cache name. */
-    private static final String CACHE_NAME = "partitioned";
+    private static final String CACHE_NAME = CacheQueryExample.class.getSimpleName();
 
     /**
      * Executes example.
@@ -78,31 +80,35 @@ public class CacheQueryExample {
      * @throws Exception If example execution failed.
      */
     public static void main(String[] args) throws Exception {
-        try (Ignite ignite = Ignition.start("examples/config/example-cache.xml")) {
+        try (Ignite ignite = Ignition.start("examples/config/example-compute.xml")) {
             System.out.println();
             System.out.println(">>> Cache query example started.");
 
-            // Clean up caches on all nodes before run.
-            ignite.jcache(CACHE_NAME).removeAll();
+            CacheConfiguration<?, ?> cfg = new CacheConfiguration<>();
 
-            // Populate cache.
-            initialize();
+            cfg.setCacheMode(CacheMode.PARTITIONED);
+            cfg.setName(CACHE_NAME);
 
-            // Example for SQL-based querying employees based on salary ranges.
-            sqlQuery();
+            try (IgniteCache<?, ?> cache = ignite.createCache(cfg)) {
+                // Populate cache.
+                initialize();
 
-            // Example for SQL-based querying employees for a given organization (includes SQL join).
-            sqlQueryWithJoin();
+                // Example for SQL-based querying employees based on salary ranges.
+                sqlQuery();
 
-            // Example for TEXT-based querying for a given string in peoples resumes.
-            textQuery();
+                // Example for SQL-based querying employees for a given organization (includes SQL join).
+                sqlQueryWithJoin();
 
-            // Example for SQL-based fields queries that return only required
-            // fields instead of whole key-value pairs.
-            sqlFieldsQuery();
+                // Example for TEXT-based querying for a given string in peoples resumes.
+                textQuery();
 
-            // Example for SQL-based fields queries that uses joins.
-            sqlFieldsQueryWithJoin();
+                // Example for SQL-based fields queries that return only required
+                // fields instead of whole key-value pairs.
+                sqlFieldsQuery();
+
+                // Example for SQL-based fields queries that uses joins.
+                sqlFieldsQueryWithJoin();
+            }
 
             print("Cache query example finished.");
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcd7f423/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheTransactionExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheTransactionExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheTransactionExample.java
index 2eb833c..fc26a7a 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheTransactionExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheTransactionExample.java
@@ -18,6 +18,8 @@
 package org.apache.ignite.examples.datagrid;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
+import org.apache.ignite.configuration.*;
 import org.apache.ignite.examples.*;
 import org.apache.ignite.transactions.*;
 
@@ -30,14 +32,14 @@ import static org.apache.ignite.transactions.TransactionIsolation.*;
  * Demonstrates how to use cache transactions.
  * <p>
  * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-cache.xml'}.
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-compute.xml'}.
  * <p>
  * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
- * start node with {@code examples/config/example-cache.xml} configuration.
+ * start node with {@code examples/config/example-compute.xml} configuration.
  */
 public class CacheTransactionExample {
     /** Cache name. */
-    private static final String CACHE_NAME = "partitioned_tx";
+    private static final String CACHE_NAME = CacheTransactionExample.class.getSimpleName();
 
     /**
      * Executes example.
@@ -46,34 +48,41 @@ public class CacheTransactionExample {
      * @throws IgniteException If example execution failed.
      */
     public static void main(String[] args) throws IgniteException {
-        try (Ignite ignite = Ignition.start("examples/config/example-cache.xml")) {
+        try (Ignite ignite = Ignition.start("examples/config/example-compute.xml")) {
             System.out.println();
             System.out.println(">>> Cache transaction example started.");
 
-            // Clean up caches on all nodes before run.
-            ignite.jcache(CACHE_NAME).clear();
+            CacheConfiguration<Integer, Account> cfg = new CacheConfiguration<>();
 
-            IgniteCache<Integer, Account> cache = ignite.jcache(CACHE_NAME);
+            cfg.setCacheMode(CacheMode.PARTITIONED);
+            cfg.setName(CACHE_NAME);
+            cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
 
-            // Initialize.
-            cache.put(1, new Account(1, 100));
-            cache.put(2, new Account(1, 200));
+            NearCacheConfiguration<Integer, Account> nearCacheCfg = new NearCacheConfiguration<>();
 
-            System.out.println();
-            System.out.println(">>> Accounts before deposit: ");
-            System.out.println(">>> " + cache.get(1));
-            System.out.println(">>> " + cache.get(2));
+            nearCacheCfg.setNearEnabled(true);
 
-            // Make transactional deposits.
-            deposit(1, 100);
-            deposit(2, 200);
+            try (IgniteCache<Integer, Account> cache = ignite.createCache(cfg, nearCacheCfg)) {
+                // Initialize.
+                cache.put(1, new Account(1, 100));
+                cache.put(2, new Account(1, 200));
 
-            System.out.println();
-            System.out.println(">>> Accounts after transfer: ");
-            System.out.println(">>> " + cache.get(1));
-            System.out.println(">>> " + cache.get(2));
+                System.out.println();
+                System.out.println(">>> Accounts before deposit: ");
+                System.out.println(">>> " + cache.get(1));
+                System.out.println(">>> " + cache.get(2));
+
+                // Make transactional deposits.
+                deposit(cache, 1, 100);
+                deposit(cache, 2, 200);
 
-            System.out.println(">>> Cache transaction example finished.");
+                System.out.println();
+                System.out.println(">>> Accounts after transfer: ");
+                System.out.println(">>> " + cache.get(1));
+                System.out.println(">>> " + cache.get(2));
+
+                System.out.println(">>> Cache transaction example finished.");
+            }
         }
     }
 
@@ -84,10 +93,7 @@ public class CacheTransactionExample {
      * @param amount Amount to deposit.
      * @throws IgniteException If failed.
      */
-    private static void deposit(int acctId, double amount) throws IgniteException {
-        // Clone every object we get from cache, so we can freely update it.
-        IgniteCache<Integer, Account> cache = Ignition.ignite().jcache(CACHE_NAME);
-
+    private static void deposit(IgniteCache<Integer, Account> cache, int acctId, double amount) throws IgniteException {
         try (Transaction tx = Ignition.ignite().transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
             Account acct0 = cache.get(acctId);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcd7f423/examples/src/main/java/org/apache/ignite/examples/datagrid/starschema/CacheStarSchemaExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/starschema/CacheStarSchemaExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/starschema/CacheStarSchemaExample.java
index 8f3c7d1..04aab84 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/starschema/CacheStarSchemaExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/starschema/CacheStarSchemaExample.java
@@ -20,8 +20,8 @@ package org.apache.ignite.examples.datagrid.starschema;
 import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
 import org.apache.ignite.cache.query.*;
+import org.apache.ignite.configuration.*;
 import org.apache.ignite.examples.*;
-import org.apache.ignite.examples.datagrid.*;
 
 import javax.cache.*;
 import java.util.*;
@@ -46,17 +46,17 @@ import static org.apache.ignite.cache.query.Query.*;
  * in various ways.
  * <p>
  * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-cache.xml'}.
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-compute.xml'}.
  * <p>
  * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
- * start node with {@code examples/config/example-cache.xml} configuration.
+ * start node with {@code examples/config/example-compute.xml} configuration.
  */
 public class CacheStarSchemaExample {
     /** Partitioned cache name. */
-    private static final String PARTITIONED_CACHE_NAME = "partitioned";
+    private static final String PARTITIONED_CACHE_NAME = CacheStarSchemaExample.class.getSimpleName() + "Partitioned";
 
     /** Replicated cache name. */
-    private static final String REPLICATED_CACHE_NAME = "replicated";
+    private static final String REPLICATED_CACHE_NAME = CacheStarSchemaExample.class.getSimpleName() + "Replicated";
 
     /** ID generator. */
     private static int idGen = (int)System.currentTimeMillis();
@@ -73,42 +73,50 @@ public class CacheStarSchemaExample {
      * @param args Command line arguments, none required.
      */
     public static void main(String[] args) {
-        Ignite ignite = Ignition.start("examples/config/example-cache.xml");
+        Ignite ignite = Ignition.start("examples/config/example-compute.xml");
 
         System.out.println();
         System.out.println(">>> Cache star schema example started.");
 
-        // Clean up caches on all nodes before run.
-        ignite.jcache(PARTITIONED_CACHE_NAME).clear();
-        ignite.jcache(REPLICATED_CACHE_NAME).clear();
+        CacheConfiguration<Integer, FactPurchase> factCacheCfg = new CacheConfiguration<>();
 
-        try {
-            populateDimensions();
-            populateFacts();
+        factCacheCfg.setCacheMode(CacheMode.PARTITIONED);
+        factCacheCfg.setName(PARTITIONED_CACHE_NAME);
 
-            queryStorePurchases();
-            queryProductPurchases();
-        }
-        finally {
-            Ignition.stop(false);
+        CacheConfiguration<Integer, Object> dimCacheCfg = new CacheConfiguration<>();
+
+        dimCacheCfg.setCacheMode(CacheMode.REPLICATED);
+        dimCacheCfg.setName(REPLICATED_CACHE_NAME);
+
+        try (IgniteCache<Integer, FactPurchase> factCache = ignite.createCache(factCacheCfg);
+            IgniteCache<Integer, Object> dimCache = ignite.createCache(dimCacheCfg)) {
+            try {
+                populateDimensions(dimCache);
+                populateFacts(factCache);
+
+                queryStorePurchases(factCache);
+                queryProductPurchases(factCache);
+            }
+            finally {
+                Ignition.stop(false);
+            }
         }
     }
 
     /**
      * Populate cache with {@code 'dimensions'} which in our case are
      * {@link DimStore} and {@link DimProduct} instances.
+     * @param dimCache Cache to populate.
      *
      * @throws IgniteException If failed.
      */
-    private static void populateDimensions() throws IgniteException {
-        IgniteCache<Integer, Object> cache = Ignition.ignite().jcache(REPLICATED_CACHE_NAME);
-
+    private static void populateDimensions(IgniteCache<Integer, Object> dimCache) throws IgniteException {
         DimStore store1 = new DimStore(idGen++, "Store1", "12345", "321 Chilly Dr, NY");
         DimStore store2 = new DimStore(idGen++, "Store2", "54321", "123 Windy Dr, San Francisco");
 
         // Populate stores.
-        cache.put(store1.getId(), store1);
-        cache.put(store2.getId(), store2);
+        dimCache.put(store1.getId(), store1);
+        dimCache.put(store2.getId(), store2);
 
         dataStore.put(store1.getId(), store1);
         dataStore.put(store2.getId(), store2);
@@ -119,7 +127,7 @@ public class CacheStarSchemaExample {
 
             DimProduct product = new DimProduct(id, "Product" + i, i + 1, (i + 1) * 10);
 
-            cache.put(id, product);
+            dimCache.put(id, product);
 
             dataProduct.put(id, product);
         }
@@ -127,12 +135,11 @@ public class CacheStarSchemaExample {
 
     /**
      * Populate cache with {@code 'facts'}, which in our case are {@link FactPurchase} objects.
+     * @param factCache Cache to populate.
      *
      * @throws IgniteException If failed.
      */
-    private static void populateFacts() throws IgniteException {
-        IgniteCache<Integer, Object> factCache = Ignition.ignite().jcache(PARTITIONED_CACHE_NAME);
-
+    private static void populateFacts(IgniteCache<Integer, FactPurchase> factCache) throws IgniteException {
         for (int i = 0; i < 100; i++) {
             int id = idGen++;
 
@@ -148,9 +155,7 @@ public class CacheStarSchemaExample {
      * between {@link DimStore} objects stored in {@code 'replicated'} cache and
      * {@link FactPurchase} objects stored in {@code 'partitioned'} cache.
      */
-    private static void queryStorePurchases() {
-        IgniteCache<Integer, FactPurchase> factCache = Ignition.ignite().jcache(PARTITIONED_CACHE_NAME);
-
+    private static void queryStorePurchases(IgniteCache<Integer, FactPurchase> factCache) {
         // All purchases for store1.
         // ========================
 
@@ -171,9 +176,7 @@ public class CacheStarSchemaExample {
      *
      * @throws IgniteException If failed.
      */
-    private static void queryProductPurchases() {
-        IgniteCache<Integer, FactPurchase> factCache = Ignition.ignite().jcache(PARTITIONED_CACHE_NAME);
-
+    private static void queryProductPurchases(IgniteCache<Integer, FactPurchase> factCache) {
         // All purchases for certain product made at store2.
         // =================================================
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dcd7f423/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteSetExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteSetExample.java b/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteSetExample.java
index c773c31..b024d12 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteSetExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteSetExample.java
@@ -59,11 +59,11 @@ public class IgniteSetExample {
             cfg.setName(CACHE_NAME);
             cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
 
-            NearCacheConfiguration<Integer, String> nearCache = new NearCacheConfiguration<>();
+            NearCacheConfiguration<Integer, String> nearCacheCfg = new NearCacheConfiguration<>();
 
-            nearCache.setNearEnabled(true);
+            nearCacheCfg.setNearEnabled(true);
 
-            try (IgniteCache<Integer, String> cache = ignite.createCache(cfg, nearCache)) {
+            try (IgniteCache<Integer, String> cache = ignite.createCache(cfg, nearCacheCfg)) {
                 // Make set name.
                 String setName = UUID.randomUUID().toString();
 


Mime
View raw message