ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [20/50] [abbrv] ignite git commit: ignite-2168 Examples should destroy created caches. This closes #372.
Date Mon, 11 Jan 2016 10:12:51 GMT
ignite-2168 Examples should destroy created caches. This closes #372.


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

Branch: refs/heads/ignite-961
Commit: 85fd7e0cdb0e85208ba93a0f68d609d38ac2a4d4
Parents: 36261ad
Author: sboikov <sboikov@gridgain.com>
Authored: Thu Dec 24 16:26:39 2015 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Thu Dec 24 16:26:39 2015 +0300

----------------------------------------------------------------------
 .../hibernate/HibernateL2CacheExample.java      | 26 ++++--
 .../hibernate/CacheHibernateStoreExample.java   |  5 ++
 .../store/auto/CacheBinaryAutoStoreExample.java |  1 +
 .../examples/datagrid/CacheAffinityExample.java |  5 ++
 .../examples/datagrid/CacheApiExample.java      |  5 ++
 .../examples/datagrid/CacheAsyncApiExample.java |  5 ++
 .../datagrid/CacheContinuousQueryExample.java   |  5 ++
 .../datagrid/CacheDataStreamerExample.java      |  5 ++
 .../datagrid/CacheEntryProcessorExample.java    |  5 ++
 .../examples/datagrid/CacheEventsExample.java   |  5 ++
 .../examples/datagrid/CacheQueryExample.java    |  6 ++
 .../datagrid/CacheTransactionExample.java       |  6 +-
 .../starschema/CacheStarSchemaExample.java      | 10 ++-
 .../store/auto/CacheAutoStoreExample.java       |  5 ++
 .../store/jdbc/CacheJdbcStoreExample.java       |  5 ++
 .../store/spring/CacheSpringStoreExample.java   |  5 ++
 .../streaming/StreamTransformerExample.java     |  4 +
 .../streaming/StreamVisitorExample.java         | 13 ++-
 .../streaming/wordcount/QueryWords.java         | 51 +++++++-----
 .../socket/WordsSocketStreamerServer.java       | 86 ++++++++++----------
 .../java8/datagrid/CacheAffinityExample.java    |  5 ++
 .../java8/datagrid/CacheApiExample.java         |  5 ++
 .../java8/datagrid/CacheAsyncApiExample.java    |  5 ++
 .../datagrid/CacheEntryProcessorExample.java    |  5 ++
 .../streaming/StreamTransformerExample.java     |  9 +-
 .../java8/streaming/StreamVisitorExample.java   |  5 ++
 26 files changed, 215 insertions(+), 77 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/85fd7e0c/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java b/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
