ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [3/7] incubator-ignite git commit: ignite master: fix for scala examples
Date Tue, 13 Jan 2015 03:58:43 GMT
ignite master: fix for scala 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/78d99206
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/78d99206
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/78d99206

Branch: refs/heads/ignite-32
Commit: 78d99206ae89c0b4f3ee9696d4209c478e73655e
Parents: 5fd0d7c
Author: Yakov Zhdanov <yzhdanov@gridgain.com>
Authored: Mon Jan 12 17:01:03 2015 +0300
Committer: Yakov Zhdanov <yzhdanov@gridgain.com>
Committed: Mon Jan 12 17:01:03 2015 +0300

----------------------------------------------------------------------
 .../examples/ScalarCacheAffinityExample1.scala  |  3 +++
 .../examples/ScalarCacheAffinityExample2.scala  |  3 +++
 .../ScalarCacheAffinitySimpleExample.scala      | 10 +++++++--
 .../scalar/examples/ScalarCacheExample.scala    | 12 ++++++++---
 .../ScalarCachePopularNumbersExample.scala      |  3 +++
 .../examples/ScalarCacheQueryExample.scala      |  3 +++
 .../examples/ScalarSnowflakeSchemaExample.scala | 22 ++++++++++++++------
 7 files changed, 45 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/78d99206/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCacheAffinityExample1.scala
