Repository: incubator-ignite Updated Branches: refs/heads/sprint-1 157591e30 -> 11f992015
renamed example Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/11f99201 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/11f99201 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/11f99201 Branch: refs/heads/sprint-1 Commit: 11f99201564a634c36b8ad023a10e9601e243962 Parents: 157591e Author: Yakov Zhdanov <yzhda...@gridgain.com> Authored: Sun Feb 15 19:30:32 2015 +0300 Committer: Yakov Zhdanov <yzhda...@gridgain.com> Committed: Sun Feb 15 19:30:32 2015 +0300 ---------------------------------------------------------------------- .../apache/ignite/examples/ExamplesUtils.java | 2 +- .../computegrid/ComputeBroadcastExample.java | 2 +- .../ComputeClusterGroupsExample.java | 93 ++++++++++++++++++++ .../computegrid/ComputeProjectionExample.java | 93 -------------------- .../datagrid/CacheDataLoaderExample.java | 2 +- .../examples/messaging/MessagingExample.java | 14 +-- .../ignite/examples/MessagingExample.java | 6 +- .../scalar/examples/ScalarCacheExample.scala | 4 +- .../scalar/examples/ScalarClosureExample.scala | 4 +- .../examples/ScalarContinuationExample.scala | 4 +- .../ComputeClusterGroupsExampleSelfTest.java | 39 ++++++++ .../examples/ProjectionExampleSelfTest.java | 39 -------- .../testsuites/IgniteExamplesSelfTestSuite.java | 2 +- 13 files changed, 152 insertions(+), 152 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/11f99201/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 871b835..a1d59c9 100644 --- a/examples/src/main/java/org/apache/ignite/examples/ExamplesUtils.java +++ b/examples/src/main/java/org/apache/ignite/examples/ExamplesUtils.java @@ -63,7 +63,7 @@ public class ExamplesUtils { /** * Checks minimum topology size for running a certain example. * - * @param prj Projection to check size for. + * @param prj Cluster to check size for. * @param size Minimum number of nodes required to run a certain example. * @return {@code True} if check passed, {@code false} otherwise. */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/11f99201/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeBroadcastExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeBroadcastExample.java b/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeBroadcastExample.java index 7fe4100..85ecb0f 100644 --- a/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeBroadcastExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeBroadcastExample.java @@ -25,7 +25,7 @@ import org.apache.ignite.resources.*; import java.util.*; /** - * Demonstrates broadcasting computations within projection. + * Demonstrates broadcasting computations within cluster. * <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'}. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/11f99201/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeClusterGroupsExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeClusterGroupsExample.java b/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeClusterGroupsExample.java new file mode 100644 index 0000000..d4d0bc4 --- /dev/null +++ b/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeClusterGroupsExample.java @@ -0,0 +1,93 @@ +/* + * 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.computegrid; + +import org.apache.ignite.*; +import org.apache.ignite.cluster.*; +import org.apache.ignite.examples.*; +import org.apache.ignite.lang.*; + +/** + * Demonstrates new functional APIs. + * <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'}. + * <p> + * Alternatively you can run {@link ComputeNodeStartup} in another JVM which will start node + * with {@code examples/config/example-compute.xml} configuration. + */ +public class ComputeClusterGroupsExample { + /** + * Executes example. + * + * @param args Command line arguments, none required. + * @throws IgniteException If example execution failed. + */ + public static void main(String[] args) throws IgniteException { + try (Ignite ignite = Ignition.start("examples/config/example-compute.xml")) { + if (!ExamplesUtils.checkMinTopologySize(ignite.cluster(), 2)) + return; + + System.out.println(); + System.out.println("Compute example started."); + + IgniteCluster cluster = ignite.cluster(); + + // Say hello to all nodes in the cluster, including local node. + sayHello(ignite, cluster); + + // Say hello to all remote nodes. + sayHello(ignite, cluster.forRemotes()); + + // Pick random node out of remote nodes. + ClusterGroup randomNode = cluster.forRemotes().forRandom(); + + // Say hello to a random node. + sayHello(ignite, randomNode); + + // Say hello to all nodes residing on the same host with random node. + sayHello(ignite, cluster.forHost(randomNode.node())); + + // Say hello to all nodes that have current CPU load less than 50%. + sayHello(ignite, cluster.forPredicate(new IgnitePredicate<ClusterNode>() { + @Override public boolean apply(ClusterNode n) { + return n.metrics().getCurrentCpuLoad() < 0.5; + } + })); + } + } + + /** + * Print 'Hello' message on remote nodes. + * + * @param ignite Ignite. + * @param grp Cluster group. + * @throws IgniteException If failed. + */ + private static void sayHello(Ignite ignite, final ClusterGroup grp) throws IgniteException { + // Print out hello message on all cluster nodes. + ignite.compute(grp).broadcast( + new IgniteRunnable() { + @Override public void run() { + // Print ID of remote node on remote node. + System.out.println(">>> Hello Node: " + grp.ignite().cluster().localNode().id()); + } + } + ); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/11f99201/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeProjectionExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeProjectionExample.java b/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeProjectionExample.java deleted file mode 100644 index 0e92790..0000000 --- a/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeProjectionExample.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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.computegrid; - -import org.apache.ignite.*; -import org.apache.ignite.cluster.*; -import org.apache.ignite.examples.*; -import org.apache.ignite.lang.*; - -/** - * Demonstrates new functional APIs. - * <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'}. - * <p> - * Alternatively you can run {@link ComputeNodeStartup} in another JVM which will start node - * with {@code examples/config/example-compute.xml} configuration. - */ -public class ComputeProjectionExample { - /** - * Executes example. - * - * @param args Command line arguments, none required. - * @throws IgniteException If example execution failed. - */ - public static void main(String[] args) throws IgniteException { - try (Ignite ignite = Ignition.start("examples/config/example-compute.xml")) { - if (!ExamplesUtils.checkMinTopologySize(ignite.cluster(), 2)) - return; - - System.out.println(); - System.out.println("Compute projection example started."); - - IgniteCluster cluster = ignite.cluster(); - - // Say hello to all nodes in the cluster, including local node. - sayHello(ignite, cluster); - - // Say hello to all remote nodes. - sayHello(ignite, cluster.forRemotes()); - - // Pick random node out of remote nodes. - ClusterGroup randomNode = cluster.forRemotes().forRandom(); - - // Say hello to a random node. - sayHello(ignite, randomNode); - - // Say hello to all nodes residing on the same host with random node. - sayHello(ignite, cluster.forHost(randomNode.node())); - - // Say hello to all nodes that have current CPU load less than 50%. - sayHello(ignite, cluster.forPredicate(new IgnitePredicate<ClusterNode>() { - @Override public boolean apply(ClusterNode n) { - return n.metrics().getCurrentCpuLoad() < 0.5; - } - })); - } - } - - /** - * Print 'Hello' message on remote nodes. - * - * @param ignite Ignite. - * @param grp Cluster group. - * @throws IgniteException If failed. - */ - private static void sayHello(Ignite ignite, final ClusterGroup grp) throws IgniteException { - // Print out hello message on all projection nodes. - ignite.compute(grp).broadcast( - new IgniteRunnable() { - @Override public void run() { - // Print ID of remote node on remote node. - System.out.println(">>> Hello Node: " + grp.ignite().cluster().localNode().id()); - } - } - ); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/11f99201/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 60b2bc5..57b0cd2 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 @@ -23,7 +23,7 @@ import org.apache.ignite.examples.*; /** * Demonstrates how cache can be populated with data utilizing {@link IgniteDataLoader} API. * {@link IgniteDataLoader} is a lot more efficient to use than standard - * {@code CacheProjection.put(...)} operation as it properly buffers cache requests + * {@code put(...)} operation as it properly buffers cache requests * together and properly manages load on remote nodes. * <p> * Remote nodes should always be started with special configuration file which http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/11f99201/examples/src/main/java/org/apache/ignite/examples/messaging/MessagingExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/messaging/MessagingExample.java b/examples/src/main/java/org/apache/ignite/examples/messaging/MessagingExample.java index e02853a..08d5c3b 100644 --- a/examples/src/main/java/org/apache/ignite/examples/messaging/MessagingExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/messaging/MessagingExample.java @@ -60,11 +60,11 @@ public final class MessagingExample { System.out.println(); System.out.println(">>> Messaging example started."); - // Projection for remote nodes. - ClusterGroup rmtPrj = ignite.cluster().forRemotes(); + // Group for remote nodes. + ClusterGroup rmts = ignite.cluster().forRemotes(); // Listen for messages from remote nodes to make sure that they received all the messages. - int msgCnt = rmtPrj.nodes().size() * MESSAGES_NUM; + int msgCnt = rmts.nodes().size() * MESSAGES_NUM; CountDownLatch orderedLatch = new CountDownLatch(msgCnt); CountDownLatch unorderedLatch = new CountDownLatch(msgCnt); @@ -72,17 +72,17 @@ public final class MessagingExample { localListen(ignite.message(ignite.cluster().forLocal()), orderedLatch, unorderedLatch); // Register listeners on all cluster nodes. - startListening(ignite.message(rmtPrj)); + startListening(ignite.message(rmts)); // Send unordered messages to all remote nodes. for (int i = 0; i < MESSAGES_NUM; i++) - ignite.message(rmtPrj).send(TOPIC.UNORDERED, Integer.toString(i)); + ignite.message(rmts).send(TOPIC.UNORDERED, Integer.toString(i)); System.out.println(">>> Finished sending unordered messages."); // Send ordered messages to all remote nodes. for (int i = 0; i < MESSAGES_NUM; i++) - ignite.message(rmtPrj).sendOrdered(TOPIC.ORDERED, Integer.toString(i), 0); + ignite.message(rmts).sendOrdered(TOPIC.ORDERED, Integer.toString(i), 0); System.out.println(">>> Finished sending ordered messages."); System.out.println(">>> Check output on all nodes for message printouts."); @@ -96,7 +96,7 @@ public final class MessagingExample { } /** - * Start listening to messages on all cluster nodes within passed in projection. + * Start listening to messages on remote cluster nodes. * * @param msg Ignite messaging. */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/11f99201/examples/src/main/java8/org/apache/ignite/examples/MessagingExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java8/org/apache/ignite/examples/MessagingExample.java b/examples/src/main/java8/org/apache/ignite/examples/MessagingExample.java index 71fa1b4..2127715 100644 --- a/examples/src/main/java8/org/apache/ignite/examples/MessagingExample.java +++ b/examples/src/main/java8/org/apache/ignite/examples/MessagingExample.java @@ -61,7 +61,7 @@ public final class MessagingExample { System.out.println(); System.out.println(">>> Messaging example started."); - // Projection for remote nodes. + // Group for remote nodes. ClusterGroup rmtGrp = ignite.cluster().forRemotes(); // Listen for messages from remote nodes to make sure that they received all the messages. @@ -97,7 +97,7 @@ public final class MessagingExample { } /** - * Start listening to messages on all cluster nodes within passed in projection. + * Start listening to messages on remote cluster nodes. * * @param ignite Ignite. * @param imsg Ignite messaging. @@ -159,4 +159,4 @@ public final class MessagingExample { return unorderedLatch.getCount() > 0; }); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/11f99201/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCacheExample.scala ---------------------------------------------------------------------- diff --git a/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCacheExample.scala b/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCacheExample.scala index 65134e2..8df7dd8 100644 --- a/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCacheExample.scala +++ b/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCacheExample.scala @@ -92,12 +92,12 @@ object ScalarCacheExample extends App { case None => println("Correct") } - // Print all projection values. + // Print all values. c.values foreach println } /** - * Demos basic type projections. + * Demos basic type features. */ def twoViewsOneCache() { // Create two typed views on the same cache. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/11f99201/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarClosureExample.scala ---------------------------------------------------------------------- diff --git a/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarClosureExample.scala b/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarClosureExample.scala index 46a78d1..b73b9ed 100644 --- a/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarClosureExample.scala +++ b/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarClosureExample.scala @@ -82,12 +82,12 @@ object ScalarClosureExample extends App { } /** - * Same as previous greetings for all remote nodes but remote projection is created manually. + * Same as previous greetings for all remote nodes but remote cluster group is filtered manually. */ def greetRemotesAgain() { val me = ignite$.cluster().localNode.id - // Just show that we can create any projections we like... + // Just show that we can create any groups we like... // Note that usage of Java-based closure via 'F' typedef. ignite$.cluster().forPredicate((n: ClusterNode) => n.id != me) match { case p if p.isEmpty => println("No remote nodes!") http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/11f99201/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarContinuationExample.scala ---------------------------------------------------------------------- diff --git a/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarContinuationExample.scala b/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarContinuationExample.scala index b307af0..fc3cb53 100644 --- a/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarContinuationExample.scala +++ b/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarContinuationExample.scala @@ -51,7 +51,7 @@ object ScalarContinuationExample { val start = System.currentTimeMillis - // Projection that excludes this node if others exists. + // Group that excludes this node if others exists. val prj = if (ignite$.cluster().nodes().size() > 1) ignite$.cluster().forOthers(thisNode) else ignite$.cluster().forNode(thisNode) val fib = ignite$.compute(prj).apply(new FibonacciClosure(thisNode.id()), N) @@ -111,7 +111,7 @@ class FibonacciClosure ( val excludeNode = ignite$.cluster().node(excludeNodeId) - // Projection that excludes node with id passed in constructor if others exists. + // Group that excludes node with id passed in constructor if others exists. val prj = if (ignite$.cluster().nodes().size() > 1) ignite$.cluster().forOthers(excludeNode) else ignite$.cluster().forNode(excludeNode) val comp = ignite$.compute(prj).withAsync() http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/11f99201/examples/src/test/java/org/apache/ignite/examples/ComputeClusterGroupsExampleSelfTest.java ---------------------------------------------------------------------- diff --git a/examples/src/test/java/org/apache/ignite/examples/ComputeClusterGroupsExampleSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/ComputeClusterGroupsExampleSelfTest.java new file mode 100644 index 0000000..6bde3f5 --- /dev/null +++ b/examples/src/test/java/org/apache/ignite/examples/ComputeClusterGroupsExampleSelfTest.java @@ -0,0 +1,39 @@ +/* + * 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; + +import org.apache.ignite.examples.computegrid.*; +import org.apache.ignite.testframework.junits.common.*; + +/** + * + */ +public class ComputeClusterGroupsExampleSelfTest extends GridAbstractExamplesTest { + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + // Start up a node. + startGrid("ignite-cluster-groups-example", DFLT_CFG); + } + + /** + * @throws Exception If failed. + */ + public void testComputeClusterGroupsExample() throws Exception { + ComputeClusterGroupsExample.main(EMPTY_ARGS); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/11f99201/examples/src/test/java/org/apache/ignite/examples/ProjectionExampleSelfTest.java ---------------------------------------------------------------------- diff --git a/examples/src/test/java/org/apache/ignite/examples/ProjectionExampleSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/ProjectionExampleSelfTest.java deleted file mode 100644 index 09037bd..0000000 --- a/examples/src/test/java/org/apache/ignite/examples/ProjectionExampleSelfTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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; - -import org.apache.ignite.examples.computegrid.*; -import org.apache.ignite.testframework.junits.common.*; - -/** - * - */ -public class ProjectionExampleSelfTest extends GridAbstractExamplesTest { - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - // Start up a node. - startGrid("ignite-projection-example", DFLT_CFG); - } - - /** - * @throws Exception If failed. - */ - public void testProjectionExample() throws Exception { - ComputeProjectionExample.main(EMPTY_ARGS); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/11f99201/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java ---------------------------------------------------------------------- diff --git a/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java b/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java index 76a25a2..11af442 100644 --- a/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java +++ b/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java @@ -54,7 +54,7 @@ public class IgniteExamplesSelfTestSuite extends TestSuite { suite.addTest(new TestSuite(IgfsExamplesSelfTest.class)); suite.addTest(new TestSuite(CheckpointExamplesSelfTest.class)); suite.addTest(new TestSuite(HibernateL2CacheExampleSelfTest.class)); - suite.addTest(new TestSuite(ProjectionExampleSelfTest.class)); + suite.addTest(new TestSuite(ComputeClusterGroupsExampleSelfTest.class)); // Multi-node. suite.addTest(new TestSuite(CacheExamplesMultiNodeSelfTest.class));