You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by dm...@apache.org on 2015/11/04 12:57:56 UTC
[1/7] ignite git commit: ignite-1153: improve stop node message
Repository: ignite
Updated Branches:
refs/heads/ignite-cont-merge 2501c3a52 -> 47919078d
ignite-1153: improve stop node message
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/51c0d805
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/51c0d805
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/51c0d805
Branch: refs/heads/ignite-cont-merge
Commit: 51c0d8055157fedf20a28d206598c7c4c514a7f1
Parents: 2501c3a
Author: kcheng.mvp <kc...@gmail.com>
Authored: Wed Nov 4 12:20:46 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Wed Nov 4 12:20:46 2015 +0300
----------------------------------------------------------------------
.../java/org/apache/ignite/internal/IgniteKernal.java | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/51c0d805/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 5a0fe16..0277acc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -641,7 +641,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
// Catch generic throwable to secure against user assertions.
catch (Throwable e) {
U.error(log, "Failed to notify lifecycle bean (safely ignored) [evt=" + evt +
- ", gridName=" + gridName + ']', e);
+ (gridName == null ? "" : ", gridName=" + gridName) + ']', e);
if (e instanceof Error)
throw (Error)e;
@@ -1673,7 +1673,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
">>> CPU(s): " + locNode.metrics().getTotalCpus() + NL +
">>> Heap: " + U.heapSize(locNode, 2) + "GB" + NL +
">>> VM name: " + rtBean.getName() + NL +
- ">>> Grid name: " + gridName + NL +
+ (gridName == null ? "" : ">>> Grid name: " + gridName + NL) +
">>> Local node [" +
"ID=" + locNode.id().toString().toUpperCase() +
", order=" + locNode.order() + ", clientMode=" + ctx.clientNode() +
@@ -1939,11 +1939,13 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
// Ack stop.
if (log.isQuiet()) {
+ String nodeName = gridName == null ? "" : "name=" + gridName + ", ";
+
if (!errOnStop)
- U.quiet(false, "Ignite node stopped OK [uptime=" +
+ U.quiet(false, "Ignite node stopped OK [" + nodeName + "uptime=" +
X.timeSpan2HMSM(U.currentTimeMillis() - startTime) + ']');
else
- U.quiet(true, "Ignite node stopped wih ERRORS [uptime=" +
+ U.quiet(true, "Ignite node stopped wih ERRORS [" + nodeName + "uptime=" +
X.timeSpan2HMSM(U.currentTimeMillis() - startTime) + ']');
}
@@ -1958,7 +1960,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
">>> " + dash + NL +
">>> " + ack + NL +
">>> " + dash + NL +
- ">>> Grid name: " + gridName + NL +
+ (gridName == null ? "" : ">>> Grid name: " + gridName + NL) +
">>> Grid uptime: " + X.timeSpan2HMSM(U.currentTimeMillis() - startTime) +
NL +
NL);
@@ -1972,7 +1974,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
log.info(NL + NL +
">>> " + ack + NL +
">>> " + dash + NL +
- ">>> Grid name: " + gridName + NL +
+ (gridName == null ? "" : ">>> Grid name: " + gridName + NL) +
">>> Grid uptime: " + X.timeSpan2HMSM(U.currentTimeMillis() - startTime) +
NL +
">>> See log above for detailed error message." + NL +
[6/7] ignite git commit: Renamed IgniteRddSpec to IgniteRDDSpec
Posted by dm...@apache.org.
Renamed IgniteRddSpec to IgniteRDDSpec
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7944be8e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7944be8e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7944be8e
Branch: refs/heads/ignite-cont-merge
Commit: 7944be8e6ad3bcad754d6e3f738ce18e6e0431c6
Parents: c66df66
Author: Stephen Boesch <ja...@gmail.com>
Authored: Wed Nov 4 13:39:09 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Wed Nov 4 13:39:09 2015 +0300
----------------------------------------------------------------------
.../scala/org/apache/ignite/spark/Entity.scala | 2 +-
.../org/apache/ignite/spark/IgniteRDDSpec.scala | 249 +++++++++++++++++++
.../apache/ignite/spark/IgniteRddSpec1.scala | 249 -------------------
3 files changed, 250 insertions(+), 250 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7944be8e/modules/spark/src/test/scala/org/apache/ignite/spark/Entity.scala
----------------------------------------------------------------------
diff --git a/modules/spark/src/test/scala/org/apache/ignite/spark/Entity.scala b/modules/spark/src/test/scala/org/apache/ignite/spark/Entity.scala
index e56558d..bef87d5 100644
--- a/modules/spark/src/test/scala/org/apache/ignite/spark/Entity.scala
+++ b/modules/spark/src/test/scala/org/apache/ignite/spark/Entity.scala
@@ -17,7 +17,7 @@
package org.apache.ignite.spark
-import org.apache.ignite.spark.IgniteRddSpec1.ScalarCacheQuerySqlField
+import org.apache.ignite.spark.IgniteRDDSpec.ScalarCacheQuerySqlField
class Entity (
@ScalarCacheQuerySqlField(index = true) val id: Int,
http://git-wip-us.apache.org/repos/asf/ignite/blob/7944be8e/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRDDSpec.scala
----------------------------------------------------------------------
diff --git a/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRDDSpec.scala b/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRDDSpec.scala
new file mode 100644
index 0000000..071897a
--- /dev/null
+++ b/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRDDSpec.scala
@@ -0,0 +1,249 @@
+/*
+ * 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.spark
+
+import org.apache.ignite.Ignition
+import org.apache.ignite.cache.query.annotations.{QueryTextField, QuerySqlField}
+import org.apache.ignite.configuration.{CacheConfiguration, IgniteConfiguration}
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder
+import org.apache.spark.SparkContext
+import org.junit.runner.RunWith
+import org.scalatest._
+import org.scalatest.junit.JUnitRunner
+
+import IgniteRDDSpec._
+
+import scala.annotation.meta.field
+
+@RunWith(classOf[JUnitRunner])
+class IgniteRDDSpec extends FunSpec with Matchers with BeforeAndAfterAll with BeforeAndAfterEach {
+ describe("IgniteRDD") {
+ it("should successfully store data to ignite") {
+ val sc = new SparkContext("local[*]", "test")
+
+ try {
+ val ic = new IgniteContext[String, String](sc,
+ () ⇒ configuration("client", client = true))
+
+ // Save pairs ("0", "val0"), ("1", "val1"), ... to Ignite cache.
+ ic.fromCache(PARTITIONED_CACHE_NAME).savePairs(sc.parallelize(0 to 10000, 2).map(i ⇒ (String.valueOf(i), "val" + i)))
+
+ // Check cache contents.
+ val ignite = Ignition.ignite("grid-0")
+
+ for (i ← 0 to 10000) {
+ val res = ignite.cache[String, String](PARTITIONED_CACHE_NAME).get(String.valueOf(i))
+
+ assert(res != null, "Value was not put to cache for key: " + i)
+ assert("val" + i == res, "Invalid value stored for key: " + i)
+ }
+ }
+ finally {
+ sc.stop()
+ }
+ }
+
+ it("should successfully read data from ignite") {
+ val sc = new SparkContext("local[*]", "test")
+
+ try {
+ val cache = Ignition.ignite("grid-0").cache[String, Int](PARTITIONED_CACHE_NAME)
+
+ val num = 10000
+
+ for (i ← 0 to num) {
+ cache.put(String.valueOf(i), i)
+ }
+
+ val ic = new IgniteContext[String, Int](sc,
+ () ⇒ configuration("client", client = true))
+
+ val res = ic.fromCache(PARTITIONED_CACHE_NAME).map(_._2).sum()
+
+ assert(res == (0 to num).sum)
+ }
+ finally {
+ sc.stop()
+ }
+ }
+
+ it("should successfully query objects from ignite") {
+ val sc = new SparkContext("local[*]", "test")
+
+ try {
+ val ic = new IgniteContext[String, Entity](sc,
+ () ⇒ configuration("client", client = true))
+
+ val cache: IgniteRDD[String, Entity] = ic.fromCache(PARTITIONED_CACHE_NAME)
+
+ cache.savePairs(sc.parallelize(0 to 1000, 2).map(i ⇒ (String.valueOf(i), new Entity(i, "name" + i, i * 100))))
+
+ val res: Array[Entity] = cache.objectSql("Entity", "name = ? and salary = ?", "name50", 5000).map(_._2).collect()
+
+ assert(res.length == 1, "Invalid result length")
+ assert(50 == res(0).id, "Invalid result")
+ assert("name50" == res(0).name, "Invalid result")
+ assert(5000 == res(0).salary)
+
+ assert(500 == cache.objectSql("Entity", "id > 500").count(), "Invalid count")
+ }
+ finally {
+ sc.stop()
+ }
+ }
+
+ it("should successfully query fields from ignite") {
+ val sc = new SparkContext("local[*]", "test")
+
+ try {
+ val ic = new IgniteContext[String, Entity](sc,
+ () ⇒ configuration("client", client = true))
+
+ val cache: IgniteRDD[String, Entity] = ic.fromCache(PARTITIONED_CACHE_NAME)
+
+ import ic.sqlContext.implicits._
+
+ cache.savePairs(sc.parallelize(0 to 1000, 2).map(i ⇒ (String.valueOf(i), new Entity(i, "name" + i, i * 100))))
+
+ val df = cache.sql("select id, name, salary from Entity where name = ? and salary = ?", "name50", 5000)
+
+ df.printSchema()
+
+ val res = df.collect()
+
+ assert(res.length == 1, "Invalid result length")
+ assert(50 == res(0)(0), "Invalid result")
+ assert("name50" == res(0)(1), "Invalid result")
+ assert(5000 == res(0)(2), "Invalid result")
+
+ val df0 = cache.sql("select id, name, salary from Entity").where('NAME === "name50" and 'SALARY === 5000)
+
+ val res0 = df0.collect()
+
+ assert(res0.length == 1, "Invalid result length")
+ assert(50 == res0(0)(0), "Invalid result")
+ assert("name50" == res0(0)(1), "Invalid result")
+ assert(5000 == res0(0)(2), "Invalid result")
+
+ assert(500 == cache.sql("select id from Entity where id > 500").count(), "Invalid count")
+ }
+ finally {
+ sc.stop()
+ }
+ }
+
+ it("should successfully start spark context with XML configuration") {
+ val sc = new SparkContext("local[*]", "test")
+
+ try {
+ val ic = new IgniteContext[String, String](sc,
+ "modules/core/src/test/config/spark/spark-config.xml")
+
+ val cache: IgniteRDD[String, String] = ic.fromCache(PARTITIONED_CACHE_NAME)
+
+ cache.savePairs(sc.parallelize(1 to 1000, 2).map(i ⇒ (String.valueOf(i), "val" + i)))
+
+ assert(1000 == cache.count())
+ }
+ finally {
+ sc.stop()
+ }
+ }
+ }
+
+ override protected def beforeEach() = {
+ Ignition.ignite("grid-0").cache(PARTITIONED_CACHE_NAME).removeAll()
+ }
+
+ override protected def afterEach() = {
+ Ignition.stop("client", false)
+ }
+
+ override protected def beforeAll() = {
+ for (i ← 0 to 3) {
+ Ignition.start(configuration("grid-" + i, client = false))
+ }
+ }
+
+ override protected def afterAll() = {
+ for (i ← 0 to 3) {
+ Ignition.stop("grid-" + i, false)
+ }
+ }
+}
+
+/**
+ * Constants and utility methods.
+ */
+object IgniteRDDSpec {
+ /** IP finder for the test. */
+ val IP_FINDER = new TcpDiscoveryVmIpFinder(true)
+
+ /** Partitioned cache name. */
+ val PARTITIONED_CACHE_NAME = "partitioned"
+
+ /** Type alias for `QuerySqlField`. */
+ type ScalarCacheQuerySqlField = QuerySqlField @field
+
+ /** Type alias for `QueryTextField`. */
+ type ScalarCacheQueryTextField = QueryTextField @field
+
+ /**
+ * Gets ignite configuration.
+ *
+ * @param gridName Grid name.
+ * @param client Client mode flag.
+ * @return Ignite configuration.
+ */
+ def configuration(gridName: String, client: Boolean): IgniteConfiguration = {
+ val cfg = new IgniteConfiguration
+
+ val discoSpi = new TcpDiscoverySpi
+
+ discoSpi.setIpFinder(IgniteRDDSpec.IP_FINDER)
+
+ cfg.setDiscoverySpi(discoSpi)
+
+ cfg.setCacheConfiguration(cacheConfiguration(gridName))
+
+ cfg.setClientMode(client)
+
+ cfg.setGridName(gridName)
+
+ cfg
+ }
+
+ /**
+ * Gets cache configuration for the given grid name.
+ *
+ * @param gridName Grid name.
+ * @return Cache configuration.
+ */
+ def cacheConfiguration(gridName: String): CacheConfiguration[Object, Object] = {
+ val ccfg = new CacheConfiguration[Object, Object]()
+
+ ccfg.setBackups(1)
+
+ ccfg.setName(PARTITIONED_CACHE_NAME)
+
+ ccfg.setIndexedTypes(classOf[String], classOf[Entity])
+
+ ccfg
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7944be8e/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRddSpec1.scala
----------------------------------------------------------------------
diff --git a/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRddSpec1.scala b/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRddSpec1.scala
deleted file mode 100644
index 3ef3225..0000000
--- a/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRddSpec1.scala
+++ /dev/null
@@ -1,249 +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.spark
-
-import org.apache.ignite.Ignition
-import org.apache.ignite.cache.query.annotations.{QueryTextField, QuerySqlField}
-import org.apache.ignite.configuration.{CacheConfiguration, IgniteConfiguration}
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder
-import org.apache.spark.SparkContext
-import org.junit.runner.RunWith
-import org.scalatest._
-import org.scalatest.junit.JUnitRunner
-
-import IgniteRddSpec1._
-
-import scala.annotation.meta.field
-
-@RunWith(classOf[JUnitRunner])
-class IgniteRddSpec1 extends FunSpec with Matchers with BeforeAndAfterAll with BeforeAndAfterEach {
- describe("IgniteRDD") {
- it("should successfully store data to ignite") {
- val sc = new SparkContext("local[*]", "test")
-
- try {
- val ic = new IgniteContext[String, String](sc,
- () ⇒ configuration("client", client = true))
-
- // Save pairs ("0", "val0"), ("1", "val1"), ... to Ignite cache.
- ic.fromCache(PARTITIONED_CACHE_NAME).savePairs(sc.parallelize(0 to 10000, 2).map(i ⇒ (String.valueOf(i), "val" + i)))
-
- // Check cache contents.
- val ignite = Ignition.ignite("grid-0")
-
- for (i ← 0 to 10000) {
- val res = ignite.cache[String, String](PARTITIONED_CACHE_NAME).get(String.valueOf(i))
-
- assert(res != null, "Value was not put to cache for key: " + i)
- assert("val" + i == res, "Invalid value stored for key: " + i)
- }
- }
- finally {
- sc.stop()
- }
- }
-
- it("should successfully read data from ignite") {
- val sc = new SparkContext("local[*]", "test")
-
- try {
- val cache = Ignition.ignite("grid-0").cache[String, Int](PARTITIONED_CACHE_NAME)
-
- val num = 10000
-
- for (i ← 0 to num) {
- cache.put(String.valueOf(i), i)
- }
-
- val ic = new IgniteContext[String, Int](sc,
- () ⇒ configuration("client", client = true))
-
- val res = ic.fromCache(PARTITIONED_CACHE_NAME).map(_._2).sum()
-
- assert(res == (0 to num).sum)
- }
- finally {
- sc.stop()
- }
- }
-
- it("should successfully query objects from ignite") {
- val sc = new SparkContext("local[*]", "test")
-
- try {
- val ic = new IgniteContext[String, Entity](sc,
- () ⇒ configuration("client", client = true))
-
- val cache: IgniteRDD[String, Entity] = ic.fromCache(PARTITIONED_CACHE_NAME)
-
- cache.savePairs(sc.parallelize(0 to 1000, 2).map(i ⇒ (String.valueOf(i), new Entity(i, "name" + i, i * 100))))
-
- val res: Array[Entity] = cache.objectSql("Entity", "name = ? and salary = ?", "name50", 5000).map(_._2).collect()
-
- assert(res.length == 1, "Invalid result length")
- assert(50 == res(0).id, "Invalid result")
- assert("name50" == res(0).name, "Invalid result")
- assert(5000 == res(0).salary)
-
- assert(500 == cache.objectSql("Entity", "id > 500").count(), "Invalid count")
- }
- finally {
- sc.stop()
- }
- }
-
- it("should successfully query fields from ignite") {
- val sc = new SparkContext("local[*]", "test")
-
- try {
- val ic = new IgniteContext[String, Entity](sc,
- () ⇒ configuration("client", client = true))
-
- val cache: IgniteRDD[String, Entity] = ic.fromCache(PARTITIONED_CACHE_NAME)
-
- import ic.sqlContext.implicits._
-
- cache.savePairs(sc.parallelize(0 to 1000, 2).map(i ⇒ (String.valueOf(i), new Entity(i, "name" + i, i * 100))))
-
- val df = cache.sql("select id, name, salary from Entity where name = ? and salary = ?", "name50", 5000)
-
- df.printSchema()
-
- val res = df.collect()
-
- assert(res.length == 1, "Invalid result length")
- assert(50 == res(0)(0), "Invalid result")
- assert("name50" == res(0)(1), "Invalid result")
- assert(5000 == res(0)(2), "Invalid result")
-
- val df0 = cache.sql("select id, name, salary from Entity").where('NAME === "name50" and 'SALARY === 5000)
-
- val res0 = df0.collect()
-
- assert(res0.length == 1, "Invalid result length")
- assert(50 == res0(0)(0), "Invalid result")
- assert("name50" == res0(0)(1), "Invalid result")
- assert(5000 == res0(0)(2), "Invalid result")
-
- assert(500 == cache.sql("select id from Entity where id > 500").count(), "Invalid count")
- }
- finally {
- sc.stop()
- }
- }
-
- it("should successfully start spark context with XML configuration") {
- val sc = new SparkContext("local[*]", "test")
-
- try {
- val ic = new IgniteContext[String, String](sc,
- "modules/core/src/test/config/spark/spark-config.xml")
-
- val cache: IgniteRDD[String, String] = ic.fromCache(PARTITIONED_CACHE_NAME)
-
- cache.savePairs(sc.parallelize(1 to 1000, 2).map(i ⇒ (String.valueOf(i), "val" + i)))
-
- assert(1000 == cache.count())
- }
- finally {
- sc.stop()
- }
- }
- }
-
- override protected def beforeEach() = {
- Ignition.ignite("grid-0").cache(PARTITIONED_CACHE_NAME).removeAll()
- }
-
- override protected def afterEach() = {
- Ignition.stop("client", false)
- }
-
- override protected def beforeAll() = {
- for (i ← 0 to 3) {
- Ignition.start(configuration("grid-" + i, client = false))
- }
- }
-
- override protected def afterAll() = {
- for (i ← 0 to 3) {
- Ignition.stop("grid-" + i, false)
- }
- }
-}
-
-/**
- * Constants and utility methods.
- */
-object IgniteRddSpec1 {
- /** IP finder for the test. */
- val IP_FINDER = new TcpDiscoveryVmIpFinder(true)
-
- /** Partitioned cache name. */
- val PARTITIONED_CACHE_NAME = "partitioned"
-
- /** Type alias for `QuerySqlField`. */
- type ScalarCacheQuerySqlField = QuerySqlField @field
-
- /** Type alias for `QueryTextField`. */
- type ScalarCacheQueryTextField = QueryTextField @field
-
- /**
- * Gets ignite configuration.
- *
- * @param gridName Grid name.
- * @param client Client mode flag.
- * @return Ignite configuration.
- */
- def configuration(gridName: String, client: Boolean): IgniteConfiguration = {
- val cfg = new IgniteConfiguration
-
- val discoSpi = new TcpDiscoverySpi
-
- discoSpi.setIpFinder(IgniteRddSpec1.IP_FINDER)
-
- cfg.setDiscoverySpi(discoSpi)
-
- cfg.setCacheConfiguration(cacheConfiguration(gridName))
-
- cfg.setClientMode(client)
-
- cfg.setGridName(gridName)
-
- cfg
- }
-
- /**
- * Gets cache configuration for the given grid name.
- *
- * @param gridName Grid name.
- * @return Cache configuration.
- */
- def cacheConfiguration(gridName: String): CacheConfiguration[Object, Object] = {
- val ccfg = new CacheConfiguration[Object, Object]()
-
- ccfg.setBackups(1)
-
- ccfg.setName(PARTITIONED_CACHE_NAME)
-
- ccfg.setIndexedTypes(classOf[String], classOf[Entity])
-
- ccfg
- }
-}
[7/7] ignite git commit: ignite-1226: Need to add method that returns
names of all available caches
Posted by dm...@apache.org.
ignite-1226: Need to add method that returns names of all available caches
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/47919078
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/47919078
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/47919078
Branch: refs/heads/ignite-cont-merge
Commit: 47919078df447d7594793f2223649784fe1b8d93
Parents: 7944be8
Author: kcheng.mvp <kc...@gmail.com>
Authored: Wed Nov 4 14:57:05 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Wed Nov 4 14:57:05 2015 +0300
----------------------------------------------------------------------
.../src/main/java/org/apache/ignite/Ignite.java | 12 +++-
.../apache/ignite/internal/IgniteKernal.java | 12 ++++
.../processors/cache/GridCacheProcessor.java | 19 ++++++
.../processors/cache/CacheNamesSelfTest.java | 69 ++++++++++++++++++++
.../ignite/testframework/junits/IgniteMock.java | 5 ++
.../junits/multijvm/IgniteProcessProxy.java | 7 +-
.../ignite/testsuites/IgniteCacheTestSuite.java | 2 +
.../org/apache/ignite/IgniteSpringBean.java | 10 ++-
8 files changed, 133 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/47919078/modules/core/src/main/java/org/apache/ignite/Ignite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/Ignite.java b/modules/core/src/main/java/org/apache/ignite/Ignite.java
index 0afccd0..fc9cf06 100644
--- a/modules/core/src/main/java/org/apache/ignite/Ignite.java
+++ b/modules/core/src/main/java/org/apache/ignite/Ignite.java
@@ -315,6 +315,16 @@ public interface Ignite extends AutoCloseable {
public <K, V> IgniteCache<K, V> cache(@Nullable String name);
/**
+ * Gets the collection of names of currently available caches.
+ *
+ * Collection may contain {@code null} as a value for a cache name. Refer to {@link CacheConfiguration#getName()}
+ * for more info.
+ *
+ * @return Collection of names of currently available caches or an empty collection if no caches are available.
+ */
+ public Collection<String> cacheNames();
+
+ /**
* Gets grid transactions facade.
*
* @return Grid transactions facade.
@@ -477,4 +487,4 @@ public interface Ignite extends AutoCloseable {
* @return Affinity.
*/
public <K> Affinity<K> affinity(String cacheName);
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/47919078/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 0277acc..2f80e5e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -2645,6 +2645,18 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
}
/** {@inheritDoc} */
+ @Override public Collection<String> cacheNames() {
+ guard();
+
+ try {
+ return ctx.cache().publicCacheNames();
+ }
+ finally {
+ unguard();
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public <K extends GridCacheUtilityKey, V> IgniteInternalCache<K, V> utilityCache() {
guard();
http://git-wip-us.apache.org/repos/asf/ignite/blob/47919078/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 301e7d3..b2bb6ff 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -1522,6 +1522,25 @@ public class GridCacheProcessor extends GridProcessorAdapter {
}
/**
+ * Gets a collection of currently started public cache names.
+ *
+ * @return Collection of currently started public cache names
+ */
+ public Collection<String> publicCacheNames() {
+ return F.viewReadOnly(registeredCaches.values(),
+ new IgniteClosure<DynamicCacheDescriptor, String>() {
+ @Override public String apply(DynamicCacheDescriptor desc) {
+ return desc.cacheConfiguration().getName();
+ }
+ },
+ new IgnitePredicate<DynamicCacheDescriptor>() {
+ @Override public boolean apply(DynamicCacheDescriptor desc) {
+ return desc.started() && desc.cacheType().userCache();
+ }
+ }
+ );
+ }
+ /**
* Gets cache mode.
*
* @param cacheName Cache name to check.
http://git-wip-us.apache.org/repos/asf/ignite/blob/47919078/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNamesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNamesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNamesSelfTest.java
new file mode 100644
index 0000000..6f65b16
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNamesSelfTest.java
@@ -0,0 +1,69 @@
+/*
+ * 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.internal.processors.cache;
+
+import java.util.Collection;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Test that validates {@link Ignite#cacheNames()} implementation.
+ */
+public class CacheNamesSelfTest extends GridCommonAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ CacheConfiguration cacheCfg1 = new CacheConfiguration();
+ cacheCfg1.setCacheMode(CacheMode.REPLICATED);
+ cacheCfg1.setName("replicated");
+
+ CacheConfiguration cacheCfg2 = new CacheConfiguration();
+ cacheCfg2.setCacheMode(CacheMode.PARTITIONED);
+ cacheCfg2.setName("partitioned");
+
+ CacheConfiguration cacheCfg3 = new CacheConfiguration();
+ cacheCfg3.setCacheMode(CacheMode.LOCAL);
+
+ cfg.setCacheConfiguration(cacheCfg1, cacheCfg2, cacheCfg3);
+
+ return cfg;
+ }
+
+ /**
+ * @throws Exception In case of failure.
+ */
+ public void testCacheNames() throws Exception {
+ try {
+ startGridsMultiThreaded(2);
+
+ Collection<String> names = grid(0).cacheNames();
+
+ assertEquals(3, names.size());
+
+ for (String name : names)
+ assertTrue(name == null || name.equals("replicated") || name.equals("partitioned"));
+ }
+ finally {
+ stopAllGrids();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/47919078/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
index 964753d..bfeafdf 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
@@ -194,6 +194,11 @@ public class IgniteMock implements Ignite {
}
/** {@inheritDoc} */
+ @Override public Collection<String> cacheNames() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
@Override public <K, V> IgniteCache<K, V> createCache(CacheConfiguration<K, V> cacheCfg) {
return null;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/47919078/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
index aa1d470..3eb9d98 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
@@ -477,6 +477,11 @@ public class IgniteProcessProxy implements IgniteEx {
}
/** {@inheritDoc} */
+ @Override public Collection<String> cacheNames() {
+ return locJvmGrid.cacheNames();
+ }
+
+ /** {@inheritDoc} */
@Override public IgniteTransactions transactions() {
throw new UnsupportedOperationException("Transactions can't be supported automatically in multi JVM mode.");
}
@@ -645,4 +650,4 @@ public class IgniteProcessProxy implements IgniteEx {
return ((IgniteEx)ignite).localNode();
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/47919078/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index c62a131..f6432a7 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -35,6 +35,7 @@ import org.apache.ignite.cache.store.jdbc.GridCacheJdbcBlobStoreMultithreadedSel
import org.apache.ignite.cache.store.jdbc.GridCacheJdbcBlobStoreSelfTest;
import org.apache.ignite.internal.processors.cache.CacheAffinityCallSelfTest;
import org.apache.ignite.internal.processors.cache.CacheFutureExceptionSelfTest;
+import org.apache.ignite.internal.processors.cache.CacheNamesSelfTest;
import org.apache.ignite.internal.processors.cache.GridCacheAffinityApiSelfTest;
import org.apache.ignite.internal.processors.cache.GridCacheAffinityMapperSelfTest;
import org.apache.ignite.internal.processors.cache.GridCacheAffinityRoutingSelfTest;
@@ -196,6 +197,7 @@ public class IgniteCacheTestSuite extends TestSuite {
suite.addTestSuite(GridCacheSwapReloadSelfTest.class);
// Common tests.
+ suite.addTestSuite(CacheNamesSelfTest.class);
suite.addTestSuite(GridCacheConcurrentMapSelfTest.class);
suite.addTestSuite(GridCacheAffinityMapperSelfTest.class);
suite.addTestSuite(CacheAffinityCallSelfTest.class);
http://git-wip-us.apache.org/repos/asf/ignite/blob/47919078/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java b/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
index 42514e3..7740907 100644
--- a/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
+++ b/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
@@ -240,6 +240,14 @@ public class IgniteSpringBean implements Ignite, DisposableBean, InitializingBea
return g.cache(name);
}
+
+ /** {@inheritDoc} */
+ @Override public Collection<String> cacheNames() {
+ assert g != null;
+
+ return g.cacheNames();
+ }
+
/** {@inheritDoc} */
@Override public <K, V> IgniteCache<K, V> createCache(CacheConfiguration<K, V> cacheCfg) {
assert g != null;
@@ -437,4 +445,4 @@ public class IgniteSpringBean implements Ignite, DisposableBean, InitializingBea
cfg = g.configuration();
}
-}
\ No newline at end of file
+}
[5/7] ignite git commit: Renamed IgniteRddSpec to IgniteRDDSpec
Posted by dm...@apache.org.
Renamed IgniteRddSpec to IgniteRDDSpec
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c66df66c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c66df66c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c66df66c
Branch: refs/heads/ignite-cont-merge
Commit: c66df66c24a9e9dbee5caca459555fae7c2b2eb8
Parents: 39405ae
Author: Stephen Boesch <ja...@gmail.com>
Authored: Wed Nov 4 13:38:13 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Wed Nov 4 13:38:13 2015 +0300
----------------------------------------------------------------------
.../scala/org/apache/ignite/spark/Entity.scala | 2 +-
.../org/apache/ignite/spark/IgniteRddSpec.scala | 249 -------------------
.../apache/ignite/spark/IgniteRddSpec1.scala | 249 +++++++++++++++++++
3 files changed, 250 insertions(+), 250 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c66df66c/modules/spark/src/test/scala/org/apache/ignite/spark/Entity.scala
----------------------------------------------------------------------
diff --git a/modules/spark/src/test/scala/org/apache/ignite/spark/Entity.scala b/modules/spark/src/test/scala/org/apache/ignite/spark/Entity.scala
index 00beac6..e56558d 100644
--- a/modules/spark/src/test/scala/org/apache/ignite/spark/Entity.scala
+++ b/modules/spark/src/test/scala/org/apache/ignite/spark/Entity.scala
@@ -17,7 +17,7 @@
package org.apache.ignite.spark
-import org.apache.ignite.spark.IgniteRddSpec.ScalarCacheQuerySqlField
+import org.apache.ignite.spark.IgniteRddSpec1.ScalarCacheQuerySqlField
class Entity (
@ScalarCacheQuerySqlField(index = true) val id: Int,
http://git-wip-us.apache.org/repos/asf/ignite/blob/c66df66c/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRddSpec.scala
----------------------------------------------------------------------
diff --git a/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRddSpec.scala b/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRddSpec.scala
deleted file mode 100644
index 8fa6949..0000000
--- a/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRddSpec.scala
+++ /dev/null
@@ -1,249 +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.spark
-
-import org.apache.ignite.Ignition
-import org.apache.ignite.cache.query.annotations.{QueryTextField, QuerySqlField}
-import org.apache.ignite.configuration.{CacheConfiguration, IgniteConfiguration}
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder
-import org.apache.spark.SparkContext
-import org.junit.runner.RunWith
-import org.scalatest._
-import org.scalatest.junit.JUnitRunner
-
-import IgniteRddSpec._
-
-import scala.annotation.meta.field
-
-@RunWith(classOf[JUnitRunner])
-class IgniteRddSpec extends FunSpec with Matchers with BeforeAndAfterAll with BeforeAndAfterEach {
- describe("IgniteRDD") {
- it("should successfully store data to ignite") {
- val sc = new SparkContext("local[*]", "test")
-
- try {
- val ic = new IgniteContext[String, String](sc,
- () ⇒ configuration("client", client = true))
-
- // Save pairs ("0", "val0"), ("1", "val1"), ... to Ignite cache.
- ic.fromCache(PARTITIONED_CACHE_NAME).savePairs(sc.parallelize(0 to 10000, 2).map(i ⇒ (String.valueOf(i), "val" + i)))
-
- // Check cache contents.
- val ignite = Ignition.ignite("grid-0")
-
- for (i ← 0 to 10000) {
- val res = ignite.cache[String, String](PARTITIONED_CACHE_NAME).get(String.valueOf(i))
-
- assert(res != null, "Value was not put to cache for key: " + i)
- assert("val" + i == res, "Invalid value stored for key: " + i)
- }
- }
- finally {
- sc.stop()
- }
- }
-
- it("should successfully read data from ignite") {
- val sc = new SparkContext("local[*]", "test")
-
- try {
- val cache = Ignition.ignite("grid-0").cache[String, Int](PARTITIONED_CACHE_NAME)
-
- val num = 10000
-
- for (i ← 0 to num) {
- cache.put(String.valueOf(i), i)
- }
-
- val ic = new IgniteContext[String, Int](sc,
- () ⇒ configuration("client", client = true))
-
- val res = ic.fromCache(PARTITIONED_CACHE_NAME).map(_._2).sum()
-
- assert(res == (0 to num).sum)
- }
- finally {
- sc.stop()
- }
- }
-
- it("should successfully query objects from ignite") {
- val sc = new SparkContext("local[*]", "test")
-
- try {
- val ic = new IgniteContext[String, Entity](sc,
- () ⇒ configuration("client", client = true))
-
- val cache: IgniteRDD[String, Entity] = ic.fromCache(PARTITIONED_CACHE_NAME)
-
- cache.savePairs(sc.parallelize(0 to 1000, 2).map(i ⇒ (String.valueOf(i), new Entity(i, "name" + i, i * 100))))
-
- val res: Array[Entity] = cache.objectSql("Entity", "name = ? and salary = ?", "name50", 5000).map(_._2).collect()
-
- assert(res.length == 1, "Invalid result length")
- assert(50 == res(0).id, "Invalid result")
- assert("name50" == res(0).name, "Invalid result")
- assert(5000 == res(0).salary)
-
- assert(500 == cache.objectSql("Entity", "id > 500").count(), "Invalid count")
- }
- finally {
- sc.stop()
- }
- }
-
- it("should successfully query fields from ignite") {
- val sc = new SparkContext("local[*]", "test")
-
- try {
- val ic = new IgniteContext[String, Entity](sc,
- () ⇒ configuration("client", client = true))
-
- val cache: IgniteRDD[String, Entity] = ic.fromCache(PARTITIONED_CACHE_NAME)
-
- import ic.sqlContext.implicits._
-
- cache.savePairs(sc.parallelize(0 to 1000, 2).map(i ⇒ (String.valueOf(i), new Entity(i, "name" + i, i * 100))))
-
- val df = cache.sql("select id, name, salary from Entity where name = ? and salary = ?", "name50", 5000)
-
- df.printSchema()
-
- val res = df.collect()
-
- assert(res.length == 1, "Invalid result length")
- assert(50 == res(0)(0), "Invalid result")
- assert("name50" == res(0)(1), "Invalid result")
- assert(5000 == res(0)(2), "Invalid result")
-
- val df0 = cache.sql("select id, name, salary from Entity").where('NAME === "name50" and 'SALARY === 5000)
-
- val res0 = df0.collect()
-
- assert(res0.length == 1, "Invalid result length")
- assert(50 == res0(0)(0), "Invalid result")
- assert("name50" == res0(0)(1), "Invalid result")
- assert(5000 == res0(0)(2), "Invalid result")
-
- assert(500 == cache.sql("select id from Entity where id > 500").count(), "Invalid count")
- }
- finally {
- sc.stop()
- }
- }
-
- it("should successfully start spark context with XML configuration") {
- val sc = new SparkContext("local[*]", "test")
-
- try {
- val ic = new IgniteContext[String, String](sc,
- "modules/core/src/test/config/spark/spark-config.xml")
-
- val cache: IgniteRDD[String, String] = ic.fromCache(PARTITIONED_CACHE_NAME)
-
- cache.savePairs(sc.parallelize(1 to 1000, 2).map(i ⇒ (String.valueOf(i), "val" + i)))
-
- assert(1000 == cache.count())
- }
- finally {
- sc.stop()
- }
- }
- }
-
- override protected def beforeEach() = {
- Ignition.ignite("grid-0").cache(PARTITIONED_CACHE_NAME).removeAll()
- }
-
- override protected def afterEach() = {
- Ignition.stop("client", false)
- }
-
- override protected def beforeAll() = {
- for (i ← 0 to 3) {
- Ignition.start(configuration("grid-" + i, client = false))
- }
- }
-
- override protected def afterAll() = {
- for (i ← 0 to 3) {
- Ignition.stop("grid-" + i, false)
- }
- }
-}
-
-/**
- * Constants and utility methods.
- */
-object IgniteRddSpec {
- /** IP finder for the test. */
- val IP_FINDER = new TcpDiscoveryVmIpFinder(true)
-
- /** Partitioned cache name. */
- val PARTITIONED_CACHE_NAME = "partitioned"
-
- /** Type alias for `QuerySqlField`. */
- type ScalarCacheQuerySqlField = QuerySqlField @field
-
- /** Type alias for `QueryTextField`. */
- type ScalarCacheQueryTextField = QueryTextField @field
-
- /**
- * Gets ignite configuration.
- *
- * @param gridName Grid name.
- * @param client Client mode flag.
- * @return Ignite configuration.
- */
- def configuration(gridName: String, client: Boolean): IgniteConfiguration = {
- val cfg = new IgniteConfiguration
-
- val discoSpi = new TcpDiscoverySpi
-
- discoSpi.setIpFinder(IgniteRddSpec.IP_FINDER)
-
- cfg.setDiscoverySpi(discoSpi)
-
- cfg.setCacheConfiguration(cacheConfiguration(gridName))
-
- cfg.setClientMode(client)
-
- cfg.setGridName(gridName)
-
- cfg
- }
-
- /**
- * Gets cache configuration for the given grid name.
- *
- * @param gridName Grid name.
- * @return Cache configuration.
- */
- def cacheConfiguration(gridName: String): CacheConfiguration[Object, Object] = {
- val ccfg = new CacheConfiguration[Object, Object]()
-
- ccfg.setBackups(1)
-
- ccfg.setName(PARTITIONED_CACHE_NAME)
-
- ccfg.setIndexedTypes(classOf[String], classOf[Entity])
-
- ccfg
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c66df66c/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRddSpec1.scala
----------------------------------------------------------------------
diff --git a/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRddSpec1.scala b/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRddSpec1.scala
new file mode 100644
index 0000000..3ef3225
--- /dev/null
+++ b/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRddSpec1.scala
@@ -0,0 +1,249 @@
+/*
+ * 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.spark
+
+import org.apache.ignite.Ignition
+import org.apache.ignite.cache.query.annotations.{QueryTextField, QuerySqlField}
+import org.apache.ignite.configuration.{CacheConfiguration, IgniteConfiguration}
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder
+import org.apache.spark.SparkContext
+import org.junit.runner.RunWith
+import org.scalatest._
+import org.scalatest.junit.JUnitRunner
+
+import IgniteRddSpec1._
+
+import scala.annotation.meta.field
+
+@RunWith(classOf[JUnitRunner])
+class IgniteRddSpec1 extends FunSpec with Matchers with BeforeAndAfterAll with BeforeAndAfterEach {
+ describe("IgniteRDD") {
+ it("should successfully store data to ignite") {
+ val sc = new SparkContext("local[*]", "test")
+
+ try {
+ val ic = new IgniteContext[String, String](sc,
+ () ⇒ configuration("client", client = true))
+
+ // Save pairs ("0", "val0"), ("1", "val1"), ... to Ignite cache.
+ ic.fromCache(PARTITIONED_CACHE_NAME).savePairs(sc.parallelize(0 to 10000, 2).map(i ⇒ (String.valueOf(i), "val" + i)))
+
+ // Check cache contents.
+ val ignite = Ignition.ignite("grid-0")
+
+ for (i ← 0 to 10000) {
+ val res = ignite.cache[String, String](PARTITIONED_CACHE_NAME).get(String.valueOf(i))
+
+ assert(res != null, "Value was not put to cache for key: " + i)
+ assert("val" + i == res, "Invalid value stored for key: " + i)
+ }
+ }
+ finally {
+ sc.stop()
+ }
+ }
+
+ it("should successfully read data from ignite") {
+ val sc = new SparkContext("local[*]", "test")
+
+ try {
+ val cache = Ignition.ignite("grid-0").cache[String, Int](PARTITIONED_CACHE_NAME)
+
+ val num = 10000
+
+ for (i ← 0 to num) {
+ cache.put(String.valueOf(i), i)
+ }
+
+ val ic = new IgniteContext[String, Int](sc,
+ () ⇒ configuration("client", client = true))
+
+ val res = ic.fromCache(PARTITIONED_CACHE_NAME).map(_._2).sum()
+
+ assert(res == (0 to num).sum)
+ }
+ finally {
+ sc.stop()
+ }
+ }
+
+ it("should successfully query objects from ignite") {
+ val sc = new SparkContext("local[*]", "test")
+
+ try {
+ val ic = new IgniteContext[String, Entity](sc,
+ () ⇒ configuration("client", client = true))
+
+ val cache: IgniteRDD[String, Entity] = ic.fromCache(PARTITIONED_CACHE_NAME)
+
+ cache.savePairs(sc.parallelize(0 to 1000, 2).map(i ⇒ (String.valueOf(i), new Entity(i, "name" + i, i * 100))))
+
+ val res: Array[Entity] = cache.objectSql("Entity", "name = ? and salary = ?", "name50", 5000).map(_._2).collect()
+
+ assert(res.length == 1, "Invalid result length")
+ assert(50 == res(0).id, "Invalid result")
+ assert("name50" == res(0).name, "Invalid result")
+ assert(5000 == res(0).salary)
+
+ assert(500 == cache.objectSql("Entity", "id > 500").count(), "Invalid count")
+ }
+ finally {
+ sc.stop()
+ }
+ }
+
+ it("should successfully query fields from ignite") {
+ val sc = new SparkContext("local[*]", "test")
+
+ try {
+ val ic = new IgniteContext[String, Entity](sc,
+ () ⇒ configuration("client", client = true))
+
+ val cache: IgniteRDD[String, Entity] = ic.fromCache(PARTITIONED_CACHE_NAME)
+
+ import ic.sqlContext.implicits._
+
+ cache.savePairs(sc.parallelize(0 to 1000, 2).map(i ⇒ (String.valueOf(i), new Entity(i, "name" + i, i * 100))))
+
+ val df = cache.sql("select id, name, salary from Entity where name = ? and salary = ?", "name50", 5000)
+
+ df.printSchema()
+
+ val res = df.collect()
+
+ assert(res.length == 1, "Invalid result length")
+ assert(50 == res(0)(0), "Invalid result")
+ assert("name50" == res(0)(1), "Invalid result")
+ assert(5000 == res(0)(2), "Invalid result")
+
+ val df0 = cache.sql("select id, name, salary from Entity").where('NAME === "name50" and 'SALARY === 5000)
+
+ val res0 = df0.collect()
+
+ assert(res0.length == 1, "Invalid result length")
+ assert(50 == res0(0)(0), "Invalid result")
+ assert("name50" == res0(0)(1), "Invalid result")
+ assert(5000 == res0(0)(2), "Invalid result")
+
+ assert(500 == cache.sql("select id from Entity where id > 500").count(), "Invalid count")
+ }
+ finally {
+ sc.stop()
+ }
+ }
+
+ it("should successfully start spark context with XML configuration") {
+ val sc = new SparkContext("local[*]", "test")
+
+ try {
+ val ic = new IgniteContext[String, String](sc,
+ "modules/core/src/test/config/spark/spark-config.xml")
+
+ val cache: IgniteRDD[String, String] = ic.fromCache(PARTITIONED_CACHE_NAME)
+
+ cache.savePairs(sc.parallelize(1 to 1000, 2).map(i ⇒ (String.valueOf(i), "val" + i)))
+
+ assert(1000 == cache.count())
+ }
+ finally {
+ sc.stop()
+ }
+ }
+ }
+
+ override protected def beforeEach() = {
+ Ignition.ignite("grid-0").cache(PARTITIONED_CACHE_NAME).removeAll()
+ }
+
+ override protected def afterEach() = {
+ Ignition.stop("client", false)
+ }
+
+ override protected def beforeAll() = {
+ for (i ← 0 to 3) {
+ Ignition.start(configuration("grid-" + i, client = false))
+ }
+ }
+
+ override protected def afterAll() = {
+ for (i ← 0 to 3) {
+ Ignition.stop("grid-" + i, false)
+ }
+ }
+}
+
+/**
+ * Constants and utility methods.
+ */
+object IgniteRddSpec1 {
+ /** IP finder for the test. */
+ val IP_FINDER = new TcpDiscoveryVmIpFinder(true)
+
+ /** Partitioned cache name. */
+ val PARTITIONED_CACHE_NAME = "partitioned"
+
+ /** Type alias for `QuerySqlField`. */
+ type ScalarCacheQuerySqlField = QuerySqlField @field
+
+ /** Type alias for `QueryTextField`. */
+ type ScalarCacheQueryTextField = QueryTextField @field
+
+ /**
+ * Gets ignite configuration.
+ *
+ * @param gridName Grid name.
+ * @param client Client mode flag.
+ * @return Ignite configuration.
+ */
+ def configuration(gridName: String, client: Boolean): IgniteConfiguration = {
+ val cfg = new IgniteConfiguration
+
+ val discoSpi = new TcpDiscoverySpi
+
+ discoSpi.setIpFinder(IgniteRddSpec1.IP_FINDER)
+
+ cfg.setDiscoverySpi(discoSpi)
+
+ cfg.setCacheConfiguration(cacheConfiguration(gridName))
+
+ cfg.setClientMode(client)
+
+ cfg.setGridName(gridName)
+
+ cfg
+ }
+
+ /**
+ * Gets cache configuration for the given grid name.
+ *
+ * @param gridName Grid name.
+ * @return Cache configuration.
+ */
+ def cacheConfiguration(gridName: String): CacheConfiguration[Object, Object] = {
+ val ccfg = new CacheConfiguration[Object, Object]()
+
+ ccfg.setBackups(1)
+
+ ccfg.setName(PARTITIONED_CACHE_NAME)
+
+ ccfg.setIndexedTypes(classOf[String], classOf[Entity])
+
+ ccfg
+ }
+}
[2/7] ignite git commit: IGNITE-1545: Java8 MessagingExample should
be optimized
Posted by dm...@apache.org.
IGNITE-1545: Java8 MessagingExample should be optimized
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/fec2450f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/fec2450f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/fec2450f
Branch: refs/heads/ignite-cont-merge
Commit: fec2450fd1f024696ae60ba3c67e6c7de4dbeca6
Parents: 51c0d80
Author: Roman Shtykh <ap...@gmail.com>
Authored: Wed Nov 4 12:25:55 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Wed Nov 4 12:28:49 2015 +0300
----------------------------------------------------------------------
.../ignite/examples/java8/messaging/MessagingExample.java | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/fec2450f/examples/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java
index 97ec58e..de060a7 100644
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java
+++ b/examples/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java
@@ -54,13 +54,8 @@ public final class MessagingExample {
*/
public static void main(String[] args) throws Exception {
try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- if (!ExamplesUtils.checkMinTopologySize(ignite.cluster(), 2)) {
- System.out.println();
- System.out.println(">>> Please start at least 2 cluster nodes to run example.");
- System.out.println();
-
+ if (!ExamplesUtils.checkMinTopologySize(ignite.cluster(), 2))
return;
- }
System.out.println();
System.out.println(">>> Messaging example started.");
[3/7] ignite git commit: ignite-1395: REST HTTP module prints out
unnecessary message
Posted by dm...@apache.org.
ignite-1395: REST HTTP module prints out unnecessary message
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/73c2db5c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/73c2db5c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/73c2db5c
Branch: refs/heads/ignite-cont-merge
Commit: 73c2db5cb55dce46ed98564cbf9a8842f09bb413
Parents: fec2450
Author: Roman Shtykh <ap...@gmail.com>
Authored: Wed Nov 4 12:35:31 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Wed Nov 4 12:35:31 2015 +0300
----------------------------------------------------------------------
modules/rest-http/pom.xml | 6 ++++++
1 file changed, 6 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/73c2db5c/modules/rest-http/pom.xml
----------------------------------------------------------------------
diff --git a/modules/rest-http/pom.xml b/modules/rest-http/pom.xml
index 58eb1ed..730e28a 100644
--- a/modules/rest-http/pom.xml
+++ b/modules/rest-http/pom.xml
@@ -113,5 +113,11 @@
<artifactId>commons-beanutils</artifactId>
<version>1.8.3</version>
</dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.7.7</version>
+ </dependency>
</dependencies>
</project>
[4/7] ignite git commit: ignite-1808: Wrong Jetty's thread pool size
settings
Posted by dm...@apache.org.
ignite-1808: Wrong Jetty's thread pool size settings
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/39405aef
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/39405aef
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/39405aef
Branch: refs/heads/ignite-cont-merge
Commit: 39405aef01c2afb88aad4ef44f9dba8a2e8468b5
Parents: 73c2db5
Author: Roman Shtykh <ap...@gmail.com>
Authored: Wed Nov 4 12:48:54 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Wed Nov 4 12:50:11 2015 +0300
----------------------------------------------------------------------
.../rest/protocols/http/jetty/GridJettyRestProtocol.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/39405aef/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestProtocol.java
----------------------------------------------------------------------
diff --git a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestProtocol.java b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestProtocol.java
index 6e201c9..ac49ef6 100644
--- a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestProtocol.java
+++ b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestProtocol.java
@@ -287,7 +287,7 @@ public class GridJettyRestProtocol extends GridRestProtocolAdapter {
"cannot be cast to integer: " + srvPortStr);
}
- httpSrv = new Server(new QueuedThreadPool(20, 200));
+ httpSrv = new Server(new QueuedThreadPool(200, 20));
ServerConnector srvConn = new ServerConnector(httpSrv, new HttpConnectionFactory(httpCfg));
@@ -421,4 +421,4 @@ public class GridJettyRestProtocol extends GridRestProtocolAdapter {
@Override public String toString() {
return S.toString(GridJettyRestProtocol.class, this);
}
-}
\ No newline at end of file
+}