# ignite-45 - fixing streaming.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/28ad5e2b Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/28ad5e2b Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/28ad5e2b Branch: refs/heads/ignite-501 Commit: 28ad5e2bbbe756cd9ce7c2a21393cd1c1697944e Parents: 9d01cfd Author: Dmitiry Setrakyan <dsetrak...@gridgain.com> Authored: Thu Mar 19 03:25:12 2015 -0400 Committer: Dmitiry Setrakyan <dsetrak...@gridgain.com> Committed: Thu Mar 19 03:25:23 2015 -0400 ---------------------------------------------------------------------- .../java8/streaming/numbers/CacheConfig.java | 21 +++++++++++++++++++- .../streaming/numbers/QueryPopularNumbers.java | 8 +++++++- .../streaming/numbers/StreamRandomNumbers.java | 8 +++++++- 3 files changed, 34 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/28ad5e2b/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/numbers/CacheConfig.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/numbers/CacheConfig.java b/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/numbers/CacheConfig.java index 76f50b1..ada7932 100644 --- a/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/numbers/CacheConfig.java +++ b/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/numbers/CacheConfig.java @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apache.ignite.examples.java8.streaming.numbers; import org.apache.ignite.cache.*; @@ -9,7 +26,9 @@ import javax.cache.expiry.*; import static java.util.concurrent.TimeUnit.*; /** - * Created by Dmitriy on 3/18/15. + * Configuration for the streaming cache to store the stream of random numbers. + * This cache is configured with sliding window of 1 second, which means that + * data older than 1 second will be automatically removed from the cache. */ public class CacheConfig { /** Cache name. */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/28ad5e2b/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/numbers/QueryPopularNumbers.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/numbers/QueryPopularNumbers.java b/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/numbers/QueryPopularNumbers.java index 92f6425..9895d2e 100644 --- a/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/numbers/QueryPopularNumbers.java +++ b/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/numbers/QueryPopularNumbers.java @@ -25,6 +25,12 @@ import java.util.*; /** * Periodically query popular numbers from the streaming cache. + * To start the example, you should: + * <ul> + * <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li> + * <li>Start streaming using {@link StreamRandomNumbers}.</li> + * <li>Start querying popular numbers using {@link QueryPopularNumbers}.</li> + * </ul> * <p> * Remote nodes should always be started with special configuration file which * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-compute.xml'}. @@ -40,7 +46,7 @@ public class QueryPopularNumbers { try (Ignite ignite = Ignition.start("examples/config/example-compute.xml")) { // Start new cache or get existing one. // The cache is configured with sliding window holding 1 second of the streaming data. - try (IgniteCache<Integer, Long> stmCache = ignite.createCache(CacheConfig.configure())) { + try (IgniteCache<Integer, Long> stmCache = ignite.getOrCreateCache(CacheConfig.configure())) { if (!ExamplesUtils.hasServerNodes(ignite)) return; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/28ad5e2b/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/numbers/StreamRandomNumbers.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/numbers/StreamRandomNumbers.java b/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/numbers/StreamRandomNumbers.java index c635c43..fd2587f 100644 --- a/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/numbers/StreamRandomNumbers.java +++ b/examples/src/main/java8/org/apache/ignite/examples/java8/streaming/numbers/StreamRandomNumbers.java @@ -25,6 +25,12 @@ import java.util.*; /** * Stream random numbers into the streaming cache. + * To start the example, you should: + * <ul> + * <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li> + * <li>Start streaming using {@link StreamRandomNumbers}.</li> + * <li>Start querying popular numbers using {@link QueryPopularNumbers}.</li> + * </ul> * <p> * Remote nodes should always be started with special configuration file which * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-compute.xml'}. @@ -46,7 +52,7 @@ public class StreamRandomNumbers { try (Ignite ignite = Ignition.start("examples/config/example-compute.xml")) { // Create new cache or get existing one. // The cache is configured with sliding window holding 1 second of the streaming data. - try (IgniteCache<Integer, Long> stmCache = ignite.createCache(CacheConfig.configure())) { + try (IgniteCache<Integer, Long> stmCache = ignite.getOrCreateCache(CacheConfig.configure())) { if (!ExamplesUtils.hasServerNodes(ignite)) return;