----------------------------------------------------------------------
diff --git a/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCacheAffinityExample1.scala
b/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCacheAffinityExample1.scala
index e7aa494..118c33c 100644
--- a/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCacheAffinityExample1.scala
+++ b/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCacheAffinityExample1.scala
@@ -45,6 +45,9 @@ object ScalarCacheAffinityExample1 {
      */
     def main(args: Array[String]) {
         scalar(CONFIG) {
+            // Clean up caches on all nodes before run.
+            cache$(NAME).get.globalClearAll(0)
+
             var keys = Seq.empty[String]
 
             ('A' to 'Z').foreach(keys :+= _.toString)

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/78d99206/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCacheAffinityExample2.scala
----------------------------------------------------------------------
diff --git a/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCacheAffinityExample2.scala
b/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCacheAffinityExample2.scala
index 2790c8c..0fd7f73 100644
--- a/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCacheAffinityExample2.scala
+++ b/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCacheAffinityExample2.scala
@@ -41,6 +41,9 @@ object ScalarCacheAffinityExample2 {
      */
     def main(args: Array[String]) {
         scalar(CONFIG) {
+            // Clean up caches on all nodes before run.
+            cache$(NAME).get.globalClearAll(0)
+
             var keys = Seq.empty[String]
 
             ('A' to 'Z').foreach(keys :+= _.toString)

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/78d99206/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCacheAffinitySimpleExample.scala
----------------------------------------------------------------------
diff --git a/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCacheAffinitySimpleExample.scala
b/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCacheAffinitySimpleExample.scala
index adc80a2..33e3afa 100644
--- a/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCacheAffinitySimpleExample.scala
+++ b/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCacheAffinitySimpleExample.scala
@@ -33,6 +33,9 @@ object ScalarCacheAffinitySimpleExample extends App {
     /** Number of keys. */
     private val KEY_CNT = 20
 
+    /** Name of cache specified in spring configuration. */
+    private val NAME = "partitioned"
+
     /** Type alias. */
     type Cache = GridCache[Int, String]
 
@@ -41,7 +44,10 @@ object ScalarCacheAffinitySimpleExample extends App {
      * since there is no distribution, values may come back as `nulls`.
      */
     scalar("examples/config/example-cache.xml") {
-        val c = grid$.cache[Int, String]("partitioned")
+        // Clean up caches on all nodes before run.
+        cache$(NAME).get.globalClearAll(0)
+
+        val c = grid$.cache[Int, String](NAME)
 
         populate(c)
         visit(c)
@@ -55,7 +61,7 @@ object ScalarCacheAffinitySimpleExample extends App {
      */
     private def visit(c: Cache) {
         (0 until KEY_CNT).foreach(i =>
-            grid$.compute().affinityRun("partitioned", i,
+            grid$.compute().affinityRun(NAME, i,
                 () => println("Co-located [key= " + i + ", value=" + c.peek(i) + ']'))
         )
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/78d99206/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCacheExample.scala
----------------------------------------------------------------------
diff --git a/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCacheExample.scala
b/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCacheExample.scala
index d61adc5..d33ff03 100644
--- a/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCacheExample.scala
+++ b/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCacheExample.scala
@@ -27,7 +27,13 @@ import collection.JavaConversions._
  * be started with or without cache.
  */
 object ScalarCacheExample extends App {
+    /** Name of cache specified in spring configuration. */
+    private val NAME = "partitioned"
+
     scalar("examples/config/example-cache.xml") {
+        // Clean up caches on all nodes before run.
+        cache$(NAME).get.globalClearAll(0)
+
         registerListener()
 
         basicOperations()
@@ -39,7 +45,7 @@ object ScalarCacheExample extends App {
      */
     def basicOperations() {
         // Create cache predicate-based projection (all values > 30).
-        val c = cache$("partitioned").get.viewByType(classOf[String], classOf[Int]).
+        val c = cache$(NAME).get.viewByType(classOf[String], classOf[Int]).
             viewByKv((k: String, v: Int) => v < 30)
 
         // Add few values.
@@ -87,8 +93,8 @@ object ScalarCacheExample extends App {
      */
     def twoViewsOneCache() {
         // Create two typed views on the same cache.
-        val view1 = cache$("partitioned").get.viewByType(classOf[String], classOf[Int])
-        val view2 = cache$("partitioned").get.viewByType(classOf[Int], classOf[String])
+        val view1 = cache$(NAME).get.viewByType(classOf[String], classOf[Int])
+        val view2 = cache$(NAME).get.viewByType(classOf[Int], classOf[String])
 
         view1 += ("key1" -> 1)
         view1 += ("key2" -> 2)

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/78d99206/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCachePopularNumbersExample.scala
----------------------------------------------------------------------
diff --git a/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCachePopularNumbersExample.scala
b/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCachePopularNumbersExample.scala
index 8546ab8..22a18e7 100644
--- a/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCachePopularNumbersExample.scala
+++ b/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCachePopularNumbersExample.scala
@@ -50,6 +50,9 @@ object ScalarCachePopularNumbersExample extends App {
     private final val CNT = 100000
 
     scalar("examples/config/example-cache.xml") {
+        // Clean up caches on all nodes before run.
+        cache$(CACHE_NAME).get.globalClearAll(0)
+
         println()
         println(">>> Cache popular numbers example started.")
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/78d99206/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCacheQueryExample.scala
----------------------------------------------------------------------
diff --git a/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCacheQueryExample.scala
b/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCacheQueryExample.scala
index f29418a..c56c619 100644
--- a/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCacheQueryExample.scala
+++ b/examples/src/main/scala/org/gridgain/scalar/examples/ScalarCacheQueryExample.scala
@@ -105,6 +105,9 @@ object ScalarCacheQueryExample {
      * Populates cache with test data.
      */
     private def initialize() {
+        // Clean up caches on all nodes before run.
+        cache$(CACHE_NAME).get.globalClearAll(0)
+
         // Organization cache projection.
         val orgCache = mkCache[UUID, Organization]
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/78d99206/examples/src/main/scala/org/gridgain/scalar/examples/ScalarSnowflakeSchemaExample.scala
----------------------------------------------------------------------
diff --git a/examples/src/main/scala/org/gridgain/scalar/examples/ScalarSnowflakeSchemaExample.scala
b/examples/src/main/scala/org/gridgain/scalar/examples/ScalarSnowflakeSchemaExample.scala
index 1ca5b78..f4216e1 100644
--- a/examples/src/main/scala/org/gridgain/scalar/examples/ScalarSnowflakeSchemaExample.scala
+++ b/examples/src/main/scala/org/gridgain/scalar/examples/ScalarSnowflakeSchemaExample.scala
@@ -29,6 +29,12 @@ import org.jdk8.backport.ThreadLocalRandom8
  * cache: `'ggstart.sh examples/config/example-cache.xml'`.
  */
 object ScalarSnowflakeSchemaExample {
+    /** Name of replicated cache specified in spring configuration. */
+    private val REPL_CACHE_NAME = "replicated"
+
+    /** Name of partitioned cache specified in spring configuration. */
+    private val PART_CACHE_NAME = "partitioned"
+
     /** ID generator. */
     private[this] val idGen = Stream.from(0).iterator
 
@@ -37,6 +43,10 @@ object ScalarSnowflakeSchemaExample {
      */
     def main(args: Array[String]) {
         scalar("examples/config/example-cache.xml") {
+            // Clean up caches on all nodes before run.
+            cache$(REPL_CACHE_NAME).get.globalClearAll(0)
+            cache$(PART_CACHE_NAME).get.globalClearAll(0)
+
             populateDimensions()
             populateFacts()
 
@@ -50,7 +60,7 @@ object ScalarSnowflakeSchemaExample {
      * `DimStore` and `DimProduct` instances.
      */
     def populateDimensions() {
-        val dimCache = grid$.cache[Int, Object]("replicated")
+        val dimCache = grid$.cache[Int, Object](REPL_CACHE_NAME)
 
         val store1 = new DimStore(idGen.next(), "Store1", "12345", "321 Chilly Dr, NY")
         val store2 = new DimStore(idGen.next(), "Store2", "54321", "123 Windy Dr, San Francisco")
@@ -70,8 +80,8 @@ object ScalarSnowflakeSchemaExample {
      * Populate cache with `facts`, which in our case are `FactPurchase` objects.
      */
     def populateFacts() {
-        val dimCache = grid$.cache[Int, Object]("replicated")
-        val factCache = grid$.cache[Int, FactPurchase]("partitioned")
+        val dimCache = grid$.cache[Int, Object](REPL_CACHE_NAME)
+        val factCache = grid$.cache[Int, FactPurchase](PART_CACHE_NAME)
 
         val stores: GridCacheProjection[Int, DimStore] = dimCache.viewByType(classOf[Int],
classOf[DimStore])
         val prods: GridCacheProjection[Int, DimProduct] = dimCache.viewByType(classOf[Int],
classOf[DimProduct])
@@ -91,7 +101,7 @@ object ScalarSnowflakeSchemaExample {
      * `FactPurchase` objects stored in `partitioned` cache.
      */
     def queryStorePurchases() {
-        val factCache = grid$.cache[Int, FactPurchase]("partitioned")
+        val factCache = grid$.cache[Int, FactPurchase](PART_CACHE_NAME)
 
         val storePurchases = factCache.sql(
             "from \"replicated\".DimStore, \"partitioned\".FactPurchase " +
@@ -107,8 +117,8 @@ object ScalarSnowflakeSchemaExample {
      * stored in `partitioned` cache.
      */
     private def queryProductPurchases() {
-        val dimCache = grid$.cache[Int, Object]("replicated")
-        val factCache = grid$.cache[Int, FactPurchase]("partitioned")
+        val dimCache = grid$.cache[Int, Object](REPL_CACHE_NAME)
+        val factCache = grid$.cache[Int, FactPurchase](PART_CACHE_NAME)
 
         val prods: GridCacheProjection[Int, DimProduct] = dimCache.viewByType(classOf[Int],
classOf[DimProduct])
 


Mime
View raw message