index 2f271c8..4f399fb 100644
--- a/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
+++ b/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
@@ -92,6 +92,13 @@ public class HibernateL2CacheExample {
     private static final List<String> ENTITY_NAMES =
         Arrays.asList(User.class.getName(), Post.class.getName(), User.class.getName() + ".posts");
 
+    /** Caches' names. */
+    private static final String UPDATE_TIMESTAMPS_CACHE_NAME = "org.hibernate.cache.spi.UpdateTimestampsCache";
+    private static final String STANDART_QUERY_CACHE_NAME = "org.hibernate.cache.internal.StandardQueryCache";
+    private static final String USER_CACHE_NAME = "org.apache.ignite.examples.datagrid.hibernate.User";
+    private static final String USER_POSTS_CACHE_NAME = "org.apache.ignite.examples.datagrid.hibernate.User.posts";
+    private static final String POST_CACHE_NAME = "org.apache.ignite.examples.datagrid.hibernate.Post";
+
     /**
      * Executes example.
      *
@@ -107,13 +114,14 @@ public class HibernateL2CacheExample {
             System.out.println();
             System.out.println(">>> Hibernate L2 cache example started.");
 
+            // Auto-close cache at the end of the example.
             try (
                 // Create all required caches.
-                IgniteCache c1 = createCache("org.hibernate.cache.spi.UpdateTimestampsCache", ATOMIC);
-                IgniteCache c2 = createCache("org.hibernate.cache.internal.StandardQueryCache", ATOMIC);
-                IgniteCache c3 = createCache("org.apache.ignite.examples.datagrid.hibernate.User", TRANSACTIONAL);
-                IgniteCache c4 = createCache("org.apache.ignite.examples.datagrid.hibernate.User.posts", TRANSACTIONAL);
-                IgniteCache c5 = createCache("org.apache.ignite.examples.datagrid.hibernate.Post", TRANSACTIONAL)
+                IgniteCache c1 = createCache(UPDATE_TIMESTAMPS_CACHE_NAME, ATOMIC);
+                IgniteCache c2 = createCache(STANDART_QUERY_CACHE_NAME, ATOMIC);
+                IgniteCache c3 = createCache(USER_CACHE_NAME, TRANSACTIONAL);
+                IgniteCache c4 = createCache(USER_POSTS_CACHE_NAME, TRANSACTIONAL);
+                IgniteCache c5 = createCache(POST_CACHE_NAME, TRANSACTIONAL)
             ) {
                 URL hibernateCfg = ExamplesUtils.url(HIBERNATE_CFG);
 
@@ -183,6 +191,14 @@ public class HibernateL2CacheExample {
                 // a miss.
                 printStats(sesFactory);
             }
+            finally {
+                // Distributed cache could be removed from cluster only by #destroyCache() call.
+                ignite.destroyCache(UPDATE_TIMESTAMPS_CACHE_NAME);
+                ignite.destroyCache(STANDART_QUERY_CACHE_NAME);
+                ignite.destroyCache(USER_CACHE_NAME);
+                ignite.destroyCache(USER_POSTS_CACHE_NAME);
+                ignite.destroyCache(POST_CACHE_NAME);
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/85fd7e0c/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java b/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java
index db34eaf..54b692f 100644
--- a/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java
+++ b/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java
@@ -103,6 +103,7 @@ public class CacheHibernateStoreExample {
             cacheCfg.setReadThrough(true);
             cacheCfg.setWriteThrough(true);
 
+            // Auto-close cache at the end of the example.
             try (IgniteCache<Long, Person> cache = ignite.getOrCreateCache(cacheCfg)) {
                 // Make initial cache loading from persistent store. This is a
                 // distributed operation and will call CacheStore.loadCache(...)
@@ -113,6 +114,10 @@ public class CacheHibernateStoreExample {
                 // read/write-through to persistent store.
                 executeTransaction(cache);
             }
+            finally {
+                // Distributed cache could be removed from cluster only by #destroyCache() call.
+                ignite.destroyCache(CACHE_NAME);
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/85fd7e0c/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/store/auto/CacheBinaryAutoStoreExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/store/auto/CacheBinaryAutoStoreExample.java b/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/store/auto/CacheBinaryAutoStoreExample.java
index 75773cb..c80c87b 100644
--- a/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/store/auto/CacheBinaryAutoStoreExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/store/auto/CacheBinaryAutoStoreExample.java
@@ -162,6 +162,7 @@ public class CacheBinaryAutoStoreExample {
                 System.out.println(">>> Loaded cache entries: " + cache.size());
             }
             finally {
+                // Distributed cache could be removed from cluster only by #destroyCache() call.
                 ignite.destroyCache(CACHE_NAME);
             }
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/85fd7e0c/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 f295ea7..2ec0620 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
@@ -59,6 +59,7 @@ public final class CacheAffinityExample {
             System.out.println();
             System.out.println(">>> Cache affinity example started.");
 
+            // Auto-close cache at the end of the example.
             try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(CACHE_NAME)) {
                 for (int i = 0; i < KEY_CNT; i++)
                     cache.put(i, Integer.toString(i));
@@ -69,6 +70,10 @@ public final class CacheAffinityExample {
                 // Co-locates jobs with data using IgniteCluster.mapKeysToNodes(...) method.
                 visitUsingMapKeysToNodes();
             }
+            finally {
+                // Distributed cache could be removed from cluster only by #destroyCache() call.
+                ignite.destroyCache(CACHE_NAME);
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/85fd7e0c/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 78221d4..a20ef16 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
@@ -50,10 +50,15 @@ public class CacheApiExample {
             System.out.println();
             System.out.println(">>> Cache API example started.");
 
+            // Auto-close cache at the end of the example.
             try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(CACHE_NAME)) {
                 // Demonstrate atomic map operations.
                 atomicMapOperations(cache);
             }
+            finally {
+                // Distributed cache could be removed from cluster only by #destroyCache() call.
+                ignite.destroyCache(CACHE_NAME);
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/85fd7e0c/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAsyncApiExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAsyncApiExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAsyncApiExample.java
index a38c133..3699361 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAsyncApiExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAsyncApiExample.java
@@ -51,6 +51,7 @@ public class CacheAsyncApiExample {
             System.out.println();
             System.out.println(">>> Cache asynchronous API example started.");
 
+            // Auto-close cache at the end of the example.
             try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(CACHE_NAME)) {
                 // Enable asynchronous mode.
                 IgniteCache<Integer, String> asyncCache = cache.withAsync();
@@ -78,6 +79,10 @@ public class CacheAsyncApiExample {
                     }
                 });
             }
+            finally {
+                // Distributed cache could be removed from cluster only by #destroyCache() call.
+                ignite.destroyCache(CACHE_NAME);
+            }
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/85fd7e0c/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 0ce6e89..59759af 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
@@ -54,6 +54,7 @@ public class CacheContinuousQueryExample {
             System.out.println();
             System.out.println(">>> Cache continuous query example started.");
 
+            // Auto-close cache at the end of the example.
             try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(CACHE_NAME)) {
                 int keyCnt = 20;
 
@@ -100,6 +101,10 @@ public class CacheContinuousQueryExample {
                     Thread.sleep(2000);
                 }
             }
+            finally {
+                // Distributed cache could be removed from cluster only by #destroyCache() call.
+                ignite.destroyCache(CACHE_NAME);
+            }
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/85fd7e0c/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheDataStreamerExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheDataStreamerExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheDataStreamerExample.java
index 2357c28..d0000c6 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheDataStreamerExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheDataStreamerExample.java
@@ -60,6 +60,7 @@ public class CacheDataStreamerExample {
             System.out.println();
             System.out.println(">>> Cache data streamer example started.");
 
+            // Auto-close cache at the end of the example.
             try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(CACHE_NAME)) {
                 long start = System.currentTimeMillis();
 
@@ -81,6 +82,10 @@ public class CacheDataStreamerExample {
 
                 System.out.println(">>> Loaded " + ENTRY_COUNT + " keys in " + (end - start) + "ms.");
             }
+            finally {
+                // Distributed cache could be removed from cluster only by #destroyCache() call.
+                ignite.destroyCache(CACHE_NAME);
+            }
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/85fd7e0c/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEntryProcessorExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEntryProcessorExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEntryProcessorExample.java
index 38d9631..04c4811 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEntryProcessorExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEntryProcessorExample.java
@@ -71,6 +71,7 @@ public class CacheEntryProcessorExample {
             System.out.println();
             System.out.println(">>> Entry processor example started.");
 
+            // Auto-close cache at the end of the example.
             try (IgniteCache<Integer, Integer> cache = ignite.getOrCreateCache(CACHE_NAME)) {
                 // Demonstrates usage of EntryProcessor.invoke(...) method.
                 populateEntriesWithInvoke(cache);
@@ -78,6 +79,10 @@ public class CacheEntryProcessorExample {
                 // Demonstrates usage of EntryProcessor.invokeAll(...) method.
                 incrementEntriesWithInvokeAll(cache);
             }
+            finally {
+                // Distributed cache could be removed from cluster only by #destroyCache() call.
+                ignite.destroyCache(CACHE_NAME);
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/85fd7e0c/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 b2fdc8c..5ee82ec 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
@@ -56,6 +56,7 @@ public class CacheEventsExample {
             System.out.println();
             System.out.println(">>> Cache events example started.");
 
+            // Auto-close cache at the end of the example.
             try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(CACHE_NAME)) {
                 // This optional local callback is called for each event notification
                 // that passed remote predicate listener.
@@ -92,6 +93,10 @@ public class CacheEventsExample {
                 // Wait for a while while callback is notified about remaining puts.
                 Thread.sleep(2000);
             }
+            finally {
+                // Distributed cache could be removed from cluster only by #destroyCache() call.
+                ignite.destroyCache(CACHE_NAME);
+            }
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/85fd7e0c/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 98af93c..9200489 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
@@ -89,6 +89,7 @@ public class CacheQueryExample {
             personCacheCfg.setCacheMode(CacheMode.PARTITIONED); // Default.
             personCacheCfg.setIndexedTypes(AffinityKey.class, Person.class);
 
+            // Auto-close cache at the end of the example.
             try (
                 IgniteCache<Long, Organization> orgCache = ignite.getOrCreateCache(orgCacheCfg);
                 IgniteCache<AffinityKey<Long>, Person> personCache = ignite.getOrCreateCache(personCacheCfg)
@@ -118,6 +119,11 @@ public class CacheQueryExample {
                 // Example for SQL-based fields queries that uses joins.
                 sqlFieldsQueryWithJoin();
             }
+            finally {
+                // Distributed cache could be removed from cluster only by #destroyCache() call.
+                ignite.destroyCache(PERSON_CACHE);
+                ignite.destroyCache(ORG_CACHE);
+            }
 
             print("Cache query example finished.");
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/85fd7e0c/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 eced5f2..337fcbc 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
@@ -24,7 +24,6 @@ import org.apache.ignite.IgniteException;
 import org.apache.ignite.Ignition;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.NearCacheConfiguration;
 import org.apache.ignite.examples.ExampleNodeStartup;
 import org.apache.ignite.transactions.Transaction;
 
@@ -59,6 +58,7 @@ public class CacheTransactionExample {
 
             cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
 
+            // Auto-close cache at the end of the example.
             try (IgniteCache<Integer, Account> cache = ignite.getOrCreateCache(cfg)) {
                 // Initialize.
                 cache.put(1, new Account(1, 100));
@@ -80,6 +80,10 @@ public class CacheTransactionExample {
 
                 System.out.println(">>> Cache transaction example finished.");
             }
+            finally {
+                // Distributed cache could be removed from cluster only by #destroyCache() call.
+                ignite.destroyCache(CACHE_NAME);
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/85fd7e0c/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 de58fb8..8424f91 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
@@ -78,10 +78,6 @@ public class CacheStarSchemaExample {
             System.out.println();
             System.out.println(">>> Cache star schema example started.");
 
-            // Destroy caches to clean up the data if any left from previous runs.
-            ignite.destroyCache(PARTITIONED_CACHE_NAME);
-            ignite.destroyCache(REPLICATED_CACHE_NAME);
-
             CacheConfiguration<Integer, FactPurchase> factCacheCfg = new CacheConfiguration<>(PARTITIONED_CACHE_NAME);
 
             factCacheCfg.setCacheMode(CacheMode.PARTITIONED);
@@ -97,6 +93,7 @@ public class CacheStarSchemaExample {
                 Integer.class, DimProduct.class
             );
 
+            // Auto-close cache at the end of the example.
             try (IgniteCache<Integer, FactPurchase> factCache = ignite.getOrCreateCache(factCacheCfg);
                  IgniteCache<Integer, Object> dimCache = ignite.getOrCreateCache(dimCacheCfg)) {
                 populateDimensions(dimCache);
@@ -105,6 +102,11 @@ public class CacheStarSchemaExample {
                 queryStorePurchases();
                 queryProductPurchases();
             }
+            finally {
+                // Distributed cache could be removed from cluster only by #destroyCache() call.
+                ignite.destroyCache(PARTITIONED_CACHE_NAME);
+                ignite.destroyCache(REPLICATED_CACHE_NAME);
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/85fd7e0c/examples/src/main/java/org/apache/ignite/examples/datagrid/store/auto/CacheAutoStoreExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/auto/CacheAutoStoreExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/auto/CacheAutoStoreExample.java
index a61752d..37a6725 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/auto/CacheAutoStoreExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/auto/CacheAutoStoreExample.java
@@ -126,6 +126,7 @@ public class CacheAutoStoreExample {
             System.out.println();
             System.out.println(">>> Cache auto store example started...");
 
+            // Auto-close cache at the end of the example.
             try (IgniteCache<Long, Person> cache = ignite.getOrCreateCache(cacheConfiguration())) {
                 try (Transaction tx = ignite.transactions().txStart()) {
                     Person val = cache.get(id);
@@ -169,6 +170,10 @@ public class CacheAutoStoreExample {
 
                 System.out.println(">>> Loaded cache entries: " + cache.size());
             }
+            finally {
+                // Distributed cache could be removed from cluster only by #destroyCache() call.
+                ignite.destroyCache(CACHE_NAME);
+            }
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/85fd7e0c/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcStoreExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcStoreExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcStoreExample.java
index e6584dd..6b8c4b2 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcStoreExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcStoreExample.java
@@ -100,6 +100,7 @@ public class CacheJdbcStoreExample {
             cacheCfg.setReadThrough(true);
             cacheCfg.setWriteThrough(true);
 
+            // Auto-close cache at the end of the example.
             try (IgniteCache<Long, Person> cache = ignite.getOrCreateCache(cacheCfg)) {
                 // Make initial cache loading from persistent store. This is a
                 // distributed operation and will call CacheStore.loadCache(...)
@@ -110,6 +111,10 @@ public class CacheJdbcStoreExample {
                 // read/write-through to persistent store.
                 executeTransaction(cache);
             }
+            finally {
+                // Distributed cache could be removed from cluster only by #destroyCache() call.
+                ignite.destroyCache(CACHE_NAME);
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/85fd7e0c/examples/src/main/java/org/apache/ignite/examples/datagrid/store/spring/CacheSpringStoreExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/spring/CacheSpringStoreExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/spring/CacheSpringStoreExample.java
index 5380fce..4bb5d1d 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/spring/CacheSpringStoreExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/spring/CacheSpringStoreExample.java
@@ -99,6 +99,7 @@ public class CacheSpringStoreExample {
             cacheCfg.setReadThrough(true);
             cacheCfg.setWriteThrough(true);
 
+            // Auto-close cache at the end of the example.
             try (IgniteCache<Long, Person> cache = ignite.getOrCreateCache(cacheCfg)) {
                 // Make initial cache loading from persistent store. This is a
                 // distributed operation and will call CacheStore.loadCache(...)
@@ -109,6 +110,10 @@ public class CacheSpringStoreExample {
                 // read/write-through to persistent store.
                 executeTransaction(cache);
             }
+            finally {
+                // Distributed cache could be removed from cluster only by #destroyCache() call.
+                ignite.destroyCache(CACHE_NAME);
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/85fd7e0c/examples/src/main/java/org/apache/ignite/examples/streaming/StreamTransformerExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/StreamTransformerExample.java b/examples/src/main/java/org/apache/ignite/examples/streaming/StreamTransformerExample.java
index 2ef5e70..6934ac3 100644
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/StreamTransformerExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/streaming/StreamTransformerExample.java
@@ -97,6 +97,10 @@ public class StreamTransformerExample {
                 // Print top 10 words.
                 ExamplesUtils.printQueryResults(top10);
             }
+            finally {
+                // Distributed cache could be removed from cluster only by #destroyCache() call.
+                ignite.destroyCache(cfg.getName());
+            }
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/85fd7e0c/examples/src/main/java/org/apache/ignite/examples/streaming/StreamVisitorExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/StreamVisitorExample.java b/examples/src/main/java/org/apache/ignite/examples/streaming/StreamVisitorExample.java
index 819cfea..29781bc 100644
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/StreamVisitorExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/streaming/StreamVisitorExample.java
@@ -52,6 +52,10 @@ public class StreamVisitorExample {
     /** The list of initial instrument prices. */
     private static final double[] INITIAL_PRICES = {194.9, 893.49, 34.21, 23.24, 57.93, 45.03, 44.41, 28.44, 378.49, 69.50};
 
+    /** Caches' names. */
+    private static final String CACHE_NAME = "instCache";
+    private static final String MARKET_TICKS_CACHE_NAME = "marketTicks";
+
     public static void main(String[] args) throws Exception {
         // Mark this cluster member as client.
         Ignition.setClientMode(true);
@@ -61,7 +65,7 @@ public class StreamVisitorExample {
                 return;
 
             // Financial instrument cache configuration.
-            CacheConfiguration<String, Instrument> instCfg = new CacheConfiguration<>("instCache");
+            CacheConfiguration<String, Instrument> instCfg = new CacheConfiguration<>(CACHE_NAME);
 
             // Index key and value for querying financial instruments.
             // Note that Instrument class has @QuerySqlField annotation for secondary field indexing.
@@ -69,7 +73,7 @@ public class StreamVisitorExample {
 
             // Auto-close caches at the end of the example.
             try (
-                IgniteCache<String, Double> mktCache = ignite.getOrCreateCache("marketTicks"); // Default config.
+                IgniteCache<String, Double> mktCache = ignite.getOrCreateCache(MARKET_TICKS_CACHE_NAME); // Default config.
                 IgniteCache<String, Instrument> instCache = ignite.getOrCreateCache(instCfg)
             ) {
                 try (IgniteDataStreamer<String, Double> mktStmr = ignite.dataStreamer(mktCache.getName())) {
@@ -140,6 +144,11 @@ public class StreamVisitorExample {
                 // Print top 10 words.
                 ExamplesUtils.printQueryResults(top3);
             }
+            finally {
+                // Distributed cache could be removed from cluster only by #destroyCache() call.
+                ignite.destroyCache(CACHE_NAME);
+                ignite.destroyCache(MARKET_TICKS_CACHE_NAME);
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/85fd7e0c/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
index 034c0c2..c1ce6e1 100644
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
+++ b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
@@ -23,6 +23,7 @@ import org.apache.ignite.IgniteCache;
 import org.apache.ignite.Ignition;
 import org.apache.ignite.cache.affinity.AffinityUuid;
 import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.examples.ExampleNodeStartup;
 import org.apache.ignite.examples.ExamplesUtils;
 
@@ -50,35 +51,41 @@ public class QueryWords {
             if (!ExamplesUtils.hasServerNodes(ignite))
                 return;
 
-            // The cache is configured with sliding window holding 1 second of the streaming data.
-            IgniteCache<AffinityUuid, String> stmCache = ignite.getOrCreateCache(CacheConfig.wordCache());
+            CacheConfiguration<AffinityUuid, String> cfg = CacheConfig.wordCache();
 
-            // Select top 10 words.
-            SqlFieldsQuery top10Qry = new SqlFieldsQuery(
-                "select _val, count(_val) as cnt from String group by _val order by cnt desc limit 10",
-                true /*collocated*/
-            );
+            // The cache is configured with sliding window holding 1 second of the streaming data.
+            try (IgniteCache<AffinityUuid, String> stmCache = ignite.getOrCreateCache(cfg)) {
+                // Select top 10 words.
+                SqlFieldsQuery top10Qry = new SqlFieldsQuery(
+                    "select _val, count(_val) as cnt from String group by _val order by cnt desc limit 10",
+                    true /*collocated*/
+                );
 
-            // Select average, min, and max counts among all the words.
-            SqlFieldsQuery statsQry = new SqlFieldsQuery(
-                "select avg(cnt), min(cnt), max(cnt) from (select count(_val) as cnt from String group by _val)");
+                // Select average, min, and max counts among all the words.
+                SqlFieldsQuery statsQry = new SqlFieldsQuery(
+                    "select avg(cnt), min(cnt), max(cnt) from (select count(_val) as cnt from String group by _val)");
 
-            // Query top 10 popular numbers every 5 seconds.
-            while (true) {
-                // Execute queries.
-                List<List<?>> top10 = stmCache.query(top10Qry).getAll();
-                List<List<?>> stats = stmCache.query(statsQry).getAll();
+                // Query top 10 popular numbers every 5 seconds.
+                while (true) {
+                    // Execute queries.
+                    List<List<?>> top10 = stmCache.query(top10Qry).getAll();
+                    List<List<?>> stats = stmCache.query(statsQry).getAll();
 
-                // Print average count.
-                List<?> row = stats.get(0);
+                    // Print average count.
+                    List<?> row = stats.get(0);
 
-                if (row.get(0) != null)
-                    System.out.printf("Query results [avg=%.2f, min=%d, max=%d]%n", row.get(0), row.get(1), row.get(2));
+                    if (row.get(0) != null)
+                        System.out.printf("Query results [avg=%.2f, min=%d, max=%d]%n", row.get(0), row.get(1), row.get(2));
 
-                // Print top 10 words.
-                ExamplesUtils.printQueryResults(top10);
+                    // Print top 10 words.
+                    ExamplesUtils.printQueryResults(top10);
 
-                Thread.sleep(5000);
+                    Thread.sleep(5000);
+                }
+            }
+            finally {
+                // Distributed cache could be removed from cluster only by #destroyCache() call.
+                ignite.destroyCache(cfg.getName());
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/85fd7e0c/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerServer.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerServer.java b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerServer.java
index 814d235..35db059 100644
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerServer.java
+++ b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerServer.java
@@ -27,6 +27,7 @@ import org.apache.ignite.IgniteDataStreamer;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.Ignition;
 import org.apache.ignite.cache.affinity.AffinityUuid;
+import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.examples.ExampleNodeStartup;
 import org.apache.ignite.examples.ExamplesUtils;
 import org.apache.ignite.examples.streaming.wordcount.CacheConfig;
@@ -69,63 +70,64 @@ public class WordsSocketStreamerServer {
         // Mark this cluster member as client.
         Ignition.setClientMode(true);
 
-        Ignite ignite = Ignition.start("examples/config/example-ignite.xml");
+        CacheConfiguration<AffinityUuid, String> cfg = CacheConfig.wordCache();
 
-        if (!ExamplesUtils.hasServerNodes(ignite)) {
-            ignite.close();
+        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
 
-            return;
-        }
-
-        // The cache is configured with sliding window holding 1 second of the streaming data.
-        IgniteCache<AffinityUuid, String> stmCache = ignite.getOrCreateCache(CacheConfig.wordCache());
+            if (!ExamplesUtils.hasServerNodes(ignite))
+                return;
 
-        IgniteDataStreamer<AffinityUuid, String> stmr = ignite.dataStreamer(stmCache.getName());
+            // The cache is configured with sliding window holding 1 second of the streaming data.
+            try (IgniteCache<AffinityUuid, String> stmCache = ignite.getOrCreateCache(cfg)) {
 
-        InetAddress addr = InetAddress.getLocalHost();
+                IgniteDataStreamer<AffinityUuid, String> stmr = ignite.dataStreamer(stmCache.getName());
 
-        // Configure socket streamer
-        SocketStreamer<String, AffinityUuid, String> sockStmr = new SocketStreamer<>();
+                InetAddress addr = InetAddress.getLocalHost();
 
-        sockStmr.setAddr(addr);
+                // Configure socket streamer
+                SocketStreamer<String, AffinityUuid, String> sockStmr = new SocketStreamer<>();
 
-        sockStmr.setPort(PORT);
+                sockStmr.setAddr(addr);
 
-        sockStmr.setDelimiter(DELIM);
+                sockStmr.setPort(PORT);
 
-        sockStmr.setIgnite(ignite);
+                sockStmr.setDelimiter(DELIM);
 
-        sockStmr.setStreamer(stmr);
+                sockStmr.setIgnite(ignite);
 
-        // Converter from zero-terminated string to Java strings.
-        sockStmr.setConverter(new SocketMessageConverter<String>() {
-            @Override public String convert(byte[] msg) {
-                try {
-                    return new String(msg, "ASCII");
-                }
-                catch (UnsupportedEncodingException e) {
-                    throw new IgniteException(e);
-                }
-            }
-        });
+                sockStmr.setStreamer(stmr);
 
-        sockStmr.setSingleTupleExtractor(new StreamSingleTupleExtractor<String, AffinityUuid, String>() {
-            @Override public Map.Entry<AffinityUuid, String> extract(String word) {
-                // By using AffinityUuid we ensure that identical
-                // words are processed on the same cluster node.
-                return new IgniteBiTuple<>(new AffinityUuid(word), word);
-            }
-        });
+                // Converter from zero-terminated string to Java strings.
+                sockStmr.setConverter(new SocketMessageConverter<String>() {
+                    @Override public String convert(byte[] msg) {
+                        try {
+                            return new String(msg, "ASCII");
+                        }
+                        catch (UnsupportedEncodingException e) {
+                            throw new IgniteException(e);
+                        }
+                    }
+                });
 
-        try {
-            sockStmr.start();
-        }
-        catch (IgniteException e) {
-            System.err.println("Streaming server didn't start due to an error: ");
+                sockStmr.setSingleTupleExtractor(new StreamSingleTupleExtractor<String, AffinityUuid, String>() {
+                    @Override public Map.Entry<AffinityUuid, String> extract(String word) {
+                        // By using AffinityUuid we ensure that identical
+                        // words are processed on the same cluster node.
+                        return new IgniteBiTuple<>(new AffinityUuid(word), word);
+                    }
+                });
 
-            e.printStackTrace();
+                sockStmr.start();
+            }
+            catch (IgniteException e) {
+                System.err.println("Streaming server didn't start due to an error: ");
 
-            ignite.close();
+                e.printStackTrace();
+            }
+            finally {
+                // Distributed cache could be removed from cluster only by #destroyCache() call.
+                ignite.destroyCache(cfg.getName());
+            }
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/85fd7e0c/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java
index 9d9bacc..fbf348f 100644
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java
+++ b/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java
@@ -66,6 +66,7 @@ public final class CacheAffinityExample {
             cfg.setCacheMode(CacheMode.PARTITIONED);
             cfg.setName(CACHE_NAME);
 
+            // Auto-close cache at the end of the example.
             try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cfg)) {
                 for (int i = 0; i < KEY_CNT; i++)
                     cache.put(i, Integer.toString(i));
@@ -76,6 +77,10 @@ public final class CacheAffinityExample {
                 // Co-locates jobs with data using IgniteCluster.mapKeysToNodes(...) method.
                 visitUsingMapKeysToNodes();
             }
+            finally {
+                // Distributed cache could be removed from cluster only by #destroyCache() call.
+                ignite.destroyCache(CACHE_NAME);
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/85fd7e0c/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheApiExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheApiExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheApiExample.java
index cca1812..b78003b 100644
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheApiExample.java
+++ b/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheApiExample.java
@@ -55,10 +55,15 @@ public class CacheApiExample {
             cfg.setCacheMode(CacheMode.PARTITIONED);
             cfg.setName(CACHE_NAME);
 
+            // Auto-close cache at the end of the example.
             try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cfg)) {
                 // Demonstrate atomic map operations.
                 atomicMapOperations(cache);
             }
+            finally {
+                // Distributed cache could be removed from cluster only by #destroyCache() call.
+                ignite.destroyCache(CACHE_NAME);
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/85fd7e0c/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAsyncApiExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAsyncApiExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAsyncApiExample.java
index 2ad5640..ac80fb6 100644
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAsyncApiExample.java
+++ b/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAsyncApiExample.java
@@ -57,6 +57,7 @@ public class CacheAsyncApiExample {
             cfg.setCacheMode(CacheMode.PARTITIONED);
             cfg.setName(CACHE_NAME);
 
+            // Auto-close cache at the end of the example.
             try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cfg)) {
                 // Enable asynchronous mode.
                 IgniteCache<Integer, String> asyncCache = cache.withAsync();
@@ -80,6 +81,10 @@ public class CacheAsyncApiExample {
                 asyncCache.<String>future().listen(fut ->
                     System.out.println("Get operation completed [value=" + fut.get() + ']'));
             }
+            finally {
+                // Distributed cache could be removed from cluster only by #destroyCache() call.
+                ignite.destroyCache(CACHE_NAME);
+            }
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/85fd7e0c/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheEntryProcessorExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheEntryProcessorExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheEntryProcessorExample.java
index fd07fa5..24633a8 100644
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheEntryProcessorExample.java
+++ b/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheEntryProcessorExample.java
@@ -69,6 +69,7 @@ public class CacheEntryProcessorExample {
             System.out.println();
             System.out.println(">>> Entry processor example started.");
 
+            // Auto-close cache at the end of the example.
             try (IgniteCache<Integer, Integer> cache = ignite.getOrCreateCache(CACHE_NAME)) {
                 // Demonstrates usage of EntryProcessor.invoke(...) method.
                 populateEntriesWithInvoke(cache);
@@ -76,6 +77,10 @@ public class CacheEntryProcessorExample {
                 // Demonstrates usage of EntryProcessor.invokeAll(...) method.
                 incrementEntriesWithInvokeAll(cache);
             }
+            finally {
+                // Distributed cache could be removed from cluster only by #destroyCache() call.
+                ignite.destroyCache(CACHE_NAME);
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/85fd7e0c/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java
index 1f0039f..358faff 100644
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java
+++ b/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java
@@ -46,6 +46,9 @@ public class StreamTransformerExample {
     /** Range within which to generate numbers. */
     private static final int RANGE = 1000;
 
+    /** Cache name. */
+    private static final String CACHE_NAME = "randomNumbers";
+
     public static void main(String[] args) throws Exception {
         // Mark this cluster member as client.
         Ignition.setClientMode(true);
@@ -54,7 +57,7 @@ public class StreamTransformerExample {
             if (!ExamplesUtils.hasServerNodes(ignite))
                 return;
 
-            CacheConfiguration<Integer, Long> cfg = new CacheConfiguration<>("randomNumbers");
+            CacheConfiguration<Integer, Long> cfg = new CacheConfiguration<>(CACHE_NAME);
 
             // Index key and value.
             cfg.setIndexedTypes(Integer.class, Long.class);
@@ -96,6 +99,10 @@ public class StreamTransformerExample {
                 // Print top 10 words.
                 ExamplesUtils.printQueryResults(top10);
             }
+            finally {
+                // Distributed cache could be removed from cluster only by #destroyCache() call.
+                ignite.destroyCache(CACHE_NAME);
+            }
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/85fd7e0c/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java
index a250d5e..bbb4f76 100644
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java
+++ b/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java
@@ -121,6 +121,11 @@ public class StreamVisitorExample {
                 // Print top 10 words.
                 ExamplesUtils.printQueryResults(top3);
             }
+            finally {
+                // Distributed cache could be removed from cluster only by #destroyCache() call.
+                ignite.destroyCache(mktDataCfg.getName());
+                ignite.destroyCache(instCfg.getName());
+            }
         }
     }
 


Mime
View raw message