Repository: incubator-ignite Updated Branches: refs/heads/ignite-45 59e27ee65 -> 8e0c00590
# ignite-45 - fixing examples. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/8e0c0059 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/8e0c0059 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/8e0c0059 Branch: refs/heads/ignite-45 Commit: 8e0c00590473914fde415524854322a5408c6fe6 Parents: 59e27ee Author: Dmitiry Setrakyan <dsetrak...@gridgain.com> Authored: Tue Mar 17 00:03:03 2015 -0700 Committer: Dmitiry Setrakyan <dsetrak...@gridgain.com> Committed: Tue Mar 17 00:03:03 2015 -0700 ---------------------------------------------------------------------- .../streaming/CachePopularNumbersExample.java | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8e0c0059/examples/src/main/java/org/apache/ignite/examples/streaming/CachePopularNumbersExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/CachePopularNumbersExample.java b/examples/src/main/java/org/apache/ignite/examples/streaming/CachePopularNumbersExample.java index 81d5f6c..eadb6ce 100644 --- a/examples/src/main/java/org/apache/ignite/examples/streaming/CachePopularNumbersExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/streaming/CachePopularNumbersExample.java @@ -22,6 +22,7 @@ import org.apache.ignite.cache.*; import org.apache.ignite.cache.query.*; import org.apache.ignite.configuration.*; +import javax.cache.*; import javax.cache.configuration.*; import javax.cache.expiry.*; import javax.cache.processor.*; @@ -74,7 +75,7 @@ public class CachePopularNumbersExample { // Mark this cluster member as client. Ignition.setClientMode(true); - try (Ignite ignite = Ignition.start()) { + try (Ignite ignite = Ignition.start("examples/config/example-compute.xml")) { System.out.println(); System.out.println(">>> Cache popular numbers example started."); @@ -88,8 +89,8 @@ public class CachePopularNumbersExample { cfg.setName(STREAM_NAME); cfg.setIndexedTypes(Integer.class, Long.class); - // Sliding window of 5 seconds. - cfg.setExpiryPolicyFactory(FactoryBuilder.factoryOf(new CreatedExpiryPolicy(new Duration(SECONDS, 5)))); + // Sliding window of 1 seconds. + cfg.setExpiryPolicyFactory(FactoryBuilder.factoryOf(new CreatedExpiryPolicy(new Duration(SECONDS, 1)))); /** * Start the streaming cache on all server nodes. @@ -97,7 +98,7 @@ public class CachePopularNumbersExample { */ try (IgniteCache<Integer, Long> stmCache = ignite.createCache(cfg)) { // Check that that server nodes have been started. - if (ignite.cluster().forCacheNodes(STREAM_NAME).nodes().isEmpty()) { + if (ignite.cluster().forDataNodes(STREAM_NAME).nodes().isEmpty()) { System.out.println("Ignite does not have streaming cache configured: " + STREAM_NAME); return; @@ -113,8 +114,8 @@ public class CachePopularNumbersExample { th.start(); - // Run this example for 3 minutes. - long duration = 3 * 60 * 60 * 1000; + // Run this example for 2 minutes. + long duration = 2 * 60 * 1000; long start = System.currentTimeMillis(); @@ -136,6 +137,13 @@ public class CachePopularNumbersExample { th.interrupt(); th.join(); } + catch (CacheException e) { + e.printStackTrace(); + + System.out.println("Destroying cache for name '" + STREAM_NAME + "'. Please try again."); + + ignite.destroyCache(STREAM_NAME); + } } }