ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sevdoki...@apache.org
Subject [06/15] incubator-ignite git commit: # IGNITE-459 Update examples in datastructure package.
Date Fri, 13 Mar 2015 09:52:13 GMT
# IGNITE-459 Update examples in datastructure package.


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

Branch: refs/heads/ignite-45
Commit: 5506cce4c6fe0cd9dde0ebbbd3dba40e73bd3bcb
Parents: 934304a
Author: sevdokimov <sevdokimov@gridgain.com>
Authored: Thu Mar 12 14:42:51 2015 +0300
Committer: sevdokimov <sevdokimov@gridgain.com>
Committed: Thu Mar 12 14:42:51 2015 +0300

----------------------------------------------------------------------
 .../datastructures/IgniteQueueExample.java      | 29 ++++++++++++------
 .../datastructures/IgniteSetExample.java        | 32 ++++++++++++++------
 2 files changed, 42 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5506cce4/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteQueueExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteQueueExample.java
b/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteQueueExample.java
index f0e13cb..549217d 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteQueueExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteQueueExample.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.examples.datastructures;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.examples.*;
 import org.apache.ignite.examples.datagrid.*;
@@ -30,14 +31,14 @@ import java.util.*;
  * cache queue.
  * <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 IgniteQueueExample {
     /** Cache name. */
-    private static final String CACHE_NAME = "partitioned_primary";
+    private static final String CACHE_NAME = IgniteQueueExample.class.getSimpleName();
 
     /** Number of retries */
     private static final int RETRIES = 20;
@@ -52,20 +53,28 @@ public class IgniteQueueExample {
      * @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(">>> Ignite queue example started.");
 
-            // Make queue name.
-            String queueName = UUID.randomUUID().toString();
+            CacheConfiguration<Object, Object> cfg = new CacheConfiguration<>();
 
-            queue = initializeQueue(ignite, queueName);
+            cfg.setCacheMode(CacheMode.PARTITIONED);
+            cfg.setName(CACHE_NAME);
+            cfg.setAtomicWriteOrderMode(CacheAtomicWriteOrderMode.PRIMARY);
 
-            readFromQueue(ignite);
+            try (IgniteCache<Object, Object> cache = ignite.createCache(cfg)) {
+                // Make queue name.
+                String queueName = UUID.randomUUID().toString();
 
-            writeToQueue(ignite);
+                queue = initializeQueue(ignite, queueName);
 
-            clearAndRemoveQueue();
+                readFromQueue(ignite);
+
+                writeToQueue(ignite);
+
+                clearAndRemoveQueue();
+            }
         }
 
         System.out.println("Cache queue example finished.");

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5506cce4/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 e1032c6..c773c31 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
@@ -18,6 +18,7 @@
 package org.apache.ignite.examples.datastructures;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.examples.*;
 import org.apache.ignite.examples.datagrid.*;
@@ -29,14 +30,14 @@ import java.util.*;
  * Ignite cache distributed set example.
  * <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 IgniteSetExample {
     /** Cache name. */
-    private static final String CACHE_NAME = "partitioned_tx";
+    private static final String CACHE_NAME = IgniteSetExample.class.getSimpleName();
 
     /** Set instance. */
     private static IgniteSet<String> set;
@@ -48,18 +49,31 @@ public class IgniteSetExample {
      * @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(">>> Ignite set example started.");
 
-            // Make set name.
-            String setName = UUID.randomUUID().toString();
+            CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
 
-            set = initializeSet(ignite, setName);
+            cfg.setCacheMode(CacheMode.PARTITIONED);
+            cfg.setName(CACHE_NAME);
+            cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
 
-            writeToSet(ignite);
+            NearCacheConfiguration<Integer, String> nearCache = new NearCacheConfiguration<>();
+
+            nearCache.setNearEnabled(true);
+
+            try (IgniteCache<Integer, String> cache = ignite.createCache(cfg, nearCache))
{
+                // Make set name.
+                String setName = UUID.randomUUID().toString();
+
+                set = initializeSet(ignite, setName);
+
+                writeToSet(ignite);
+
+                clearAndRemoveSet();
+            }
 
-            clearAndRemoveSet();
         }
 
         System.out.println("Ignite set example finished.");


Mime
View raw message